microsoft / sqltoolsservice

SQL Tools API service that provides SQL Server data management capabilities.
Other
438 stars 153 forks source link

Regression in parsing statement in Microsoft.SqlServer.Management.SqlParser. #1447

Open brettshearer opened 2 years ago

brettshearer commented 2 years ago

The latest version of Microsoft.SqlServer.Management.SqlParser fails to parse the following statement

create index f on t (y) with (resumable=on)

It fails with and incorrectly handled null.

nhandled exception. Microsoft.SqlServer.Management.SqlParser.SqlParserInternalParserError: Internal Parser Error ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SqlServer.Management.SqlParser.SqlCodeDom.SqlCreateIndexStatement..ctor(Boolean isUnique, SqlClusterOption clusterOption, SqlIdentifier name, SqlObjectIdentifier targetObject, IEnumerable1 indexedColumns, IEnumerable1 includedColumns, SqlFilterClause filterClause, IEnumerable1 options, SqlStorageSpecification storageSpecification, SqlStorageSpecification fileStreamStorageSpecification) at Microsoft.SqlServer.Management.SqlParser.SqlCodeDom.SqlCreateIndexStatement..ctor(CreateIndexStart createIndexStart, SqlIdentifier name, SqlObjectIdentifier targetObject, CreateIndexKeyList createIndexKeyList, SqlFilterClause filterClause, IEnumerable1 options, SqlStorageSpecification storageSpecification, SqlStorageSpecification fileStreamStorageSpecification) at Microsoft.SqlServer.Management.SqlParser.Parser.Internals160.Parser.DoAction_900_949(Int32 action) at Microsoft.SqlServer.Management.SqlParser.Parser.Internals160.Parser.DoAction(Int32 action) at Babel.ParserGenerator.ShiftReduceParser.Reduce(Int32 rule_nr) at Babel.ParserGenerator.ShiftReduceParser.DoParse() at Babel.ParserGenerator.ShiftReduceParser.Parse(Boolean isIncremental, ParserScanner inputScanner, ParseContext parseContext, ReusableStatementsCollection reusableStmts) at Microsoft.SqlServer.Management.SqlParser.Parser.Internals.VersionedParserBase.Parse(Boolean isIncremental, String sql, SqlScript prevScript, ParseOptions options, ParseOptions& resultOptions) --- End of inner exception stack trace --- at Microsoft.SqlServer.Management.SqlParser.Parser.Internals.VersionedParserBase.Parse(Boolean isIncremental, String sql, SqlScript prevScript, ParseOptions options, ParseOptions& resultOptions) at Microsoft.SqlServer.Management.SqlParser.Parser.Parser.Parse(Boolean isIncremental, String sql, ParseResult prevResult, ParseOptions options, ParseOptions& resultOptions) at Microsoft.SqlServer.Management.SqlParser.Parser.Parser.Parse(String sql, ParseOptions options, ParseOptions& resultOptions) at Microsoft.SqlServer.Management.SqlParser.Parser.Parser.Parse(String sql, ParseOptions options) at Program.

$(String[] args) in C:\git\wtg\CargoWise\ConsoleApp4\ConsoleApp4\Program.cs:line 23

Previous versions would have correctly reported this syntax failure to the Errors property.

shueybubbles commented 2 years ago

Which previous versions have you used successfully? I think people have added some options to the grammar without updating this constructor for multiple releases.