microsoft / microsoft/sqlmanagementobjects
Internal Parser Error when trying to parse (legit) syntax
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 143
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
Using the below SMO version:
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" Version="161.46367.54" />
The below code throws SqlParserInternalParserError:
var sql = @"SELECT * FROM n as n1, e, n as n2 WHERE MATCH (n1-(e)->n2)";
Microsoft.SqlServer.Management.SqlParser.Parser.ParseOptions resultOptions;
var res = Microsoft.SqlServer.Management.SqlParser.Parser.Parser.Parse(sql,
new ParseOptions("GO",
true,
Microsoft.SqlServer.Management.SqlParser.Common.DatabaseCompatibilityLevel.Azure,
Microsoft.SqlServer.Management.SqlParser.Common.TransactSqlVersion.Azure),
out resultOptions);
Here is the associated call stack:
Unhandled 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.SqlCodeObject.SetParentPointers()
at Microsoft.SqlServer.Management.SqlParser.SqlCodeDom.SqlCodeObject.SetParentPointers()
at Microsoft.SqlServer.Management.SqlParser.SqlCodeDom.SqlCodeObject.SetParentPointers()
at Microsoft.SqlServer.Management.SqlParser.SqlCodeDom.SqlCodeObject.SetParentPointers()
at Microsoft.SqlServer.Management.SqlParser.SqlCodeDom.SqlStatement.SetParentPointers()
at Microsoft.SqlServer.Management.SqlParser.SqlCodeDom.SqlCodeObject.SetParentPointers()
at Microsoft.SqlServer.Management.SqlParser.SqlCodeDom.SqlCodeObject.SetParentPointers()
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)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Parser.Parser.Parse entry point and the supplied SQL statement and ParseOptions. Trace the failure through VersionedParserBase.Parse and SqlCodeDom.SqlCodeObject.SetParentPointers, using the call stack to identify the null object. Done means the shown graph query parses without SqlParserInternalParserError and a regression test covers it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- compilers, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100