public class OceanBaseMysqlSqlParser extends AbstractSqlParser
This class is a verbatim fork of MySqlSqlParser with class
names rewritten to point at the forked grammar artifacts under
gsp_java_parser/.../parser/oceanbasemysql/. The structural
intent is identical to the MySQL parser; what differs is:
TLexerOceanbasemysql and
TParserOceanbasemysql (generated from the forked
lzlexoceanbasemysql.l / lzyaccoceanbasemysql.y
sources by parsetable's generic-vendor fallback path).EDbVendor.dbvoceanbase so downstream
components (sqlcmds, IdentifierProfile, the various TSQLEnv
EnumMaps) consult OceanBase rules rather than MySQL rules.OceanBaseSqlParser when the active
EOBTenantMode is
EOBTenantMode.MYSQL or
EOBTenantMode.SYSTEM.Phase 2 ships this fork at zero divergence from the MySQL base
grammar — same shift/reduce conflicts, same token positions, same
statement coverage. OceanBase-specific extensions (hints, partition
extensions, tenant DDL, outlines, tablegroups) arrive incrementally
in Phase 4 via additive edits to the .y source. Each Phase 4
addition is tracked in oceanbasemysql/FORK_DIVERGENCE.md.
Backporting upstream MySQL grammar fixes is documented in the
Phase 0 plan (gsp_java_core/doc/oceanbase/PHASE0_REPORT.md)
and the per-fork oceanbasemysql/REGEN.md.
AbstractSqlParser.PreparedSqlReader| Modifier and Type | Field and Description |
|---|---|
TLexerOceanbasemysql |
flexer
The MySQL lexer used for tokenization (public for TGSqlParser.getFlexer())
|
defaultDelimiterStr, delimiterChar, frameStack, globalContext, globalFrame, lexer, parserContext, sourcetokenlist, sqlcmds, sqlEnv, sqlstatements, syntaxErrors, vendor| Constructor and Description |
|---|
OceanBaseMysqlSqlParser()
Construct MySQL SQL parser.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
extractVendorRawStatements(SqlParseResult.Builder builder)
Call MySQL-specific raw statement extraction logic.
|
protected TCustomLexer |
getLexer(ParserContext context)
Return the MySQL lexer instance.
|
protected TCustomParser |
getParser(ParserContext context,
TSourceTokenList tokens)
Return the MySQL SQL parser instance with updated token list.
|
protected TStatementList |
performParsing(ParserContext context,
TCustomParser parser,
TCustomParser secondaryParser,
TSourceTokenList tokens,
TStatementList rawStatements)
Perform full parsing of statements with syntax checking.
|
protected void |
setupVendorParsersForExtraction()
Setup MySQL parser for raw statement extraction.
|
protected void |
tokenizeVendorSql()
Call MySQL-specific tokenization logic.
|
String |
toString() |
afterStatementParsed, attemptErrorRecovery, copyErrorsFromStatement, doAfterTokenize, doExtractRawStatements, extractRawStatements, getanewsourcetoken, getDefaultDelimiterStr, getDelimiterChar, getErrorCount, getrawsqlstatements, getSecondaryParser, getSyntaxErrors, getVendor, handleStatementParsingException, initializeGlobalContext, isDollarFunctionDelimiter, onRawStatementComplete, onRawStatementCompleteVendorSpecific, parse, performInterpreter, performSemanticAnalysis, performTokenization, prepareSqlReader, processTokensBeforeParse, processTokensInTokenTable, setTokenHandle, tokenize, towinlinebreakpublic TLexerOceanbasemysql flexer
public OceanBaseMysqlSqlParser()
Configures the parser for MySQL database with default delimiter: semicolon (;)
Following the original TGSqlParser pattern, the lexer and parser are created once in the constructor and reused for all parsing operations.
protected TCustomLexer getLexer(ParserContext context)
The lexer is created once in the constructor and reused for all parsing operations. This method simply returns the existing instance, matching the original TGSqlParser pattern where the lexer is created once and reset before each use.
getLexer in class AbstractSqlParsercontext - parser context (not used, lexer already created)protected TCustomParser getParser(ParserContext context, TSourceTokenList tokens)
The parser is created once in the constructor and reused for all parsing operations. This method updates the token list and returns the existing instance, matching the original TGSqlParser pattern.
getParser in class AbstractSqlParsercontext - parser context (not used, parser already created)tokens - source token list to parseprotected void tokenizeVendorSql()
Delegates to domysqltexttotokenlist which handles MySQL's specific keyword recognition, delimiter handling, and token generation.
tokenizeVendorSql in class AbstractSqlParserprotected void setupVendorParsersForExtraction()
MySQL uses a single parser, so we inject sqlcmds and update the token list for the main parser only.
setupVendorParsersForExtraction in class AbstractSqlParserprotected void extractVendorRawStatements(SqlParseResult.Builder builder)
Delegates to domysqlgetrawsqlstatements which handles MySQL's statement delimiters (semicolon by default, or custom delimiter via DELIMITER command).
extractVendorRawStatements in class AbstractSqlParserbuilder - the result builder to populate with raw statementsprotected TStatementList performParsing(ParserContext context, TCustomParser parser, TCustomParser secondaryParser, TSourceTokenList tokens, TStatementList rawStatements)
This method orchestrates the parsing of all statements.
Important: This method does NOT extract raw statements - they are
passed in as a parameter already extracted by AbstractSqlParser.extractRawStatements(gudusoft.gsqlparser.parser.ParserContext, gudusoft.gsqlparser.TSourceTokenList, gudusoft.gsqlparser.TCustomLexer, long).
performParsing in class AbstractSqlParsercontext - parser contextparser - main SQL parser (TParserOceanbasemysql)secondaryParser - not used for MySQLtokens - source token listrawStatements - raw statements already extracted (never null)public String toString()
toString in class AbstractSqlParser