SQL Parser

Background

Spring namespace’s SQL parser configuration applies to traditional Spring projects. SQL parsing rules and attributes can be configured through the XML configuration files of the namespace.

Parameters

Namespace:http://shardingsphere.apache.org/schema/shardingsphere/sql-parser/sql-parser-5.2.1.xsd

<sql-parser:rule />

NameTypeDescription
idAttributeSpring Bean Id
sql-comment-parse-enableAttributeWhether to parse SQL comments
parse-tree-cache-refAttributeParse tree local cache name
sql-statement-cache-refAttributeSQL statement local cache name

<sql-parser:cache-option />

NameTypeDescription
idAttributeLocal cache configuration item name
initial-capacityAttributeInitial capacity of local cache
maximum-sizeAttributeMaximum capacity of local cache

Procedure

  1. Set local cache configuration.
  2. Set parser configuration.
  3. Parse SQL with a parsing engine.

Sample

  1. <sql-parser:rule id="sqlParseRule" sql-comment-parse-enable="true" parse-tree-cache-ref="parseTreeCache" sql-statement-cache-ref="sqlStatementCache" />
  2. <sql-parser:cache-option id="sqlStatementCache" initial-capacity="1024" maximum-size="1024"/>
  3. <sql-parser:cache-option id="parseTreeCache" initial-capacity="1024" maximum-size="1024"/>