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

public abstract class AbstractSqlCmds extends Object implements ISqlCmds
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 Details

  • Constructor Details

    • AbstractSqlCmds

      protected AbstractSqlCmds(EDbVendor vendor)
      Constructor for vendor-specific implementation.
      Parameters:
      vendor - Database vendor this resolver handles
  • Method Details

    • getVendor

      public EDbVendor getVendor()
      Description copied from interface: ISqlCmds
      Gets the vendor this command resolver handles.
      Specified by:
      getVendor in interface ISqlCmds
      Returns:
      Database vendor
    • getSqlCmdList

      Description copied from interface: ISqlCmds
      Gets the command list for this vendor (for compatibility and debugging).
      Specified by:
      getSqlCmdList in interface ISqlCmds
      Returns:
      Command list containing all recognized commands
    • ensureInitialized

      protected void ensureInitialized()
      Ensures command list is initialized using double-checked locking. This provides thread-safe lazy initialization.
    • initializeCommands

      protected abstract void 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 pattern
      token3 - Third token pattern
      token4 - Fourth token pattern
      token5 - Fifth token pattern
      token6 - Sixth token pattern
      token7 - Seventh token pattern
      stmtType - Statement type
    • getToken1Str

      protected String getToken1Str(int token1)
      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

      protected void addCmd(int token1, ESqlStatementType stmtType)
      Overloaded helper for simpler commands.
    • addCmd

      protected void addCmd(int token1, String token2, ESqlStatementType stmtType)
    • addCmd

      protected void addCmd(int token1, String token2, String token3, ESqlStatementType stmtType)
    • addCmd

      protected void addCmd(int token1, String token2, String token3, String token4, ESqlStatementType stmtType)
    • addCmd

      protected void addCmd(int token1, String token2, String token3, String token4, String token5, ESqlStatementType stmtType)
    • addCmd

      protected void addCmd(int token1, String token2, String token3, String token4, String token5, String token6, ESqlStatementType stmtType)
    • finddbcmd

      protected TSqlCmd finddbcmd(TSourceToken pcst, TSqlCmdList cmdList)
      Find command in the list starting from a specific token. This is the core search algorithm used by all vendors.
      Parameters:
      pcst - Starting token
      cmdList - Command list to search
      Returns:
      Found command or null
    • getStatementTypeForToken

      Description copied from interface: ISqlCmds
      Finds SQL command type for yacc parser integration. Used by vendor-specific yacc parsers to identify statement types.
      Specified by:
      getStatementTypeForToken in interface ISqlCmds
      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