Package gudusoft.gsqlparser.sqlcmds
Class AbstractSqlCmds
Object
gudusoft.gsqlparser.sqlcmds.AbstractSqlCmds
- All Implemented Interfaces:
ISqlCmds
- Direct Known Subclasses:
TSqlCmdsAthena,TSqlCmdsBigquery,TSqlCmdsCouchbase,TSqlCmdsDatabricks,TSqlCmdsDb2,TSqlCmdsGaussdb,TSqlCmdsGreenplum,TSqlCmdsHana,TSqlCmdsHive,TSqlCmdsInformix,TSqlCmdsMdx,TSqlCmdsMssql,TSqlCmdsMysql,TSqlCmdsNetezza,TSqlCmdsOdbc,TSqlCmdsOpenedge,TSqlCmdsOracle,TSqlCmdsPostgresql,TSqlCmdsPresto,TSqlCmdsRedshift,TSqlCmdsSnowflake,TSqlCmdsSoql,TSqlCmdsSparksql,TSqlCmdsSybase,TSqlCmdsTeradata,TSqlCmdsTrino,TSqlCmdsVertica
Abstract base class for vendor-specific SQL command resolvers.
Provides common functionality and the TSqlCmd/TSqlCmdList infrastructure
that all vendor implementations share.
- Since:
- 3.1.0.9
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ESqlStatementTypeTemporary field for tracking statement type during issql() processing.protected booleanprotected final Objectprotected TSqlCmdListprotected EDbVendor -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSqlCmds(EDbVendor vendor) Constructor for vendor-specific implementation. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCmd(int token1, ESqlStatementType stmtType) Overloaded helper for simpler commands.protected voidaddCmd(int token1, String token2, ESqlStatementType stmtType) protected voidaddCmd(int token1, String token2, String token3, ESqlStatementType stmtType) protected voidaddCmd(int token1, String token2, String token3, String token4, ESqlStatementType stmtType) protected voidaddCmd(int token1, String token2, String token3, String token4, String token5, ESqlStatementType stmtType) protected voidaddCmd(int token1, String token2, String token3, String token4, String token5, String token6, ESqlStatementType stmtType) protected voidaddCmd(int token1, String token2, String token3, String token4, String token5, String token6, String token7, ESqlStatementType stmtType) Helper method to add a command to the list.protected voidEnsures command list is initialized using double-checked locking.protected TCustomSqlStatementfindcte(TSourceToken ptoken) Detect Common Table Expression (CTE) for all database vendors.protected TSqlCmdfinddbcmd(TSourceToken pcst, TSqlCmdList cmdList) Find command in the list starting from a specific token.Gets the command list for this vendor (for compatibility and debugging).Finds SQL command type for yacc parser integration.protected StringgetToken1Str(int token1) Get the string representation for vendor-specific token codes.Gets the vendor this command resolver handles.protected abstract voidInitialize vendor-specific commands.
-
Field Details
-
vendor
-
sqlCmdList
-
initLock
-
initialized
-
gnewsqlstatementtype
Temporary field for tracking statement type during issql() processing. Used by both findcte() and issql() methods.
-
-
Constructor Details
-
AbstractSqlCmds
Constructor for vendor-specific implementation.- Parameters:
vendor- Database vendor this resolver handles
-
-
Method Details
-
getVendor
Description copied from interface:ISqlCmdsGets the vendor this command resolver handles. -
getSqlCmdList
Description copied from interface:ISqlCmdsGets the command list for this vendor (for compatibility and debugging).- Specified by:
getSqlCmdListin interfaceISqlCmds- Returns:
- Command list containing all recognized commands
-
ensureInitialized
Ensures command list is initialized using double-checked locking. This provides thread-safe lazy initialization. -
initializeCommands
Initialize vendor-specific commands. Subclasses must implement this to populate sqlCmdList. -
addCmd
protected void addCmd(int token1, String token2, String token3, String token4, String token5, String token6, String token7, ESqlStatementType stmtType) Helper method to add a command to the list. Simplifies command initialization in subclasses.- Parameters:
token1- First token (keyword)token2- Second token patterntoken3- Third token patterntoken4- Fourth token patterntoken5- Fifth token patterntoken6- Sixth token patterntoken7- Seventh token patternstmtType- Statement type
-
getToken1Str
Get the string representation for vendor-specific token codes. Subclasses should override this method to provide mappings for vendor-specific reserved words (tokens > TBaseType.rrw_abort).- Parameters:
token1- Token code- Returns:
- String representation of the token, or null if not applicable
-
addCmd
Overloaded helper for simpler commands. -
addCmd
-
addCmd
-
addCmd
protected void addCmd(int token1, String token2, String token3, String token4, ESqlStatementType stmtType) -
addCmd
-
addCmd
-
finddbcmd
Find command in the list starting from a specific token. This is the core search algorithm used by all vendors.- Parameters:
pcst- Starting tokencmdList- Command list to search- Returns:
- Found command or null
-
getStatementTypeForToken
Description copied from interface:ISqlCmdsFinds SQL command type for yacc parser integration. Used by vendor-specific yacc parsers to identify statement types.- Specified by:
getStatementTypeForTokenin interfaceISqlCmds- Parameters:
token- Token to analyze- Returns:
- SQL statement type, or sstunknown if not recognized
-
findcte
Detect Common Table Expression (CTE) for all database vendors. Handles WITH clauses before DELETE, INSERT, SELECT, UPDATE, MERGE. This is a shared method used by all vendor implementations since CTE syntax is similar across vendors (standardized by SQL:1999).- Parameters:
ptoken- The WITH token- Returns:
- Statement object for the CTE query, or null if not a valid CTE
-