Skip to content

Architecture

This topic contains an architecture overview of the SQL Enlight analysis feature.

SQL Enlight Analysis feature depends on several components:

SQL ParserParses the T-SQL code and results in an XML-based syntax tree of the SQL code.

Schema ReaderLoad databases and server schema, and generate XML DOM representation of it (Analysis Context).

Analysis EngineValidates, Compiles XSLT analysis rules and applies them to the syntax tree and XML Analysis Context.

XSLT ExtensionsCan be used by the analysis rules and provide some additions to the standard XSLT and XPath functions as well as access to some of the internal SQL Enlight features.

The analysis goes through several steps:

1.Parse T-SQL code, validate the syntax and generate syntax tree.

architecture-1

2.Load database context and generate Analysis Context XML.

architecture-2

3.Generate XSLT template from available analysis rules expressions.

4.Apply XSLT transformation on the syntax tree of each T-SQL batch using all active batch scoped analysis rules. The analysis context and rule parameters are provided to the analysis rule as XSLT variables.

5.Apply XSLT transformation on the Analysis Context XML using all active Context Only analysis rules. The rule parameters and the analysis context are provided to the analysis rule as XSLT variables.

6.Reports rule violations.

architecture-3

Syntax Tree Schema Reference

XSLT Extension Functions

Analysis Context