diff --git a/src/include/parser/gramparse.h b/src/include/parser/gramparse.h index adade36..5544d7f 100644 --- a/src/include/parser/gramparse.h +++ b/src/include/parser/gramparse.h @@ -8,8 +8,8 @@ * Definitions that are needed outside the core parser should be in parser.h. * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/parser/gramparse.h diff --git a/src/include/parser/keywords.h b/src/include/parser/keywords.h index 63f074d..e2f44d0 100644 --- a/src/include/parser/keywords.h +++ b/src/include/parser/keywords.h @@ -4,8 +4,8 @@ * lexical token lookup for key words in PostgreSQL * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/parser/keywords.h diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h index e202eeb..8e07e97 100644 --- a/src/include/parser/kwlist.h +++ b/src/include/parser/kwlist.h @@ -7,8 +7,8 @@ * by the PG_KEYWORD macro, which is not defined in this file; it can * be defined by the caller for special purposes. * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION @@ -64,6 +64,7 @@ PG_KEYWORD("boolean", BOOLEAN_P, COL_NAME_KEYWORD) PG_KEYWORD("both", BOTH, RESERVED_KEYWORD) PG_KEYWORD("by", BY, UNRESERVED_KEYWORD) PG_KEYWORD("cache", CACHE, UNRESERVED_KEYWORD) +PG_KEYWORD("call", CALL, UNRESERVED_KEYWORD) PG_KEYWORD("called", CALLED, UNRESERVED_KEYWORD) PG_KEYWORD("cascade", CASCADE, UNRESERVED_KEYWORD) PG_KEYWORD("cascaded", CASCADED, UNRESERVED_KEYWORD) @@ -182,6 +183,7 @@ PG_KEYWORD("granted", GRANTED, UNRESERVED_KEYWORD) PG_KEYWORD("greatest", GREATEST, COL_NAME_KEYWORD) PG_KEYWORD("group", GROUP_P, RESERVED_KEYWORD) PG_KEYWORD("grouping", GROUPING, COL_NAME_KEYWORD) +PG_KEYWORD("groups", GROUPS, UNRESERVED_KEYWORD) PG_KEYWORD("handler", HANDLER, UNRESERVED_KEYWORD) PG_KEYWORD("having", HAVING, RESERVED_KEYWORD) PG_KEYWORD("header", HEADER_P, UNRESERVED_KEYWORD) @@ -195,6 +197,7 @@ PG_KEYWORD("immutable", IMMUTABLE, UNRESERVED_KEYWORD) PG_KEYWORD("implicit", IMPLICIT_P, UNRESERVED_KEYWORD) PG_KEYWORD("import", IMPORT_P, UNRESERVED_KEYWORD) PG_KEYWORD("in", IN_P, RESERVED_KEYWORD) +PG_KEYWORD("include", INCLUDE, UNRESERVED_KEYWORD) PG_KEYWORD("including", INCLUDING, UNRESERVED_KEYWORD) PG_KEYWORD("increment", INCREMENT, UNRESERVED_KEYWORD) PG_KEYWORD("index", INDEX, UNRESERVED_KEYWORD) @@ -283,6 +286,7 @@ PG_KEYWORD("options", OPTIONS, UNRESERVED_KEYWORD) PG_KEYWORD("or", OR, RESERVED_KEYWORD) PG_KEYWORD("order", ORDER, RESERVED_KEYWORD) PG_KEYWORD("ordinality", ORDINALITY, UNRESERVED_KEYWORD) +PG_KEYWORD("others", OTHERS, UNRESERVED_KEYWORD) PG_KEYWORD("out", OUT_P, COL_NAME_KEYWORD) PG_KEYWORD("outer", OUTER_P, TYPE_FUNC_NAME_KEYWORD) PG_KEYWORD("over", OVER, UNRESERVED_KEYWORD) @@ -312,6 +316,7 @@ PG_KEYWORD("prior", PRIOR, UNRESERVED_KEYWORD) PG_KEYWORD("privileges", PRIVILEGES, UNRESERVED_KEYWORD) PG_KEYWORD("procedural", PROCEDURAL, UNRESERVED_KEYWORD) PG_KEYWORD("procedure", PROCEDURE, UNRESERVED_KEYWORD) +PG_KEYWORD("procedures", PROCEDURES, UNRESERVED_KEYWORD) PG_KEYWORD("program", PROGRAM, UNRESERVED_KEYWORD) PG_KEYWORD("publication", PUBLICATION, UNRESERVED_KEYWORD) PG_KEYWORD("quote", QUOTE, UNRESERVED_KEYWORD) @@ -342,6 +347,8 @@ PG_KEYWORD("right", RIGHT, TYPE_FUNC_NAME_KEYWORD) PG_KEYWORD("role", ROLE, UNRESERVED_KEYWORD) PG_KEYWORD("rollback", ROLLBACK, UNRESERVED_KEYWORD) PG_KEYWORD("rollup", ROLLUP, UNRESERVED_KEYWORD) +PG_KEYWORD("routine", ROUTINE, UNRESERVED_KEYWORD) +PG_KEYWORD("routines", ROUTINES, UNRESERVED_KEYWORD) PG_KEYWORD("row", ROW, COL_NAME_KEYWORD) PG_KEYWORD("rows", ROWS, UNRESERVED_KEYWORD) PG_KEYWORD("rule", RULE, UNRESERVED_KEYWORD) @@ -395,6 +402,7 @@ PG_KEYWORD("template", TEMPLATE, UNRESERVED_KEYWORD) PG_KEYWORD("temporary", TEMPORARY, UNRESERVED_KEYWORD) PG_KEYWORD("text", TEXT_P, UNRESERVED_KEYWORD) PG_KEYWORD("then", THEN, RESERVED_KEYWORD) +PG_KEYWORD("ties", TIES, UNRESERVED_KEYWORD) PG_KEYWORD("time", TIME, COL_NAME_KEYWORD) PG_KEYWORD("timestamp", TIMESTAMP, COL_NAME_KEYWORD) PG_KEYWORD("to", TO, RESERVED_KEYWORD) diff --git a/src/include/parser/makefuncs.h b/src/include/parser/makefuncs.h index 9681923..b39c19e 100644 --- a/src/include/parser/makefuncs.h +++ b/src/include/parser/makefuncs.h @@ -4,8 +4,8 @@ * prototypes for the creator functions (for primitive nodes) * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/nodes/makefuncs.h @@ -87,4 +87,6 @@ extern DefElem *makeDefElemExtended(char *nameSpace, char *name, Node *arg, extern GroupingSet *makeGroupingSet(GroupingSetKind kind, List *content, int location); +extern VacuumRelation *makeVacuumRelation(RangeVar *relation, Oid oid, List *va_cols); + #endif /* MAKEFUNC_H */ diff --git a/src/include/parser/nodes.h b/src/include/parser/nodes.h index 666df5f..4df7e13 100644 --- a/src/include/parser/nodes.h +++ b/src/include/parser/nodes.h @@ -4,8 +4,8 @@ * Definitions for tagged nodes. * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/nodes/nodes.h @@ -37,6 +37,7 @@ typedef enum NodeTag T_ExprContext, T_ProjectionInfo, T_JunkFilter, + T_OnConflictSetState, T_ResultRelInfo, T_EState, T_TupleTableSlot, @@ -89,6 +90,10 @@ typedef enum NodeTag /* these aren't subclasses of Plan: */ T_NestLoopParam, T_PlanRowMark, + T_PartitionPruneInfo, + T_PartitionedRelPruneInfo, + T_PartitionPruneStepOp, + T_PartitionPruneStepCombine, T_PlanInvalItem, /* @@ -263,7 +268,6 @@ typedef enum NodeTag T_PlaceHolderVar, T_SpecialJoinInfo, T_AppendRelInfo, - T_PartitionedChildRelInfo, T_PlaceHolderInfo, T_MinMaxAggInfo, T_PlannerParamItem, @@ -277,6 +281,7 @@ typedef enum NodeTag T_MemoryContext, T_AllocSetContext, T_SlabContext, + T_GenerationContext, /* * TAGS FOR VALUE NODES (value.h) @@ -416,6 +421,7 @@ typedef enum NodeTag T_DropSubscriptionStmt, T_CreateStatsStmt, T_AlterCollationStmt, + T_CallStmt, /* * TAGS FOR PARSE TREE NODES (parsenodes.h) @@ -471,6 +477,7 @@ typedef enum NodeTag T_PartitionBoundSpec, T_PartitionRangeDatum, T_PartitionCmd, + T_VacuumRelation, /* * TAGS FOR REPLICATION GRAMMAR PARSE NODES (replnodes.h) @@ -500,7 +507,8 @@ typedef enum NodeTag T_FdwRoutine, /* in foreign/fdwapi.h */ T_IndexAmRoutine, /* in access/amapi.h */ TsmRoutine , /* in access/tsmapi.h */ - T_ForeignKeyCacheInfo, /* in utils/rel.h */ + T_ForeignKeyCacheInfo, /* in utils/rel.h */ + T_CallContext, /* in nodes/parsenodes.h */ /* pgpool Extention */ T_PgpoolVariableSetStmt, T_PgpoolVariableShowStmt diff --git a/src/include/parser/parsenodes.h b/src/include/parser/parsenodes.h index e30206f..438b76a 100644 --- a/src/include/parser/parsenodes.h +++ b/src/include/parser/parsenodes.h @@ -12,8 +12,8 @@ * identifying statement boundaries in multi-statement source strings. * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/nodes/parsenodes.h @@ -112,7 +112,7 @@ typedef struct Query QuerySource querySource; /* where did I come from? */ - uint32 queryId; /* query identifier (can be set by plugins) */ + uint64 queryId; /* query identifier (can be set by plugins) */ bool canSetTag; /* do I set the command result tag? */ @@ -199,7 +199,7 @@ typedef struct Query * Similarly, if "typmods" is NIL then the actual typmod is expected to * be prespecified in typemod, otherwise typemod is unused. * - * If pct_type is TRUE, then names is actually a field name and we look up + * If pct_type is true, then names is actually a field name and we look up * the type of that field. Otherwise (the normal case), names is a type * name possibly qualified with schema and database name. */ @@ -500,27 +500,33 @@ typedef struct WindowDef * which were defaulted; the correct behavioral bits must be set either way. * The START_foo and END_foo options must come in pairs of adjacent bits for * the convenience of gram.y, even though some of them are useless/invalid. - * We will need more bits (and fields) to cover the full SQL:2008 option set. */ #define FRAMEOPTION_NONDEFAULT 0x00001 /* any specified? */ #define FRAMEOPTION_RANGE 0x00002 /* RANGE behavior */ #define FRAMEOPTION_ROWS 0x00004 /* ROWS behavior */ -#define FRAMEOPTION_BETWEEN 0x00008 /* BETWEEN given? */ -#define FRAMEOPTION_START_UNBOUNDED_PRECEDING 0x00010 /* start is U. P. */ -#define FRAMEOPTION_END_UNBOUNDED_PRECEDING 0x00020 /* (disallowed) */ -#define FRAMEOPTION_START_UNBOUNDED_FOLLOWING 0x00040 /* (disallowed) */ -#define FRAMEOPTION_END_UNBOUNDED_FOLLOWING 0x00080 /* end is U. F. */ -#define FRAMEOPTION_START_CURRENT_ROW 0x00100 /* start is C. R. */ -#define FRAMEOPTION_END_CURRENT_ROW 0x00200 /* end is C. R. */ -#define FRAMEOPTION_START_VALUE_PRECEDING 0x00400 /* start is V. P. */ -#define FRAMEOPTION_END_VALUE_PRECEDING 0x00800 /* end is V. P. */ -#define FRAMEOPTION_START_VALUE_FOLLOWING 0x01000 /* start is V. F. */ -#define FRAMEOPTION_END_VALUE_FOLLOWING 0x02000 /* end is V. F. */ - -#define FRAMEOPTION_START_VALUE \ - (FRAMEOPTION_START_VALUE_PRECEDING | FRAMEOPTION_START_VALUE_FOLLOWING) -#define FRAMEOPTION_END_VALUE \ - (FRAMEOPTION_END_VALUE_PRECEDING | FRAMEOPTION_END_VALUE_FOLLOWING) +#define FRAMEOPTION_GROUPS 0x00008 /* GROUPS behavior */ +#define FRAMEOPTION_BETWEEN 0x00010 /* BETWEEN given? */ +#define FRAMEOPTION_START_UNBOUNDED_PRECEDING 0x00020 /* start is U. P. */ +#define FRAMEOPTION_END_UNBOUNDED_PRECEDING 0x00040 /* (disallowed) */ +#define FRAMEOPTION_START_UNBOUNDED_FOLLOWING 0x00080 /* (disallowed) */ +#define FRAMEOPTION_END_UNBOUNDED_FOLLOWING 0x00100 /* end is U. F. */ +#define FRAMEOPTION_START_CURRENT_ROW 0x00200 /* start is C. R. */ +#define FRAMEOPTION_END_CURRENT_ROW 0x00400 /* end is C. R. */ +#define FRAMEOPTION_START_OFFSET_PRECEDING 0x00800 /* start is O. P. */ +#define FRAMEOPTION_END_OFFSET_PRECEDING 0x01000 /* end is O. P. */ +#define FRAMEOPTION_START_OFFSET_FOLLOWING 0x02000 /* start is O. F. */ +#define FRAMEOPTION_END_OFFSET_FOLLOWING 0x04000 /* end is O. F. */ +#define FRAMEOPTION_EXCLUDE_CURRENT_ROW 0x08000 /* omit C.R. */ +#define FRAMEOPTION_EXCLUDE_GROUP 0x10000 /* omit C.R. & peers */ +#define FRAMEOPTION_EXCLUDE_TIES 0x20000 /* omit C.R.'s peers */ + +#define FRAMEOPTION_START_OFFSET \ + (FRAMEOPTION_START_OFFSET_PRECEDING | FRAMEOPTION_START_OFFSET_FOLLOWING) +#define FRAMEOPTION_END_OFFSET \ + (FRAMEOPTION_END_OFFSET_PRECEDING | FRAMEOPTION_END_OFFSET_FOLLOWING) +#define FRAMEOPTION_EXCLUSION \ + (FRAMEOPTION_EXCLUDE_CURRENT_ROW | FRAMEOPTION_EXCLUDE_GROUP | \ + FRAMEOPTION_EXCLUDE_TIES) #define FRAMEOPTION_DEFAULTS \ (FRAMEOPTION_RANGE | FRAMEOPTION_START_UNBOUNDED_PRECEDING | \ @@ -648,6 +654,8 @@ typedef struct ColumnDef Node *raw_default; /* default value (untransformed parse tree) */ Node *cooked_default; /* default value (transformed expr tree) */ char identity; /* attidentity setting */ + RangeVar *identitySequence; /* to store identity sequence name for + * ALTER TABLE ... ADD COLUMN */ CollateClause *collClause; /* untransformed COLLATE spec, if any */ Oid collOid; /* collation OID (InvalidOid if not set) */ List *constraints; /* other constraints on column */ @@ -667,12 +675,13 @@ typedef struct TableLikeClause typedef enum TableLikeOption { - CREATE_TABLE_LIKE_DEFAULTS = 1 << 0, + CREATE_TABLE_LIKE_COMMENTS = 1 << 0, CREATE_TABLE_LIKE_CONSTRAINTS = 1 << 1, - CREATE_TABLE_LIKE_IDENTITY = 1 << 2, - CREATE_TABLE_LIKE_INDEXES = 1 << 3, - CREATE_TABLE_LIKE_STORAGE = 1 << 4, - CREATE_TABLE_LIKE_COMMENTS = 1 << 5, + CREATE_TABLE_LIKE_DEFAULTS = 1 << 2, + CREATE_TABLE_LIKE_IDENTITY = 1 << 3, + CREATE_TABLE_LIKE_INDEXES = 1 << 4, + CREATE_TABLE_LIKE_STATISTICS = 1 << 5, + CREATE_TABLE_LIKE_STORAGE = 1 << 6, CREATE_TABLE_LIKE_ALL = PG_INT32_MAX } TableLikeOption; @@ -778,12 +787,14 @@ typedef struct PartitionElem typedef struct PartitionSpec { NodeTag type; - char *strategy; /* partitioning strategy ('list' or 'range') */ + char *strategy; /* partitioning strategy ('hash', 'list' or + * 'range') */ List *partParams; /* List of PartitionElems */ int location; /* token location, or -1 if unknown */ } PartitionSpec; /* Internal codes for partitioning strategies */ +#define PARTITION_STRATEGY_HASH 'h' #define PARTITION_STRATEGY_LIST 'l' #define PARTITION_STRATEGY_RANGE 'r' @@ -798,6 +809,11 @@ typedef struct PartitionBoundSpec NodeTag type; char strategy; /* see PARTITION_STRATEGY codes above */ + bool is_default; /* is it a default partition bound? */ + + /* Partitioning info for HASH strategy: */ + int modulus; + int remainder; /* Partitioning info for LIST strategy: */ List *listdatums; /* List of Consts (or A_Consts in raw tree) */ @@ -833,7 +849,7 @@ typedef struct PartitionRangeDatum } PartitionRangeDatum; /* - * PartitionCmd - info for ALTER TABLE ATTACH/DETACH PARTITION commands + * PartitionCmd - info for ALTER TABLE/INDEX ATTACH/DETACH PARTITION commands */ typedef struct PartitionCmd { @@ -888,8 +904,8 @@ typedef struct PartitionCmd * them from the joinaliasvars list, because that would affect the attnums * of Vars referencing the rest of the list.) * - * inh is TRUE for relation references that should be expanded to include - * inheritance children, if the rel has any. This *must* be FALSE for + * inh is true for relation references that should be expanded to include + * inheritance children, if the rel has any. This *must* be false for * RTEs other than RTE_RELATION entries. * * inFromCl marks those range variables that are listed in the FROM clause. @@ -1026,6 +1042,11 @@ typedef struct RangeTblEntry * from the catalogs if 'relid' was supplied, but we'd still need these * for TupleDesc-based ENRs, so we might as well always store the type * info here). + * + * For ENRs only, we have to consider the possibility of dropped columns. + * A dropped column is included in these lists, but it will have zeroes in + * all three lists (as well as an empty-string entry in eref). Testing + * for zero coltype is the standard way to detect a dropped column. */ List *coltypes; /* OID list of column type OIDs */ List *coltypmods; /* integer list of column typmods */ @@ -1142,7 +1163,7 @@ typedef struct WithCheckOption * or InvalidOid if not available. * nulls_first means about what you'd expect. If sortop is InvalidOid * then nulls_first is meaningless and should be set to false. - * hashable is TRUE if eqop is hashable (note this condition also depends + * hashable is true if eqop is hashable (note this condition also depends * on the datatype of the input expression). * * In an ORDER BY item, all fields must be valid. (The eqop isn't essential @@ -1264,6 +1285,9 @@ typedef struct GroupingSet * if the clause originally came from WINDOW, and is NULL if it originally * was an OVER clause (but note that we collapse out duplicate OVERs). * partitionClause and orderClause are lists of SortGroupClause structs. + * If we have RANGE with offset PRECEDING/FOLLOWING, the semantics of that are + * specified by startInRangeFunc/inRangeColl/inRangeAsc/inRangeNullsFirst + * for the start offset, or endInRangeFunc/inRange* for the end offset. * winref is an ID number referenced by WindowFunc nodes; it must be unique * among the members of a Query's windowClause list. * When refname isn't null, the partitionClause is always copied from there; @@ -1280,6 +1304,11 @@ typedef struct WindowClause int frameOptions; /* frame_clause options, see WindowDef */ Node *startOffset; /* expression for starting bound, if any */ Node *endOffset; /* expression for ending bound, if any */ + Oid startInRangeFunc; /* in_range function for startOffset */ + Oid endInRangeFunc; /* in_range function for endOffset */ + Oid inRangeColl; /* collation for in_range tests */ + bool inRangeAsc; /* use ASC sort order for in_range tests? */ + bool inRangeNullsFirst; /* nulls sort first for in_range tests? */ Index winref; /* ID referenced by window functions */ bool copiedOrder; /* did we copy orderClause from refname? */ } WindowClause; @@ -1631,9 +1660,11 @@ typedef enum ObjectType OBJECT_OPERATOR, OBJECT_OPFAMILY, OBJECT_POLICY, + OBJECT_PROCEDURE, OBJECT_PUBLICATION, OBJECT_PUBLICATION_REL, OBJECT_ROLE, + OBJECT_ROUTINE, OBJECT_RULE, OBJECT_SCHEMA, OBJECT_SEQUENCE, @@ -1708,6 +1739,7 @@ typedef enum AlterTableType AT_AddConstraint, /* add constraint */ AT_AddConstraintRecurse, /* internal to commands/tablecmds.c */ AT_ReAddConstraint, /* internal to commands/tablecmds.c */ + AT_ReAddDomainConstraint, /* internal to commands/tablecmds.c */ AT_AlterConstraint, /* alter constraint */ AT_ValidateConstraint, /* validate constraint */ AT_ValidateConstraintRecurse, /* internal to commands/tablecmds.c */ @@ -1773,6 +1805,8 @@ typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */ AlterTableType subtype; /* Type of table alteration to apply */ char *name; /* column, constraint, or trigger to act on, * or tablespace */ + int16 num; /* attribute number for columns referenced by + * number */ RoleSpec *newowner; Node *def; /* definition of new column, index, * constraint, or parent table */ @@ -1829,29 +1863,12 @@ typedef enum GrantTargetType ACL_TARGET_DEFAULTS /* ALTER DEFAULT PRIVILEGES */ } GrantTargetType; -typedef enum GrantObjectType -{ - ACL_OBJECT_COLUMN, /* column */ - ACL_OBJECT_RELATION, /* table, view */ - ACL_OBJECT_SEQUENCE, /* sequence */ - ACL_OBJECT_DATABASE, /* database */ - ACL_OBJECT_DOMAIN, /* domain */ - ACL_OBJECT_FDW, /* foreign-data wrapper */ - ACL_OBJECT_FOREIGN_SERVER, /* foreign server */ - ACL_OBJECT_FUNCTION, /* function */ - ACL_OBJECT_LANGUAGE, /* procedural language */ - ACL_OBJECT_LARGEOBJECT, /* largeobject */ - ACL_OBJECT_NAMESPACE, /* namespace */ - ACL_OBJECT_TABLESPACE, /* tablespace */ - ACL_OBJECT_TYPE /* type */ -} GrantObjectType; - typedef struct GrantStmt { NodeTag type; bool is_grant; /* true = GRANT, false = REVOKE */ GrantTargetType targtype; /* type of the grant target */ - GrantObjectType objtype; /* kind of object being operated on */ + ObjectType objtype; /* kind of object being operated on */ List *objects; /* list of RangeVar nodes, ObjectWithArgs * nodes, or plain names (as Value strings) */ List *privileges; /* list of AccessPriv nodes */ @@ -2086,7 +2103,10 @@ typedef struct Constraint char generated_when; /* Fields used for unique constraints (UNIQUE and PRIMARY KEY): */ - List *keys; /* String nodes naming referenced column(s) */ + List *keys; /* String nodes naming referenced key + * column(s) */ + List *including; /* String nodes naming referenced nonkey + * column(s) */ /* Fields used for EXCLUSION constraints: */ List *exclusions; /* list of (IndexElem, operator name) pairs */ @@ -2672,7 +2692,7 @@ typedef struct FetchStmt FetchDirection direction; /* see above */ long howMany; /* number of rows, or position argument */ char *portalname; /* name of portal (cursor) */ - bool ismove; /* TRUE if MOVE */ + bool ismove; /* true if MOVE */ } FetchStmt; /* ---------------------- @@ -2684,6 +2704,10 @@ typedef struct FetchStmt * index, just a UNIQUE/PKEY constraint using an existing index. isconstraint * must always be true in this case, and the fields describing the index * properties are empty. + * + * The relation to build the index on can be represented either by name + * (in which case the RangeVar indicates whether to recurse or not) or by OID + * (in which case the command is always recursive). * ---------------------- */ typedef struct IndexStmt @@ -2691,9 +2715,12 @@ typedef struct IndexStmt NodeTag type; char *idxname; /* name of new index, or NULL for default */ RangeVar *relation; /* relation to build index on */ + Oid relationId; /* OID of relation to build index on */ char *accessMethod; /* name of access method (eg. btree) */ char *tableSpace; /* tablespace, or NULL for default */ List *indexParams; /* columns to index: a list of IndexElem */ + List *indexIncludingParams; /* additional columns to index: a list + * of IndexElem */ List *options; /* WITH clause options: a list of DefElem */ Node *whereClause; /* qualification (partial-index predicate) */ List *excludeOpNames; /* exclusion operator names, or NIL if none */ @@ -2721,6 +2748,7 @@ typedef struct CreateStatsStmt List *stat_types; /* stat types (list of Value strings) */ List *exprs; /* expressions to build statistics on */ List *relations; /* rels to build stats on (list of RangeVar) */ + char *stxcomment; /* comment to apply to stats, or NULL */ bool if_not_exists; /* do nothing if stats name already exists */ } CreateStatsStmt; @@ -2731,12 +2759,12 @@ typedef struct CreateStatsStmt typedef struct CreateFunctionStmt { NodeTag type; + bool is_procedure; /* it's really CREATE PROCEDURE */ bool replace; /* T => replace if already exists */ List *funcname; /* qualified name of function to create */ List *parameters; /* a list of FunctionParameter */ TypeName *returnType; /* the return type */ List *options; /* a list of DefElem */ - List *withClause; /* a list of DefElem */ } CreateFunctionStmt; typedef enum FunctionParameterMode @@ -2761,6 +2789,7 @@ typedef struct FunctionParameter typedef struct AlterFunctionStmt { NodeTag type; + ObjectType objtype; ObjectWithArgs *func; /* name and args of function */ List *actions; /* list of DefElem */ } AlterFunctionStmt; @@ -2783,9 +2812,27 @@ typedef struct InlineCodeBlock char *source_text; /* source text of anonymous code block */ Oid langOid; /* OID of selected language */ bool langIsTrusted; /* trusted property of the language */ + bool atomic; /* atomic execution context */ } InlineCodeBlock; /* ---------------------- + * CALL statement + * ---------------------- + */ +typedef struct CallStmt +{ + NodeTag type; + FuncCall *funccall; /* from the parser */ + FuncExpr *funcexpr; /* transformed */ +} CallStmt; + +typedef struct CallContext +{ + NodeTag type; + bool atomic; +} CallContext; + +/* ---------------------- * Alter Object Rename Statement * ---------------------- */ @@ -2925,7 +2972,8 @@ typedef struct TransactionStmt { NodeTag type; TransactionStmtKind kind; /* see above */ - List *options; /* for BEGIN/START and savepoint commands */ + List *options; /* for BEGIN/START commands */ + char *savepoint_name; /* for savepoint commands */ char *gid; /* for two-phase-commit related commands */ } TransactionStmt; @@ -3091,12 +3139,26 @@ typedef enum VacuumOption VACOPT_DISABLE_PAGE_SKIPPING = 1 << 7 /* don't skip any pages */ } VacuumOption; +/* + * Info about a single target table of VACUUM/ANALYZE. + * + * If the OID field is set, it always identifies the table to process. + * Then the relation field can be NULL; if it isn't, it's used only to report + * failure to open/lock the relation. + */ +typedef struct VacuumRelation +{ + NodeTag type; + RangeVar *relation; /* table name to process, or NULL */ + Oid oid; /* table's OID; InvalidOid if not looked up */ + List *va_cols; /* list of column names, or NIL for all */ +} VacuumRelation; + typedef struct VacuumStmt { NodeTag type; int options; /* OR of VacuumOption flags */ - RangeVar *relation; /* single table to process, or NULL */ - List *va_cols; /* list of column names, or NIL for all */ + List *rels; /* list of VacuumRelation, or NIL for all */ } VacuumStmt; /* ---------------------- @@ -3369,7 +3431,7 @@ typedef struct AlterTSConfigurationStmt typedef struct CreatePublicationStmt { NodeTag type; - char *pubname; /* Name of of the publication */ + char *pubname; /* Name of the publication */ List *options; /* List of DefElem nodes */ List *tables; /* Optional list of tables to add */ bool for_all_tables; /* Special publication for all tables in db */ @@ -3378,7 +3440,7 @@ typedef struct CreatePublicationStmt typedef struct AlterPublicationStmt { NodeTag type; - char *pubname; /* Name of of the publication */ + char *pubname; /* Name of the publication */ /* parameters used for ALTER PUBLICATION ... WITH */ List *options; /* List of DefElem nodes */ @@ -3392,7 +3454,7 @@ typedef struct AlterPublicationStmt typedef struct CreateSubscriptionStmt { NodeTag type; - char *subname; /* Name of of the subscription */ + char *subname; /* Name of the subscription */ char *conninfo; /* Connection string to publisher */ List *publication; /* One or more publication to subscribe to */ List *options; /* List of DefElem nodes */ @@ -3411,7 +3473,7 @@ typedef struct AlterSubscriptionStmt { NodeTag type; AlterSubscriptionType kind; /* ALTER_SUBSCRIPTION_OPTIONS, etc */ - char *subname; /* Name of of the subscription */ + char *subname; /* Name of the subscription */ char *conninfo; /* Connection string to publisher */ List *publication; /* One or more publication to subscribe to */ List *options; /* List of DefElem nodes */ @@ -3420,7 +3482,7 @@ typedef struct AlterSubscriptionStmt typedef struct DropSubscriptionStmt { NodeTag type; - char *subname; /* Name of of the subscription */ + char *subname; /* Name of the subscription */ bool missing_ok; /* Skip error if missing? */ DropBehavior behavior; /* RESTRICT or CASCADE behavior */ } DropSubscriptionStmt; diff --git a/src/include/parser/parser.h b/src/include/parser/parser.h index 2ac15f1..5082640 100644 --- a/src/include/parser/parser.h +++ b/src/include/parser/parser.h @@ -5,8 +5,8 @@ * * This is the external API for the raw lexing/parsing functions. * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/parser/parser.h @@ -31,11 +31,12 @@ extern int backslash_quote; extern bool escape_string_warning; extern PGDLLIMPORT bool standard_conforming_strings; - /* Primary entry point for the raw parsing functions */ extern List *raw_parser(const char *str, bool *error); extern Node *raw_parser2(List *parse_tree_list); +extern int32 defGetInt32(DefElem *def); + /* Utility functions exported by gram.y (perhaps these should be elsewhere) */ extern List *SystemFuncName(char *name); extern TypeName *SystemTypeName(char *name); diff --git a/src/include/parser/pg_class.h b/src/include/parser/pg_class.h index 5310313..466c588 100644 --- a/src/include/parser/pg_class.h +++ b/src/include/parser/pg_class.h @@ -1,19 +1,18 @@ /*------------------------------------------------------------------------- * * pg_class.h - * definition of the system "relation" relation (pg_class) - * along with the relation's initial contents. + * definition of the "relation" system catalog (pg_class) * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/catalog/pg_class.h * * NOTES - * the genbki.pl script reads this file and generates .bki - * information from the DATA() statements. + * The Catalog.pm module reads this file and derives schema + * information. * *------------------------------------------------------------------------- */ @@ -23,16 +22,14 @@ #if 0 /* NOT_USED_IN_PGPOOL */ #include "catalog/genbki.h" +#include "catalog/pg_class_d.h" /* ---------------- * pg_class definition. cpp turns this into * typedef struct FormData_pg_class * ---------------- */ -#define RelationRelationId 1259 -#define RelationRelation_Rowtype_Id 83 - -CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO +CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,RelationRelation_Rowtype_Id) BKI_SCHEMA_MACRO { NameData relname; /* class name */ Oid relnamespace; /* OID of namespace containing this class */ @@ -64,7 +61,6 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO */ int16 relchecks; /* # of CHECK constraints for class */ bool relhasoids; /* T if we generate OIDs for rows of rel */ - bool relhaspkey; /* has (or has had) PRIMARY KEY index */ bool relhasrules; /* has (or has had) any rules */ bool relhastriggers; /* has (or has had) any TRIGGERs */ bool relhassubclass; /* has (or has had) derived classes */ @@ -74,6 +70,8 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO bool relispopulated; /* matview currently holds query results */ char relreplident; /* see REPLICA_IDENTITY_xxx constants */ bool relispartition; /* is relation a partition? */ + Oid relrewrite; /* heap for rewrite during DDL, link to + * original rel */ TransactionId relfrozenxid; /* all Xids < this are frozen in this rel */ TransactionId relminmxid; /* all multixacts in this rel are >= this. * this is really a MultiXactId */ @@ -97,69 +95,6 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO */ typedef FormData_pg_class *Form_pg_class; -/* ---------------- - * compiler constants for pg_class - * ---------------- - */ - -#define Natts_pg_class 33 -#define Anum_pg_class_relname 1 -#define Anum_pg_class_relnamespace 2 -#define Anum_pg_class_reltype 3 -#define Anum_pg_class_reloftype 4 -#define Anum_pg_class_relowner 5 -#define Anum_pg_class_relam 6 -#define Anum_pg_class_relfilenode 7 -#define Anum_pg_class_reltablespace 8 -#define Anum_pg_class_relpages 9 -#define Anum_pg_class_reltuples 10 -#define Anum_pg_class_relallvisible 11 -#define Anum_pg_class_reltoastrelid 12 -#define Anum_pg_class_relhasindex 13 -#define Anum_pg_class_relisshared 14 -#define Anum_pg_class_relpersistence 15 -#define Anum_pg_class_relkind 16 -#define Anum_pg_class_relnatts 17 -#define Anum_pg_class_relchecks 18 -edefine Anum_pg_class_relhasoids 19 -#define Anum_pg_class_relhaspkey 20 -#define Anum_pg_class_relhasrules 21 -#define Anum_pg_class_relhastriggers 22 -#define Anum_pg_class_relhassubclass 23 -#define Anum_pg_class_relrowsecurity 24 -#define Anum_pg_class_relforcerowsecurity 25 -#define Anum_pg_class_relispopulated 26 -#define Anum_pg_class_relreplident 27 -#define Anum_pg_class_relispartition 28 -#define Anum_pg_class_relfrozenxid 29 -#define Anum_pg_class_relminmxid 30 -#define Anum_pg_class_relacl 31 -#define Anum_pg_class_reloptions 32 -#define Anum_pg_class_relpartbound 33 - -/* ---------------- - * initial contents of pg_class - * - * NOTE: only "bootstrapped" relations need to be declared here. Be sure that - * the OIDs listed here match those given in their CATALOG macros, and that - * the relnatts values are correct. - * ---------------- - */ - -/* - * Note: "3" in the relfrozenxid column stands for FirstNormalTransactionId; - * similarly, "1" in relminmxid stands for FirstMultiXactId - */ - DATA(insert OID = 1247(pg_type PGNSP 71 0 PGUID 0 0 0 0 0 0 0 f f p r 30 0 t f f f f f f t n f 3 1 _null_ _null_ _null_)); - -DESCR(""); -DATA(insert OID = 1249(pg_attribute PGNSP 75 0 PGUID 0 0 0 0 0 0 0 f f p r 22 0 f f f f f f f t n f 3 1 _null_ _null_ _null_)); -DESCR(""); -DATA(insert OID = 1255(pg_proc PGNSP 81 0 PGUID 0 0 0 0 0 0 0 f f p r 29 0 t f f f f f f t n f 3 1 _null_ _null_ _null_)); -DESCR(""); -DATA(insert OID = 1259(pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 f f p r 33 0 t f f f f f f t n f 3 1 _null_ _null_ _null_)); -DESCR(""); - #define RELKIND_RELATION 'r' /* ordinary table */ #define RELKIND_INDEX 'i' /* secondary index */ @@ -171,6 +106,7 @@ DESCR(""); #define RELKIND_COMPOSITE_TYPE 'c' /* composite type */ #define RELKIND_FOREIGN_TABLE 'f' /* foreign table */ #define RELKIND_PARTITIONED_TABLE 'p' /* partitioned table */ +#define RELKIND_PARTITIONED_INDEX 'I' /* partitioned index */ #endif /* NOT_USED_IN_PGPOOL */ diff --git a/src/include/parser/pg_config_manual.h b/src/include/parser/pg_config_manual.h index bac8023..b4ba6f4 100644 --- a/src/include/parser/pg_config_manual.h +++ b/src/include/parser/pg_config_manual.h @@ -6,8 +6,8 @@ * for developers. If you edit any of these, be sure to do a *full* * rebuild (and an initdb if noted). * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/pg_config_manual.h @@ -41,6 +41,12 @@ #define pg_attribute_printf(f,a) #endif /* + * This is default value for wal_segment_size to be used at initdb when run + * without --walsegsize option. Must be a valid segment size. + */ +#define DEFAULT_XLOG_SEG_SIZE (16*1024*1024) + +/* * Maximum length for identifiers (e.g. table names, column names, * function names). Names actually are limited to one less byte than this, * because the length must include a trailing zero byte. @@ -94,16 +100,6 @@ #define NUM_ATOMICS_SEMAPHORES 64 /* - * Define this if you want to allow the lo_import and lo_export SQL - * functions to be executed by ordinary users. By default these - * functions are only available to the Postgres superuser. CAUTION: - * These functions are SECURITY HOLES since they can read and write - * any file that the PostgreSQL server has permission to access. If - * you turn this on, don't say we didn't warn you. - */ -/* #define ALLOW_DANGEROUS_LO_FUNCTIONS */ - -/* * MAXPGPATH: standard size of a pathname buffer in PostgreSQL (hence, * maximum usable pathname length is one less). * diff --git a/src/include/parser/pg_list.h b/src/include/parser/pg_list.h index ff5cfc8..afb2fbb 100644 --- a/src/include/parser/pg_list.h +++ b/src/include/parser/pg_list.h @@ -27,8 +27,8 @@ * always be so; try to be careful to maintain the distinction.) * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/nodes/pg_list.h @@ -271,6 +271,9 @@ extern void list_free_deep(List *list); extern List *list_copy(const List *list); extern List *list_copy_tail(const List *list, int nskip); +typedef int (*list_qsort_comparator) (const void *a, const void *b); +extern List *list_qsort(const List *list, list_qsort_comparator cmp); + /* * To ease migration to the new list API, a set of compatibility * macros are provided that reduce the impact of the list API changes diff --git a/src/include/parser/pg_trigger.h b/src/include/parser/pg_trigger.h index 8b3ac4a..3d41b55 100644 --- a/src/include/parser/pg_trigger.h +++ b/src/include/parser/pg_trigger.h @@ -1,19 +1,18 @@ /*------------------------------------------------------------------------- * * pg_trigger.h - * definition of the system "trigger" relation (pg_trigger) - * along with the relation's initial contents. + * definition of the "trigger" system catalog (pg_trigger) * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/catalog/pg_trigger.h * * NOTES - * the genbki.pl script reads this file and generates .bki - * information from the DATA() statements. + * The Catalog.pm module reads this file and derives schema + * information. * *------------------------------------------------------------------------- */ @@ -22,6 +21,7 @@ #if 0 #include "catalog/genbki.h" +#include "catalog/pg_trigger_d.h" /* ---------------- * pg_trigger definition. cpp turns this into @@ -33,9 +33,7 @@ * to be associated with a deferrable constraint. * ---------------- */ -#define TriggerRelationId 2620 - -CATALOG(pg_trigger,2620) +CATALOG(pg_trigger,2620,TriggerRelationId) { Oid tgrelid; /* relation trigger is attached to */ NameData tgname; /* trigger's name */ @@ -74,28 +72,8 @@ CATALOG(pg_trigger,2620) typedef FormData_pg_trigger *Form_pg_trigger; #endif -/* ---------------- - * compiler constants for pg_trigger - * ---------------- - */ -#define Natts_pg_trigger 17 -#define Anum_pg_trigger_tgrelid 1 -#define Anum_pg_trigger_tgname 2 -#define Anum_pg_trigger_tgfoid 3 -#define Anum_pg_trigger_tgtype 4 -#define Anum_pg_trigger_tgenabled 5 -#define Anum_pg_trigger_tgisinternal 6 -#define Anum_pg_trigger_tgconstrrelid 7 -#define Anum_pg_trigger_tgconstrindid 8 -#define Anum_pg_trigger_tgconstraint 9 -#define Anum_pg_trigger_tgdeferrable 10 -#define Anum_pg_trigger_tginitdeferred 11 -#define Anum_pg_trigger_tgnargs 12 -#define Anum_pg_trigger_tgattr 13 -#define Anum_pg_trigger_tgargs 14 -#define Anum_pg_trigger_tgqual 15 -#define Anum_pg_trigger_tgoldtable 16 -#define Anum_pg_trigger_tgnewtable 17 +#define EXPOSE_TO_CLIENT_CODE +#ifdef EXPOSE_TO_CLIENT_CODE /* Bits within tgtype */ #define TRIGGER_TYPE_ROW (1 << 0) @@ -156,4 +134,6 @@ typedef FormData_pg_trigger *Form_pg_trigger; #define TRIGGER_USES_TRANSITION_TABLE(namepointer) \ ((namepointer) != (char *) NULL) +#endif /* EXPOSE_TO_CLIENT_CODE */ + #endif /* PG_TRIGGER_H */ diff --git a/src/include/parser/pg_wchar.h b/src/include/parser/pg_wchar.h index 3f262b4..58f353d 100644 --- a/src/include/parser/pg_wchar.h +++ b/src/include/parser/pg_wchar.h @@ -3,8 +3,8 @@ * pg_wchar.h * multibyte-character support * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/mb/pg_wchar.h @@ -306,6 +306,17 @@ typedef enum pg_enc #define PG_VALID_FE_ENCODING(_enc) PG_VALID_ENCODING(_enc) /* + * When converting strings between different encodings, we assume that space + * for converted result is 4-to-1 growth in the worst case. The rate for + * currently supported encoding pairs are within 3 (SJIS JIS X0201 half width + * kanna -> UTF8 is the worst case). So "4" should be enough for the moment. + * + * Note that this is not the same as the maximum character width in any + * particular encoding. + */ +#define MAX_CONVERSION_GROWTH 4 + +/* * Table for mapping an encoding number to official encoding name and * possibly other subsidiary data. Be careful to check encoding number * before accessing a table entry! @@ -400,7 +411,7 @@ extern const pg_wchar_tbl pg_wchar_table[]; * points to a lookup table for the second byte. And so on. * * Physically, all the trees are stored in one big array, in 'chars16' or - * 'chars32', depending on the maximum value that needs to be reprented. For + * 'chars32', depending on the maximum value that needs to be represented. For * each level in each tree, we also store lower and upper bound of allowed * values - values outside those bounds are considered invalid, and are left * out of the tables. diff --git a/src/include/parser/primnodes.h b/src/include/parser/primnodes.h index cedd67b..a277bbb 100644 --- a/src/include/parser/primnodes.h +++ b/src/include/parser/primnodes.h @@ -6,8 +6,8 @@ * Currently, these are mostly nodes for executable expressions * and join trees. * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group * - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group * + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/nodes/primnodes.h @@ -179,7 +179,7 @@ typedef struct Var Index varno; /* index of this var's relation in the range * table, or INNER_VAR/OUTER_VAR/INDEX_VAR */ AttrNumber varattno; /* attribute number of this var, or zero for - * all */ + * all attrs ("whole-row Var") */ Oid vartype; /* pg_type OID for the type of this var */ int32 vartypmod; /* pg_attribute typmod value */ Oid varcollid; /* OID of collation, or InvalidOid if none */ @@ -315,7 +315,7 @@ typedef struct Aggref List *aggorder; /* ORDER BY (list of SortGroupClause) */ List *aggdistinct; /* DISTINCT (list of SortGroupClause) */ Expr *aggfilter; /* FILTER expression, if any */ - bool aggstar; /* TRUE if argument list was really '*' */ + bool aggstar; /* true if argument list was really '*' */ bool aggvariadic; /* true if variadic arguments have been * combined into an array last argument */ char aggkind; /* aggregate kind (see pg_aggregate.h) */ @@ -372,7 +372,7 @@ typedef struct WindowFunc List *args; /* arguments to the window function */ Expr *aggfilter; /* FILTER expression, if any */ Index winref; /* index of associated WindowClause */ - bool winstar; /* TRUE if argument list was really '*' */ + bool winstar; /* true if argument list was really '*' */ bool winagg; /* is function a simple aggregate? */ int location; /* token location, or -1 if unknown */ } WindowFunc; @@ -708,9 +708,9 @@ typedef struct SubPlan Oid firstColCollation; /* Collation of first column of subplan * result */ /* Information about execution strategy: */ - bool useHashTable; /* TRUE to store subselect output in a hash + bool useHashTable; /* true to store subselect output in a hash * table (implies we are doing "IN") */ - bool unknownEqFalse; /* TRUE if it's okay to return FALSE when the + bool unknownEqFalse; /* true if it's okay to return FALSE when the * spec result is UNKNOWN; this allows much * simpler handling of null values */ bool parallel_safe; /* is the subplan parallel-safe? */ @@ -768,6 +768,9 @@ typedef struct FieldSelect * the assign case of ArrayRef, this is used to implement UPDATE of a * portion of a column. * + * resulttype is always a named composite type (not a domain). To update + * a composite domain value, apply CoerceToDomain to the FieldStore. + * * A single FieldStore can actually represent updates of several different * fields. The parser only generates FieldStores with single-element lists, * but the planner will collapse multiple updates of the same base column @@ -833,11 +836,12 @@ typedef struct CoerceViaIO * ArrayCoerceExpr * * ArrayCoerceExpr represents a type coercion from one array type to another, - * which is implemented by applying the indicated element-type coercion - * function to each element of the source array. If elemfuncid is InvalidOid - * then the element types are binary-compatible, but the coercion still - * requires some effort (we have to fix the element type ID stored in the - * array header). + * which is implemented by applying the per-element coercion expression + * "elemexpr" to each element of the source array. Within elemexpr, the + * source element is represented by a CaseTestExpr node. Note that even if + * elemexpr is a no-op (that is, just CaseTestExpr + RelabelType), the + * coercion still requires some effort: we have to fix the element type OID + * stored in the array header. * ---------------- */ @@ -845,11 +849,10 @@ typedef struct ArrayCoerceExpr { Expr xpr; Expr *arg; /* input expression (yields an array) */ - Oid elemfuncid; /* OID of element coercion function, or 0 */ + Expr *elemexpr; /* expression representing per-element work */ Oid resulttype; /* output type of coercion (an array type) */ int32 resulttypmod; /* output typmod (also element typmod) */ Oid resultcollid; /* OID of collation, or InvalidOid if none */ - bool isExplicit; /* conversion semantics flag to pass to func */ CoercionForm coerceformat; /* how to display this node */ int location; /* token location, or -1 if unknown */ } ArrayCoerceExpr; @@ -862,7 +865,8 @@ typedef struct ArrayCoerceExpr * needed for the destination type plus possibly others; the columns need not * be in the same positions, but are matched up by name. This is primarily * used to convert a whole-row value of an inheritance child table into a - * valid whole-row value of its parent table's rowtype. + * valid whole-row value of its parent table's rowtype. Both resulttype + * and the exposed type of "arg" must be named composite types (not domains). * ---------------- */ @@ -1000,6 +1004,9 @@ typedef struct RowExpr Oid row_typeid; /* RECORDOID or a composite type's ID */ /* + * row_typeid cannot be a domain over composite, only plain composite. To + * create a composite domain value, apply CoerceToDomain to the RowExpr. + * * Note: we deliberately do NOT store a typmod. Although a typmod will be * associated with specific RECORD types at runtime, it will differ for * different backends, and so cannot safely be stored in stored diff --git a/src/include/parser/scanner.h b/src/include/parser/scanner.h index 49b8d16..91f5636 100644 --- a/src/include/parser/scanner.h +++ b/src/include/parser/scanner.h @@ -8,8 +8,8 @@ * higher-level API provided by parser.h. * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/parser/scanner.h diff --git a/src/include/parser/scansup.h b/src/include/parser/scansup.h index 93179d3..f73862c 100644 --- a/src/include/parser/scansup.h +++ b/src/include/parser/scansup.h @@ -4,8 +4,8 @@ * scanner support routines. used by both the bootstrap lexer * as well as the normal lexer * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/parser/scansup.h diff --git a/src/include/parser/stringinfo.h b/src/include/parser/stringinfo.h index a704293..ec42916 100644 --- a/src/include/parser/stringinfo.h +++ b/src/include/parser/stringinfo.h @@ -7,8 +7,8 @@ * It can be used to buffer either ordinary C strings (null-terminated text) * or arbitrary binary data. All storage is allocated with palloc(). * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/lib/stringinfo.h @@ -193,6 +193,14 @@ extern void appendBinaryStringInfo(StringInfo str, const char *data, int datalen); /*------------------------ + * appendBinaryStringInfoNT + * Append arbitrary binary data to a StringInfo, allocating more space + * if necessary. Does not ensure a trailing null-byte exists. + */ +extern void appendBinaryStringInfoNT(StringInfo str, + const char *data, int datalen); + +/*------------------------ * enlargeStringInfo * Make sure a StringInfo's buffer can hold at least 'needed' more bytes. */ diff --git a/src/include/parser/value.h b/src/include/parser/value.h index 082bcb2..39ee6be 100644 --- a/src/include/parser/value.h +++ b/src/include/parser/value.h @@ -4,8 +4,8 @@ * interface for Value nodes * * - * Copyright (c) 2003-2017, PgPool Global Development Group - * Copyright (c) 2003-2017, PostgreSQL Global Development Group + * Copyright (c) 2003-2018, PgPool Global Development Group + * Copyright (c) 2003-2018, PostgreSQL Global Development Group * * src/include/nodes/value.h * @@ -35,7 +35,7 @@ * better to use the more general representation.) * * Note that an integer-looking string will get lexed as T_Float if - * the value is too large to fit in a 'long'. + * the value is too large to fit in an 'int'. * * Nulls, of course, don't need the value part at all. *---------------------- @@ -45,7 +45,7 @@ typedef struct Value NodeTag type; /* tag appropriately (eg. T_String) */ union ValUnion { - long ival; /* machine integer */ + int ival; /* machine integer */ char *str; /* string */ } val; } Value; @@ -54,7 +54,7 @@ typedef struct Value #define floatVal(v) atof(((Value *)(v))->val.str) #define strVal(v) (((Value *)(v))->val.str) -extern Value *makeInteger(long i); +extern Value *makeInteger(int i); extern Value *makeFloat(char *numericStr); extern Value *makeString(char *str); extern Value *makeBitString(char *str); diff --git a/src/parser/copyfuncs.c b/src/parser/copyfuncs.c index f3a6a70..da43fa6 100644 --- a/src/parser/copyfuncs.c +++ b/src/parser/copyfuncs.c @@ -11,8 +11,8 @@ * be handled easily in a simple depth-first traversal. * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION @@ -89,6 +89,7 @@ _copyPlannedStmt(const PlannedStmt *from) COPY_SCALAR_FIELD(transientPlan); COPY_SCALAR_FIELD(dependsOnRole); COPY_SCALAR_FIELD(parallelModeNeeded); + COPY_SCALAR_FIELD(jitFlags); COPY_NODE_FIELD(planTree); COPY_NODE_FIELD(rtable); COPY_NODE_FIELD(resultRelations); @@ -99,7 +100,7 @@ _copyPlannedStmt(const PlannedStmt *from) COPY_NODE_FIELD(rowMarks); COPY_NODE_FIELD(relationOids); COPY_NODE_FIELD(invalItems); - COPY_SCALAR_FIELD(nParamExec); + COPY_NODE_FIELD(paramExecTypes); COPY_NODE_FIELD(utilityStmt); COPY_LOCATION_FIELD(stmt_location); COPY_LOCATION_FIELD(stmt_len); @@ -206,6 +207,7 @@ _copyModifyTable(const ModifyTable *from) COPY_SCALAR_FIELD(canSetTag); COPY_SCALAR_FIELD(nominalRelation); COPY_NODE_FIELD(partitioned_rels); + COPY_SCALAR_FIELD(partColsUpdated); COPY_NODE_FIELD(resultRelations); COPY_SCALAR_FIELD(resultRelIndex); COPY_SCALAR_FIELD(rootResultRelIndex); @@ -242,8 +244,10 @@ _copyAppend(const Append *from) /* * copy remainder of node */ - COPY_NODE_FIELD(partitioned_rels); COPY_NODE_FIELD(appendplans); + COPY_SCALAR_FIELD(first_partial_plan); + COPY_NODE_FIELD(partitioned_rels); + COPY_NODE_FIELD(part_prune_info); return newnode; } @@ -366,6 +370,7 @@ _copyGather(const Gather *from) COPY_SCALAR_FIELD(rescan_param); COPY_SCALAR_FIELD(single_copy); COPY_SCALAR_FIELD(invisible); + COPY_BITMAPSET_FIELD(initParam); return newnode; } @@ -803,6 +808,7 @@ _copyGatherMerge(const GatherMerge *from) COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid)); COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid)); COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool)); + COPY_BITMAPSET_FIELD(initParam); return newnode; } @@ -1008,6 +1014,11 @@ _copyWindowAgg(const WindowAgg *from) COPY_SCALAR_FIELD(frameOptions); COPY_NODE_FIELD(startOffset); COPY_NODE_FIELD(endOffset); + COPY_SCALAR_FIELD(startInRangeFunc); + COPY_SCALAR_FIELD(endInRangeFunc); + COPY_SCALAR_FIELD(inRangeColl); + COPY_SCALAR_FIELD(inRangeAsc); + COPY_SCALAR_FIELD(inRangeNullsFirst); return newnode; } @@ -1054,6 +1065,7 @@ _copyHash(const Hash *from) COPY_SCALAR_FIELD(skewTable); COPY_SCALAR_FIELD(skewColumn); COPY_SCALAR_FIELD(skewInherit); + COPY_SCALAR_FIELD(rows_total); return newnode; } @@ -1164,6 +1176,69 @@ _copyPlanRowMark(const PlanRowMark *from) return newnode; } +static PartitionPruneInfo * +_copyPartitionPruneInfo(const PartitionPruneInfo *from) +{ + PartitionPruneInfo *newnode = makeNode(PartitionPruneInfo); + + COPY_NODE_FIELD(prune_infos); + COPY_BITMAPSET_FIELD(other_subplans); + + return newnode; +} + +static PartitionedRelPruneInfo * +_copyPartitionedRelPruneInfo(const PartitionedRelPruneInfo *from) +{ + PartitionedRelPruneInfo *newnode = makeNode(PartitionedRelPruneInfo); + + COPY_SCALAR_FIELD(reloid); + COPY_NODE_FIELD(pruning_steps); + COPY_BITMAPSET_FIELD(present_parts); + COPY_SCALAR_FIELD(nparts); + COPY_SCALAR_FIELD(nexprs); + COPY_POINTER_FIELD(subplan_map, from->nparts * sizeof(int)); + COPY_POINTER_FIELD(subpart_map, from->nparts * sizeof(int)); + COPY_POINTER_FIELD(hasexecparam, from->nexprs * sizeof(bool)); + COPY_SCALAR_FIELD(do_initial_prune); + COPY_SCALAR_FIELD(do_exec_prune); + COPY_BITMAPSET_FIELD(execparamids); + + return newnode; +} + +/* + * _copyPartitionPruneStepOp + */ +static PartitionPruneStepOp * +_copyPartitionPruneStepOp(const PartitionPruneStepOp *from) +{ + PartitionPruneStepOp *newnode = makeNode(PartitionPruneStepOp); + + COPY_SCALAR_FIELD(step.step_id); + COPY_SCALAR_FIELD(opstrategy); + COPY_NODE_FIELD(exprs); + COPY_NODE_FIELD(cmpfns); + COPY_BITMAPSET_FIELD(nullkeys); + + return newnode; +} + +/* + * _copyPartitionPruneStepCombine + */ +static PartitionPruneStepCombine * +_copyPartitionPruneStepCombine(const PartitionPruneStepCombine *from) +{ + PartitionPruneStepCombine *newnode = makeNode(PartitionPruneStepCombine); + + COPY_SCALAR_FIELD(step.step_id); + COPY_SCALAR_FIELD(combineOp); + COPY_NODE_FIELD(source_stepids); + + return newnode; +} + /* * _copyPlanInvalItem */ @@ -1701,11 +1776,10 @@ _copyArrayCoerceExpr(const ArrayCoerceExpr *from) ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr); COPY_NODE_FIELD(arg); - COPY_SCALAR_FIELD(elemfuncid); + COPY_NODE_FIELD(elemexpr); COPY_SCALAR_FIELD(resulttype); COPY_SCALAR_FIELD(resulttypmod); COPY_SCALAR_FIELD(resultcollid); - COPY_SCALAR_FIELD(isExplicit); COPY_SCALAR_FIELD(coerceformat); COPY_LOCATION_FIELD(location); @@ -2191,6 +2265,8 @@ _copyRestrictInfo(const RestrictInfo *from) COPY_SCALAR_FIELD(hashjoinoperator); COPY_SCALAR_FIELD(left_bucketsize); COPY_SCALAR_FIELD(right_bucketsize); + COPY_SCALAR_FIELD(left_mcvfreq); + COPY_SCALAR_FIELD(right_mcvfreq); return newnode; } @@ -2253,20 +2329,6 @@ _copyAppendRelInfo(const AppendRelInfo *from) } /* - * _copyPartitionedChildRelInfo - */ -static PartitionedChildRelInfo * -_copyPartitionedChildRelInfo(const PartitionedChildRelInfo * from) -{ - PartitionedChildRelInfo *newnode = makeNode(PartitionedChildRelInfo); - - COPY_SCALAR_FIELD(parent_relid); - COPY_NODE_FIELD(child_rels); - - return newnode; -} - -/* * _copyPlaceHolderInfo */ static PlaceHolderInfo * @@ -2410,6 +2472,11 @@ _copyWindowClause(const WindowClause *from) COPY_SCALAR_FIELD(frameOptions); COPY_NODE_FIELD(startOffset); COPY_NODE_FIELD(endOffset); + COPY_SCALAR_FIELD(startInRangeFunc); + COPY_SCALAR_FIELD(endInRangeFunc); + COPY_SCALAR_FIELD(inRangeColl); + COPY_SCALAR_FIELD(inRangeAsc); + COPY_SCALAR_FIELD(inRangeNullsFirst); COPY_SCALAR_FIELD(winref); COPY_SCALAR_FIELD(copiedOrder); @@ -2817,6 +2884,7 @@ _copyColumnDef(const ColumnDef *from) COPY_NODE_FIELD(raw_default); COPY_NODE_FIELD(cooked_default); COPY_SCALAR_FIELD(identity); + COPY_NODE_FIELD(identitySequence); COPY_NODE_FIELD(collClause); COPY_SCALAR_FIELD(collOid); COPY_NODE_FIELD(constraints); @@ -2841,6 +2909,7 @@ _copyConstraint(const Constraint *from) COPY_STRING_FIELD(cooked_expr); COPY_SCALAR_FIELD(generated_when); COPY_NODE_FIELD(keys); + COPY_NODE_FIELD(including); COPY_NODE_FIELD(exclusions); COPY_NODE_FIELD(options); COPY_STRING_FIELD(indexname); @@ -3090,6 +3159,7 @@ _copyAlterTableCmd(const AlterTableCmd *from) COPY_SCALAR_FIELD(subtype); COPY_STRING_FIELD(name); + COPY_SCALAR_FIELD(num); COPY_NODE_FIELD(newowner); COPY_NODE_FIELD(def); COPY_SCALAR_FIELD(behavior); @@ -3211,6 +3281,17 @@ _copyClosePortalStmt(const ClosePortalStmt *from) return newnode; } +static CallStmt * +_copyCallStmt(const CallStmt *from) +{ + CallStmt *newnode = makeNode(CallStmt); + + COPY_NODE_FIELD(funccall); + COPY_NODE_FIELD(funcexpr); + + return newnode; +} + static ClusterStmt * _copyClusterStmt(const ClusterStmt *from) { @@ -3368,9 +3449,11 @@ _copyIndexStmt(const IndexStmt *from) COPY_STRING_FIELD(idxname); COPY_NODE_FIELD(relation); + COPY_SCALAR_FIELD(relationId); COPY_STRING_FIELD(accessMethod); COPY_STRING_FIELD(tableSpace); COPY_NODE_FIELD(indexParams); + COPY_NODE_FIELD(indexIncludingParams); COPY_NODE_FIELD(options); COPY_NODE_FIELD(whereClause); COPY_NODE_FIELD(excludeOpNames); @@ -3398,6 +3481,7 @@ _copyCreateStatsStmt(const CreateStatsStmt *from) COPY_NODE_FIELD(stat_types); COPY_NODE_FIELD(exprs); COPY_NODE_FIELD(relations); + COPY_STRING_FIELD(stxcomment); COPY_SCALAR_FIELD(if_not_exists); return newnode; @@ -3408,12 +3492,12 @@ _copyCreateFunctionStmt(const CreateFunctionStmt *from) { CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt); + COPY_SCALAR_FIELD(is_procedure); COPY_SCALAR_FIELD(replace); COPY_NODE_FIELD(funcname); COPY_NODE_FIELD(parameters); COPY_NODE_FIELD(returnType); COPY_NODE_FIELD(options); - COPY_NODE_FIELD(withClause); return newnode; } @@ -3436,6 +3520,7 @@ _copyAlterFunctionStmt(const AlterFunctionStmt *from) { AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt); + COPY_SCALAR_FIELD(objtype); COPY_NODE_FIELD(func); COPY_NODE_FIELD(actions); @@ -3574,6 +3659,7 @@ _copyTransactionStmt(const TransactionStmt *from) COPY_SCALAR_FIELD(kind); COPY_NODE_FIELD(options); + COPY_STRING_FIELD(savepoint_name); COPY_STRING_FIELD(gid); return newnode; @@ -3769,7 +3855,18 @@ _copyVacuumStmt(const VacuumStmt *from) VacuumStmt *newnode = makeNode(VacuumStmt); COPY_SCALAR_FIELD(options); + COPY_NODE_FIELD(rels); + + return newnode; +} + +static VacuumRelation * +_copyVacuumRelation(const VacuumRelation *from) +{ + VacuumRelation *newnode = makeNode(VacuumRelation); + COPY_NODE_FIELD(relation); + COPY_SCALAR_FIELD(oid); COPY_NODE_FIELD(va_cols); return newnode; @@ -4452,6 +4549,9 @@ _copyPartitionBoundSpec(const PartitionBoundSpec *from) PartitionBoundSpec *newnode = makeNode(PartitionBoundSpec); COPY_SCALAR_FIELD(strategy); + COPY_SCALAR_FIELD(is_default); + COPY_SCALAR_FIELD(modulus); + COPY_SCALAR_FIELD(remainder); COPY_NODE_FIELD(listdatums); COPY_NODE_FIELD(lowerdatums); COPY_NODE_FIELD(upperdatums); @@ -4826,6 +4926,18 @@ copyObjectImpl(const void *from) case T_PlanRowMark: retval = _copyPlanRowMark(from); break; + case T_PartitionPruneInfo: + retval = _copyPartitionPruneInfo(from); + break; + case T_PartitionedRelPruneInfo: + retval = _copyPartitionedRelPruneInfo(from); + break; + case T_PartitionPruneStepOp: + retval = _copyPartitionPruneStepOp(from); + break; + case T_PartitionPruneStepCombine: + retval = _copyPartitionPruneStepCombine(from); + break; case T_PlanInvalItem: retval = _copyPlanInvalItem(from); break; @@ -5010,9 +5122,6 @@ copyObjectImpl(const void *from) case T_AppendRelInfo: retval = _copyAppendRelInfo(from); break; - case T_PartitionedChildRelInfo: - retval = _copyPartitionedChildRelInfo(from); - break; case T_PlaceHolderInfo: retval = _copyPlaceHolderInfo(from); break; @@ -5107,6 +5216,9 @@ copyObjectImpl(const void *from) case T_ClosePortalStmt: retval = _copyClosePortalStmt(from); break; + case T_CallStmt: + retval = _copyCallStmt(from); + break; case T_ClusterStmt: retval = _copyClusterStmt(from); break; @@ -5233,6 +5345,9 @@ copyObjectImpl(const void *from) case T_VacuumStmt: retval = _copyVacuumStmt(from); break; + case T_VacuumRelation: + retval = _copyVacuumRelation(from); + break; case T_ExplainStmt: retval = _copyExplainStmt(from); break; diff --git a/src/parser/gram.h b/src/parser/gram.h index bc4c06f..c8c9576 100644 --- a/src/parser/gram.h +++ b/src/parser/gram.h @@ -97,407 +97,415 @@ extern int base_yydebug; BOTH = 307, BY = 308, CACHE = 309, - CALLED = 310, - CASCADE = 311, - CASCADED = 312, - CASE = 313, - CAST = 314, - CATALOG_P = 315, - CHAIN = 316, - CHAR_P = 317, - CHARACTER = 318, - CHARACTERISTICS = 319, - CHECK = 320, - CHECKPOINT = 321, - CLASS = 322, - CLOSE = 323, - CLUSTER = 324, - COALESCE = 325, - COLLATE = 326, - COLLATION = 327, - COLUMN = 328, - COLUMNS = 329, - COMMENT = 330, - COMMENTS = 331, - COMMIT = 332, - COMMITTED = 333, - CONCURRENTLY = 334, - CONFIGURATION = 335, - CONFLICT = 336, - CONNECTION = 337, - CONSTRAINT = 338, - CONSTRAINTS = 339, - CONTENT_P = 340, - CONTINUE_P = 341, - CONVERSION_P = 342, - COPY = 343, - COST = 344, - CREATE = 345, - CROSS = 346, - CSV = 347, - CUBE = 348, - CURRENT_P = 349, - CURRENT_CATALOG = 350, - CURRENT_DATE = 351, - CURRENT_ROLE = 352, - CURRENT_SCHEMA = 353, - CURRENT_TIME = 354, - CURRENT_TIMESTAMP = 355, - CURRENT_USER = 356, - CURSOR = 357, - CYCLE = 358, - DATA_P = 359, - DATABASE = 360, - DAY_P = 361, - DEALLOCATE = 362, - DEC = 363, - DECIMAL_P = 364, - DECLARE = 365, - DEFAULT = 366, - DEFAULTS = 367, - DEFERRABLE = 368, - DEFERRED = 369, - DEFINER = 370, - DELETE_P = 371, - DELIMITER = 372, - DELIMITERS = 373, - DEPENDS = 374, - DESC = 375, - DETACH = 376, - DICTIONARY = 377, - DISABLE_P = 378, - DISCARD = 379, - DISTINCT = 380, - DO = 381, - DOCUMENT_P = 382, - DOMAIN_P = 383, - DOUBLE_P = 384, - DROP = 385, - EACH = 386, - ELSE = 387, - ENABLE_P = 388, - ENCODING = 389, - ENCRYPTED = 390, - END_P = 391, - ENUM_P = 392, - ESCAPE = 393, - EVENT = 394, - EXCEPT = 395, - EXCLUDE = 396, - EXCLUDING = 397, - EXCLUSIVE = 398, - EXECUTE = 399, - EXISTS = 400, - EXPLAIN = 401, - EXTENSION = 402, - EXTERNAL = 403, - EXTRACT = 404, - FALSE_P = 405, - FAMILY = 406, - FETCH = 407, - FILTER = 408, - FIRST_P = 409, - FLOAT_P = 410, - FOLLOWING = 411, - FOR = 412, - FORCE = 413, - FOREIGN = 414, - FORWARD = 415, - FREEZE = 416, - FROM = 417, - FULL = 418, - FUNCTION = 419, - FUNCTIONS = 420, - GENERATED = 421, - GLOBAL = 422, - GRANT = 423, - GRANTED = 424, - GREATEST = 425, - GROUP_P = 426, - GROUPING = 427, - HANDLER = 428, - HAVING = 429, - HEADER_P = 430, - HOLD = 431, - HOUR_P = 432, - IDENTITY_P = 433, - IF_P = 434, - ILIKE = 435, - IMMEDIATE = 436, - IMMUTABLE = 437, - IMPLICIT_P = 438, - IMPORT_P = 439, - IN_P = 440, - INCLUDING = 441, - INCREMENT = 442, - INDEX = 443, - INDEXES = 444, - INHERIT = 445, - INHERITS = 446, - INITIALLY = 447, - INLINE_P = 448, - INNER_P = 449, - INOUT = 450, - INPUT_P = 451, - INSENSITIVE = 452, - INSERT = 453, - INSTEAD = 454, - INT_P = 455, - INTEGER = 456, - INTERSECT = 457, - INTERVAL = 458, - INTO = 459, - INVOKER = 460, - IS = 461, - ISNULL = 462, - ISOLATION = 463, - JOIN = 464, - KEY = 465, - LABEL = 466, - LANGUAGE = 467, - LARGE_P = 468, - LAST_P = 469, - LATERAL_P = 470, - LEADING = 471, - LEAKPROOF = 472, - LEAST = 473, - LEFT = 474, - LEVEL = 475, - LIKE = 476, - LIMIT = 477, - LISTEN = 478, - LOAD = 479, - LOCAL = 480, - LOCALTIME = 481, - LOCALTIMESTAMP = 482, - LOCATION = 483, - LOCK_P = 484, - LOCKED = 485, - LOGGED = 486, - MAPPING = 487, - MATCH = 488, - MATERIALIZED = 489, - MAXVALUE = 490, - METHOD = 491, - MINUTE_P = 492, - MINVALUE = 493, - MODE = 494, - MONTH_P = 495, - MOVE = 496, - NAME_P = 497, - NAMES = 498, - NATIONAL = 499, - NATURAL = 500, - NCHAR = 501, - NEW = 502, - NEXT = 503, - NO = 504, - NONE = 505, - NOT = 506, - NOTHING = 507, - NOTIFY = 508, - NOTNULL = 509, - NOWAIT = 510, - NULL_P = 511, - NULLIF = 512, - NULLS_P = 513, - NUMERIC = 514, - OBJECT_P = 515, - OF = 516, - OFF = 517, - OFFSET = 518, - OIDS = 519, - OLD = 520, - ON = 521, - ONLY = 522, - OPERATOR = 523, - OPTION = 524, - OPTIONS = 525, - OR = 526, - ORDER = 527, - ORDINALITY = 528, - OUT_P = 529, - OUTER_P = 530, - OVER = 531, - OVERLAPS = 532, - OVERLAY = 533, - OVERRIDING = 534, - OWNED = 535, - OWNER = 536, - PARALLEL = 537, - PARSER = 538, - PARTIAL = 539, - PARTITION = 540, - PASSING = 541, - PASSWORD = 542, - PGPOOL = 543, - PLACING = 544, - PLANS = 545, - POLICY = 546, - POSITION = 547, - PRECEDING = 548, - PRECISION = 549, - PRESERVE = 550, - PREPARE = 551, - PREPARED = 552, - PRIMARY = 553, - PRIOR = 554, - PRIVILEGES = 555, - PROCEDURAL = 556, - PROCEDURE = 557, - PROGRAM = 558, - PUBLICATION = 559, - QUOTE = 560, - RANGE = 561, - READ = 562, - REAL = 563, - REASSIGN = 564, - RECHECK = 565, - RECURSIVE = 566, - REF = 567, - REFERENCES = 568, - REFERENCING = 569, - REFRESH = 570, - REINDEX = 571, - RELATIVE_P = 572, - RELEASE = 573, - RENAME = 574, - REPEATABLE = 575, - REPLACE = 576, - REPLICA = 577, - RESET = 578, - RESTART = 579, - RESTRICT = 580, - RETURNING = 581, - RETURNS = 582, - REVOKE = 583, - RIGHT = 584, - ROLE = 585, - ROLLBACK = 586, - ROLLUP = 587, - ROW = 588, - ROWS = 589, - RULE = 590, - SAVEPOINT = 591, - SCHEMA = 592, - SCHEMAS = 593, - SCROLL = 594, - SEARCH = 595, - SECOND_P = 596, - SECURITY = 597, - SELECT = 598, - SEQUENCE = 599, - SEQUENCES = 600, - SERIALIZABLE = 601, - SERVER = 602, - SESSION = 603, - SESSION_USER = 604, - SET = 605, - SETS = 606, - SETOF = 607, - SHARE = 608, - SHOW = 609, - SIMILAR = 610, - SIMPLE = 611, - SKIP = 612, - SMALLINT = 613, - SNAPSHOT = 614, - SOME = 615, - SQL_P = 616, - STABLE = 617, - STANDALONE_P = 618, - START = 619, - STATEMENT = 620, - STATISTICS = 621, - STDIN = 622, - STDOUT = 623, - STORAGE = 624, - STRICT_P = 625, - STRIP_P = 626, - SUBSCRIPTION = 627, - SUBSTRING = 628, - SYMMETRIC = 629, - SYSID = 630, - SYSTEM_P = 631, - TABLE = 632, - TABLES = 633, - TABLESAMPLE = 634, - TABLESPACE = 635, - TEMP = 636, - TEMPLATE = 637, - TEMPORARY = 638, - TEXT_P = 639, - THEN = 640, - TIME = 641, - TIMESTAMP = 642, - TO = 643, - TRAILING = 644, - TRANSACTION = 645, - TRANSFORM = 646, - TREAT = 647, - TRIGGER = 648, - TRIM = 649, - TRUE_P = 650, - TRUNCATE = 651, - TRUSTED = 652, - TYPE_P = 653, - TYPES_P = 654, - UNBOUNDED = 655, - UNCOMMITTED = 656, - UNENCRYPTED = 657, - UNION = 658, - UNIQUE = 659, - UNKNOWN = 660, - UNLISTEN = 661, - UNLOGGED = 662, - UNTIL = 663, - UPDATE = 664, - USER = 665, - USING = 666, - VACUUM = 667, - VALID = 668, - VALIDATE = 669, - VALIDATOR = 670, - VALUE_P = 671, - VALUES = 672, - VARCHAR = 673, - VARIADIC = 674, - VARYING = 675, - VERBOSE = 676, - VERSION_P = 677, - VIEW = 678, - VIEWS = 679, - VOLATILE = 680, - WHEN = 681, - WHERE = 682, - WHITESPACE_P = 683, - WINDOW = 684, - WITH = 685, - WITHIN = 686, - WITHOUT = 687, - WORK = 688, - WRAPPER = 689, - WRITE = 690, - XML_P = 691, - XMLATTRIBUTES = 692, - XMLCONCAT = 693, - XMLELEMENT = 694, - XMLEXISTS = 695, - XMLFOREST = 696, - XMLNAMESPACES = 697, - XMLPARSE = 698, - XMLPI = 699, - XMLROOT = 700, - XMLSERIALIZE = 701, - XMLTABLE = 702, - YEAR_P = 703, - YES_P = 704, - ZONE = 705, - NOT_LA = 706, - NULLS_LA = 707, - WITH_LA = 708, - POSTFIXOP = 709, - UMINUS = 710 + CALL = 310, + CALLED = 311, + CASCADE = 312, + CASCADED = 313, + CASE = 314, + CAST = 315, + CATALOG_P = 316, + CHAIN = 317, + CHAR_P = 318, + CHARACTER = 319, + CHARACTERISTICS = 320, + CHECK = 321, + CHECKPOINT = 322, + CLASS = 323, + CLOSE = 324, + CLUSTER = 325, + COALESCE = 326, + COLLATE = 327, + COLLATION = 328, + COLUMN = 329, + COLUMNS = 330, + COMMENT = 331, + COMMENTS = 332, + COMMIT = 333, + COMMITTED = 334, + CONCURRENTLY = 335, + CONFIGURATION = 336, + CONFLICT = 337, + CONNECTION = 338, + CONSTRAINT = 339, + CONSTRAINTS = 340, + CONTENT_P = 341, + CONTINUE_P = 342, + CONVERSION_P = 343, + COPY = 344, + COST = 345, + CREATE = 346, + CROSS = 347, + CSV = 348, + CUBE = 349, + CURRENT_P = 350, + CURRENT_CATALOG = 351, + CURRENT_DATE = 352, + CURRENT_ROLE = 353, + CURRENT_SCHEMA = 354, + CURRENT_TIME = 355, + CURRENT_TIMESTAMP = 356, + CURRENT_USER = 357, + CURSOR = 358, + CYCLE = 359, + DATA_P = 360, + DATABASE = 361, + DAY_P = 362, + DEALLOCATE = 363, + DEC = 364, + DECIMAL_P = 365, + DECLARE = 366, + DEFAULT = 367, + DEFAULTS = 368, + DEFERRABLE = 369, + DEFERRED = 370, + DEFINER = 371, + DELETE_P = 372, + DELIMITER = 373, + DELIMITERS = 374, + DEPENDS = 375, + DESC = 376, + DETACH = 377, + DICTIONARY = 378, + DISABLE_P = 379, + DISCARD = 380, + DISTINCT = 381, + DO = 382, + DOCUMENT_P = 383, + DOMAIN_P = 384, + DOUBLE_P = 385, + DROP = 386, + EACH = 387, + ELSE = 388, + ENABLE_P = 389, + ENCODING = 390, + ENCRYPTED = 391, + END_P = 392, + ENUM_P = 393, + ESCAPE = 394, + EVENT = 395, + EXCEPT = 396, + EXCLUDE = 397, + EXCLUDING = 398, + EXCLUSIVE = 399, + EXECUTE = 400, + EXISTS = 401, + EXPLAIN = 402, + EXTENSION = 403, + EXTERNAL = 404, + EXTRACT = 405, + FALSE_P = 406, + FAMILY = 407, + FETCH = 408, + FILTER = 409, + FIRST_P = 410, + FLOAT_P = 411, + FOLLOWING = 412, + FOR = 413, + FORCE = 414, + FOREIGN = 415, + FORWARD = 416, + FREEZE = 417, + FROM = 418, + FULL = 419, + FUNCTION = 420, + FUNCTIONS = 421, + GENERATED = 422, + GLOBAL = 423, + GRANT = 424, + GRANTED = 425, + GREATEST = 426, + GROUP_P = 427, + GROUPING = 428, + GROUPS = 429, + HANDLER = 430, + HAVING = 431, + HEADER_P = 432, + HOLD = 433, + HOUR_P = 434, + IDENTITY_P = 435, + IF_P = 436, + ILIKE = 437, + IMMEDIATE = 438, + IMMUTABLE = 439, + IMPLICIT_P = 440, + IMPORT_P = 441, + IN_P = 442, + INCLUDE = 443, + INCLUDING = 444, + INCREMENT = 445, + INDEX = 446, + INDEXES = 447, + INHERIT = 448, + INHERITS = 449, + INITIALLY = 450, + INLINE_P = 451, + INNER_P = 452, + INOUT = 453, + INPUT_P = 454, + INSENSITIVE = 455, + INSERT = 456, + INSTEAD = 457, + INT_P = 458, + INTEGER = 459, + INTERSECT = 460, + INTERVAL = 461, + INTO = 462, + INVOKER = 463, + IS = 464, + ISNULL = 465, + ISOLATION = 466, + JOIN = 467, + KEY = 468, + LABEL = 469, + LANGUAGE = 470, + LARGE_P = 471, + LAST_P = 472, + LATERAL_P = 473, + LEADING = 474, + LEAKPROOF = 475, + LEAST = 476, + LEFT = 477, + LEVEL = 478, + LIKE = 479, + LIMIT = 480, + LISTEN = 481, + LOAD = 482, + LOCAL = 483, + LOCALTIME = 484, + LOCALTIMESTAMP = 485, + LOCATION = 486, + LOCK_P = 487, + LOCKED = 488, + LOGGED = 489, + MAPPING = 490, + MATCH = 491, + MATERIALIZED = 492, + MAXVALUE = 493, + METHOD = 494, + MINUTE_P = 495, + MINVALUE = 496, + MODE = 497, + MONTH_P = 498, + MOVE = 499, + NAME_P = 500, + NAMES = 501, + NATIONAL = 502, + NATURAL = 503, + NCHAR = 504, + NEW = 505, + NEXT = 506, + NO = 507, + NONE = 508, + NOT = 509, + NOTHING = 510, + NOTIFY = 511, + NOTNULL = 512, + NOWAIT = 513, + NULL_P = 514, + NULLIF = 515, + NULLS_P = 516, + NUMERIC = 517, + OBJECT_P = 518, + OF = 519, + OFF = 520, + OFFSET = 521, + OIDS = 522, + OLD = 523, + ON = 524, + ONLY = 525, + OPERATOR = 526, + OPTION = 527, + OPTIONS = 528, + OR = 529, + ORDER = 530, + ORDINALITY = 531, + OTHERS = 532, + OUT_P = 533, + OUTER_P = 534, + OVER = 535, + OVERLAPS = 536, + OVERLAY = 537, + OVERRIDING = 538, + OWNED = 539, + OWNER = 540, + PARALLEL = 541, + PARSER = 542, + PARTIAL = 543, + PARTITION = 544, + PASSING = 545, + PASSWORD = 546, + PGPOOL = 547, + PLACING = 548, + PLANS = 549, + POLICY = 550, + POSITION = 551, + PRECEDING = 552, + PRECISION = 553, + PRESERVE = 554, + PREPARE = 555, + PREPARED = 556, + PRIMARY = 557, + PRIOR = 558, + PRIVILEGES = 559, + PROCEDURAL = 560, + PROCEDURE = 561, + PROCEDURES = 562, + PROGRAM = 563, + PUBLICATION = 564, + QUOTE = 565, + RANGE = 566, + READ = 567, + REAL = 568, + REASSIGN = 569, + RECHECK = 570, + RECURSIVE = 571, + REF = 572, + REFERENCES = 573, + REFERENCING = 574, + REFRESH = 575, + REINDEX = 576, + RELATIVE_P = 577, + RELEASE = 578, + RENAME = 579, + REPEATABLE = 580, + REPLACE = 581, + REPLICA = 582, + RESET = 583, + RESTART = 584, + RESTRICT = 585, + RETURNING = 586, + RETURNS = 587, + REVOKE = 588, + RIGHT = 589, + ROLE = 590, + ROLLBACK = 591, + ROLLUP = 592, + ROUTINE = 593, + ROUTINES = 594, + ROW = 595, + ROWS = 596, + RULE = 597, + SAVEPOINT = 598, + SCHEMA = 599, + SCHEMAS = 600, + SCROLL = 601, + SEARCH = 602, + SECOND_P = 603, + SECURITY = 604, + SELECT = 605, + SEQUENCE = 606, + SEQUENCES = 607, + SERIALIZABLE = 608, + SERVER = 609, + SESSION = 610, + SESSION_USER = 611, + SET = 612, + SETS = 613, + SETOF = 614, + SHARE = 615, + SHOW = 616, + SIMILAR = 617, + SIMPLE = 618, + SKIP = 619, + SMALLINT = 620, + SNAPSHOT = 621, + SOME = 622, + SQL_P = 623, + STABLE = 624, + STANDALONE_P = 625, + START = 626, + STATEMENT = 627, + STATISTICS = 628, + STDIN = 629, + STDOUT = 630, + STORAGE = 631, + STRICT_P = 632, + STRIP_P = 633, + SUBSCRIPTION = 634, + SUBSTRING = 635, + SYMMETRIC = 636, + SYSID = 637, + SYSTEM_P = 638, + TABLE = 639, + TABLES = 640, + TABLESAMPLE = 641, + TABLESPACE = 642, + TEMP = 643, + TEMPLATE = 644, + TEMPORARY = 645, + TEXT_P = 646, + THEN = 647, + TIES = 648, + TIME = 649, + TIMESTAMP = 650, + TO = 651, + TRAILING = 652, + TRANSACTION = 653, + TRANSFORM = 654, + TREAT = 655, + TRIGGER = 656, + TRIM = 657, + TRUE_P = 658, + TRUNCATE = 659, + TRUSTED = 660, + TYPE_P = 661, + TYPES_P = 662, + UNBOUNDED = 663, + UNCOMMITTED = 664, + UNENCRYPTED = 665, + UNION = 666, + UNIQUE = 667, + UNKNOWN = 668, + UNLISTEN = 669, + UNLOGGED = 670, + UNTIL = 671, + UPDATE = 672, + USER = 673, + USING = 674, + VACUUM = 675, + VALID = 676, + VALIDATE = 677, + VALIDATOR = 678, + VALUE_P = 679, + VALUES = 680, + VARCHAR = 681, + VARIADIC = 682, + VARYING = 683, + VERBOSE = 684, + VERSION_P = 685, + VIEW = 686, + VIEWS = 687, + VOLATILE = 688, + WHEN = 689, + WHERE = 690, + WHITESPACE_P = 691, + WINDOW = 692, + WITH = 693, + WITHIN = 694, + WITHOUT = 695, + WORK = 696, + WRAPPER = 697, + WRITE = 698, + XML_P = 699, + XMLATTRIBUTES = 700, + XMLCONCAT = 701, + XMLELEMENT = 702, + XMLEXISTS = 703, + XMLFOREST = 704, + XMLNAMESPACES = 705, + XMLPARSE = 706, + XMLPI = 707, + XMLROOT = 708, + XMLSERIALIZE = 709, + XMLTABLE = 710, + YEAR_P = 711, + YES_P = 712, + ZONE = 713, + NOT_LA = 714, + NULLS_LA = 715, + WITH_LA = 716, + POSTFIXOP = 717, + UMINUS = 718 }; #endif /* Tokens. */ @@ -553,407 +561,415 @@ extern int base_yydebug; #define BOTH 307 #define BY 308 #define CACHE 309 -#define CALLED 310 -#define CASCADE 311 -#define CASCADED 312 -#define CASE 313 -#define CAST 314 -#define CATALOG_P 315 -#define CHAIN 316 -#define CHAR_P 317 -#define CHARACTER 318 -#define CHARACTERISTICS 319 -#define CHECK 320 -#define CHECKPOINT 321 -#define CLASS 322 -#define CLOSE 323 -#define CLUSTER 324 -#define COALESCE 325 -#define COLLATE 326 -#define COLLATION 327 -#define COLUMN 328 -#define COLUMNS 329 -#define COMMENT 330 -#define COMMENTS 331 -#define COMMIT 332 -#define COMMITTED 333 -#define CONCURRENTLY 334 -#define CONFIGURATION 335 -#define CONFLICT 336 -#define CONNECTION 337 -#define CONSTRAINT 338 -#define CONSTRAINTS 339 -#define CONTENT_P 340 -#define CONTINUE_P 341 -#define CONVERSION_P 342 -#define COPY 343 -#define COST 344 -#define CREATE 345 -#define CROSS 346 -#define CSV 347 -#define CUBE 348 -#define CURRENT_P 349 -#define CURRENT_CATALOG 350 -#define CURRENT_DATE 351 -#define CURRENT_ROLE 352 -#define CURRENT_SCHEMA 353 -#define CURRENT_TIME 354 -#define CURRENT_TIMESTAMP 355 -#define CURRENT_USER 356 -#define CURSOR 357 -#define CYCLE 358 -#define DATA_P 359 -#define DATABASE 360 -#define DAY_P 361 -#define DEALLOCATE 362 -#define DEC 363 -#define DECIMAL_P 364 -#define DECLARE 365 -#define DEFAULT 366 -#define DEFAULTS 367 -#define DEFERRABLE 368 -#define DEFERRED 369 -#define DEFINER 370 -#define DELETE_P 371 -#define DELIMITER 372 -#define DELIMITERS 373 -#define DEPENDS 374 -#define DESC 375 -#define DETACH 376 -#define DICTIONARY 377 -#define DISABLE_P 378 -#define DISCARD 379 -#define DISTINCT 380 -#define DO 381 -#define DOCUMENT_P 382 -#define DOMAIN_P 383 -#define DOUBLE_P 384 -#define DROP 385 -#define EACH 386 -#define ELSE 387 -#define ENABLE_P 388 -#define ENCODING 389 -#define ENCRYPTED 390 -#define END_P 391 -#define ENUM_P 392 -#define ESCAPE 393 -#define EVENT 394 -#define EXCEPT 395 -#define EXCLUDE 396 -#define EXCLUDING 397 -#define EXCLUSIVE 398 -#define EXECUTE 399 -#define EXISTS 400 -#define EXPLAIN 401 -#define EXTENSION 402 -#define EXTERNAL 403 -#define EXTRACT 404 -#define FALSE_P 405 -#define FAMILY 406 -#define FETCH 407 -#define FILTER 408 -#define FIRST_P 409 -#define FLOAT_P 410 -#define FOLLOWING 411 -#define FOR 412 -#define FORCE 413 -#define FOREIGN 414 -#define FORWARD 415 -#define FREEZE 416 -#define FROM 417 -#define FULL 418 -#define FUNCTION 419 -#define FUNCTIONS 420 -#define GENERATED 421 -#define GLOBAL 422 -#define GRANT 423 -#define GRANTED 424 -#define GREATEST 425 -#define GROUP_P 426 -#define GROUPING 427 -#define HANDLER 428 -#define HAVING 429 -#define HEADER_P 430 -#define HOLD 431 -#define HOUR_P 432 -#define IDENTITY_P 433 -#define IF_P 434 -#define ILIKE 435 -#define IMMEDIATE 436 -#define IMMUTABLE 437 -#define IMPLICIT_P 438 -#define IMPORT_P 439 -#define IN_P 440 -#define INCLUDING 441 -#define INCREMENT 442 -#define INDEX 443 -#define INDEXES 444 -#define INHERIT 445 -#define INHERITS 446 -#define INITIALLY 447 -#define INLINE_P 448 -#define INNER_P 449 -#define INOUT 450 -#define INPUT_P 451 -#define INSENSITIVE 452 -#define INSERT 453 -#define INSTEAD 454 -#define INT_P 455 -#define INTEGER 456 -#define INTERSECT 457 -#define INTERVAL 458 -#define INTO 459 -#define INVOKER 460 -#define IS 461 -#define ISNULL 462 -#define ISOLATION 463 -#define JOIN 464 -#define KEY 465 -#define LABEL 466 -#define LANGUAGE 467 -#define LARGE_P 468 -#define LAST_P 469 -#define LATERAL_P 470 -#define LEADING 471 -#define LEAKPROOF 472 -#define LEAST 473 -#define LEFT 474 -#define LEVEL 475 -#define LIKE 476 -#define LIMIT 477 -#define LISTEN 478 -#define LOAD 479 -#define LOCAL 480 -#define LOCALTIME 481 -#define LOCALTIMESTAMP 482 -#define LOCATION 483 -#define LOCK_P 484 -#define LOCKED 485 -#define LOGGED 486 -#define MAPPING 487 -#define MATCH 488 -#define MATERIALIZED 489 -#define MAXVALUE 490 -#define METHOD 491 -#define MINUTE_P 492 -#define MINVALUE 493 -#define MODE 494 -#define MONTH_P 495 -#define MOVE 496 -#define NAME_P 497 -#define NAMES 498 -#define NATIONAL 499 -#define NATURAL 500 -#define NCHAR 501 -#define NEW 502 -#define NEXT 503 -#define NO 504 -#define NONE 505 -#define NOT 506 -#define NOTHING 507 -#define NOTIFY 508 -#define NOTNULL 509 -#define NOWAIT 510 -#define NULL_P 511 -#define NULLIF 512 -#define NULLS_P 513 -#define NUMERIC 514 -#define OBJECT_P 515 -#define OF 516 -#define OFF 517 -#define OFFSET 518 -#define OIDS 519 -#define OLD 520 -#define ON 521 -#define ONLY 522 -#define OPERATOR 523 -#define OPTION 524 -#define OPTIONS 525 -#define OR 526 -#define ORDER 527 -#define ORDINALITY 528 -#define OUT_P 529 -#define OUTER_P 530 -#define OVER 531 -#define OVERLAPS 532 -#define OVERLAY 533 -#define OVERRIDING 534 -#define OWNED 535 -#define OWNER 536 -#define PARALLEL 537 -#define PARSER 538 -#define PARTIAL 539 -#define PARTITION 540 -#define PASSING 541 -#define PASSWORD 542 -#define PGPOOL 543 -#define PLACING 544 -#define PLANS 545 -#define POLICY 546 -#define POSITION 547 -#define PRECEDING 548 -#define PRECISION 549 -#define PRESERVE 550 -#define PREPARE 551 -#define PREPARED 552 -#define PRIMARY 553 -#define PRIOR 554 -#define PRIVILEGES 555 -#define PROCEDURAL 556 -#define PROCEDURE 557 -#define PROGRAM 558 -#define PUBLICATION 559 -#define QUOTE 560 -#define RANGE 561 -#define READ 562 -#define REAL 563 -#define REASSIGN 564 -#define RECHECK 565 -#define RECURSIVE 566 -#define REF 567 -#define REFERENCES 568 -#define REFERENCING 569 -#define REFRESH 570 -#define REINDEX 571 -#define RELATIVE_P 572 -#define RELEASE 573 -#define RENAME 574 -#define REPEATABLE 575 -#define REPLACE 576 -#define REPLICA 577 -#define RESET 578 -#define RESTART 579 -#define RESTRICT 580 -#define RETURNING 581 -#define RETURNS 582 -#define REVOKE 583 -#define RIGHT 584 -#define ROLE 585 -#define ROLLBACK 586 -#define ROLLUP 587 -#define ROW 588 -#define ROWS 589 -#define RULE 590 -#define SAVEPOINT 591 -#define SCHEMA 592 -#define SCHEMAS 593 -#define SCROLL 594 -#define SEARCH 595 -#define SECOND_P 596 -#define SECURITY 597 -#define SELECT 598 -#define SEQUENCE 599 -#define SEQUENCES 600 -#define SERIALIZABLE 601 -#define SERVER 602 -#define SESSION 603 -#define SESSION_USER 604 -#define SET 605 -#define SETS 606 -#define SETOF 607 -#define SHARE 608 -#define SHOW 609 -#define SIMILAR 610 -#define SIMPLE 611 -#define SKIP 612 -#define SMALLINT 613 -#define SNAPSHOT 614 -#define SOME 615 -#define SQL_P 616 -#define STABLE 617 -#define STANDALONE_P 618 -#define START 619 -#define STATEMENT 620 -#define STATISTICS 621 -#define STDIN 622 -#define STDOUT 623 -#define STORAGE 624 -#define STRICT_P 625 -#define STRIP_P 626 -#define SUBSCRIPTION 627 -#define SUBSTRING 628 -#define SYMMETRIC 629 -#define SYSID 630 -#define SYSTEM_P 631 -#define TABLE 632 -#define TABLES 633 -#define TABLESAMPLE 634 -#define TABLESPACE 635 -#define TEMP 636 -#define TEMPLATE 637 -#define TEMPORARY 638 -#define TEXT_P 639 -#define THEN 640 -#define TIME 641 -#define TIMESTAMP 642 -#define TO 643 -#define TRAILING 644 -#define TRANSACTION 645 -#define TRANSFORM 646 -#define TREAT 647 -#define TRIGGER 648 -#define TRIM 649 -#define TRUE_P 650 -#define TRUNCATE 651 -#define TRUSTED 652 -#define TYPE_P 653 -#define TYPES_P 654 -#define UNBOUNDED 655 -#define UNCOMMITTED 656 -#define UNENCRYPTED 657 -#define UNION 658 -#define UNIQUE 659 -#define UNKNOWN 660 -#define UNLISTEN 661 -#define UNLOGGED 662 -#define UNTIL 663 -#define UPDATE 664 -#define USER 665 -#define USING 666 -#define VACUUM 667 -#define VALID 668 -#define VALIDATE 669 -#define VALIDATOR 670 -#define VALUE_P 671 -#define VALUES 672 -#define VARCHAR 673 -#define VARIADIC 674 -#define VARYING 675 -#define VERBOSE 676 -#define VERSION_P 677 -#define VIEW 678 -#define VIEWS 679 -#define VOLATILE 680 -#define WHEN 681 -#define WHERE 682 -#define WHITESPACE_P 683 -#define WINDOW 684 -#define WITH 685 -#define WITHIN 686 -#define WITHOUT 687 -#define WORK 688 -#define WRAPPER 689 -#define WRITE 690 -#define XML_P 691 -#define XMLATTRIBUTES 692 -#define XMLCONCAT 693 -#define XMLELEMENT 694 -#define XMLEXISTS 695 -#define XMLFOREST 696 -#define XMLNAMESPACES 697 -#define XMLPARSE 698 -#define XMLPI 699 -#define XMLROOT 700 -#define XMLSERIALIZE 701 -#define XMLTABLE 702 -#define YEAR_P 703 -#define YES_P 704 -#define ZONE 705 -#define NOT_LA 706 -#define NULLS_LA 707 -#define WITH_LA 708 -#define POSTFIXOP 709 -#define UMINUS 710 +#define CALL 310 +#define CALLED 311 +#define CASCADE 312 +#define CASCADED 313 +#define CASE 314 +#define CAST 315 +#define CATALOG_P 316 +#define CHAIN 317 +#define CHAR_P 318 +#define CHARACTER 319 +#define CHARACTERISTICS 320 +#define CHECK 321 +#define CHECKPOINT 322 +#define CLASS 323 +#define CLOSE 324 +#define CLUSTER 325 +#define COALESCE 326 +#define COLLATE 327 +#define COLLATION 328 +#define COLUMN 329 +#define COLUMNS 330 +#define COMMENT 331 +#define COMMENTS 332 +#define COMMIT 333 +#define COMMITTED 334 +#define CONCURRENTLY 335 +#define CONFIGURATION 336 +#define CONFLICT 337 +#define CONNECTION 338 +#define CONSTRAINT 339 +#define CONSTRAINTS 340 +#define CONTENT_P 341 +#define CONTINUE_P 342 +#define CONVERSION_P 343 +#define COPY 344 +#define COST 345 +#define CREATE 346 +#define CROSS 347 +#define CSV 348 +#define CUBE 349 +#define CURRENT_P 350 +#define CURRENT_CATALOG 351 +#define CURRENT_DATE 352 +#define CURRENT_ROLE 353 +#define CURRENT_SCHEMA 354 +#define CURRENT_TIME 355 +#define CURRENT_TIMESTAMP 356 +#define CURRENT_USER 357 +#define CURSOR 358 +#define CYCLE 359 +#define DATA_P 360 +#define DATABASE 361 +#define DAY_P 362 +#define DEALLOCATE 363 +#define DEC 364 +#define DECIMAL_P 365 +#define DECLARE 366 +#define DEFAULT 367 +#define DEFAULTS 368 +#define DEFERRABLE 369 +#define DEFERRED 370 +#define DEFINER 371 +#define DELETE_P 372 +#define DELIMITER 373 +#define DELIMITERS 374 +#define DEPENDS 375 +#define DESC 376 +#define DETACH 377 +#define DICTIONARY 378 +#define DISABLE_P 379 +#define DISCARD 380 +#define DISTINCT 381 +#define DO 382 +#define DOCUMENT_P 383 +#define DOMAIN_P 384 +#define DOUBLE_P 385 +#define DROP 386 +#define EACH 387 +#define ELSE 388 +#define ENABLE_P 389 +#define ENCODING 390 +#define ENCRYPTED 391 +#define END_P 392 +#define ENUM_P 393 +#define ESCAPE 394 +#define EVENT 395 +#define EXCEPT 396 +#define EXCLUDE 397 +#define EXCLUDING 398 +#define EXCLUSIVE 399 +#define EXECUTE 400 +#define EXISTS 401 +#define EXPLAIN 402 +#define EXTENSION 403 +#define EXTERNAL 404 +#define EXTRACT 405 +#define FALSE_P 406 +#define FAMILY 407 +#define FETCH 408 +#define FILTER 409 +#define FIRST_P 410 +#define FLOAT_P 411 +#define FOLLOWING 412 +#define FOR 413 +#define FORCE 414 +#define FOREIGN 415 +#define FORWARD 416 +#define FREEZE 417 +#define FROM 418 +#define FULL 419 +#define FUNCTION 420 +#define FUNCTIONS 421 +#define GENERATED 422 +#define GLOBAL 423 +#define GRANT 424 +#define GRANTED 425 +#define GREATEST 426 +#define GROUP_P 427 +#define GROUPING 428 +#define GROUPS 429 +#define HANDLER 430 +#define HAVING 431 +#define HEADER_P 432 +#define HOLD 433 +#define HOUR_P 434 +#define IDENTITY_P 435 +#define IF_P 436 +#define ILIKE 437 +#define IMMEDIATE 438 +#define IMMUTABLE 439 +#define IMPLICIT_P 440 +#define IMPORT_P 441 +#define IN_P 442 +#define INCLUDE 443 +#define INCLUDING 444 +#define INCREMENT 445 +#define INDEX 446 +#define INDEXES 447 +#define INHERIT 448 +#define INHERITS 449 +#define INITIALLY 450 +#define INLINE_P 451 +#define INNER_P 452 +#define INOUT 453 +#define INPUT_P 454 +#define INSENSITIVE 455 +#define INSERT 456 +#define INSTEAD 457 +#define INT_P 458 +#define INTEGER 459 +#define INTERSECT 460 +#define INTERVAL 461 +#define INTO 462 +#define INVOKER 463 +#define IS 464 +#define ISNULL 465 +#define ISOLATION 466 +#define JOIN 467 +#define KEY 468 +#define LABEL 469 +#define LANGUAGE 470 +#define LARGE_P 471 +#define LAST_P 472 +#define LATERAL_P 473 +#define LEADING 474 +#define LEAKPROOF 475 +#define LEAST 476 +#define LEFT 477 +#define LEVEL 478 +#define LIKE 479 +#define LIMIT 480 +#define LISTEN 481 +#define LOAD 482 +#define LOCAL 483 +#define LOCALTIME 484 +#define LOCALTIMESTAMP 485 +#define LOCATION 486 +#define LOCK_P 487 +#define LOCKED 488 +#define LOGGED 489 +#define MAPPING 490 +#define MATCH 491 +#define MATERIALIZED 492 +#define MAXVALUE 493 +#define METHOD 494 +#define MINUTE_P 495 +#define MINVALUE 496 +#define MODE 497 +#define MONTH_P 498 +#define MOVE 499 +#define NAME_P 500 +#define NAMES 501 +#define NATIONAL 502 +#define NATURAL 503 +#define NCHAR 504 +#define NEW 505 +#define NEXT 506 +#define NO 507 +#define NONE 508 +#define NOT 509 +#define NOTHING 510 +#define NOTIFY 511 +#define NOTNULL 512 +#define NOWAIT 513 +#define NULL_P 514 +#define NULLIF 515 +#define NULLS_P 516 +#define NUMERIC 517 +#define OBJECT_P 518 +#define OF 519 +#define OFF 520 +#define OFFSET 521 +#define OIDS 522 +#define OLD 523 +#define ON 524 +#define ONLY 525 +#define OPERATOR 526 +#define OPTION 527 +#define OPTIONS 528 +#define OR 529 +#define ORDER 530 +#define ORDINALITY 531 +#define OTHERS 532 +#define OUT_P 533 +#define OUTER_P 534 +#define OVER 535 +#define OVERLAPS 536 +#define OVERLAY 537 +#define OVERRIDING 538 +#define OWNED 539 +#define OWNER 540 +#define PARALLEL 541 +#define PARSER 542 +#define PARTIAL 543 +#define PARTITION 544 +#define PASSING 545 +#define PASSWORD 546 +#define PGPOOL 547 +#define PLACING 548 +#define PLANS 549 +#define POLICY 550 +#define POSITION 551 +#define PRECEDING 552 +#define PRECISION 553 +#define PRESERVE 554 +#define PREPARE 555 +#define PREPARED 556 +#define PRIMARY 557 +#define PRIOR 558 +#define PRIVILEGES 559 +#define PROCEDURAL 560 +#define PROCEDURE 561 +#define PROCEDURES 562 +#define PROGRAM 563 +#define PUBLICATION 564 +#define QUOTE 565 +#define RANGE 566 +#define READ 567 +#define REAL 568 +#define REASSIGN 569 +#define RECHECK 570 +#define RECURSIVE 571 +#define REF 572 +#define REFERENCES 573 +#define REFERENCING 574 +#define REFRESH 575 +#define REINDEX 576 +#define RELATIVE_P 577 +#define RELEASE 578 +#define RENAME 579 +#define REPEATABLE 580 +#define REPLACE 581 +#define REPLICA 582 +#define RESET 583 +#define RESTART 584 +#define RESTRICT 585 +#define RETURNING 586 +#define RETURNS 587 +#define REVOKE 588 +#define RIGHT 589 +#define ROLE 590 +#define ROLLBACK 591 +#define ROLLUP 592 +#define ROUTINE 593 +#define ROUTINES 594 +#define ROW 595 +#define ROWS 596 +#define RULE 597 +#define SAVEPOINT 598 +#define SCHEMA 599 +#define SCHEMAS 600 +#define SCROLL 601 +#define SEARCH 602 +#define SECOND_P 603 +#define SECURITY 604 +#define SELECT 605 +#define SEQUENCE 606 +#define SEQUENCES 607 +#define SERIALIZABLE 608 +#define SERVER 609 +#define SESSION 610 +#define SESSION_USER 611 +#define SET 612 +#define SETS 613 +#define SETOF 614 +#define SHARE 615 +#define SHOW 616 +#define SIMILAR 617 +#define SIMPLE 618 +#define SKIP 619 +#define SMALLINT 620 +#define SNAPSHOT 621 +#define SOME 622 +#define SQL_P 623 +#define STABLE 624 +#define STANDALONE_P 625 +#define START 626 +#define STATEMENT 627 +#define STATISTICS 628 +#define STDIN 629 +#define STDOUT 630 +#define STORAGE 631 +#define STRICT_P 632 +#define STRIP_P 633 +#define SUBSCRIPTION 634 +#define SUBSTRING 635 +#define SYMMETRIC 636 +#define SYSID 637 +#define SYSTEM_P 638 +#define TABLE 639 +#define TABLES 640 +#define TABLESAMPLE 641 +#define TABLESPACE 642 +#define TEMP 643 +#define TEMPLATE 644 +#define TEMPORARY 645 +#define TEXT_P 646 +#define THEN 647 +#define TIES 648 +#define TIME 649 +#define TIMESTAMP 650 +#define TO 651 +#define TRAILING 652 +#define TRANSACTION 653 +#define TRANSFORM 654 +#define TREAT 655 +#define TRIGGER 656 +#define TRIM 657 +#define TRUE_P 658 +#define TRUNCATE 659 +#define TRUSTED 660 +#define TYPE_P 661 +#define TYPES_P 662 +#define UNBOUNDED 663 +#define UNCOMMITTED 664 +#define UNENCRYPTED 665 +#define UNION 666 +#define UNIQUE 667 +#define UNKNOWN 668 +#define UNLISTEN 669 +#define UNLOGGED 670 +#define UNTIL 671 +#define UPDATE 672 +#define USER 673 +#define USING 674 +#define VACUUM 675 +#define VALID 676 +#define VALIDATE 677 +#define VALIDATOR 678 +#define VALUE_P 679 +#define VALUES 680 +#define VARCHAR 681 +#define VARIADIC 682 +#define VARYING 683 +#define VERBOSE 684 +#define VERSION_P 685 +#define VIEW 686 +#define VIEWS 687 +#define VOLATILE 688 +#define WHEN 689 +#define WHERE 690 +#define WHITESPACE_P 691 +#define WINDOW 692 +#define WITH 693 +#define WITHIN 694 +#define WITHOUT 695 +#define WORK 696 +#define WRAPPER 697 +#define WRITE 698 +#define XML_P 699 +#define XMLATTRIBUTES 700 +#define XMLCONCAT 701 +#define XMLELEMENT 702 +#define XMLEXISTS 703 +#define XMLFOREST 704 +#define XMLNAMESPACES 705 +#define XMLPARSE 706 +#define XMLPI 707 +#define XMLROOT 708 +#define XMLSERIALIZE 709 +#define XMLTABLE 710 +#define YEAR_P 711 +#define YES_P 712 +#define ZONE 713 +#define NOT_LA 714 +#define NULLS_LA 715 +#define WITH_LA 716 +#define POSTFIXOP 717 +#define UMINUS 718 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED @@ -1004,7 +1020,7 @@ union YYSTYPE PartitionBoundSpec *partboundspec; RoleSpec *rolespec; -#line 1008 "gram.h" /* yacc.c:1909 */ +#line 1024 "gram.h" /* yacc.c:1909 */ }; typedef union YYSTYPE YYSTYPE; diff --git a/src/parser/gram.y b/src/parser/gram.y index 36759f2..c8e5ca4 100644 --- a/src/parser/gram.y +++ b/src/parser/gram.y @@ -6,8 +6,8 @@ * gram.y * POSTGRESQL BISON rules/actions * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * @@ -155,7 +155,7 @@ typedef enum typedef struct PrivTarget { GrantTargetType targtype; - GrantObjectType objtype; + ObjectType objtype; List *objs; } PrivTarget; @@ -290,7 +290,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); AlterCompositeTypeStmt AlterUserMappingStmt AlterRoleStmt AlterRoleSetStmt AlterPolicyStmt AlterDefaultPrivilegesStmt DefACLAction - AnalyzeStmt ClosePortalStmt ClusterStmt CommentStmt + AnalyzeStmt CallStmt ClosePortalStmt ClusterStmt CommentStmt ConstraintsSetStmt CopyStmt CreateAsStmt CreateCastStmt CreateDomainStmt CreateExtensionStmt CreateGroupStmt CreateOpClassStmt CreateOpFamilyStmt AlterOpFamilyStmt CreatePLangStmt @@ -327,7 +327,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); %type add_drop opt_asc_desc opt_nulls_order %type alter_table_cmd alter_type_cmd opt_collate_clause - replica_identity partition_cmd + replica_identity partition_cmd index_partition_cmd %type alter_table_cmds alter_type_cmds %type alter_identity_column_option_list %type alter_identity_column_option @@ -343,6 +343,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); %type opt_lock lock_type cast_context %type vacuum_option_list vacuum_option_elem + analyze_option_list analyze_option_elem %type opt_or_replace opt_grant_grant_option opt_grant_admin_option opt_nowait opt_if_exists opt_with_data @@ -402,6 +403,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); %type DefACLOptionList %type import_qualification_type %type import_qualification +%type vacuum_relation %type stmtblock stmtmulti OptTableElementList TableElementList OptInherit definition @@ -415,6 +417,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); oper_argtypes RuleActionList RuleActionMulti opt_column_list columnList opt_name_list sort_clause opt_sort_clause sortby_list index_params + opt_include opt_c_include index_including_params name_list role_list from_clause from_list opt_array_bounds qualified_name_list any_name any_name_list type_name_list any_operator expr_list attrs @@ -433,6 +436,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); transform_element_list transform_type_list TriggerTransitions TriggerReferencing publication_name_list + vacuum_relation_list opt_vacuum_relation_list %type group_by_list %type group_by_item empty_grouping_set rollup_clause cube_clause @@ -472,7 +476,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); %type opt_instead %type opt_unique opt_concurrently opt_verbose opt_full -%type opt_freeze opt_default opt_recheck +%type opt_freeze opt_analyze opt_default opt_recheck %type opt_binary opt_oids copy_delimiter %type copy_from opt_program @@ -484,7 +488,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); %type fetch_args limit_clause select_limit_value offset_clause select_offset_value - select_offset_value2 opt_select_fetch_first_value + select_fetch_first_value I_or_F_const %type row_or_rows first_or_next %type OptSeqOptList SeqOptList OptParenthesizedSeqOptList @@ -605,6 +609,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); %type window_clause window_definition_list opt_partition_clause %type window_definition over_clause window_specification opt_frame_clause frame_extent frame_bound +%type opt_window_exclusion_clause %type opt_existing_window_name %type opt_if_not_exists %type generated_when override_kind @@ -612,9 +617,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); %type part_strategy %type part_elem %type part_params -%type ForValues +%type PartitionBoundSpec %type partbound_datum PartitionRangeDatum -%type partbound_datum_list range_datum_list +%type hash_partbound partbound_datum_list range_datum_list +%type hash_partbound_elem /* * Non-keyword token types. These are hard-wired into the "flex" lexer. @@ -645,7 +651,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT BOOLEAN_P BOTH BY - CACHE CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P + CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE CLUSTER COALESCE COLLATE COLLATION COLUMN COLUMNS COMMENT COMMENTS COMMIT COMMITTED CONCURRENTLY CONFIGURATION CONFLICT CONNECTION CONSTRAINT @@ -666,11 +672,11 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); FALSE_P FAMILY FETCH FILTER FIRST_P FLOAT_P FOLLOWING FOR FORCE FOREIGN FORWARD FREEZE FROM FULL FUNCTION FUNCTIONS - GENERATED GLOBAL GRANT GRANTED GREATEST GROUP_P GROUPING + GENERATED GLOBAL GRANT GRANTED GREATEST GROUP_P GROUPING GROUPS HANDLER HAVING HEADER_P HOLD HOUR_P - IDENTITY_P IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P IN_P + IDENTITY_P IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P IN_P INCLUDE INCLUDING INCREMENT INDEX INDEXES INHERIT INHERITS INITIALLY INLINE_P INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION @@ -690,18 +696,19 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); NULLS_P NUMERIC OBJECT_P OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OPTIONS OR - ORDER ORDINALITY OUT_P OUTER_P OVER OVERLAPS OVERLAY OVERRIDING OWNED OWNER + ORDER ORDINALITY OTHERS OUT_P OUTER_P + OVER OVERLAPS OVERLAY OVERRIDING OWNED OWNER PARALLEL PARSER PARTIAL PARTITION PASSING PASSWORD PGPOOL PLACING PLANS POLICY POSITION PRECEDING PRECISION PRESERVE PREPARE PREPARED PRIMARY - PRIOR PRIVILEGES PROCEDURAL PROCEDURE PROGRAM PUBLICATION + PRIOR PRIVILEGES PROCEDURAL PROCEDURE PROCEDURES PROGRAM PUBLICATION QUOTE RANGE READ REAL REASSIGN RECHECK RECURSIVE REF REFERENCES REFERENCING REFRESH REINDEX RELATIVE_P RELEASE RENAME REPEATABLE REPLACE REPLICA RESET RESTART RESTRICT RETURNING RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP - ROW ROWS RULE + ROUTINE ROUTINES ROW ROWS RULE SAVEPOINT SCHEMA SCHEMAS SCROLL SEARCH SECOND_P SECURITY SELECT SEQUENCE SEQUENCES SERIALIZABLE SERVER SESSION SESSION_USER SET SETS SETOF SHARE SHOW @@ -710,7 +717,8 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); SUBSCRIPTION SUBSTRING SYMMETRIC SYSID SYSTEM_P TABLE TABLES TABLESAMPLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN - TIME TIMESTAMP TO TRAILING TRANSACTION TRANSFORM TREAT TRIGGER TRIM TRUE_P + TIES TIME TIMESTAMP TO TRAILING TRANSACTION TRANSFORM + TREAT TRIGGER TRIM TRUE_P TRUNCATE TRUSTED TYPE_P TYPES_P UNBOUNDED UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNLOGGED @@ -758,9 +766,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); * between POSTFIXOP and Op. We can safely assign the same priority to * various unreserved keywords as needed to resolve ambiguities (this can't * have any bad effects since obviously the keywords will still behave the - * same as if they weren't keywords). We need to do this for PARTITION, - * RANGE, ROWS to support opt_existing_window_name; and for RANGE, ROWS - * so that they can follow a_expr without creating postfix-operator problems; + * same as if they weren't keywords). We need to do this: + * for PARTITION, RANGE, ROWS, GROUPS to support opt_existing_window_name; + * for RANGE, ROWS, GROUPS so that they can follow a_expr without creating + * postfix-operator problems; * for GENERATED so that it can follow b_expr; * and for NULL so that it can follow b_expr in ColQualList without creating * postfix-operator problems. @@ -780,7 +789,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); * blame any funny behavior of UNBOUNDED on the SQL standard, though. */ %nonassoc UNBOUNDED /* ideally should have same precedence as IDENT */ -%nonassoc IDENT GENERATED NULL_P PARTITION RANGE ROWS PRECEDING FOLLOWING CUBE ROLLUP +%nonassoc IDENT GENERATED NULL_P PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE ROLLUP %left Op OPERATOR /* multi-character ops and user-defined operators */ %left '+' '-' %left '*' '/' '%' @@ -879,6 +888,7 @@ stmt : | AlterTSDictionaryStmt | AlterUserMappingStmt | AnalyzeStmt + | CallStmt | CheckPointStmt | ClosePortalStmt | ClusterStmt @@ -976,6 +986,20 @@ stmt : /***************************************************************************** * + * CALL statement + * + *****************************************************************************/ + +CallStmt: CALL func_application + { + CallStmt *n = makeNode(CallStmt); + n->funccall = castNode(FuncCall, $2); + $$ = (Node *)n; + } + ; + +/***************************************************************************** + * * Create a new Postgres DBMS role * *****************************************************************************/ @@ -1042,7 +1066,7 @@ AlterOptRoleElem: } | INHERIT { - $$ = makeDefElem("inherit", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("inherit", (Node *)makeInteger(true), @1); } | CONNECTION LIMIT SignedIconst { @@ -1065,36 +1089,36 @@ AlterOptRoleElem: * size of the main parser. */ if (strcmp($1, "superuser") == 0) - $$ = makeDefElem("superuser", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("superuser", (Node *)makeInteger(true), @1); else if (strcmp($1, "nosuperuser") == 0) - $$ = makeDefElem("superuser", (Node *)makeInteger(FALSE), @1); + $$ = makeDefElem("superuser", (Node *)makeInteger(false), @1); else if (strcmp($1, "createrole") == 0) - $$ = makeDefElem("createrole", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("createrole", (Node *)makeInteger(true), @1); else if (strcmp($1, "nocreaterole") == 0) - $$ = makeDefElem("createrole", (Node *)makeInteger(FALSE), @1); + $$ = makeDefElem("createrole", (Node *)makeInteger(false), @1); else if (strcmp($1, "replication") == 0) - $$ = makeDefElem("isreplication", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("isreplication", (Node *)makeInteger(true), @1); else if (strcmp($1, "noreplication") == 0) - $$ = makeDefElem("isreplication", (Node *)makeInteger(FALSE), @1); + $$ = makeDefElem("isreplication", (Node *)makeInteger(false), @1); else if (strcmp($1, "createdb") == 0) - $$ = makeDefElem("createdb", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("createdb", (Node *)makeInteger(true), @1); else if (strcmp($1, "nocreatedb") == 0) - $$ = makeDefElem("createdb", (Node *)makeInteger(FALSE), @1); + $$ = makeDefElem("createdb", (Node *)makeInteger(false), @1); else if (strcmp($1, "login") == 0) - $$ = makeDefElem("canlogin", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("canlogin", (Node *)makeInteger(true), @1); else if (strcmp($1, "nologin") == 0) - $$ = makeDefElem("canlogin", (Node *)makeInteger(FALSE), @1); + $$ = makeDefElem("canlogin", (Node *)makeInteger(false), @1); else if (strcmp($1, "bypassrls") == 0) - $$ = makeDefElem("bypassrls", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("bypassrls", (Node *)makeInteger(true), @1); else if (strcmp($1, "nobypassrls") == 0) - $$ = makeDefElem("bypassrls", (Node *)makeInteger(FALSE), @1); + $$ = makeDefElem("bypassrls", (Node *)makeInteger(false), @1); else if (strcmp($1, "noinherit") == 0) { /* * Note that INHERIT is a keyword, so it's handled by main parser, but * NOINHERIT is handled here. */ - $$ = makeDefElem("inherit", (Node *)makeInteger(FALSE), @1); + $$ = makeDefElem("inherit", (Node *)makeInteger(false), @1); } else ereport(ERROR, @@ -1227,21 +1251,21 @@ DropRoleStmt: DROP ROLE role_list { DropRoleStmt *n = makeNode(DropRoleStmt); - n->missing_ok = FALSE; + n->missing_ok = false; n->roles = $3; $$ = (Node *)n; } | DROP ROLE IF_P EXISTS role_list { DropRoleStmt *n = makeNode(DropRoleStmt); - n->missing_ok = TRUE; + n->missing_ok = true; n->roles = $5; $$ = (Node *)n; } | DROP USER role_list { DropRoleStmt *n = makeNode(DropRoleStmt); - n->missing_ok = FALSE; + n->missing_ok = false; n->roles = $3; $$ = (Node *)n; } @@ -1249,20 +1273,20 @@ DropRoleStmt: { DropRoleStmt *n = makeNode(DropRoleStmt); n->roles = $5; - n->missing_ok = TRUE; + n->missing_ok = true; $$ = (Node *)n; } | DROP GROUP_P role_list { DropRoleStmt *n = makeNode(DropRoleStmt); - n->missing_ok = FALSE; + n->missing_ok = false; n->roles = $3; $$ = (Node *)n; } | DROP GROUP_P IF_P EXISTS role_list { DropRoleStmt *n = makeNode(DropRoleStmt); - n->missing_ok = TRUE; + n->missing_ok = true; n->roles = $5; $$ = (Node *)n; } @@ -1793,8 +1817,8 @@ constraints_set_list: ; constraints_set_mode: - DEFERRED { $$ = TRUE; } - | IMMEDIATE { $$ = FALSE; } + DEFERRED { $$ = true; } + | IMMEDIATE { $$ = false; } ; @@ -1936,6 +1960,15 @@ AlterTableStmt: n->missing_ok = true; $$ = (Node *)n; } + | ALTER INDEX qualified_name index_partition_cmd + { + AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $3; + n->cmds = list_make1($4); + n->relkind = OBJECT_INDEX; + n->missing_ok = false; + $$ = (Node *)n; + } | ALTER INDEX ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait { AlterTableMoveAllStmt *n = @@ -2043,7 +2076,7 @@ alter_table_cmds: partition_cmd: /* ALTER TABLE ATTACH PARTITION FOR VALUES */ - ATTACH PARTITION qualified_name ForValues + ATTACH PARTITION qualified_name PartitionBoundSpec { AlterTableCmd *n = makeNode(AlterTableCmd); PartitionCmd *cmd = makeNode(PartitionCmd); @@ -2070,6 +2103,22 @@ partition_cmd: } ; +index_partition_cmd: + /* ALTER INDEX ATTACH PARTITION */ + ATTACH PARTITION qualified_name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + PartitionCmd *cmd = makeNode(PartitionCmd); + + n->subtype = AT_AttachPartition; + cmd->name = $3; + cmd->bound = NULL; + n->def = (Node *) cmd; + + $$ = (Node *) n; + } + ; + alter_table_cmd: /* ALTER TABLE ADD */ ADD_P columnDef @@ -2141,6 +2190,22 @@ alter_table_cmd: n->def = (Node *) makeInteger($6); $$ = (Node *)n; } + /* ALTER TABLE ALTER [COLUMN] SET STATISTICS */ + | ALTER opt_column Iconst SET STATISTICS SignedIconst + { + AlterTableCmd *n = makeNode(AlterTableCmd); + + if ($3 <= 0 || $3 > PG_INT16_MAX) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("column number must be in range from 1 to %d", PG_INT16_MAX), + parser_errposition(@3))); + + n->subtype = AT_SetStatistics; + n->num = (int16) $3; + n->def = (Node *) makeInteger($6); + $$ = (Node *)n; + } /* ALTER TABLE ALTER [COLUMN] SET ( column_parameter = value [, ... ] ) */ | ALTER opt_column ColId SET reloptions { @@ -2219,7 +2284,7 @@ alter_table_cmd: n->subtype = AT_DropColumn; n->name = $5; n->behavior = $6; - n->missing_ok = TRUE; + n->missing_ok = true; $$ = (Node *)n; } /* ALTER TABLE DROP [COLUMN] [RESTRICT|CASCADE] */ @@ -2229,7 +2294,7 @@ alter_table_cmd: n->subtype = AT_DropColumn; n->name = $3; n->behavior = $4; - n->missing_ok = FALSE; + n->missing_ok = false; $$ = (Node *)n; } /* @@ -2298,7 +2363,7 @@ alter_table_cmd: n->subtype = AT_DropConstraint; n->name = $5; n->behavior = $6; - n->missing_ok = TRUE; + n->missing_ok = true; $$ = (Node *)n; } /* ALTER TABLE DROP CONSTRAINT [RESTRICT|CASCADE] */ @@ -2308,7 +2373,7 @@ alter_table_cmd: n->subtype = AT_DropConstraint; n->name = $3; n->behavior = $4; - n->missing_ok = FALSE; + n->missing_ok = false; $$ = (Node *)n; } /* ALTER TABLE SET WITH OIDS */ @@ -2683,13 +2748,67 @@ alter_identity_column_option: } ; -ForValues: +PartitionBoundSpec: + /* a HASH partition*/ + FOR VALUES WITH '(' hash_partbound ')' + { + ListCell *lc; + PartitionBoundSpec *n = makeNode(PartitionBoundSpec); + + n->strategy = PARTITION_STRATEGY_HASH; + n->modulus = n->remainder = -1; + + foreach (lc, $5) + { + DefElem *opt = lfirst_node(DefElem, lc); + + if (strcmp(opt->defname, "modulus") == 0) + { + if (n->modulus != -1) + ereport(ERROR, + (errcode(ERRCODE_DUPLICATE_OBJECT), + errmsg("modulus for hash partition provided more than once"), + parser_errposition(opt->location))); + n->modulus = defGetInt32(opt); + } + else if (strcmp(opt->defname, "remainder") == 0) + { + if (n->remainder != -1) + ereport(ERROR, + (errcode(ERRCODE_DUPLICATE_OBJECT), + errmsg("remainder for hash partition provided more than once"), + parser_errposition(opt->location))); + n->remainder = defGetInt32(opt); + } + else + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("unrecognized hash partition bound specification \"%s\"", + opt->defname), + parser_errposition(opt->location))); + } + + if (n->modulus == -1) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("modulus for hash partition must be specified"))); + if (n->remainder == -1) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("remainder for hash partition must be specified"))); + + n->location = @3; + + $$ = n; + } + /* a LIST partition */ - FOR VALUES IN_P '(' partbound_datum_list ')' + | FOR VALUES IN_P '(' partbound_datum_list ')' { PartitionBoundSpec *n = makeNode(PartitionBoundSpec); n->strategy = PARTITION_STRATEGY_LIST; + n->is_default = false; n->listdatums = $5; n->location = @3; @@ -2702,17 +2821,49 @@ ForValues: PartitionBoundSpec *n = makeNode(PartitionBoundSpec); n->strategy = PARTITION_STRATEGY_RANGE; + n->is_default = false; n->lowerdatums = $5; n->upperdatums = $9; n->location = @3; $$ = n; } + + /* a DEFAULT partition */ + | DEFAULT + { + PartitionBoundSpec *n = makeNode(PartitionBoundSpec); + + n->is_default = true; + n->location = @1; + + $$ = n; + } + ; + +hash_partbound_elem: + NonReservedWord Iconst + { + $$ = makeDefElem($1, (Node *)makeInteger($2), @1); + } + ; + +hash_partbound: + hash_partbound_elem + { + $$ = list_make1($1); + } + | hash_partbound ',' hash_partbound_elem + { + $$ = lappend($1, $3); + } ; partbound_datum: Sconst { $$ = makeStringConst($1, @1); } | NumericOnly { $$ = makeAConst($1, @1); } + | TRUE_P { $$ = makeStringConst(pstrdup("true"), @1); } + | FALSE_P { $$ = makeStringConst(pstrdup("false"), @1); } | NULL_P { $$ = makeNullAConst(@1); } ; @@ -2803,7 +2954,7 @@ alter_type_cmd: n->subtype = AT_DropColumn; n->name = $5; n->behavior = $6; - n->missing_ok = TRUE; + n->missing_ok = true; $$ = (Node *)n; } /* ALTER TYPE DROP ATTRIBUTE [RESTRICT|CASCADE] */ @@ -2813,7 +2964,7 @@ alter_type_cmd: n->subtype = AT_DropColumn; n->name = $3; n->behavior = $4; - n->missing_ok = FALSE; + n->missing_ok = false; $$ = (Node *)n; } /* ALTER TYPE ALTER ATTRIBUTE [SET DATA] TYPE [RESTRICT|CASCADE] */ @@ -2933,13 +3084,13 @@ CopyStmt: COPY opt_binary qualified_name opt_column_list opt_oids ; copy_from: - FROM { $$ = TRUE; } - | TO { $$ = FALSE; } + FROM { $$ = true; } + | TO { $$ = false; } ; opt_program: - PROGRAM { $$ = TRUE; } - | /* EMPTY */ { $$ = FALSE; } + PROGRAM { $$ = true; } + | /* EMPTY */ { $$ = false; } ; /* @@ -2970,11 +3121,11 @@ copy_opt_item: } | OIDS { - $$ = makeDefElem("oids", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("oids", (Node *)makeInteger(true), @1); } | FREEZE { - $$ = makeDefElem("freeze", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("freeze", (Node *)makeInteger(true), @1); } | DELIMITER opt_as Sconst { @@ -2990,7 +3141,7 @@ copy_opt_item: } | HEADER_P { - $$ = makeDefElem("header", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("header", (Node *)makeInteger(true), @1); } | QUOTE opt_as Sconst { @@ -3035,7 +3186,7 @@ opt_binary: opt_oids: WITH OIDS { - $$ = makeDefElem("oids", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("oids", (Node *)makeInteger(true), @1); } | /*EMPTY*/ { $$ = NULL; } ; @@ -3178,7 +3329,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' $$ = (Node *)n; } | CREATE OptTemp TABLE qualified_name PARTITION OF qualified_name - OptTypedTableElementList ForValues OptPartitionSpec OptWith + OptTypedTableElementList PartitionBoundSpec OptPartitionSpec OptWith OnCommitOption OptTableSpace { CreateStmt *n = makeNode(CreateStmt); @@ -3197,7 +3348,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' $$ = (Node *)n; } | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name PARTITION OF - qualified_name OptTypedTableElementList ForValues OptPartitionSpec + qualified_name OptTypedTableElementList PartitionBoundSpec OptPartitionSpec OptWith OnCommitOption OptTableSpace { CreateStmt *n = makeNode(CreateStmt); @@ -3555,12 +3706,13 @@ TableLikeOptionList: ; TableLikeOption: - DEFAULTS { $$ = CREATE_TABLE_LIKE_DEFAULTS; } + COMMENTS { $$ = CREATE_TABLE_LIKE_COMMENTS; } | CONSTRAINTS { $$ = CREATE_TABLE_LIKE_CONSTRAINTS; } + | DEFAULTS { $$ = CREATE_TABLE_LIKE_DEFAULTS; } | IDENTITY_P { $$ = CREATE_TABLE_LIKE_IDENTITY; } | INDEXES { $$ = CREATE_TABLE_LIKE_INDEXES; } + | STATISTICS { $$ = CREATE_TABLE_LIKE_STATISTICS; } | STORAGE { $$ = CREATE_TABLE_LIKE_STORAGE; } - | COMMENTS { $$ = CREATE_TABLE_LIKE_COMMENTS; } | ALL { $$ = CREATE_TABLE_LIKE_ALL; } ; @@ -3594,17 +3746,18 @@ ConstraintElem: n->initially_valid = !n->skip_validation; $$ = (Node *)n; } - | UNIQUE '(' columnList ')' opt_definition OptConsTableSpace + | UNIQUE '(' columnList ')' opt_c_include opt_definition OptConsTableSpace ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); n->contype = CONSTR_UNIQUE; n->location = @1; n->keys = $3; - n->options = $5; + n->including = $5; + n->options = $6; n->indexname = NULL; - n->indexspace = $6; - processCASbits($7, @7, "UNIQUE", + n->indexspace = $7; + processCASbits($8, @8, "UNIQUE", &n->deferrable, &n->initdeferred, NULL, NULL, yyscanner); $$ = (Node *)n; @@ -3615,6 +3768,7 @@ ConstraintElem: n->contype = CONSTR_UNIQUE; n->location = @1; n->keys = NIL; + n->including = NIL; n->options = NIL; n->indexname = $2; n->indexspace = NULL; @@ -3623,17 +3777,18 @@ ConstraintElem: NULL, yyscanner); $$ = (Node *)n; } - | PRIMARY KEY '(' columnList ')' opt_definition OptConsTableSpace + | PRIMARY KEY '(' columnList ')' opt_c_include opt_definition OptConsTableSpace ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); n->contype = CONSTR_PRIMARY; n->location = @1; n->keys = $4; - n->options = $6; + n->including = $6; + n->options = $7; n->indexname = NULL; - n->indexspace = $7; - processCASbits($8, @8, "PRIMARY KEY", + n->indexspace = $8; + processCASbits($9, @9, "PRIMARY KEY", &n->deferrable, &n->initdeferred, NULL, NULL, yyscanner); $$ = (Node *)n; @@ -3644,6 +3799,7 @@ ConstraintElem: n->contype = CONSTR_PRIMARY; n->location = @1; n->keys = NIL; + n->including = NIL; n->options = NIL; n->indexname = $3; n->indexspace = NULL; @@ -3653,7 +3809,7 @@ ConstraintElem: $$ = (Node *)n; } | EXCLUDE access_method_clause '(' ExclusionConstraintList ')' - opt_definition OptConsTableSpace ExclusionWhereClause + opt_c_include opt_definition OptConsTableSpace ExclusionWhereClause ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); @@ -3661,11 +3817,12 @@ ConstraintElem: n->location = @1; n->access_method = $2; n->exclusions = $4; - n->options = $6; + n->including = $6; + n->options = $7; n->indexname = NULL; - n->indexspace = $7; - n->where_clause = $8; - processCASbits($9, @9, "EXCLUDE", + n->indexspace = $8; + n->where_clause = $9; + processCASbits($10, @10, "EXCLUDE", &n->deferrable, &n->initdeferred, NULL, NULL, yyscanner); $$ = (Node *)n; @@ -3691,8 +3848,8 @@ ConstraintElem: } ; -opt_no_inherit: NO INHERIT { $$ = TRUE; } - | /* EMPTY */ { $$ = FALSE; } +opt_no_inherit: NO INHERIT { $$ = true; } + | /* EMPTY */ { $$ = false; } ; opt_column_list: @@ -3711,6 +3868,10 @@ columnElem: ColId } ; +opt_c_include: INCLUDE '(' columnList ')' { $$ = $3; } + | /* EMPTY */ { $$ = NIL; } + ; + key_match: MATCH FULL { $$ = FKCONSTR_MATCH_FULL; @@ -3899,6 +4060,7 @@ CreateStatsStmt: n->stat_types = $4; n->exprs = $6; n->relations = $8; + n->stxcomment = NULL; n->if_not_exists = false; $$ = (Node *)n; } @@ -3910,6 +4072,7 @@ CreateStatsStmt: n->stat_types = $7; n->exprs = $9; n->relations = $11; + n->stxcomment = NULL; n->if_not_exists = true; $$ = (Node *)n; } @@ -3969,9 +4132,9 @@ create_as_target: ; opt_with_data: - WITH DATA_P { $$ = TRUE; } - | WITH NO DATA_P { $$ = FALSE; } - | /*EMPTY*/ { $$ = TRUE; } + WITH DATA_P { $$ = true; } + | WITH NO DATA_P { $$ = false; } + | /*EMPTY*/ { $$ = true; } ; @@ -4122,11 +4285,11 @@ SeqOptElem: AS SimpleTypename } | CYCLE { - $$ = makeDefElem("cycle", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("cycle", (Node *)makeInteger(true), @1); } | NO CYCLE { - $$ = makeDefElem("cycle", (Node *)makeInteger(FALSE), @1); + $$ = makeDefElem("cycle", (Node *)makeInteger(false), @1); } | INCREMENT opt_by NumericOnly { @@ -4226,8 +4389,8 @@ CreatePLangStmt: ; opt_trusted: - TRUSTED { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } + TRUSTED { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; /* This ought to be just func_name, but that causes reduce/reduce conflicts @@ -4378,7 +4541,7 @@ create_extension_opt_item: } | CASCADE { - $$ = makeDefElem("cascade", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("cascade", (Node *)makeInteger(true), @1); } ; @@ -4517,6 +4680,24 @@ AlterExtensionContentsStmt: n->object = (Node *) lcons(makeString($9), $7); $$ = (Node *)n; } + | ALTER EXTENSION name add_drop PROCEDURE function_with_argtypes + { + AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; + n->action = $4; + n->objtype = OBJECT_PROCEDURE; + n->object = (Node *) $6; + $$ = (Node *)n; + } + | ALTER EXTENSION name add_drop ROUTINE function_with_argtypes + { + AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; + n->action = $4; + n->objtype = OBJECT_ROUTINE; + n->object = (Node *) $6; + $$ = (Node *)n; + } | ALTER EXTENSION name add_drop SCHEMA name { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); @@ -4914,7 +5095,7 @@ CreateForeignTableStmt: $$ = (Node *) n; } | CREATE FOREIGN TABLE qualified_name - PARTITION OF qualified_name OptTypedTableElementList ForValues + PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec SERVER name create_generic_options { CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt); @@ -4935,7 +5116,7 @@ CreateForeignTableStmt: $$ = (Node *) n; } | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name - PARTITION OF qualified_name OptTypedTableElementList ForValues + PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec SERVER name create_generic_options { CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt); @@ -5242,9 +5423,9 @@ CreateTrigStmt: n->columns = (List *) lsecond($5); n->whenClause = $10; n->transitionRels = $8; - n->isconstraint = FALSE; - n->deferrable = FALSE; - n->initdeferred = FALSE; + n->isconstraint = false; + n->deferrable = false; + n->initdeferred = false; n->constrrel = NULL; $$ = (Node *)n; } @@ -5258,13 +5439,13 @@ CreateTrigStmt: n->relation = $8; n->funcname = $17; n->args = $19; - n->row = TRUE; + n->row = true; n->timing = TRIGGER_TYPE_AFTER; n->events = intVal(linitial($6)); n->columns = (List *) lsecond($6); n->whenClause = $14; n->transitionRels = NIL; - n->isconstraint = TRUE; + n->isconstraint = true; processCASbits($10, @10, "TRIGGER", &n->deferrable, &n->initdeferred, NULL, NULL, yyscanner); @@ -5338,12 +5519,12 @@ TriggerTransition: ; TransitionOldOrNew: - NEW { $$ = TRUE; } - | OLD { $$ = FALSE; } + NEW { $$ = true; } + | OLD { $$ = false; } ; TransitionRowOrTable: - TABLE { $$ = TRUE; } + TABLE { $$ = true; } /* * According to the standard, lack of a keyword here implies ROW. * Support for that would require prohibiting ROW entirely here, @@ -5352,7 +5533,7 @@ TransitionRowOrTable: * next token. Requiring ROW seems cleanest and easiest to * explain. */ - | ROW { $$ = FALSE; } + | ROW { $$ = false; } ; TransitionRelName: @@ -5370,7 +5551,7 @@ TriggerForSpec: * If ROW/STATEMENT not specified, default to * STATEMENT, per SQL */ - $$ = FALSE; + $$ = false; } ; @@ -5380,8 +5561,8 @@ TriggerForOptEach: ; TriggerForType: - ROW { $$ = TRUE; } - | STATEMENT { $$ = FALSE; } + ROW { $$ = true; } + | STATEMENT { $$ = false; } ; TriggerWhen: @@ -5532,7 +5713,7 @@ CreateAssertStmt: CreateTrigStmt *n = makeNode(CreateTrigStmt); n->trigname = $3; n->args = list_make1($6); - n->isconstraint = TRUE; + n->isconstraint = true; processCASbits($8, @8, "ASSERTION", &n->deferrable, &n->initdeferred, NULL, NULL, yyscanner); @@ -5912,8 +6093,8 @@ opclass_item: } ; -opt_default: DEFAULT { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } +opt_default: DEFAULT { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; opt_opfamily: FAMILY any_name { $$ = $2; } @@ -5937,9 +6118,9 @@ opt_recheck: RECHECK errmsg("RECHECK is no longer required"), errhint("Update your data type."), parser_errposition(@1))); - $$ = TRUE; + $$ = true; } - | /*EMPTY*/ { $$ = FALSE; } + | /*EMPTY*/ { $$ = false; } ; @@ -6087,7 +6268,7 @@ DropStmt: DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); n->removeType = $2; - n->missing_ok = TRUE; + n->missing_ok = true; n->objects = $5; n->behavior = $6; n->concurrent = false; @@ -6097,7 +6278,7 @@ DropStmt: DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); n->removeType = $2; - n->missing_ok = FALSE; + n->missing_ok = false; n->objects = $3; n->behavior = $4; n->concurrent = false; @@ -6107,7 +6288,7 @@ DropStmt: DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); n->removeType = $2; - n->missing_ok = TRUE; + n->missing_ok = true; n->objects = $5; n->behavior = $6; n->concurrent = false; @@ -6117,7 +6298,7 @@ DropStmt: DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); n->removeType = $2; - n->missing_ok = FALSE; + n->missing_ok = false; n->objects = $3; n->behavior = $4; n->concurrent = false; @@ -6147,7 +6328,7 @@ DropStmt: DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); n->removeType = OBJECT_TYPE; - n->missing_ok = FALSE; + n->missing_ok = false; n->objects = $3; n->behavior = $4; n->concurrent = false; @@ -6157,7 +6338,7 @@ DropStmt: DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); n->removeType = OBJECT_TYPE; - n->missing_ok = TRUE; + n->missing_ok = true; n->objects = $5; n->behavior = $6; n->concurrent = false; @@ -6167,7 +6348,7 @@ DropStmt: DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); n->removeType = OBJECT_DOMAIN; - n->missing_ok = FALSE; + n->missing_ok = false; n->objects = $3; n->behavior = $4; n->concurrent = false; @@ -6177,7 +6358,7 @@ DropStmt: DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); n->removeType = OBJECT_DOMAIN; - n->missing_ok = TRUE; + n->missing_ok = true; n->objects = $5; n->behavior = $6; n->concurrent = false; @@ -6187,7 +6368,7 @@ DropStmt: DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); n->removeType = OBJECT_INDEX; - n->missing_ok = FALSE; + n->missing_ok = false; n->objects = $4; n->behavior = $5; n->concurrent = true; @@ -6197,7 +6378,7 @@ DropStmt: DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); n->removeType = OBJECT_INDEX; - n->missing_ok = TRUE; + n->missing_ok = true; n->objects = $6; n->behavior = $7; n->concurrent = true; @@ -6399,6 +6580,22 @@ CommentStmt: n->comment = $8; $$ = (Node *) n; } + | COMMENT ON PROCEDURE function_with_argtypes IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_PROCEDURE; + n->object = (Node *) $4; + n->comment = $6; + $$ = (Node *) n; + } + | COMMENT ON ROUTINE function_with_argtypes IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_ROUTINE; + n->object = (Node *) $4; + n->comment = $6; + $$ = (Node *) n; + } | COMMENT ON RULE name ON any_name IS comment_text { CommentStmt *n = makeNode(CommentStmt); @@ -6577,6 +6774,26 @@ SecLabelStmt: n->label = $9; $$ = (Node *) n; } + | SECURITY LABEL opt_provider ON PROCEDURE function_with_argtypes + IS security_label + { + SecLabelStmt *n = makeNode(SecLabelStmt); + n->provider = $3; + n->objtype = OBJECT_PROCEDURE; + n->object = (Node *) $6; + n->label = $8; + $$ = (Node *) n; + } + | SECURITY LABEL opt_provider ON ROUTINE function_with_argtypes + IS security_label + { + SecLabelStmt *n = makeNode(SecLabelStmt); + n->provider = $3; + n->objtype = OBJECT_ROUTINE; + n->object = (Node *) $6; + n->label = $8; + $$ = (Node *) n; + } ; opt_provider: FOR NonReservedWord_or_Sconst { $$ = $2; } @@ -6619,13 +6836,13 @@ security_label: Sconst { $$ = $1; } FetchStmt: FETCH fetch_args { FetchStmt *n = (FetchStmt *) $2; - n->ismove = FALSE; + n->ismove = false; $$ = (Node *)n; } | MOVE fetch_args { FetchStmt *n = (FetchStmt *) $2; - n->ismove = TRUE; + n->ismove = true; $$ = (Node *)n; } ; @@ -6896,7 +7113,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_RELATION; + n->objtype = OBJECT_TABLE; n->objs = $1; $$ = n; } @@ -6904,7 +7121,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_RELATION; + n->objtype = OBJECT_TABLE; n->objs = $2; $$ = n; } @@ -6912,7 +7129,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_SEQUENCE; + n->objtype = OBJECT_SEQUENCE; n->objs = $2; $$ = n; } @@ -6920,7 +7137,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_FDW; + n->objtype = OBJECT_FDW; n->objs = $4; $$ = n; } @@ -6928,7 +7145,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_FOREIGN_SERVER; + n->objtype = OBJECT_FOREIGN_SERVER; n->objs = $3; $$ = n; } @@ -6936,7 +7153,23 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_FUNCTION; + n->objtype = OBJECT_FUNCTION; + n->objs = $2; + $$ = n; + } + | PROCEDURE function_with_argtypes_list + { + PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; + n->objtype = OBJECT_PROCEDURE; + n->objs = $2; + $$ = n; + } + | ROUTINE function_with_argtypes_list + { + PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; + n->objtype = OBJECT_ROUTINE; n->objs = $2; $$ = n; } @@ -6944,7 +7177,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_DATABASE; + n->objtype = OBJECT_DATABASE; n->objs = $2; $$ = n; } @@ -6952,7 +7185,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_DOMAIN; + n->objtype = OBJECT_DOMAIN; n->objs = $2; $$ = n; } @@ -6960,7 +7193,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_LANGUAGE; + n->objtype = OBJECT_LANGUAGE; n->objs = $2; $$ = n; } @@ -6968,7 +7201,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_LARGEOBJECT; + n->objtype = OBJECT_LARGEOBJECT; n->objs = $3; $$ = n; } @@ -6976,7 +7209,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_NAMESPACE; + n->objtype = OBJECT_SCHEMA; n->objs = $2; $$ = n; } @@ -6984,7 +7217,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_TABLESPACE; + n->objtype = OBJECT_TABLESPACE; n->objs = $2; $$ = n; } @@ -6992,7 +7225,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_TYPE; + n->objtype = OBJECT_TYPE; n->objs = $2; $$ = n; } @@ -7000,7 +7233,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_ALL_IN_SCHEMA; - n->objtype = ACL_OBJECT_RELATION; + n->objtype = OBJECT_TABLE; n->objs = $5; $$ = n; } @@ -7008,7 +7241,7 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_ALL_IN_SCHEMA; - n->objtype = ACL_OBJECT_SEQUENCE; + n->objtype = OBJECT_SEQUENCE; n->objs = $5; $$ = n; } @@ -7016,7 +7249,23 @@ privilege_target: { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); n->targtype = ACL_TARGET_ALL_IN_SCHEMA; - n->objtype = ACL_OBJECT_FUNCTION; + n->objtype = OBJECT_FUNCTION; + n->objs = $5; + $$ = n; + } + | ALL PROCEDURES IN_P SCHEMA name_list + { + PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_ALL_IN_SCHEMA; + n->objtype = OBJECT_PROCEDURE; + n->objs = $5; + $$ = n; + } + | ALL ROUTINES IN_P SCHEMA name_list + { + PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_ALL_IN_SCHEMA; + n->objtype = OBJECT_ROUTINE; n->objs = $5; $$ = n; } @@ -7035,8 +7284,8 @@ grantee: opt_grant_grant_option: - WITH GRANT OPTION { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } + WITH GRANT OPTION { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; /***************************************************************************** @@ -7081,8 +7330,8 @@ RevokeRoleStmt: } ; -opt_grant_admin_option: WITH ADMIN OPTION { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } +opt_grant_admin_option: WITH ADMIN OPTION { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; opt_granted_by: GRANTED BY RoleSpec { $$ = $3; } @@ -7174,11 +7423,12 @@ DefACLAction: ; defacl_privilege_target: - TABLES { $$ = ACL_OBJECT_RELATION; } - | FUNCTIONS { $$ = ACL_OBJECT_FUNCTION; } - | SEQUENCES { $$ = ACL_OBJECT_SEQUENCE; } - | TYPES_P { $$ = ACL_OBJECT_TYPE; } - | SCHEMAS { $$ = ACL_OBJECT_NAMESPACE; } + TABLES { $$ = OBJECT_TABLE; } + | FUNCTIONS { $$ = OBJECT_FUNCTION; } + | ROUTINES { $$ = OBJECT_FUNCTION; } + | SEQUENCES { $$ = OBJECT_SEQUENCE; } + | TYPES_P { $$ = OBJECT_TYPE; } + | SCHEMAS { $$ = OBJECT_SCHEMA; } ; @@ -7191,19 +7441,21 @@ defacl_privilege_target: *****************************************************************************/ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name - ON qualified_name access_method_clause '(' index_params ')' - opt_reloptions OptTableSpace where_clause + ON relation_expr access_method_clause '(' index_params ')' + opt_include opt_reloptions OptTableSpace where_clause { IndexStmt *n = makeNode(IndexStmt); n->unique = $2; n->concurrent = $4; n->idxname = $5; n->relation = $7; + n->relationId = InvalidOid; n->accessMethod = $8; n->indexParams = $10; - n->options = $12; - n->tableSpace = $13; - n->whereClause = $14; + n->indexIncludingParams = $12; + n->options = $13; + n->tableSpace = $14; + n->whereClause = $15; n->excludeOpNames = NIL; n->idxcomment = NULL; n->indexOid = InvalidOid; @@ -7217,19 +7469,21 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name $$ = (Node *)n; } | CREATE opt_unique INDEX opt_concurrently IF_P NOT EXISTS index_name - ON qualified_name access_method_clause '(' index_params ')' - opt_reloptions OptTableSpace where_clause + ON relation_expr access_method_clause '(' index_params ')' + opt_include opt_reloptions OptTableSpace where_clause { IndexStmt *n = makeNode(IndexStmt); n->unique = $2; n->concurrent = $4; n->idxname = $8; n->relation = $10; + n->relationId = InvalidOid; n->accessMethod = $11; n->indexParams = $13; - n->options = $15; - n->tableSpace = $16; - n->whereClause = $17; + n->indexIncludingParams = $15; + n->options = $16; + n->tableSpace = $17; + n->whereClause = $18; n->excludeOpNames = NIL; n->idxcomment = NULL; n->indexOid = InvalidOid; @@ -7245,13 +7499,13 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name ; opt_unique: - UNIQUE { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } + UNIQUE { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; opt_concurrently: - CONCURRENTLY { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } + CONCURRENTLY { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; opt_index_name: @@ -7308,6 +7562,14 @@ index_elem: ColId opt_collate opt_class opt_asc_desc opt_nulls_order } ; +opt_include: INCLUDE '(' index_including_params ')' { $$ = $3; } + | /* EMPTY */ { $$ = NIL; } + ; + +index_including_params: index_elem { $$ = list_make1($1); } + | index_including_params ',' index_elem { $$ = lappend($1, $3); } + ; + opt_collate: COLLATE any_name { $$ = $2; } | /*EMPTY*/ { $$ = NIL; } ; @@ -7340,47 +7602,59 @@ opt_nulls_order: NULLS_LA FIRST_P { $$ = SORTBY_NULLS_FIRST; } CreateFunctionStmt: CREATE opt_or_replace FUNCTION func_name func_args_with_defaults - RETURNS func_return createfunc_opt_list opt_definition + RETURNS func_return createfunc_opt_list { CreateFunctionStmt *n = makeNode(CreateFunctionStmt); + n->is_procedure = false; n->replace = $2; n->funcname = $4; n->parameters = $5; n->returnType = $7; n->options = $8; - n->withClause = $9; $$ = (Node *)n; } | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults - RETURNS TABLE '(' table_func_column_list ')' createfunc_opt_list opt_definition + RETURNS TABLE '(' table_func_column_list ')' createfunc_opt_list { CreateFunctionStmt *n = makeNode(CreateFunctionStmt); + n->is_procedure = false; n->replace = $2; n->funcname = $4; n->parameters = mergeTableFuncParameters($5, $9); n->returnType = TableFuncTypeName($9); n->returnType->location = @7; n->options = $11; - n->withClause = $12; $$ = (Node *)n; } | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults - createfunc_opt_list opt_definition + createfunc_opt_list + { + CreateFunctionStmt *n = makeNode(CreateFunctionStmt); + n->is_procedure = false; + n->replace = $2; + n->funcname = $4; + n->parameters = $5; + n->returnType = NULL; + n->options = $6; + $$ = (Node *)n; + } + | CREATE opt_or_replace PROCEDURE func_name func_args_with_defaults + createfunc_opt_list { CreateFunctionStmt *n = makeNode(CreateFunctionStmt); + n->is_procedure = true; n->replace = $2; n->funcname = $4; n->parameters = $5; n->returnType = NULL; n->options = $6; - n->withClause = $7; $$ = (Node *)n; } ; opt_or_replace: - OR REPLACE { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } + OR REPLACE { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; func_args: '(' func_args_list ')' { $$ = $2; } @@ -7549,7 +7823,7 @@ func_type: Typename { $$ = $1; } { $$ = makeTypeNameFromNameList(lcons(makeString($2), $3)); $$->pct_type = true; - $$->setof = TRUE; + $$->setof = true; $$->location = @2; } ; @@ -7665,15 +7939,15 @@ createfunc_opt_list: common_func_opt_item: CALLED ON NULL_P INPUT_P { - $$ = makeDefElem("strict", (Node *)makeInteger(FALSE), @1); + $$ = makeDefElem("strict", (Node *)makeInteger(false), @1); } | RETURNS NULL_P ON NULL_P INPUT_P { - $$ = makeDefElem("strict", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("strict", (Node *)makeInteger(true), @1); } | STRICT_P { - $$ = makeDefElem("strict", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("strict", (Node *)makeInteger(true), @1); } | IMMUTABLE { @@ -7689,27 +7963,27 @@ common_func_opt_item: } | EXTERNAL SECURITY DEFINER { - $$ = makeDefElem("security", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("security", (Node *)makeInteger(true), @1); } | EXTERNAL SECURITY INVOKER { - $$ = makeDefElem("security", (Node *)makeInteger(FALSE), @1); + $$ = makeDefElem("security", (Node *)makeInteger(false), @1); } | SECURITY DEFINER { - $$ = makeDefElem("security", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("security", (Node *)makeInteger(true), @1); } | SECURITY INVOKER { - $$ = makeDefElem("security", (Node *)makeInteger(FALSE), @1); + $$ = makeDefElem("security", (Node *)makeInteger(false), @1); } | LEAKPROOF { - $$ = makeDefElem("leakproof", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("leakproof", (Node *)makeInteger(true), @1); } | NOT LEAKPROOF { - $$ = makeDefElem("leakproof", (Node *)makeInteger(FALSE), @1); + $$ = makeDefElem("leakproof", (Node *)makeInteger(false), @1); } | COST NumericOnly { @@ -7745,7 +8019,7 @@ createfunc_opt_item: } | WINDOW { - $$ = makeDefElem("window", (Node *)makeInteger(TRUE), @1); + $$ = makeDefElem("window", (Node *)makeInteger(true), @1); } | common_func_opt_item { @@ -7793,7 +8067,7 @@ table_func_column_list: ; /***************************************************************************** - * ALTER FUNCTION + * ALTER FUNCTION / ALTER PROCEDURE / ALTER ROUTINE * * RENAME and OWNER subcommands are already provided by the generic * ALTER infrastructure, here we just specify alterations that can @@ -7804,6 +8078,23 @@ AlterFunctionStmt: ALTER FUNCTION function_with_argtypes alterfunc_opt_list opt_restrict { AlterFunctionStmt *n = makeNode(AlterFunctionStmt); + n->objtype = OBJECT_FUNCTION; + n->func = $3; + n->actions = $4; + $$ = (Node *) n; + } + | ALTER PROCEDURE function_with_argtypes alterfunc_opt_list opt_restrict + { + AlterFunctionStmt *n = makeNode(AlterFunctionStmt); + n->objtype = OBJECT_PROCEDURE; + n->func = $3; + n->actions = $4; + $$ = (Node *) n; + } + | ALTER ROUTINE function_with_argtypes alterfunc_opt_list opt_restrict + { + AlterFunctionStmt *n = makeNode(AlterFunctionStmt); + n->objtype = OBJECT_ROUTINE; n->func = $3; n->actions = $4; $$ = (Node *) n; @@ -7828,6 +8119,8 @@ opt_restrict: * QUERY: * * DROP FUNCTION funcname (arg1, arg2, ...) [ RESTRICT | CASCADE ] + * DROP PROCEDURE procname (arg1, arg2, ...) [ RESTRICT | CASCADE ] + * DROP ROUTINE routname (arg1, arg2, ...) [ RESTRICT | CASCADE ] * DROP AGGREGATE aggname (arg1, ...) [ RESTRICT | CASCADE ] * DROP OPERATOR opname (leftoperand_typ, rightoperand_typ) [ RESTRICT | CASCADE ] * @@ -7854,6 +8147,46 @@ RemoveFuncStmt: n->concurrent = false; $$ = (Node *)n; } + | DROP PROCEDURE function_with_argtypes_list opt_drop_behavior + { + DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_PROCEDURE; + n->objects = $3; + n->behavior = $4; + n->missing_ok = false; + n->concurrent = false; + $$ = (Node *)n; + } + | DROP PROCEDURE IF_P EXISTS function_with_argtypes_list opt_drop_behavior + { + DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_PROCEDURE; + n->objects = $5; + n->behavior = $6; + n->missing_ok = true; + n->concurrent = false; + $$ = (Node *)n; + } + | DROP ROUTINE function_with_argtypes_list opt_drop_behavior + { + DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_ROUTINE; + n->objects = $3; + n->behavior = $4; + n->missing_ok = false; + n->concurrent = false; + $$ = (Node *)n; + } + | DROP ROUTINE IF_P EXISTS function_with_argtypes_list opt_drop_behavior + { + DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_ROUTINE; + n->objects = $5; + n->behavior = $6; + n->missing_ok = true; + n->concurrent = false; + $$ = (Node *)n; + } ; RemoveAggrStmt: @@ -8034,8 +8367,8 @@ DropCastStmt: DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_beha } ; -opt_if_exists: IF_P EXISTS { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } +opt_if_exists: IF_P EXISTS { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; @@ -8163,7 +8496,7 @@ AlterTblSpcStmt: makeNode(AlterTableSpaceOptionsStmt); n->tablespacename = $3; n->options = $5; - n->isReset = FALSE; + n->isReset = false; $$ = (Node *)n; } | ALTER TABLESPACE name RESET reloptions @@ -8172,7 +8505,7 @@ AlterTblSpcStmt: makeNode(AlterTableSpaceOptionsStmt); n->tablespacename = $3; n->options = $5; - n->isReset = TRUE; + n->isReset = true; $$ = (Node *)n; } ; @@ -8311,6 +8644,15 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name n->missing_ok = true; $$ = (Node *)n; } + | ALTER PROCEDURE function_with_argtypes RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_PROCEDURE; + n->object = (Node *) $3; + n->newname = $6; + n->missing_ok = false; + $$ = (Node *)n; + } | ALTER PUBLICATION name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); @@ -8320,6 +8662,15 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name n->missing_ok = false; $$ = (Node *)n; } + | ALTER ROUTINE function_with_argtypes RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_ROUTINE; + n->object = (Node *) $3; + n->newname = $6; + n->missing_ok = false; + $$ = (Node *)n; + } | ALTER SCHEMA name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); @@ -8699,6 +9050,22 @@ AlterObjectDependsStmt: n->extname = makeString($7); $$ = (Node *)n; } + | ALTER PROCEDURE function_with_argtypes DEPENDS ON EXTENSION name + { + AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt); + n->objectType = OBJECT_PROCEDURE; + n->object = (Node *) $3; + n->extname = makeString($7); + $$ = (Node *)n; + } + | ALTER ROUTINE function_with_argtypes DEPENDS ON EXTENSION name + { + AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt); + n->objectType = OBJECT_ROUTINE; + n->object = (Node *) $3; + n->extname = makeString($7); + $$ = (Node *)n; + } | ALTER TRIGGER name ON qualified_name DEPENDS ON EXTENSION name { AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt); @@ -8814,6 +9181,24 @@ AlterObjectSchemaStmt: n->missing_ok = false; $$ = (Node *)n; } + | ALTER PROCEDURE function_with_argtypes SET SCHEMA name + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_PROCEDURE; + n->object = (Node *) $3; + n->newschema = $6; + n->missing_ok = false; + $$ = (Node *)n; + } + | ALTER ROUTINE function_with_argtypes SET SCHEMA name + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_ROUTINE; + n->object = (Node *) $3; + n->newschema = $6; + n->missing_ok = false; + $$ = (Node *)n; + } | ALTER TABLE relation_expr SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); @@ -9089,6 +9474,22 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec n->newowner = $9; $$ = (Node *)n; } + | ALTER PROCEDURE function_with_argtypes OWNER TO RoleSpec + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_PROCEDURE; + n->object = (Node *) $3; + n->newowner = $6; + $$ = (Node *)n; + } + | ALTER ROUTINE function_with_argtypes OWNER TO RoleSpec + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_ROUTINE; + n->object = (Node *) $3; + n->newowner = $6; + $$ = (Node *)n; + } | ALTER SCHEMA name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); @@ -9199,7 +9600,7 @@ CreatePublicationStmt: n->tables = (List *)$4; /* FOR ALL TABLES */ else - n->for_all_tables = TRUE; + n->for_all_tables = true; } $$ = (Node *)n; } @@ -9217,7 +9618,7 @@ publication_for_tables: } | FOR ALL TABLES { - $$ = (Node *) makeInteger(TRUE); + $$ = (Node *) makeInteger(true); } ; @@ -9352,7 +9753,7 @@ AlterSubscriptionStmt: n->kind = ALTER_SUBSCRIPTION_ENABLED; n->subname = $3; n->options = list_make1(makeDefElem("enabled", - (Node *)makeInteger(TRUE), @1)); + (Node *)makeInteger(true), @1)); $$ = (Node *)n; } | ALTER SUBSCRIPTION name DISABLE_P @@ -9362,7 +9763,7 @@ AlterSubscriptionStmt: n->kind = ALTER_SUBSCRIPTION_ENABLED; n->subname = $3; n->options = list_make1(makeDefElem("enabled", - (Node *)makeInteger(FALSE), @1)); + (Node *)makeInteger(false), @1)); $$ = (Node *)n; } ; @@ -9455,9 +9856,9 @@ event: SELECT { $$ = CMD_SELECT; } ; opt_instead: - INSTEAD { $$ = TRUE; } - | ALSO { $$ = FALSE; } - | /*EMPTY*/ { $$ = FALSE; } + INSTEAD { $$ = true; } + | ALSO { $$ = false; } + | /*EMPTY*/ { $$ = false; } ; @@ -9563,40 +9964,35 @@ TransactionStmt: { TransactionStmt *n = makeNode(TransactionStmt); n->kind = TRANS_STMT_SAVEPOINT; - n->options = list_make1(makeDefElem("savepoint_name", - (Node *)makeString($2), @1)); + n->savepoint_name = $2; $$ = (Node *)n; } | RELEASE SAVEPOINT ColId { TransactionStmt *n = makeNode(TransactionStmt); n->kind = TRANS_STMT_RELEASE; - n->options = list_make1(makeDefElem("savepoint_name", - (Node *)makeString($3), @1)); + n->savepoint_name = $3; $$ = (Node *)n; } | RELEASE ColId { TransactionStmt *n = makeNode(TransactionStmt); n->kind = TRANS_STMT_RELEASE; - n->options = list_make1(makeDefElem("savepoint_name", - (Node *)makeString($2), @1)); + n->savepoint_name = $2; $$ = (Node *)n; } | ROLLBACK opt_transaction TO SAVEPOINT ColId { TransactionStmt *n = makeNode(TransactionStmt); n->kind = TRANS_STMT_ROLLBACK_TO; - n->options = list_make1(makeDefElem("savepoint_name", - (Node *)makeString($5), @1)); + n->savepoint_name = $5; $$ = (Node *)n; } | ROLLBACK opt_transaction TO ColId { TransactionStmt *n = makeNode(TransactionStmt); n->kind = TRANS_STMT_ROLLBACK_TO; - n->options = list_make1(makeDefElem("savepoint_name", - (Node *)makeString($4), @1)); + n->savepoint_name = $4; $$ = (Node *)n; } | PREPARE TRANSACTION Sconst @@ -9633,16 +10029,16 @@ transaction_mode_item: makeStringConst($3, @3), @1); } | READ ONLY { $$ = makeDefElem("transaction_read_only", - makeIntConst(TRUE, @1), @1); } + makeIntConst(true, @1), @1); } | READ WRITE { $$ = makeDefElem("transaction_read_only", - makeIntConst(FALSE, @1), @1); } + makeIntConst(false, @1), @1); } | DEFERRABLE { $$ = makeDefElem("transaction_deferrable", - makeIntConst(TRUE, @1), @1); } + makeIntConst(true, @1), @1); } | NOT DEFERRABLE { $$ = makeDefElem("transaction_deferrable", - makeIntConst(FALSE, @1), @1); } + makeIntConst(false, @1), @1); } ; /* Syntax with commas is SQL-spec, without commas is Postgres historical */ @@ -9881,14 +10277,14 @@ DropdbStmt: DROP DATABASE database_name { DropdbStmt *n = makeNode(DropdbStmt); n->dbname = $3; - n->missing_ok = FALSE; + n->missing_ok = false; $$ = (Node *)n; } | DROP DATABASE IF_P EXISTS database_name { DropdbStmt *n = makeNode(DropdbStmt); n->dbname = $5; - n->missing_ok = TRUE; + n->missing_ok = true; $$ = (Node *)n; } ; @@ -10184,21 +10580,7 @@ cluster_index_specification: * *****************************************************************************/ -VacuumStmt: VACUUM opt_full opt_freeze opt_verbose - { - VacuumStmt *n = makeNode(VacuumStmt); - n->options = VACOPT_VACUUM; - if ($2) - n->options |= VACOPT_FULL; - if ($3) - n->options |= VACOPT_FREEZE; - if ($4) - n->options |= VACOPT_VERBOSE; - n->relation = NULL; - n->va_cols = NIL; - $$ = (Node *)n; - } - | VACUUM opt_full opt_freeze opt_verbose qualified_name +VacuumStmt: VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); n->options = VACOPT_VACUUM; @@ -10208,38 +10590,16 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose n->options |= VACOPT_FREEZE; if ($4) n->options |= VACOPT_VERBOSE; - n->relation = $5; - n->va_cols = NIL; - $$ = (Node *)n; - } - | VACUUM opt_full opt_freeze opt_verbose AnalyzeStmt - { - VacuumStmt *n = (VacuumStmt *) $5; - n->options |= VACOPT_VACUUM; - if ($2) - n->options |= VACOPT_FULL; - if ($3) - n->options |= VACOPT_FREEZE; - if ($4) - n->options |= VACOPT_VERBOSE; + if ($5) + n->options |= VACOPT_ANALYZE; + n->rels = $6; $$ = (Node *)n; } - | VACUUM '(' vacuum_option_list ')' + | VACUUM '(' vacuum_option_list ')' opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); n->options = VACOPT_VACUUM | $3; - n->relation = NULL; - n->va_cols = NIL; - $$ = (Node *) n; - } - | VACUUM '(' vacuum_option_list ')' qualified_name opt_name_list - { - VacuumStmt *n = makeNode(VacuumStmt); - n->options = VACOPT_VACUUM | $3; - n->relation = $5; - n->va_cols = $6; - if (n->va_cols != NIL) /* implies analyze */ - n->options |= VACOPT_ANALYZE; + n->rels = $5; $$ = (Node *) n; } ; @@ -10266,45 +10626,54 @@ vacuum_option_elem: } ; -AnalyzeStmt: - analyze_keyword opt_verbose +AnalyzeStmt: analyze_keyword opt_verbose opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); n->options = VACOPT_ANALYZE; if ($2) n->options |= VACOPT_VERBOSE; - n->relation = NULL; - n->va_cols = NIL; + n->rels = $3; $$ = (Node *)n; } - | analyze_keyword opt_verbose qualified_name opt_name_list + | analyze_keyword '(' analyze_option_list ')' opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); - n->options = VACOPT_ANALYZE; - if ($2) - n->options |= VACOPT_VERBOSE; - n->relation = $3; - n->va_cols = $4; - $$ = (Node *)n; + n->options = VACOPT_ANALYZE | $3; + n->rels = $5; + $$ = (Node *) n; } ; +analyze_option_list: + analyze_option_elem { $$ = $1; } + | analyze_option_list ',' analyze_option_elem { $$ = $1 | $3; } + ; + +analyze_option_elem: + VERBOSE { $$ = VACOPT_VERBOSE; } + ; + analyze_keyword: ANALYZE {} | ANALYSE /* British */ {} ; +opt_analyze: + analyze_keyword { $$ = true; } + | /*EMPTY*/ { $$ = false; } + ; + opt_verbose: - VERBOSE { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } + VERBOSE { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; -opt_full: FULL { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } +opt_full: FULL { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; -opt_freeze: FREEZE { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } +opt_freeze: FREEZE { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; opt_name_list: @@ -10312,6 +10681,25 @@ opt_name_list: | /*EMPTY*/ { $$ = NIL; } ; +vacuum_relation: + qualified_name opt_name_list + { + $$ = (Node *) makeVacuumRelation($1, InvalidOid, $2); + } + ; + +vacuum_relation_list: + vacuum_relation + { $$ = list_make1($1); } + | vacuum_relation_list ',' vacuum_relation + { $$ = lappend($1, $3); } + ; + +opt_vacuum_relation_list: + vacuum_relation_list { $$ = $1; } + | /*EMPTY*/ { $$ = NIL; } + ; + /***************************************************************************** * @@ -10702,8 +11090,8 @@ lock_type: ACCESS SHARE { $$ = AccessShareLock; } | ACCESS EXCLUSIVE { $$ = AccessExclusiveLock; } ; -opt_nowait: NOWAIT { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } +opt_nowait: NOWAIT { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; opt_nowait_or_skip: @@ -11170,9 +11558,9 @@ opt_table: TABLE {} ; all_or_distinct: - ALL { $$ = TRUE; } - | DISTINCT { $$ = FALSE; } - | /*EMPTY*/ { $$ = FALSE; } + ALL { $$ = true; } + | DISTINCT { $$ = false; } + | /*EMPTY*/ { $$ = false; } ; /* We use (NIL) as a placeholder to indicate that all target expressions @@ -11248,15 +11636,23 @@ limit_clause: parser_errposition(@1))); } /* SQL:2008 syntax */ - | FETCH first_or_next opt_select_fetch_first_value row_or_rows ONLY + /* to avoid shift/reduce conflicts, handle the optional value with + * a separate production rather than an opt_ expression. The fact + * that ONLY is fully reserved means that this way, we defer any + * decision about what rule reduces ROW or ROWS to the point where + * we can see the ONLY token in the lookahead slot. + */ + | FETCH first_or_next select_fetch_first_value row_or_rows ONLY { $$ = $3; } + | FETCH first_or_next row_or_rows ONLY + { $$ = makeIntConst(1, -1); } ; offset_clause: OFFSET select_offset_value { $$ = $2; } /* SQL:2008 syntax */ - | OFFSET select_offset_value2 row_or_rows + | OFFSET select_fetch_first_value row_or_rows { $$ = $2; } ; @@ -11275,22 +11671,31 @@ select_offset_value: /* * Allowing full expressions without parentheses causes various parsing - * problems with the trailing ROW/ROWS key words. SQL only calls for - * constants, so we allow the rest only with parentheses. If omitted, - * default to 1. + * problems with the trailing ROW/ROWS key words. SQL spec only calls for + * , which is either a literal or a parameter (but + * an could be an identifier, bringing up conflicts + * with ROW/ROWS). We solve this by leveraging the presence of ONLY (see above) + * to determine whether the expression is missing rather than trying to make it + * optional in this rule. + * + * c_expr covers almost all the spec-required cases (and more), but it doesn't + * cover signed numeric literals, which are allowed by the spec. So we include + * those here explicitly. We need FCONST as well as ICONST because values that + * don't fit in the platform's "long", but do fit in bigint, should still be + * accepted here. (This is possible in 64-bit Windows as well as all 32-bit + * builds.) */ -opt_select_fetch_first_value: - SignedIconst { $$ = makeIntConst($1, @1); } - | '(' a_expr ')' { $$ = $2; } - | /*EMPTY*/ { $$ = makeIntConst(1, -1); } +select_fetch_first_value: + c_expr { $$ = $1; } + | '+' I_or_F_const + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", NULL, $2, @1); } + | '-' I_or_F_const + { $$ = doNegate($2, @1); } ; -/* - * Again, the trailing ROW/ROWS in this case prevent the full expression - * syntax. c_expr is the best we can do. - */ -select_offset_value2: - c_expr { $$ = $1; } +I_or_F_const: + Iconst { $$ = makeIntConst($1,@1); } + | FCONST { $$ = makeFloatConst($1,@1); } ; /* noise words */ @@ -11601,7 +12006,7 @@ joined_table: /* CROSS JOIN is same as unqualified inner join */ JoinExpr *n = makeNode(JoinExpr); n->jointype = JOIN_INNER; - n->isNatural = FALSE; + n->isNatural = false; n->larg = $1; n->rarg = $4; n->usingClause = NIL; @@ -11612,7 +12017,7 @@ joined_table: { JoinExpr *n = makeNode(JoinExpr); n->jointype = $2; - n->isNatural = FALSE; + n->isNatural = false; n->larg = $1; n->rarg = $4; if ($5 != NULL && IsA($5, List)) @@ -11626,7 +12031,7 @@ joined_table: /* letting join_type reduce to empty doesn't work */ JoinExpr *n = makeNode(JoinExpr); n->jointype = JOIN_INNER; - n->isNatural = FALSE; + n->isNatural = false; n->larg = $1; n->rarg = $3; if ($4 != NULL && IsA($4, List)) @@ -11639,7 +12044,7 @@ joined_table: { JoinExpr *n = makeNode(JoinExpr); n->jointype = $3; - n->isNatural = TRUE; + n->isNatural = true; n->larg = $1; n->rarg = $5; n->usingClause = NIL; /* figure out which columns later... */ @@ -11651,7 +12056,7 @@ joined_table: /* letting join_type reduce to empty doesn't work */ JoinExpr *n = makeNode(JoinExpr); n->jointype = JOIN_INNER; - n->isNatural = TRUE; + n->isNatural = true; n->larg = $1; n->rarg = $4; n->usingClause = NIL; /* figure out which columns later... */ @@ -12121,7 +12526,7 @@ Typename: SimpleTypename opt_array_bounds { $$ = $2; $$->arrayBounds = $3; - $$->setof = TRUE; + $$->setof = true; } /* SQL standard syntax, currently only one-dimensional */ | SimpleTypename ARRAY '[' Iconst ']' @@ -12133,7 +12538,7 @@ Typename: SimpleTypename opt_array_bounds { $$ = $2; $$->arrayBounds = list_make1(makeInteger($5)); - $$->setof = TRUE; + $$->setof = true; } | SimpleTypename ARRAY { @@ -12144,7 +12549,7 @@ Typename: SimpleTypename opt_array_bounds { $$ = $2; $$->arrayBounds = list_make1(makeInteger(-1)); - $$->setof = TRUE; + $$->setof = true; } ; @@ -12431,8 +12836,8 @@ character: CHARACTER opt_varying ; opt_varying: - VARYING { $$ = TRUE; } - | /*EMPTY*/ { $$ = FALSE; } + VARYING { $$ = true; } + | /*EMPTY*/ { $$ = false; } ; /* @@ -12484,9 +12889,9 @@ ConstInterval: ; opt_timezone: - WITH_LA TIME ZONE { $$ = TRUE; } - | WITHOUT TIME ZONE { $$ = FALSE; } - | /*EMPTY*/ { $$ = FALSE; } + WITH_LA TIME ZONE { $$ = true; } + | WITHOUT TIME ZONE { $$ = false; } + | /*EMPTY*/ { $$ = false; } ; opt_interval: @@ -13247,14 +13652,14 @@ func_application: func_name '(' ')' | func_name '(' VARIADIC func_arg_expr opt_sort_clause ')' { FuncCall *n = makeFuncCall($1, list_make1($4), @1); - n->func_variadic = TRUE; + n->func_variadic = true; n->agg_order = $5; $$ = (Node *)n; } | func_name '(' func_arg_list ',' VARIADIC func_arg_expr opt_sort_clause ')' { FuncCall *n = makeFuncCall($1, lappend($3, $6), @1); - n->func_variadic = TRUE; + n->func_variadic = true; n->agg_order = $7; $$ = (Node *)n; } @@ -13272,7 +13677,7 @@ func_application: func_name '(' ')' { FuncCall *n = makeFuncCall($1, $4, @1); n->agg_order = $5; - n->agg_distinct = TRUE; + n->agg_distinct = true; $$ = (Node *)n; } | func_name '(' '*' ')' @@ -13288,7 +13693,7 @@ func_application: func_name '(' ')' * really was. */ FuncCall *n = makeFuncCall($1, NIL, @1); - n->agg_star = TRUE; + n->agg_star = true; $$ = (Node *)n; } ; @@ -13332,7 +13737,7 @@ func_expr: func_application within_group_clause filter_clause over_clause errmsg("cannot use VARIADIC with WITHIN GROUP"), parser_errposition(@2))); n->agg_order = $2; - n->agg_within_group = TRUE; + n->agg_within_group = true; } n->agg_filter = $3; n->over = $4; @@ -13622,9 +14027,9 @@ document_or_content: DOCUMENT_P { $$ = XMLOPTION_DOCUMENT; } | CONTENT_P { $$ = XMLOPTION_CONTENT; } ; -xml_whitespace_option: PRESERVE WHITESPACE_P { $$ = TRUE; } - | STRIP_P WHITESPACE_P { $$ = FALSE; } - | /*EMPTY*/ { $$ = FALSE; } +xml_whitespace_option: PRESERVE WHITESPACE_P { $$ = true; } + | STRIP_P WHITESPACE_P { $$ = false; } + | /*EMPTY*/ { $$ = false; } ; /* We allow several variants for SQL and other compatibility. */ @@ -13722,7 +14127,7 @@ window_specification: '(' opt_existing_window_name opt_partition_clause ; /* - * If we see PARTITION, RANGE, or ROWS as the first token after the '(' + * If we see PARTITION, RANGE, ROWS or GROUPS as the first token after the '(' * of a window_specification, we want the assumption to be that there is * no existing_window_name; but those keywords are unreserved and so could * be ColIds. We fix this by making them have the same precedence as IDENT @@ -13742,33 +14147,27 @@ opt_partition_clause: PARTITION BY expr_list { $$ = $3; } /* * For frame clauses, we return a WindowDef, but only some fields are used: * frameOptions, startOffset, and endOffset. - * - * This is only a subset of the full SQL:2008 frame_clause grammar. - * We don't support yet. */ opt_frame_clause: - RANGE frame_extent + RANGE frame_extent opt_window_exclusion_clause { WindowDef *n = $2; n->frameOptions |= FRAMEOPTION_NONDEFAULT | FRAMEOPTION_RANGE; - if (n->frameOptions & (FRAMEOPTION_START_VALUE_PRECEDING | - FRAMEOPTION_END_VALUE_PRECEDING)) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("RANGE PRECEDING is only supported with UNBOUNDED"), - parser_errposition(@1))); - if (n->frameOptions & (FRAMEOPTION_START_VALUE_FOLLOWING | - FRAMEOPTION_END_VALUE_FOLLOWING)) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("RANGE FOLLOWING is only supported with UNBOUNDED"), - parser_errposition(@1))); + n->frameOptions |= $3; $$ = n; } - | ROWS frame_extent + | ROWS frame_extent opt_window_exclusion_clause { WindowDef *n = $2; n->frameOptions |= FRAMEOPTION_NONDEFAULT | FRAMEOPTION_ROWS; + n->frameOptions |= $3; + $$ = n; + } + | GROUPS frame_extent opt_window_exclusion_clause + { + WindowDef *n = $2; + n->frameOptions |= FRAMEOPTION_NONDEFAULT | FRAMEOPTION_GROUPS; + n->frameOptions |= $3; $$ = n; } | /*EMPTY*/ @@ -13790,7 +14189,7 @@ frame_extent: frame_bound (errcode(ERRCODE_WINDOWING_ERROR), errmsg("frame start cannot be UNBOUNDED FOLLOWING"), parser_errposition(@1))); - if (n->frameOptions & FRAMEOPTION_START_VALUE_FOLLOWING) + if (n->frameOptions & FRAMEOPTION_START_OFFSET_FOLLOWING) ereport(ERROR, (errcode(ERRCODE_WINDOWING_ERROR), errmsg("frame starting from following row cannot end with current row"), @@ -13819,13 +14218,13 @@ frame_extent: frame_bound errmsg("frame end cannot be UNBOUNDED PRECEDING"), parser_errposition(@4))); if ((frameOptions & FRAMEOPTION_START_CURRENT_ROW) && - (frameOptions & FRAMEOPTION_END_VALUE_PRECEDING)) + (frameOptions & FRAMEOPTION_END_OFFSET_PRECEDING)) ereport(ERROR, (errcode(ERRCODE_WINDOWING_ERROR), errmsg("frame starting from current row cannot have preceding rows"), parser_errposition(@4))); - if ((frameOptions & FRAMEOPTION_START_VALUE_FOLLOWING) && - (frameOptions & (FRAMEOPTION_END_VALUE_PRECEDING | + if ((frameOptions & FRAMEOPTION_START_OFFSET_FOLLOWING) && + (frameOptions & (FRAMEOPTION_END_OFFSET_PRECEDING | FRAMEOPTION_END_CURRENT_ROW))) ereport(ERROR, (errcode(ERRCODE_WINDOWING_ERROR), @@ -13870,7 +14269,7 @@ frame_bound: | a_expr PRECEDING { WindowDef *n = makeNode(WindowDef); - n->frameOptions = FRAMEOPTION_START_VALUE_PRECEDING; + n->frameOptions = FRAMEOPTION_START_OFFSET_PRECEDING; n->startOffset = $1; n->endOffset = NULL; $$ = n; @@ -13878,13 +14277,21 @@ frame_bound: | a_expr FOLLOWING { WindowDef *n = makeNode(WindowDef); - n->frameOptions = FRAMEOPTION_START_VALUE_FOLLOWING; + n->frameOptions = FRAMEOPTION_START_OFFSET_FOLLOWING; n->startOffset = $1; n->endOffset = NULL; $$ = n; } ; +opt_window_exclusion_clause: + EXCLUDE CURRENT_P ROW { $$ = FRAMEOPTION_EXCLUDE_CURRENT_ROW; } + | EXCLUDE GROUP_P { $$ = FRAMEOPTION_EXCLUDE_GROUP; } + | EXCLUDE TIES { $$ = FRAMEOPTION_EXCLUDE_TIES; } + | EXCLUDE NO OTHERS { $$ = 0; } + | /*EMPTY*/ { $$ = 0; } + ; + /* * Supporting nonterminals for expressions. @@ -14496,11 +14903,11 @@ AexprConst: Iconst } | TRUE_P { - $$ = makeBoolAConst(TRUE, @1); + $$ = makeBoolAConst(true, @1); } | FALSE_P { - $$ = makeBoolAConst(FALSE, @1); + $$ = makeBoolAConst(false, @1); } | NULL_P { @@ -14531,18 +14938,21 @@ RoleId: RoleSpec errmsg("role name \"%s\" is reserved", "public"), parser_errposition(@1))); + break; case ROLESPEC_SESSION_USER: ereport(ERROR, (errcode(ERRCODE_RESERVED_NAME), errmsg("%s cannot be used as a role name here", "SESSION_USER"), parser_errposition(@1))); + break; case ROLESPEC_CURRENT_USER: ereport(ERROR, (errcode(ERRCODE_RESERVED_NAME), errmsg("%s cannot be used as a role name here", "CURRENT_USER"), parser_errposition(@1))); + break; } } ; @@ -14671,6 +15081,7 @@ unreserved_keyword: | BEGIN_P | BY | CACHE + | CALL | CALLED | CASCADE | CASCADED @@ -14745,6 +15156,7 @@ unreserved_keyword: | GENERATED | GLOBAL | GRANTED + | GROUPS | HANDLER | HEADER_P | HOLD @@ -14755,6 +15167,7 @@ unreserved_keyword: | IMMUTABLE | IMPLICIT_P | IMPORT_P + | INCLUDE | INCLUDING | INCREMENT | INDEX @@ -14810,6 +15223,7 @@ unreserved_keyword: | OPTION | OPTIONS | ORDINALITY + | OTHERS | OVER | OVERRIDING | OWNED @@ -14830,6 +15244,7 @@ unreserved_keyword: | PRIVILEGES | PROCEDURAL | PROCEDURE + | PROCEDURES | PROGRAM | PUBLICATION | QUOTE @@ -14856,6 +15271,8 @@ unreserved_keyword: | ROLE | ROLLBACK | ROLLUP + | ROUTINE + | ROUTINES | ROWS | RULE | SAVEPOINT @@ -14897,6 +15314,7 @@ unreserved_keyword: | TEMPLATE | TEMPORARY | TEXT_P + | TIES | TRANSACTION | TRANSFORM | TRIGGER diff --git a/src/parser/keywords.c b/src/parser/keywords.c index 59e6b2a..9fded54 100644 --- a/src/parser/keywords.c +++ b/src/parser/keywords.c @@ -4,8 +4,8 @@ * lexical token lookup for key words in PostgreSQL * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * diff --git a/src/parser/list.c b/src/parser/list.c index c13d9cc..9c1e71c 100644 --- a/src/parser/list.c +++ b/src/parser/list.c @@ -4,8 +4,8 @@ * implementation for PostgreSQL generic linked list package * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * @@ -1266,6 +1266,68 @@ list_copy_tail(const List *oldlist, int nskip) } /* + * Sort a list as though by qsort. + * + * A new list is built and returned. Like list_copy, this doesn't make + * fresh copies of any pointed-to data. + * + * The comparator function receives arguments of type ListCell **. + */ +List * +list_qsort(const List *list, list_qsort_comparator cmp) +{ + int len = list_length(list); + ListCell **list_arr; + List *newlist; + ListCell *newlist_prev; + ListCell *cell; + int i; + + /* Empty list is easy */ + if (len == 0) + return NIL; + + /* Flatten list cells into an array, so we can use qsort */ + list_arr = (ListCell **) palloc(sizeof(ListCell *) * len); + i = 0; + foreach(cell, list) + list_arr[i++] = cell; + + qsort(list_arr, len, sizeof(ListCell *), cmp); + + /* Construct new list (this code is much like list_copy) */ + newlist = new_list(list->type); + newlist->length = len; + + /* + * Copy over the data in the first cell; new_list() has already allocated + * the head cell itself + */ + newlist->head->data = list_arr[0]->data; + + newlist_prev = newlist->head; + for (i = 1; i < len; i++) + { + ListCell *newlist_cur; + + newlist_cur = (ListCell *) palloc(sizeof(*newlist_cur)); + newlist_cur->data = list_arr[i]->data; + newlist_prev->next = newlist_cur; + + newlist_prev = newlist_cur; + } + + newlist_prev->next = NULL; + newlist->tail = newlist_prev; + + /* Might as well free the workspace array */ + pfree(list_arr); + + check_list_invariants(newlist); + return newlist; +} + +/* * Temporary compatibility functions * * In order to avoid warnings for these function definitions, we need diff --git a/src/parser/makefuncs.c b/src/parser/makefuncs.c index f8ce360..e73ad05 100644 --- a/src/parser/makefuncs.c +++ b/src/parser/makefuncs.c @@ -4,8 +4,8 @@ * creator functions for primitive nodes. The functions here are for * the most frequently created nodes. * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * @@ -121,8 +121,10 @@ makeVarFromTargetEntry(Index varno, * table entry, and varattno == 0 to signal that it references the whole * tuple. (Use of zero here is unclean, since it could easily be confused * with error cases, but it's not worth changing now.) The vartype indicates - * a rowtype; either a named composite type, or RECORD. This function - * encapsulates the logic for determining the correct rowtype OID to use. + * a rowtype; either a named composite type, or a domain over a named + * composite type (only possible if the RTE is a function returning that), + * or RECORD. This function encapsulates the logic for determining the + * correct rowtype OID to use. * * If allowScalar is true, then for the case where the RTE is a single function * returning a non-composite result type, we produce a normal Var referencing @@ -609,3 +611,18 @@ makeGroupingSet(GroupingSetKind kind, List *content, int location) n->location = location; return n; } + +/* + * makeVacuumRelation - + * create a VacuumRelation node + */ +VacuumRelation * +makeVacuumRelation(RangeVar *relation, Oid oid, List *va_cols) +{ + VacuumRelation *v = makeNode(VacuumRelation); + + v->relation = relation; + v->oid = oid; + v->va_cols = va_cols; + return v; +} diff --git a/src/parser/nodes.c b/src/parser/nodes.c index 62f15f7..c682d0f 100644 --- a/src/parser/nodes.c +++ b/src/parser/nodes.c @@ -4,8 +4,8 @@ * support code for nodes (now that we have removed the home-brew * inheritance system, our support code for nodes is much simpler) * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * diff --git a/src/parser/outfuncs.c b/src/parser/outfuncs.c index 7e22703..e47a1d9 100644 --- a/src/parser/outfuncs.c +++ b/src/parser/outfuncs.c @@ -3,8 +3,8 @@ * outfuncs.c * Output functions for Postgres tree nodes. * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * @@ -1737,7 +1737,7 @@ _outValue(String * str, Value *value) switch (value->type) { case T_Integer: - sprintf(buf, "%ld", value->val.ival); + sprintf(buf, "%d", value->val.ival); string_append_char(str, buf); break; @@ -1813,7 +1813,7 @@ _outAConst(String * str, A_Const *node) switch (node->val.type) { case T_Integer: - sprintf(buf, "%ld", node->val.val.ival); + sprintf(buf, "%d", node->val.val.ival); string_append_char(str, buf); break; @@ -1973,13 +1973,13 @@ _outWindowDef(String * str, WindowDef *node) string_append_char(str, " UNBOUNDED FOLLOWING"); else if (node->frameOptions & FRAMEOPTION_START_CURRENT_ROW) string_append_char(str, " UNBOUNDED CURRENT ROW"); - else if (node->frameOptions & FRAMEOPTION_START_VALUE_PRECEDING) + else if (node->frameOptions & FRAMEOPTION_START_OFFSET_PRECEDING) { string_append_char(str, " "); _outNode(str, node->startOffset); string_append_char(str, " PRECEDING"); } - else if (node->frameOptions & FRAMEOPTION_START_VALUE_FOLLOWING) + else if (node->frameOptions & FRAMEOPTION_START_OFFSET_FOLLOWING) { string_append_char(str, " "); _outNode(str, node->startOffset); @@ -1995,13 +1995,13 @@ _outWindowDef(String * str, WindowDef *node) string_append_char(str, " UNBOUNDED FOLLOWING"); else if (node->frameOptions & FRAMEOPTION_END_CURRENT_ROW) string_append_char(str, " UNBOUNDED CURRENT ROW"); - else if (node->frameOptions & FRAMEOPTION_END_VALUE_PRECEDING) + else if (node->frameOptions & FRAMEOPTION_END_OFFSET_PRECEDING) { string_append_char(str, " "); _outNode(str, node->endOffset); string_append_char(str, " PRECEDING"); } - else if (node->frameOptions & FRAMEOPTION_END_VALUE_FOLLOWING) + else if (node->frameOptions & FRAMEOPTION_END_OFFSET_FOLLOWING) { string_append_char(str, " "); _outNode(str, node->endOffset); @@ -2489,13 +2489,21 @@ _outVacuumStmt(String * str, VacuumStmt *node) if (node->options & VACOPT_VACUUM && node->options & VACOPT_ANALYZE) string_append_char(str, "ANALYZE "); - _outNode(str, node->relation); - if (node->va_cols) + /* XXXXXXXX */ + ListCell *lc; + foreach(lc, node->rels) { - string_append_char(str, "("); - _outIdList(str, node->va_cols); - string_append_char(str, ") "); + VacuumRelation *vrel = lfirst_node(VacuumRelation, lc); + + _outNode(str, vrel->relation); + if (vrel->va_cols) + { + string_append_char(str, "("); + _outIdList(str, vrel->va_cols); + string_append_char(str, ") "); + } } + /* XXXXXXXX */ } static void @@ -2973,7 +2981,7 @@ _outOptRoleList(String * str, List *options) char buf[16]; string_append_char(str, " CONNECTION LIMIT "); - snprintf(buf, 16, "%ld", value->val.ival); + snprintf(buf, 16, "%d", value->val.ival); string_append_char(str, buf); } else if (strcmp(elem->defname, "validUntil") == 0) @@ -2992,7 +3000,7 @@ _outOptRoleList(String * str, List *options) char buf[16]; string_append_char(str, " SYSID "); - snprintf(buf, 16, "%ld", value->val.ival); + snprintf(buf, 16, "%d", value->val.ival); string_append_char(str, buf); } else if (strcmp(elem->defname, "adminmembers") == 0) @@ -3281,7 +3289,7 @@ _outAlterTableCmd(String * str, AlterTableCmd *node) string_append_char(str, "ALTER \""); string_append_char(str, node->name); string_append_char(str, "\" SET STATISTICS "); - snprintf(buf, 16, "%ld", ((Value *) node->def)->val.ival); + snprintf(buf, 16, "%d", ((Value *) node->def)->val.ival); string_append_char(str, buf); break; @@ -3474,7 +3482,7 @@ _outOptSeqList(String * str, List *options) string_append_char(str, v->val.str); else { - snprintf(buf, 16, "%ld", v->val.ival); + snprintf(buf, 16, "%d", v->val.ival); string_append_char(str, buf); } } @@ -4195,54 +4203,91 @@ _outGrantStmt(String * str, GrantStmt *node) switch (node->objtype) { - case ACL_OBJECT_RELATION: + case OBJECT_TABLE: _outNode(str, node->objects); break; - case ACL_OBJECT_SEQUENCE: + case OBJECT_SEQUENCE: string_append_char(str, "SEQUENCE "); _outNode(str, node->objects); break; - case ACL_OBJECT_FUNCTION: + case OBJECT_FUNCTION: string_append_char(str, "FUNCTION "); _outNode(str, node->objects); break; - case ACL_OBJECT_DATABASE: + case OBJECT_DATABASE: string_append_char(str, "DATABASE "); _outIdList(str, node->objects); break; - case ACL_OBJECT_LANGUAGE: + case OBJECT_LANGUAGE: string_append_char(str, "LANGUAGE "); _outIdList(str, node->objects); break; - case ACL_OBJECT_NAMESPACE: + case OBJECT_SCHEMA: string_append_char(str, "SCHEMA "); _outIdList(str, node->objects); break; - case ACL_OBJECT_TABLESPACE: + case OBJECT_TABLESPACE: string_append_char(str, "TABLESPACE "); _outIdList(str, node->objects); break; - case ACL_OBJECT_FDW: + case OBJECT_FDW: string_append_char(str, "FOREIGN DATA WRAPPER "); _outIdList(str, node->objects); break; - case ACL_OBJECT_FOREIGN_SERVER: + case OBJECT_FOREIGN_SERVER: string_append_char(str, "FOREIGN SERVER "); _outIdList(str, node->objects); break; - case ACL_OBJECT_COLUMN: - case ACL_OBJECT_DOMAIN: - case ACL_OBJECT_LARGEOBJECT: - case ACL_OBJECT_TYPE: + case OBJECT_COLUMN: + case OBJECT_DOMAIN: + case OBJECT_LARGEOBJECT: + case OBJECT_TYPE: + case OBJECT_ACCESS_METHOD: + case OBJECT_AGGREGATE: + case OBJECT_AMOP: + case OBJECT_AMPROC: + case OBJECT_ATTRIBUTE: + case OBJECT_CAST: + case OBJECT_COLLATION: + case OBJECT_CONVERSION: + case OBJECT_DEFAULT: + case OBJECT_DEFACL: + case OBJECT_DOMCONSTRAINT: + case OBJECT_EVENT_TRIGGER: + case OBJECT_EXTENSION: + case OBJECT_FOREIGN_TABLE: + case OBJECT_INDEX: + case OBJECT_MATVIEW: + case OBJECT_OPCLASS: + case OBJECT_OPERATOR: + case OBJECT_OPFAMILY: + case OBJECT_POLICY: + case OBJECT_PROCEDURE: + case OBJECT_PUBLICATION: + case OBJECT_PUBLICATION_REL: + case OBJECT_ROLE: + case OBJECT_ROUTINE: + case OBJECT_RULE: + case OBJECT_SUBSCRIPTION: + case OBJECT_STATISTIC_EXT: + case OBJECT_TABCONSTRAINT: + case OBJECT_TRANSFORM: + case OBJECT_TRIGGER: + case OBJECT_TSCONFIGURATION: + case OBJECT_TSDICTIONARY: + case OBJECT_TSPARSER: + case OBJECT_TSTEMPLATE: + case OBJECT_USER_MAPPING: + case OBJECT_VIEW: break; } @@ -4361,12 +4406,6 @@ _outCreateFunctionStmt(String * str, CreateFunctionStmt *node) } _outFuncOptList(str, node->options); - - if (node->withClause) - { - string_append_char(str, " WITH "); - _outDefinition(str, node->withClause); - } } static void @@ -4803,7 +4842,7 @@ _outCreatedbOptList(String * str, List *options) { char buf[16]; - snprintf(buf, 16, "%ld", v->val.ival); + snprintf(buf, 16, "%d", v->val.ival); string_append_char(str, buf); } } @@ -5108,7 +5147,7 @@ _outCommentStmt(String * str, CommentStmt *node) string_append_char(str, v->val.str); else if (IsA(v, Integer)) { - snprintf(buf, 16, "%ld", v->val.ival); + snprintf(buf, 16, "%d", v->val.ival); string_append_char(str, buf); } break; diff --git a/src/parser/parser.c b/src/parser/parser.c index 2ded1ed..a7a7970 100644 --- a/src/parser/parser.c +++ b/src/parser/parser.c @@ -10,8 +10,8 @@ * analyze.c and related files. * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION @@ -108,6 +108,30 @@ raw_parser2(List *parse_tree_list) } /* + * Extract an int32 value from a DefElem. + */ +int32 +defGetInt32(DefElem *def) +{ + if (def->arg == NULL) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("%s requires an integer value", + def->defname))); + switch (nodeTag(def->arg)) + { + case T_Integer: + return (int32) intVal(def->arg); + default: + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("%s requires an integer value", + def->defname))); + } + return 0; /* keep compiler quiet */ +} + +/* * Intermediate filter between parser and core lexer (core_yylex in scan.l). * * This filter is needed because in some cases the standard SQL grammar diff --git a/src/parser/scan.l b/src/parser/scan.l index a8b9243..93097ba 100644 --- a/src/parser/scan.l +++ b/src/parser/scan.l @@ -21,8 +21,8 @@ * Postgres 9.2, this check is made automatically by the Makefile.) * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION @@ -47,6 +47,9 @@ } %{ + +/* LCOV_EXCL_START */ + /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ #undef fprintf #define fprintf(file, fmt, msg) fprintf_to_ereport(fmt, msg) @@ -1019,6 +1022,8 @@ other . %% +/* LCOV_EXCL_STOP */ + /* * Arrange access to yyextra for subroutines of the main yylex() function. * We expect each subroutine to have a yyscanner parameter. Rather than @@ -1217,15 +1222,18 @@ litbufdup(core_yyscan_t yyscanner) static int process_integer_literal(const char *token, YYSTYPE *lval) { - long val; + int val; + long val_long; char *endptr; errno = 0; - val = strtol(token, &endptr, 10); + val_long = strtol(token, &endptr, 10); + val = (int) val_long; + if (*endptr != '\0' || errno == ERANGE #ifdef HAVE_LONG_INT_64 /* if long > 32 bits, check for overflow of int4 */ - || val != (long) ((int32) val) + || val != (int) val_long #endif ) { diff --git a/src/parser/scansup.c b/src/parser/scansup.c index 842d4b4..16c4faf 100644 --- a/src/parser/scansup.c +++ b/src/parser/scansup.c @@ -4,8 +4,8 @@ * support routines for the lex/flex scanner, used by both the normal * backend as well as the bootstrap backend * - * Portions Copyright (c) 1996-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * @@ -214,7 +214,7 @@ truncate_identifier(char *ident, int len, bool warn) } /* - * scanner_isspace() --- return TRUE if flex scanner considers char whitespace + * scanner_isspace() --- return true if flex scanner considers char whitespace * * This should be used instead of the potentially locale-dependent isspace() * function when it's important to match the lexer's behavior. diff --git a/src/parser/snprintf.c b/src/parser/snprintf.c index 5a1c35d..e73048f 100644 --- a/src/parser/snprintf.c +++ b/src/parser/snprintf.c @@ -807,6 +807,8 @@ nextch2: strvalue = argvalues[fmtpos].cptr; else strvalue = va_arg(args, char *); + /* Whine if someone tries to print a NULL string */ + Assert(strvalue != NULL); fmtstr(strvalue, leftjust, fieldwidth, precision, pointflag, target); break; @@ -852,16 +854,6 @@ bad_format: target->failed = true; } -static size_t -pg_strnlen(const char *str, size_t maxlen) -{ - const char *p = str; - - while (maxlen-- > 0 && *p) - p++; - return p - str; -} - static void fmtstr(char *value, int leftjust, int minlen, int maxwidth, int pointflag, PrintfTarget *target) @@ -874,7 +866,7 @@ fmtstr(char *value, int leftjust, int minlen, int maxwidth, * than that. */ if (pointflag) - vallen = pg_strnlen(value, maxwidth); + vallen = strnlen(value, maxwidth); else vallen = strlen(value); diff --git a/src/parser/stringinfo.c b/src/parser/stringinfo.c index 8170879..646d704 100644 --- a/src/parser/stringinfo.c +++ b/src/parser/stringinfo.c @@ -6,8 +6,8 @@ * It can be used to buffer either ordinary C strings (null-terminated text) * or arbitrary binary data. All storage is allocated with palloc(). * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group - * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group + * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/backend/lib/stringinfo.c @@ -203,7 +203,7 @@ appendStringInfoSpaces(StringInfo str, int count) * appendBinaryStringInfo * * Append arbitrary binary data to a StringInfo, allocating more space - * if necessary. + * if necessary. Ensures that a trailing null byte is present. */ void appendBinaryStringInfo(StringInfo str, const char *data, int datalen) @@ -226,6 +226,25 @@ appendBinaryStringInfo(StringInfo str, const char *data, int datalen) } /* + * appendBinaryStringInfoNT + * + * Append arbitrary binary data to a StringInfo, allocating more space + * if necessary. Does not ensure a trailing null-byte exists. + */ +void +appendBinaryStringInfoNT(StringInfo str, const char *data, int datalen) +{ + Assert(str != NULL); + + /* Make more room if needed */ + enlargeStringInfo(str, datalen); + + /* OK, append the data */ + memcpy(str->data + str->len, data, datalen); + str->len += datalen; +} + +/* * enlargeStringInfo * * Make sure there is enough space for 'needed' more bytes diff --git a/src/parser/value.c b/src/parser/value.c index e61be49..644fd5d 100644 --- a/src/parser/value.c +++ b/src/parser/value.c @@ -4,7 +4,7 @@ * implementation of Value nodes * * - * Portions Copyright (c) 2003-2017, PgPool Global Development Group + * Portions Copyright (c) 2003-2018, PgPool Global Development Group * Copyright (c) 2003-2017, PostgreSQL Global Development Group * * @@ -23,7 +23,7 @@ * makeInteger */ Value * -makeInteger(long i) +makeInteger(int i) { Value *v = makeNode(Value); diff --git a/src/parser/wchar.c b/src/parser/wchar.c index b0802cd..e489f60 100644 --- a/src/parser/wchar.c +++ b/src/parser/wchar.c @@ -1887,8 +1887,8 @@ int pg_encoding_mblen(int encoding, const char *mbstr) { return (PG_VALID_ENCODING(encoding) ? - ((*pg_wchar_table[encoding].mblen) ((const unsigned char *) mbstr)) : - ((*pg_wchar_table[PG_SQL_ASCII].mblen) ((const unsigned char *) mbstr))); + pg_wchar_table[encoding].mblen((const unsigned char *) mbstr) : + pg_wchar_table[PG_SQL_ASCII].mblen((const unsigned char *) mbstr)); } /* @@ -1898,8 +1898,8 @@ int pg_encoding_dsplen(int encoding, const char *mbstr) { return (PG_VALID_ENCODING(encoding) ? - ((*pg_wchar_table[encoding].dsplen) ((const unsigned char *) mbstr)) : - ((*pg_wchar_table[PG_SQL_ASCII].dsplen) ((const unsigned char *) mbstr))); + pg_wchar_table[encoding].dsplen((const unsigned char *) mbstr) : + pg_wchar_table[PG_SQL_ASCII].dsplen((const unsigned char *) mbstr)); } /* @@ -1911,8 +1911,8 @@ int pg_encoding_verifymb(int encoding, const char *mbstr, int len) { return (PG_VALID_ENCODING(encoding) ? - ((*pg_wchar_table[encoding].mbverify) ((const unsigned char *) mbstr, len)) : - ((*pg_wchar_table[PG_SQL_ASCII].mbverify) ((const unsigned char *) mbstr, len))); + pg_wchar_table[encoding].mbverify((const unsigned char *) mbstr, len) : + pg_wchar_table[PG_SQL_ASCII].mbverify((const unsigned char *) mbstr, len)); } /* diff --git a/src/protocol/pool_proto_modules.c b/src/protocol/pool_proto_modules.c index ccaaec0..426aa95 100644 --- a/src/protocol/pool_proto_modules.c +++ b/src/protocol/pool_proto_modules.c @@ -3629,7 +3629,7 @@ flatten_set_variable_args(const char *name, List *args) switch (nodeTag(&con->val)) { case T_Integer: - appendStringInfo(&buf, "%ld", intVal(&con->val)); + appendStringInfo(&buf, "%d", intVal(&con->val)); break; case T_Float: /* represented as a string, so just copy it */