microsoft / vscode-mssql

Visual Studio Code SQL Server extension.
Other
1.53k stars 456 forks source link

Port BatchParserWrapper from DacFx into the tools service to fix batch execution reliability issues #594

Closed kevcunnane closed 7 years ago

kevcunnane commented 7 years ago

Why is this needed? Reliability: We're running into issues where the intellisense-parser that's currently used for identifying batches fails in some situations due to edge cases and bugs in syntax for the latest versions of SQL. Batch parsing should be one of the most reliable scenarios as it's vital for query execution, so we need to move away from Intellisense parser which is inherently unreliable against latest in-development SQL versions

Perf: intellisense parsing is slow, and the batch parser implementations are much faster since they just need to identify GO statements, batch them up and (optionally) execute the batches.

Implementation details DacFx contains a copy of the BatchParser code found in Microsoft.Data.Tools.Sql.BatchParser.dll, presumably a fork from a long time ago. It then leverages this in the Product/Source/SchemaSql/Common/ExecutionEngine code, notably the following classes:

We should be able to copy this folder over in its entirety - it includes useful settings for executing with ShowPlan and other code, with minimal external dependencies.

Unit Tests Tests are located in Product/Test/DacFx/UnitTests/UTData/TSQLExecutionEngine and again should be ported in their entirety. These are really integration tests as they have to hit a live DB in order to verify correct execution.

Additional notes / future considerations

abist commented 7 years ago

Hey @kevcunnane, which DacFx enlistment are we supposed to use? I don't see BatchParserWrapper.cs file in the enlistments.