Fix BACKUP_PRIORITY and GRANT/DENY CREATE ANY DATABASE - #223
Open
NAVEEN NAIK (ZEUSXXIV) wants to merge 1 commit into
Open
Fix BACKUP_PRIORITY and GRANT/DENY CREATE ANY DATABASE #223NAVEEN NAIK (ZEUSXXIV) wants to merge 1 commit into
NAVEEN NAIK (ZEUSXXIV) wants to merge 1 commit into
Conversation
…ty groups (microsoft#222) Two independent ALTER AVAILABILITY GROUP syntax gaps, both documented and valid T-SQL, failed to parse: 1. BACKUP_PRIORITY replica option In ADD REPLICA ON ... WITH (...) / MODIFY REPLICA ON ..., the literalReplicaOption rule only accepted an integer-valued option when it was SESSION_TIMEOUT, otherwise forcing a match on APPLY_DELAY. So BACKUP_PRIORITY = n produced "Expected APPLY_DELAY but encountered BACKUP_PRIORITY". Add a BackupPriority branch to the integer path, AvailabilityReplicaOptionKind.BackupPriority (appended), the BACKUP_PRIORITY keyword constant, and the option-helper mapping. Applied to all grammars that have the rule: TSql110 through TSql180 and TSqlFabricDW (SQL 2012+). 2. GRANT / DENY CREATE ANY DATABASE ALTER AVAILABILITY GROUP had no branch for this clause, so GRANT/CREATE/ANY all errored. Add the grammar branch plus two appended AlterAvailabilityGroupStatementType values (GrantCreateAnyDatabase, DenyCreateAnyDatabase) and the corresponding script-generator cases. Applied to TSql130 through TSql180 and TSqlFabricDW (SQL 2016+); earlier parsers correctly continue to reject it. Both changes are additive to the public AST (new appended enum members, no renumbering or retyping), so they are non-breaking for downstream consumers. Tests: - Positive round-trip: AlterAvailabilityGroupBackupPriorityTests.sql (110) and AlterAvailabilityGroupCreateAnyDatabaseTests130.sql (130), with baselines, wired through Only110SyntaxTests.cs / Only130SyntaxTests.cs. Error counts version-gate the syntax (BACKUP_PRIORITY rejected pre-110, GRANT/DENY CREATE ANY DATABASE rejected pre-130). - Negative: AlterAvailabilityGroupCreateAnyDatabaseNegativeTest in ParserErrorsTests.cs asserts only CREATE ANY DATABASE is accepted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #222
Two documented
ALTER AVAILABILITY GROUPclauses failed to parse; both are added here.BACKUP_PRIORITYreplica option — inADD REPLICA ON … WITH (…)/MODIFY REPLICA ON …, integer options only acceptedSESSION_TIMEOUT(else forcedAPPLY_DELAY), soBACKUP_PRIORITY = nerrored. Added aBackupPrioritybranch, the appendedAvailabilityReplicaOptionKind.BackupPriority, the keyword constant, and the generator mapping. Grammars TSql110–TSql180 + FabricDW (SQL 2012+).GRANT/DENY CREATE ANY DATABASE— no grammar branch existed. Added the branch, two appendedAlterAvailabilityGroupStatementTypevalues, and the generator cases. Grammars TSql130–TSql180 + FabricDW (SQL 2016+); earlier parsers still reject it.Both are additive to the public AST (appended enum members only — no renumbering or retyping), so they're non-breaking for downstream consumers.
Tests: positive round-trips (
AlterAvailabilityGroupBackupPriorityTests.sql/AlterAvailabilityGroupCreateAnyDatabaseTests130.sql, with baselines and version-gated error counts) and a negative test asserting onlyCREATE ANY DATABASEis accepted.Code Changes