BACKUP_PRIORITY does not parse while using clause ADD REPLICA ON

Open
#222 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp, sql
Domain
compilers

Research direction

Start with the TSql180Parser and TSql170Parser handling for ALTER AVAILABILITY GROUP, using the provided SQL script as the reproduction case. Trace the ADD REPLICA ON and GRANT CREATE ANY DATABASE clauses, then verify that the script parses without the reported errors for both parser versions.

Written by the indexing model from the issue text.

Description

Version - 180.78.1
Parser - TSql180Parser and TSql170Parser
  1. BACKUP_PRIORITY does not parse while using clause ADD REPLICA ON it expects APPLY_DELAY instead.
  2. GRANT, CREATE and ANY does not parse in ALTER AVAILABILITY GROUP Clause.
Steps to reproduce -

Try parsing the below SQL script with the parser:

ALTER AVAILABILITY GROUP [SalesAG]
ADD REPLICA ON 'SQL-NODE03\PROD_INSTANCE' WITH (ENDPOINT_URL = 'TCP://SQL-NODE03.corp.local:5022', FAILOVER_MODE = MANUAL, AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT, BACKUP_PRIORITY = 50, SEEDING_MODE = AUTOMATIC, PRIMARY_ROLE(READ_ONLY_ROUTING_LIST = ('SQL-NODE03\PROD_INSTANCE', 'SQL-NODE02\PROD_INSTANCE')), SECONDARY_ROLE(READ_ONLY_ROUTING_URL = 'TCP://SQL-NODE02.corp.local:1433', ALLOW_CONNECTIONS = ALL));
ALTER AVAILABILITY GROUP [SalesAG] GRANT CREATE ANY DATABASE;

Example -

using Microsoft.SqlServer.TransactSql.ScriptDom;

internal class Program
{
    static void Main(string[] args)
    {
        var script = "Example Script";
        var parser = new TSql180Parser(true);
        var fragment = parser.Parse(new StringReader(script), out var parseErrors);

        if (parseErrors.Count > 0)
        {
            foreach(var parseError in parseErrors)
                Console.WriteLine(parseError.Message);
        }
        else
        {
            Console.WriteLine("Parsed successfully");
        }
    }
}
Error message :-
Expected APPLY_DELAY but encountered BACKUP_PRIORITY instead.
Incorrect syntax near 'GRANT'.
Incorrect syntax near 'CREATE'.
Incorrect syntax near 'ANY'.```

Dominant language
GAP
Stars
277
Forks
43
Avg merge
6d 17h
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/SqlScriptDOM

All issues in microsoft/SqlScriptDOM

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.