TGSqlParser
necessary to create a SQL Parser and the classes a SQL Parser uses
internally to handle different SQL dialects.See: Description
Interface | Description |
---|---|
IMetaDatabase | Deprecated
As of v2.0.3.1, please use
TSQLEnv instead
In order to link column to table correctly without connecting to database,
we need to provide a class which implements IMetaDatabase to TGSqlParser. |
IProcExchange | |
IRelation | |
ISQLStatementHandle |
This is the interface for handling SQL statements after parsing each SQL statement.
|
ITokenHandle |
use this interface if you like to change token properties generated by lexer
before send to parser.
if you change a source token's TSourceToken#tokencode to TBaseType#cmtslashstar TBaseType#cmtdoublehyphen then, this token will be treated as comment you may also like to change tokencode of a keyword to TBaseType#ident, this will let parser treat this keyword as an identifier. |
ITokenListHandle |
Class | Description |
---|---|
TAttributeNode |
TAttributeNode 类似 column,但含义更广泛。用来表示 SQL 语句中 table 包含的字段(table 或许用 relation 更准确)。
这里的 table 可以是数据库的基本表,也可以是 from clause 中出现的子查询,或者是 CTE。
GSP 会把 SQL 语句中出现的每个 table 都生成对应的 TAttributeNode 列表,表示该 table 可以在 SQL 中被使用的字段。
例如:一般 table
select column1 from table1
GSP 会在 SQLEnv 中查找 table1 的定义,如果找到(column1,column2,column3), 则 table 会创建三个对应的 TAttributeNode。
用户可以通过
TTable.getAttributes() 来获取。
如果SQLEnv 中没有查找 table1 的定义,则创建一个 star column TAttributeNode, 形如 table1.*
例如:子查询
select column1 from (select c1,c2 from table1) t1
针对上例中的 t1 子查询, GSP 会创建两个 TAttributeNode,对应 t1.c1, t1.c2
针对其他类型的 table, 也做类似处理。为 SQL 中的每个 table 准备好 TAttributeNode 列表,
在接下来的分析中,SQL 语句中出现的 column 引用都应该能找到对应的来源表和 TAttributeNode
相关的属性
TAttributeNode.getName() , 字段名,不带前缀。
TAttributeNode.getTable_ref() , 该字段对应的 table,每个在 SQL 语句中出现的 table 都有对应的 TTable 对象。
TAttributeNode.getSqlColumn() , 如果在 SQLEnv 中找到该 table 的定义,这个方法返回数据库中定义的字段、
TAttributeNode.getSubLevelResultColumn() , 如果 table 类型为子查询,该方法返回子查询 select list 中的 TResultColumn 对象,为该字段的数据来源。
或者是 values() 中的 result column。 |
TBaseType |
Constants and functions used by parser internally.
|
TCustomLexer |
Base lexer of all databases.
|
TCustomParser |
Base parser of all databases.
|
TCustomSqlStatement |
TCustomSqlStatement is the root class for all SQL statements.
|
TGSqlParser |
This is the first class people start to use this SQL parser library.
|
TLexerAnsi | |
TLexerDb2 | |
TLexerMssql | |
TLog | |
TParserAnsi | |
TParserDb2Sql | |
TSingletonParser | |
TSourceToken |
Represents a source token which is the basic syntactic unit of SQL.
|
TSourceTokenList |
List of source token.
|
TSqlCmds | |
TStatementList |
List of SQL statements which is instance of class that descends from
TCustomSqlStatement . |
TSyntaxError |
Detailed information about syntax error.
|
TVisitedAbs |
Base class of all parse tree nodes that can be visited by visitors.
|
TVisitorAbs |
Base class of all visitors that used to visit parse tree nodes.
|
TGSqlParser
necessary to create a SQL Parser and the classes a SQL Parser uses
internally to handle different SQL dialects.