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
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 Summary
Modifier and TypeMethodDescriptionstatic voidfillOptionParams(String[] options, BiConsumer<String, String> c, boolean isToast, boolean forceQuote, boolean isQuoted) Processes option parameters into key-value pairs.static voidfillOptionParams(String value, String option, boolean isToast, BiConsumer<String, String> c) Processes a single option parameter.static List<org.antlr.v4.runtime.ParserRuleContext>getIdentifiers(SQLParser.Operator_nameContext operQNameCtx) Extracts identifier contexts from an operator name context.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.static List<org.antlr.v4.runtime.ParserRuleContext>Extracts identifier contexts from a schema-qualified name context.static StringgetTypeName(SQLParser.Data_typeContext datatype) Extracts the normalized type name from a data type context, converting PostgreSQL type aliases to their canonical forms.parseArguments(SQLParser.Function_argsContext argsContext) Parses function arguments from the function arguments context.static StringparseOperatorSignature(String name, SQLParser.Operator_argsContext operatorArgsCtx) Parses an operator signature from the operator name and arguments context.static StringparseSignature(String name, SQLParser.Function_argsContext argsContext) Parses a function signature from the function name and arguments context.Unquotes a string constant from a parser context and returns both the unquoted string and the corresponding token.Methods inherited from class org.pgcodekeeper.core.database.base.parser.statement.ParserAbstract
getFullCtxText, getFullCtxText, getFullCtxText, getSafe, getSafe, parseArgMode, parseObject, parseObject
-
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 parsec- the consumer to receive each key-value pairisToast- whether these are TOAST optionsforceQuote- whether to force quoting of valuesisQuoted- 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 valueoption- the option nameisToast- whether this is a TOAST optionc- 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
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 nameoperatorArgsCtx- the operator arguments context- Returns:
- the formatted operator signature string
-
parseArguments
Parses function arguments from the function arguments context.- Parameters:
argsContext- the function arguments context- Returns:
- the formatted arguments string
-
parseSignature
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
-