public class TSqlCmdsOceanbase extends TSqlCmdsMysql
OceanBase user tenants in MySQL mode and the sys system tenant
share the MySQL command surface, so this resolver inherits all MySQL
command patterns from TSqlCmdsMysql via subclassing. The
vendor field is then re-tagged to EDbVendor.dbvoceanbase so any
statement constructed via the inherited resolver carries OceanBase
vendor identity.
For Phase 1 we additionally register a small set of unmistakable
OceanBase administrative DDL prefixes (CREATE TENANT,
ALTER TENANT, DROP TENANT, ALTER SYSTEM,
CREATE/ALTER RESOURCE POOL, CREATE/ALTER RESOURCE UNIT)
so the splitter recognizes them as statement boundaries in multi-statement
admin scripts. These statements are tagged ESqlStatementType.sstunknown
because Phase 1 has no AST nodes for them yet — Phase 4 will add proper
AST classes and replace sstunknown with vendor-specific types
such as sstoceanbase_create_tenant.
This class is constructed once per TGSqlParser
instance via SqlCmdsFactory, before the user has had a chance to
call setOBTenantMode. So a single TSqlCmdsOceanbase
cannot select between MySQL-family and Oracle-family command sets at
construction time. Phase 1 deliberately accepts a MySQL-family command
surface here because:
OracleSqlParser)
used by OceanBaseSqlParser for ORACLE mode has its
own internal TSqlCmdsOracle that handles PL/SQL boundary
detection independently of this class.TGSqlParser-level sqlcmds field is consulted
primarily for validation and post-processing of MySQL-family
statements; ORACLE-mode dbvoceanbase scripts that exercise this
class are a Phase 4 concern.Phase 4 will revisit whether TSqlCmdsOceanbase should grow
mode-awareness via a separate factory dispatch path or whether it should
be split into TSqlCmdsOceanbaseMysql / TSqlCmdsOceanbaseOracle
with the active instance selected from EOBTenantMode.
TSqlCmdsMysql,
SqlCmdsFactory,
EOBTenantModegnewsqlstatementtype, initialized, initLock, sqlCmdList, vendor| Constructor and Description |
|---|
TSqlCmdsOceanbase() |
| Modifier and Type | Method and Description |
|---|---|
static String |
detectSystemPrefixConflict(String sqltext)
Scan
sqltext for an unmistakable OceanBase system-tenant DDL
prefix at a statement boundary. |
protected String |
getToken1Str(int token1)
Get the string representation for vendor-specific token codes.
|
protected void |
initializeCommands()
Initialize vendor-specific commands.
|
TCustomSqlStatement |
issql(TSourceToken pcst,
EFindSqlStateType pstate,
TCustomSqlStatement psqlstatement)
Identifies the SQL statement type from a token stream.
|
addCmd, addCmd, addCmd, addCmd, addCmd, addCmd, addCmd, addCmd, ensureInitialized, findcte, finddbcmd, getSqlCmdList, getStatementTypeForToken, getVendorpublic TSqlCmdsOceanbase()
protected void initializeCommands()
AbstractSqlCmdsinitializeCommands in class TSqlCmdsMysqlprotected String getToken1Str(int token1)
AbstractSqlCmdsgetToken1Str in class TSqlCmdsMysqltoken1 - Token codepublic TCustomSqlStatement issql(TSourceToken pcst, EFindSqlStateType pstate, TCustomSqlStatement psqlstatement)
The inherited TSqlCmdsMysql.issql(gudusoft.gsqlparser.TSourceToken, gudusoft.gsqlparser.EFindSqlStateType, gudusoft.gsqlparser.TCustomSqlStatement) switch statement does not
know about sstoceanbase_* enum values and routes them to its
default branch, which produces a TUnknownSqlStatement.
This override intercepts the result and swaps in the proper OceanBase
statement class when a tenant-family type is detected, preserving the
splitter's tag on the returned instance.
issql in interface ISqlCmdsissql in class TSqlCmdsMysqlpcst - Current token being analyzedpstate - Current parsing state (start, in body, or in exception)psqlstatement - Current statement being built (may be modified)public static String detectSystemPrefixConflict(String sqltext)
sqltext for an unmistakable OceanBase system-tenant DDL
prefix at a statement boundary. Comments and string literals are
masked before the scan so text inside them cannot trigger a false
positive.
This helper exists so OceanBaseSqlParser can emit a
targeted error when a user submits system-tenant DDL while the
parser is in EOBTenantMode.ORACLE, matching the real
OceanBase server's "wrong tenant" rejection with a clearer
message than a raw Oracle yacc syntax error at the TENANT
token.
Per ADR-7 the check is narrow by design and the caller still owns mode selection — this helper reports; it never promotes.
sqltext - the raw SQL script to scan; may be null"CREATE TENANT") when a system-only prefix is
found, or null when the script contains no such
prefix (or the input is null / empty)