Skip to content

Fix BACKUP_PRIORITY and GRANT/DENY CREATE ANY DATABASE - #223

Open
NAVEEN NAIK (ZEUSXXIV) wants to merge 1 commit into
microsoft:mainfrom
ZEUSXXIV:fix-issue-222
Open

Fix BACKUP_PRIORITY and GRANT/DENY CREATE ANY DATABASE #223
NAVEEN NAIK (ZEUSXXIV) wants to merge 1 commit into
microsoft:mainfrom
ZEUSXXIV:fix-issue-222

Conversation

@ZEUSXXIV

Copy link
Copy Markdown
Contributor

Fixes #222

Two documented ALTER AVAILABILITY GROUP clauses failed to parse; both are added here.

  1. BACKUP_PRIORITY replica option — in ADD REPLICA ON … WITH (…) / MODIFY REPLICA ON …, integer options only accepted SESSION_TIMEOUT (else forced APPLY_DELAY), so BACKUP_PRIORITY = n errored. Added a BackupPriority branch, the appended AvailabilityReplicaOptionKind.BackupPriority, the keyword constant, and the generator mapping. Grammars TSql110–TSql180 + FabricDW (SQL 2012+).

  2. GRANT / DENY CREATE ANY DATABASE — no grammar branch existed. Added the branch, two appended AlterAvailabilityGroupStatementType values, 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 only CREATE ANY DATABASE is accepted.

Code Changes

  • Unit tests are added, if possible
  • Existing tests are passing
  • New or updated code follows the guidelines here

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BACKUP_PRIORITY does not parse while using clause ADD REPLICA ON

1 participant