Class PgParserAbstract

java.lang.Object
org.pgcodekeeper.core.database.base.parser.statement.ParserAbstract<PgDatabase>
org.pgcodekeeper.core.database.pg.parser.statement.PgParserAbstract
Direct Known Subclasses:
PgAlterDomain, PgAlterFtsStatement, PgAlterIndex, PgAlterMatView, PgAlterOther, PgAlterOwner, PgAlterSequence, PgAlterView, PgCommentOn, PgCreateAggregate, PgCreateCast, PgCreateCollation, PgCreateDatabase, PgCreateDomain, PgCreateEventTrigger, PgCreateExtension, PgCreateFdw, PgCreateFtsConfiguration, PgCreateFtsDictionary, PgCreateFtsParser, PgCreateFtsTemplate, PgCreateFunction, PgCreateIndex, PgCreateOperator, PgCreatePolicy, PgCreateRule, PgCreateSchema, PgCreateSequence, PgCreateServer, PgCreateStatistics, PgCreateTrigger, PgCreateType, PgCreateUserMapping, PgCreateView, PgDeleteStatement, PgDropStatement, PgGrantPrivilege, PgInsertStatement, PgMergeStatement, PgTableAbstract, PgUpdateStatement

public abstract class PgParserAbstract extends ParserAbstract<PgDatabase>
Abstract base class for PostgreSQL statement parsers that provides common operations and utilities for parsing PostgreSQL database objects.

This class extends ParserAbstract to handle PostgreSQL-specific parsing operations such as column definitions, data types, operators, and other database constructs specific to PostgreSQL syntax.

  • Method Details

    • fillOptionParams

      public static void fillOptionParams(String[] options, BiConsumer<String,String> c, boolean isToast, boolean forceQuote, boolean isQuoted)
      Processes option parameters into key-value pairs.
      Parameters:
      options - the option strings to parse
      c - the consumer to receive each key-value pair
      isToast - whether these are TOAST options
      forceQuote - whether to force quoting of values
      isQuoted - whether values are already quoted
    • fillOptionParams

      public static void fillOptionParams(String value, String option, boolean isToast, BiConsumer<String,String> c)
      Processes a single option parameter.
      Parameters:
      value - the option value
      option - the option name
      isToast - whether this is a TOAST option
      c - the consumer to receive the key-value pair
    • unquoteQuotedString

      public static Pair<String,org.antlr.v4.runtime.Token> unquoteQuotedString(SQLParser.SconstContext ctx)
      Unquotes a string constant from a parser context and returns both the unquoted string and the corresponding token.
      Parameters:
      ctx - the string constant context to unquote
      Returns:
      a pair containing the unquoted string and its token
    • getIdentifiers

      public static List<org.antlr.v4.runtime.ParserRuleContext> getIdentifiers(SQLParser.Schema_qualified_nameContext qNameCtx)
      Extracts identifier contexts from a schema-qualified name context.
      Parameters:
      qNameCtx - the schema-qualified name context
      Returns:
      a list of parser rule contexts representing the identifiers
    • getIdentifiers

      public static List<org.antlr.v4.runtime.ParserRuleContext> getIdentifiers(SQLParser.Schema_qualified_name_nontypeContext qNameNonTypeCtx)
      Extracts identifier contexts from a schema-qualified non-type name context.
      Parameters:
      qNameNonTypeCtx - the schema-qualified non-type name context
      Returns:
      a list of parser rule contexts representing the identifiers
    • getIdentifiers

      public static List<org.antlr.v4.runtime.ParserRuleContext> getIdentifiers(SQLParser.Operator_nameContext operQNameCtx)
      Extracts identifier contexts from an operator name context.
      Parameters:
      operQNameCtx - the operator name context
      Returns:
      a list of parser rule contexts representing the operator identifiers
    • getTypeName

      public static String getTypeName(SQLParser.Data_typeContext datatype)
      Extracts the normalized type name from a data type context, converting PostgreSQL type aliases to their canonical forms.
      Parameters:
      datatype - the data type context
      Returns:
      the normalized type name string
    • parseOperatorSignature

      public static String parseOperatorSignature(String name, SQLParser.Operator_argsContext operatorArgsCtx)
      Parses an operator signature from the operator name and arguments context.
      Parameters:
      name - the operator name
      operatorArgsCtx - the operator arguments context
      Returns:
      the formatted operator signature string
    • parseArguments

      public String parseArguments(SQLParser.Function_argsContext argsContext)
      Parses function arguments from the function arguments context.
      Parameters:
      argsContext - the function arguments context
      Returns:
      the formatted arguments string
    • parseSignature

      public static String parseSignature(String name, SQLParser.Function_argsContext argsContext)
      Parses a function signature from the function name and arguments context.
      Parameters:
      name - the function name (can be null for unnamed functions)
      argsContext - the function arguments context
      Returns:
      the formatted function signature string