LCOV - differential code coverage report
Current view: top level - src/backend/parser - gram.y (source / functions) Coverage Total Hit UNC LBC UBC GBC GNC CBC DUB DCB
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 90.6 % 7494 6788 4 3 699 4 65 6719 5 32
Current Date: 2025-09-06 07:49:51 +0900 Functions: 100.0 % 41 41 41
Baseline: lcov-20250906-005545-baseline Branches: 62.3 % 734 457 3 274 9 448
Baseline Date: 2025-09-05 08:21:35 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(30,360] days: 96.0 % 298 286 4 8 65 221
(360..) days: 90.4 % 7196 6502 3 691 4 6498
Function coverage date bins:
(30,360] days: 100.0 % 4 4 4
(360..) days: 100.0 % 37 37 37
Branch coverage date bins:
(30,360] days: 80.0 % 60 48 3 9 9 39
(360..) days: 60.7 % 674 409 265 409

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : %{
                                  2                 :                : 
                                  3                 :                : /*#define YYDEBUG 1*/
                                  4                 :                : /*-------------------------------------------------------------------------
                                  5                 :                :  *
                                  6                 :                :  * gram.y
                                  7                 :                :  *    POSTGRESQL BISON rules/actions
                                  8                 :                :  *
                                  9                 :                :  * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
                                 10                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                 11                 :                :  *
                                 12                 :                :  *
                                 13                 :                :  * IDENTIFICATION
                                 14                 :                :  *    src/backend/parser/gram.y
                                 15                 :                :  *
                                 16                 :                :  * HISTORY
                                 17                 :                :  *    AUTHOR            DATE            MAJOR EVENT
                                 18                 :                :  *    Andrew Yu         Sept, 1994      POSTQUEL to SQL conversion
                                 19                 :                :  *    Andrew Yu         Oct, 1994       lispy code conversion
                                 20                 :                :  *
                                 21                 :                :  * NOTES
                                 22                 :                :  *    CAPITALS are used to represent terminal symbols.
                                 23                 :                :  *    non-capitals are used to represent non-terminals.
                                 24                 :                :  *
                                 25                 :                :  *    In general, nothing in this file should initiate database accesses
                                 26                 :                :  *    nor depend on changeable state (such as SET variables).  If you do
                                 27                 :                :  *    database accesses, your code will fail when we have aborted the
                                 28                 :                :  *    current transaction and are just parsing commands to find the next
                                 29                 :                :  *    ROLLBACK or COMMIT.  If you make use of SET variables, then you
                                 30                 :                :  *    will do the wrong thing in multi-query strings like this:
                                 31                 :                :  *          SET constraint_exclusion TO off; SELECT * FROM foo;
                                 32                 :                :  *    because the entire string is parsed by gram.y before the SET gets
                                 33                 :                :  *    executed.  Anything that depends on the database or changeable state
                                 34                 :                :  *    should be handled during parse analysis so that it happens at the
                                 35                 :                :  *    right time not the wrong time.
                                 36                 :                :  *
                                 37                 :                :  * WARNINGS
                                 38                 :                :  *    If you use a list, make sure the datum is a node so that the printing
                                 39                 :                :  *    routines work.
                                 40                 :                :  *
                                 41                 :                :  *    Sometimes we assign constants to makeStrings. Make sure we don't free
                                 42                 :                :  *    those.
                                 43                 :                :  *
                                 44                 :                :  *-------------------------------------------------------------------------
                                 45                 :                :  */
                                 46                 :                : #include "postgres.h"
                                 47                 :                : 
                                 48                 :                : #include <ctype.h>
                                 49                 :                : #include <limits.h>
                                 50                 :                : 
                                 51                 :                : #include "catalog/index.h"
                                 52                 :                : #include "catalog/namespace.h"
                                 53                 :                : #include "catalog/pg_am.h"
                                 54                 :                : #include "catalog/pg_trigger.h"
                                 55                 :                : #include "commands/defrem.h"
                                 56                 :                : #include "commands/trigger.h"
                                 57                 :                : #include "gramparse.h"
                                 58                 :                : #include "nodes/makefuncs.h"
                                 59                 :                : #include "nodes/nodeFuncs.h"
                                 60                 :                : #include "parser/parser.h"
                                 61                 :                : #include "utils/datetime.h"
                                 62                 :                : #include "utils/xml.h"
                                 63                 :                : 
                                 64                 :                : 
                                 65                 :                : /*
                                 66                 :                :  * Location tracking support.  Unlike bison's default, we only want
                                 67                 :                :  * to track the start position not the end position of each nonterminal.
                                 68                 :                :  * Nonterminals that reduce to empty receive position "-1".  Since a
                                 69                 :                :  * production's leading RHS nonterminal(s) may have reduced to empty,
                                 70                 :                :  * we have to scan to find the first one that's not -1.
                                 71                 :                :  */
                                 72                 :                : #define YYLLOC_DEFAULT(Current, Rhs, N) \
                                 73                 :                :     do { \
                                 74                 :                :         (Current) = (-1); \
                                 75                 :                :         for (int _i = 1; _i <= (N); _i++) \
                                 76                 :                :         { \
                                 77                 :                :             if ((Rhs)[_i] >= 0) \
                                 78                 :                :             { \
                                 79                 :                :                 (Current) = (Rhs)[_i]; \
                                 80                 :                :                 break; \
                                 81                 :                :             } \
                                 82                 :                :         } \
                                 83                 :                :     } while (0)
                                 84                 :                : 
                                 85                 :                : /*
                                 86                 :                :  * Bison doesn't allocate anything that needs to live across parser calls,
                                 87                 :                :  * so we can easily have it use palloc instead of malloc.  This prevents
                                 88                 :                :  * memory leaks if we error out during parsing.
                                 89                 :                :  */
                                 90                 :                : #define YYMALLOC palloc
                                 91                 :                : #define YYFREE   pfree
                                 92                 :                : 
                                 93                 :                : /* Private struct for the result of privilege_target production */
                                 94                 :                : typedef struct PrivTarget
                                 95                 :                : {
                                 96                 :                :     GrantTargetType targtype;
                                 97                 :                :     ObjectType  objtype;
                                 98                 :                :     List       *objs;
                                 99                 :                : } PrivTarget;
                                100                 :                : 
                                101                 :                : /* Private struct for the result of import_qualification production */
                                102                 :                : typedef struct ImportQual
                                103                 :                : {
                                104                 :                :     ImportForeignSchemaType type;
                                105                 :                :     List       *table_names;
                                106                 :                : } ImportQual;
                                107                 :                : 
                                108                 :                : /* Private struct for the result of select_limit & limit_clause productions */
                                109                 :                : typedef struct SelectLimit
                                110                 :                : {
                                111                 :                :     Node       *limitOffset;
                                112                 :                :     Node       *limitCount;
                                113                 :                :     LimitOption limitOption;    /* indicates presence of WITH TIES */
                                114                 :                :     ParseLoc    offsetLoc;      /* location of OFFSET token, if present */
                                115                 :                :     ParseLoc    countLoc;       /* location of LIMIT/FETCH token, if present */
                                116                 :                :     ParseLoc    optionLoc;      /* location of WITH TIES, if present */
                                117                 :                : } SelectLimit;
                                118                 :                : 
                                119                 :                : /* Private struct for the result of group_clause production */
                                120                 :                : typedef struct GroupClause
                                121                 :                : {
                                122                 :                :     bool        distinct;
                                123                 :                :     List       *list;
                                124                 :                : } GroupClause;
                                125                 :                : 
                                126                 :                : /* Private structs for the result of key_actions and key_action productions */
                                127                 :                : typedef struct KeyAction
                                128                 :                : {
                                129                 :                :     char        action;
                                130                 :                :     List       *cols;
                                131                 :                : } KeyAction;
                                132                 :                : 
                                133                 :                : typedef struct KeyActions
                                134                 :                : {
                                135                 :                :     KeyAction *updateAction;
                                136                 :                :     KeyAction *deleteAction;
                                137                 :                : } KeyActions;
                                138                 :                : 
                                139                 :                : /* ConstraintAttributeSpec yields an integer bitmask of these flags: */
                                140                 :                : #define CAS_NOT_DEFERRABLE          0x01
                                141                 :                : #define CAS_DEFERRABLE              0x02
                                142                 :                : #define CAS_INITIALLY_IMMEDIATE     0x04
                                143                 :                : #define CAS_INITIALLY_DEFERRED      0x08
                                144                 :                : #define CAS_NOT_VALID               0x10
                                145                 :                : #define CAS_NO_INHERIT              0x20
                                146                 :                : #define CAS_NOT_ENFORCED            0x40
                                147                 :                : #define CAS_ENFORCED                0x80
                                148                 :                : 
                                149                 :                : 
                                150                 :                : #define parser_yyerror(msg)  scanner_yyerror(msg, yyscanner)
                                151                 :                : #define parser_errposition(pos)  scanner_errposition(pos, yyscanner)
                                152                 :                : 
                                153                 :                : static void base_yyerror(YYLTYPE *yylloc, core_yyscan_t yyscanner,
                                154                 :                :                          const char *msg);
                                155                 :                : static RawStmt *makeRawStmt(Node *stmt, int stmt_location);
                                156                 :                : static void updateRawStmtEnd(RawStmt *rs, int end_location);
                                157                 :                : static Node *makeColumnRef(char *colname, List *indirection,
                                158                 :                :                            int location, core_yyscan_t yyscanner);
                                159                 :                : static Node *makeTypeCast(Node *arg, TypeName *typename, int location);
                                160                 :                : static Node *makeStringConstCast(char *str, int location, TypeName *typename);
                                161                 :                : static Node *makeIntConst(int val, int location);
                                162                 :                : static Node *makeFloatConst(char *str, int location);
                                163                 :                : static Node *makeBoolAConst(bool state, int location);
                                164                 :                : static Node *makeBitStringConst(char *str, int location);
                                165                 :                : static Node *makeNullAConst(int location);
                                166                 :                : static Node *makeAConst(Node *v, int location);
                                167                 :                : static RoleSpec *makeRoleSpec(RoleSpecType type, int location);
                                168                 :                : static void check_qualified_name(List *names, core_yyscan_t yyscanner);
                                169                 :                : static List *check_func_name(List *names, core_yyscan_t yyscanner);
                                170                 :                : static List *check_indirection(List *indirection, core_yyscan_t yyscanner);
                                171                 :                : static List *extractArgTypes(List *parameters);
                                172                 :                : static List *extractAggrArgTypes(List *aggrargs);
                                173                 :                : static List *makeOrderedSetArgs(List *directargs, List *orderedargs,
                                174                 :                :                                 core_yyscan_t yyscanner);
                                175                 :                : static void insertSelectOptions(SelectStmt *stmt,
                                176                 :                :                                 List *sortClause, List *lockingClause,
                                177                 :                :                                 SelectLimit *limitClause,
                                178                 :                :                                 WithClause *withClause,
                                179                 :                :                                 core_yyscan_t yyscanner);
                                180                 :                : static Node *makeSetOp(SetOperation op, bool all, Node *larg, Node *rarg);
                                181                 :                : static Node *doNegate(Node *n, int location);
                                182                 :                : static void doNegateFloat(Float *v);
                                183                 :                : static Node *makeAndExpr(Node *lexpr, Node *rexpr, int location);
                                184                 :                : static Node *makeOrExpr(Node *lexpr, Node *rexpr, int location);
                                185                 :                : static Node *makeNotExpr(Node *expr, int location);
                                186                 :                : static Node *makeAArrayExpr(List *elements, int location, int end_location);
                                187                 :                : static Node *makeSQLValueFunction(SQLValueFunctionOp op, int32 typmod,
                                188                 :                :                                   int location);
                                189                 :                : static Node *makeXmlExpr(XmlExprOp op, char *name, List *named_args,
                                190                 :                :                          List *args, int location);
                                191                 :                : static List *mergeTableFuncParameters(List *func_args, List *columns, core_yyscan_t yyscanner);
                                192                 :                : static TypeName *TableFuncTypeName(List *columns);
                                193                 :                : static RangeVar *makeRangeVarFromAnyName(List *names, int position, core_yyscan_t yyscanner);
                                194                 :                : static RangeVar *makeRangeVarFromQualifiedName(char *name, List *namelist, int location,
                                195                 :                :                                                core_yyscan_t yyscanner);
                                196                 :                : static void SplitColQualList(List *qualList,
                                197                 :                :                              List **constraintList, CollateClause **collClause,
                                198                 :                :                              core_yyscan_t yyscanner);
                                199                 :                : static void processCASbits(int cas_bits, int location, const char *constrType,
                                200                 :                :                bool *deferrable, bool *initdeferred, bool *is_enforced,
                                201                 :                :                bool *not_valid, bool *no_inherit, core_yyscan_t yyscanner);
                                202                 :                : static PartitionStrategy parsePartitionStrategy(char *strategy, int location,
                                203                 :                :                                                 core_yyscan_t yyscanner);
                                204                 :                : static void preprocess_pubobj_list(List *pubobjspec_list,
                                205                 :                :                                    core_yyscan_t yyscanner);
                                206                 :                : static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
                                207                 :                : 
                                208                 :                : %}
                                209                 :                : 
                                210                 :                : %pure-parser
                                211                 :                : %expect 0
                                212                 :                : %name-prefix="base_yy"
                                213                 :                : %locations
                                214                 :                : 
                                215                 :                : %parse-param {core_yyscan_t yyscanner}
                                216                 :                : %lex-param   {core_yyscan_t yyscanner}
                                217                 :                : 
                                218                 :                : %union
                                219                 :                : {
                                220                 :                :     core_YYSTYPE core_yystype;
                                221                 :                :     /* these fields must match core_YYSTYPE: */
                                222                 :                :     int         ival;
                                223                 :                :     char       *str;
                                224                 :                :     const char *keyword;
                                225                 :                : 
                                226                 :                :     char        chr;
                                227                 :                :     bool        boolean;
                                228                 :                :     JoinType    jtype;
                                229                 :                :     DropBehavior dbehavior;
                                230                 :                :     OnCommitAction oncommit;
                                231                 :                :     List       *list;
                                232                 :                :     Node       *node;
                                233                 :                :     ObjectType  objtype;
                                234                 :                :     TypeName   *typnam;
                                235                 :                :     FunctionParameter *fun_param;
                                236                 :                :     FunctionParameterMode fun_param_mode;
                                237                 :                :     ObjectWithArgs *objwithargs;
                                238                 :                :     DefElem    *defelt;
                                239                 :                :     SortBy     *sortby;
                                240                 :                :     WindowDef  *windef;
                                241                 :                :     JoinExpr   *jexpr;
                                242                 :                :     IndexElem  *ielem;
                                243                 :                :     StatsElem  *selem;
                                244                 :                :     Alias      *alias;
                                245                 :                :     RangeVar   *range;
                                246                 :                :     IntoClause *into;
                                247                 :                :     WithClause *with;
                                248                 :                :     InferClause *infer;
                                249                 :                :     OnConflictClause *onconflict;
                                250                 :                :     A_Indices  *aind;
                                251                 :                :     ResTarget  *target;
                                252                 :                :     struct PrivTarget *privtarget;
                                253                 :                :     AccessPriv *accesspriv;
                                254                 :                :     struct ImportQual *importqual;
                                255                 :                :     InsertStmt *istmt;
                                256                 :                :     VariableSetStmt *vsetstmt;
                                257                 :                :     PartitionElem *partelem;
                                258                 :                :     PartitionSpec *partspec;
                                259                 :                :     PartitionBoundSpec *partboundspec;
                                260                 :                :     RoleSpec   *rolespec;
                                261                 :                :     PublicationObjSpec *publicationobjectspec;
                                262                 :                :     struct SelectLimit *selectlimit;
                                263                 :                :     SetQuantifier setquantifier;
                                264                 :                :     struct GroupClause *groupclause;
                                265                 :                :     MergeMatchKind mergematch;
                                266                 :                :     MergeWhenClause *mergewhen;
                                267                 :                :     struct KeyActions *keyactions;
                                268                 :                :     struct KeyAction *keyaction;
                                269                 :                :     ReturningClause *retclause;
                                270                 :                :     ReturningOptionKind retoptionkind;
                                271                 :                : }
                                272                 :                : 
                                273                 :                : %type <node>  stmt toplevel_stmt schema_stmt routine_body_stmt
                                274                 :                :         AlterEventTrigStmt AlterCollationStmt
                                275                 :                :         AlterDatabaseStmt AlterDatabaseSetStmt AlterDomainStmt AlterEnumStmt
                                276                 :                :         AlterFdwStmt AlterForeignServerStmt AlterGroupStmt
                                277                 :                :         AlterObjectDependsStmt AlterObjectSchemaStmt AlterOwnerStmt
                                278                 :                :         AlterOperatorStmt AlterTypeStmt AlterSeqStmt AlterSystemStmt AlterTableStmt
                                279                 :                :         AlterTblSpcStmt AlterExtensionStmt AlterExtensionContentsStmt
                                280                 :                :         AlterCompositeTypeStmt AlterUserMappingStmt
                                281                 :                :         AlterRoleStmt AlterRoleSetStmt AlterPolicyStmt AlterStatsStmt
                                282                 :                :         AlterDefaultPrivilegesStmt DefACLAction
                                283                 :                :         AnalyzeStmt CallStmt ClosePortalStmt ClusterStmt CommentStmt
                                284                 :                :         ConstraintsSetStmt CopyStmt CreateAsStmt CreateCastStmt
                                285                 :                :         CreateDomainStmt CreateExtensionStmt CreateGroupStmt CreateOpClassStmt
                                286                 :                :         CreateOpFamilyStmt AlterOpFamilyStmt CreatePLangStmt
                                287                 :                :         CreateSchemaStmt CreateSeqStmt CreateStmt CreateStatsStmt CreateTableSpaceStmt
                                288                 :                :         CreateFdwStmt CreateForeignServerStmt CreateForeignTableStmt
                                289                 :                :         CreateAssertionStmt CreateTransformStmt CreateTrigStmt CreateEventTrigStmt
                                290                 :                :         CreateUserStmt CreateUserMappingStmt CreateRoleStmt CreatePolicyStmt
                                291                 :                :         CreatedbStmt DeclareCursorStmt DefineStmt DeleteStmt DiscardStmt DoStmt
                                292                 :                :         DropOpClassStmt DropOpFamilyStmt DropStmt
                                293                 :                :         DropCastStmt DropRoleStmt
                                294                 :                :         DropdbStmt DropTableSpaceStmt
                                295                 :                :         DropTransformStmt
                                296                 :                :         DropUserMappingStmt ExplainStmt FetchStmt
                                297                 :                :         GrantStmt GrantRoleStmt ImportForeignSchemaStmt IndexStmt InsertStmt
                                298                 :                :         ListenStmt LoadStmt LockStmt MergeStmt NotifyStmt ExplainableStmt PreparableStmt
                                299                 :                :         CreateFunctionStmt AlterFunctionStmt ReindexStmt RemoveAggrStmt
                                300                 :                :         RemoveFuncStmt RemoveOperStmt RenameStmt ReturnStmt RevokeStmt RevokeRoleStmt
                                301                 :                :         RuleActionStmt RuleActionStmtOrEmpty RuleStmt
                                302                 :                :         SecLabelStmt SelectStmt TransactionStmt TransactionStmtLegacy TruncateStmt
                                303                 :                :         UnlistenStmt UpdateStmt VacuumStmt
                                304                 :                :         VariableResetStmt VariableSetStmt VariableShowStmt
                                305                 :                :         ViewStmt CheckPointStmt CreateConversionStmt
                                306                 :                :         DeallocateStmt PrepareStmt ExecuteStmt
                                307                 :                :         DropOwnedStmt ReassignOwnedStmt
                                308                 :                :         AlterTSConfigurationStmt AlterTSDictionaryStmt
                                309                 :                :         CreateMatViewStmt RefreshMatViewStmt CreateAmStmt
                                310                 :                :         CreatePublicationStmt AlterPublicationStmt
                                311                 :                :         CreateSubscriptionStmt AlterSubscriptionStmt DropSubscriptionStmt
                                312                 :                : 
                                313                 :                : %type <node>  select_no_parens select_with_parens select_clause
                                314                 :                :                 simple_select values_clause
                                315                 :                :                 PLpgSQL_Expr PLAssignStmt
                                316                 :                : 
                                317                 :                : %type <str>           opt_single_name
                                318                 :                : %type <list>      opt_qualified_name
                                319                 :                : %type <boolean>       opt_concurrently
                                320                 :                : %type <dbehavior> opt_drop_behavior
                                321                 :                : %type <list>      opt_utility_option_list
                                322                 :                : %type <list>      utility_option_list
                                323                 :                : %type <defelt>        utility_option_elem
                                324                 :                : %type <str>           utility_option_name
                                325                 :                : %type <node>      utility_option_arg
                                326                 :                : 
                                327                 :                : %type <node>  alter_column_default opclass_item opclass_drop alter_using
                                328                 :                : %type <ival>  add_drop opt_asc_desc opt_nulls_order
                                329                 :                : 
                                330                 :                : %type <node>  alter_table_cmd alter_type_cmd opt_collate_clause
                                331                 :                :        replica_identity partition_cmd index_partition_cmd
                                332                 :                : %type <list>  alter_table_cmds alter_type_cmds
                                333                 :                : %type <list>    alter_identity_column_option_list
                                334                 :                : %type <defelt>  alter_identity_column_option
                                335                 :                : %type <node>  set_statistics_value
                                336                 :                : %type <str>       set_access_method_name
                                337                 :                : 
                                338                 :                : %type <list>  createdb_opt_list createdb_opt_items copy_opt_list
                                339                 :                :                 transaction_mode_list
                                340                 :                :                 create_extension_opt_list alter_extension_opt_list
                                341                 :                : %type <defelt>    createdb_opt_item copy_opt_item
                                342                 :                :                 transaction_mode_item
                                343                 :                :                 create_extension_opt_item alter_extension_opt_item
                                344                 :                : 
                                345                 :                : %type <ival>  opt_lock lock_type cast_context
                                346                 :                : %type <defelt>    drop_option
                                347                 :                : %type <boolean>   opt_or_replace opt_no
                                348                 :                :                 opt_grant_grant_option
                                349                 :                :                 opt_nowait opt_if_exists opt_with_data
                                350                 :                :                 opt_transaction_chain
                                351                 :                : %type <list>  grant_role_opt_list
                                352                 :                : %type <defelt>    grant_role_opt
                                353                 :                : %type <node>  grant_role_opt_value
                                354                 :                : %type <ival>  opt_nowait_or_skip
                                355                 :                : 
                                356                 :                : %type <list>  OptRoleList AlterOptRoleList
                                357                 :                : %type <defelt>    CreateOptRoleElem AlterOptRoleElem
                                358                 :                : 
                                359                 :                : %type <str>       opt_type
                                360                 :                : %type <str>       foreign_server_version opt_foreign_server_version
                                361                 :                : %type <str>       opt_in_database
                                362                 :                : 
                                363                 :                : %type <str>       parameter_name
                                364                 :                : %type <list>  OptSchemaEltList parameter_name_list
                                365                 :                : 
                                366                 :                : %type <chr>       am_type
                                367                 :                : 
                                368                 :                : %type <boolean> TriggerForSpec TriggerForType
                                369                 :                : %type <ival>  TriggerActionTime
                                370                 :                : %type <list>  TriggerEvents TriggerOneEvent
                                371                 :                : %type <node>  TriggerFuncArg
                                372                 :                : %type <node>  TriggerWhen
                                373                 :                : %type <str>       TransitionRelName
                                374                 :                : %type <boolean>   TransitionRowOrTable TransitionOldOrNew
                                375                 :                : %type <node>  TriggerTransition
                                376                 :                : 
                                377                 :                : %type <list>  event_trigger_when_list event_trigger_value_list
                                378                 :                : %type <defelt>    event_trigger_when_item
                                379                 :                : %type <chr>       enable_trigger
                                380                 :                : 
                                381                 :                : %type <str>       copy_file_name
                                382                 :                :                 access_method_clause attr_name
                                383                 :                :                 table_access_method_clause name cursor_name file_name
                                384                 :                :                 cluster_index_specification
                                385                 :                : 
                                386                 :                : %type <list>  func_name handler_name qual_Op qual_all_Op subquery_Op
                                387                 :                :                 opt_inline_handler opt_validator validator_clause
                                388                 :                :                 opt_collate
                                389                 :                : 
                                390                 :                : %type <range> qualified_name insert_target OptConstrFromTable
                                391                 :                : 
                                392                 :                : %type <str>       all_Op MathOp
                                393                 :                : 
                                394                 :                : %type <str>       row_security_cmd RowSecurityDefaultForCmd
                                395                 :                : %type <boolean> RowSecurityDefaultPermissive
                                396                 :                : %type <node>  RowSecurityOptionalWithCheck RowSecurityOptionalExpr
                                397                 :                : %type <list>  RowSecurityDefaultToRole RowSecurityOptionalToRole
                                398                 :                : 
                                399                 :                : %type <str>       iso_level opt_encoding
                                400                 :                : %type <rolespec> grantee
                                401                 :                : %type <list>  grantee_list
                                402                 :                : %type <accesspriv> privilege
                                403                 :                : %type <list>  privileges privilege_list
                                404                 :                : %type <privtarget> privilege_target
                                405                 :                : %type <objwithargs> function_with_argtypes aggregate_with_argtypes operator_with_argtypes
                                406                 :                : %type <list>  function_with_argtypes_list aggregate_with_argtypes_list operator_with_argtypes_list
                                407                 :                : %type <ival>  defacl_privilege_target
                                408                 :                : %type <defelt>    DefACLOption
                                409                 :                : %type <list>  DefACLOptionList
                                410                 :                : %type <ival>  import_qualification_type
                                411                 :                : %type <importqual> import_qualification
                                412                 :                : %type <node>  vacuum_relation
                                413                 :                : %type <selectlimit> opt_select_limit select_limit limit_clause
                                414                 :                : 
                                415                 :                : %type <list>  parse_toplevel stmtmulti routine_body_stmt_list
                                416                 :                :                 OptTableElementList TableElementList OptInherit definition
                                417                 :                :                 OptTypedTableElementList TypedTableElementList
                                418                 :                :                 reloptions opt_reloptions
                                419                 :                :                 OptWith opt_definition func_args func_args_list
                                420                 :                :                 func_args_with_defaults func_args_with_defaults_list
                                421                 :                :                 aggr_args aggr_args_list
                                422                 :                :                 func_as createfunc_opt_list opt_createfunc_opt_list alterfunc_opt_list
                                423                 :                :                 old_aggr_definition old_aggr_list
                                424                 :                :                 oper_argtypes RuleActionList RuleActionMulti
                                425                 :                :                 opt_column_list columnList opt_name_list
                                426                 :                :                 sort_clause opt_sort_clause sortby_list index_params
                                427                 :                :                 stats_params
                                428                 :                :                 opt_include opt_c_include index_including_params
                                429                 :                :                 name_list role_list from_clause from_list opt_array_bounds
                                430                 :                :                 qualified_name_list any_name any_name_list type_name_list
                                431                 :                :                 any_operator expr_list attrs
                                432                 :                :                 distinct_clause opt_distinct_clause
                                433                 :                :                 target_list opt_target_list insert_column_list set_target_list
                                434                 :                :                 merge_values_clause
                                435                 :                :                 set_clause_list set_clause
                                436                 :                :                 def_list operator_def_list indirection opt_indirection
                                437                 :                :                 reloption_list TriggerFuncArgs opclass_item_list opclass_drop_list
                                438                 :                :                 opclass_purpose opt_opfamily transaction_mode_list_or_empty
                                439                 :                :                 OptTableFuncElementList TableFuncElementList opt_type_modifiers
                                440                 :                :                 prep_type_clause
                                441                 :                :                 execute_param_clause using_clause
                                442                 :                :                 returning_with_clause returning_options
                                443                 :                :                 opt_enum_val_list enum_val_list table_func_column_list
                                444                 :                :                 create_generic_options alter_generic_options
                                445                 :                :                 relation_expr_list dostmt_opt_list
                                446                 :                :                 transform_element_list transform_type_list
                                447                 :                :                 TriggerTransitions TriggerReferencing
                                448                 :                :                 vacuum_relation_list opt_vacuum_relation_list
                                449                 :                :                 drop_option_list pub_obj_list
                                450                 :                : 
                                451                 :                : %type <retclause> returning_clause
                                452                 :                : %type <node>  returning_option
                                453                 :                : %type <retoptionkind> returning_option_kind
                                454                 :                : %type <node>  opt_routine_body
                                455                 :                : %type <groupclause> group_clause
                                456                 :                : %type <list>  group_by_list
                                457                 :                : %type <node>  group_by_item empty_grouping_set rollup_clause cube_clause
                                458                 :                : %type <node>  grouping_sets_clause
                                459                 :                : 
                                460                 :                : %type <list>  opt_fdw_options fdw_options
                                461                 :                : %type <defelt>    fdw_option
                                462                 :                : 
                                463                 :                : %type <range> OptTempTableName
                                464                 :                : %type <into>  into_clause create_as_target create_mv_target
                                465                 :                : 
                                466                 :                : %type <defelt>    createfunc_opt_item common_func_opt_item dostmt_opt_item
                                467                 :                : %type <fun_param> func_arg func_arg_with_default table_func_column aggr_arg
                                468                 :                : %type <fun_param_mode> arg_class
                                469                 :                : %type <typnam>    func_return func_type
                                470                 :                : 
                                471                 :                : %type <boolean>  opt_trusted opt_restart_seqs
                                472                 :                : %type <ival>   OptTemp
                                473                 :                : %type <ival>   OptNoLog
                                474                 :                : %type <oncommit> OnCommitOption
                                475                 :                : 
                                476                 :                : %type <ival>  for_locking_strength
                                477                 :                : %type <node>  for_locking_item
                                478                 :                : %type <list>  for_locking_clause opt_for_locking_clause for_locking_items
                                479                 :                : %type <list>  locked_rels_list
                                480                 :                : %type <setquantifier> set_quantifier
                                481                 :                : 
                                482                 :                : %type <node>  join_qual
                                483                 :                : %type <jtype> join_type
                                484                 :                : 
                                485                 :                : %type <list>  extract_list overlay_list position_list
                                486                 :                : %type <list>  substr_list trim_list
                                487                 :                : %type <list>  opt_interval interval_second
                                488                 :                : %type <str>       unicode_normal_form
                                489                 :                : 
                                490                 :                : %type <boolean> opt_instead
                                491                 :                : %type <boolean> opt_unique opt_verbose opt_full
                                492                 :                : %type <boolean> opt_freeze opt_analyze opt_default
                                493                 :                : %type <defelt>    opt_binary copy_delimiter
                                494                 :                : 
                                495                 :                : %type <boolean> copy_from opt_program
                                496                 :                : 
                                497                 :                : %type <ival>  event cursor_options opt_hold opt_set_data
                                498                 :                : %type <objtype>   object_type_any_name object_type_name object_type_name_on_any_name
                                499                 :                :                 drop_type_name
                                500                 :                : 
                                501                 :                : %type <node>  fetch_args select_limit_value
                                502                 :                :                 offset_clause select_offset_value
                                503                 :                :                 select_fetch_first_value I_or_F_const
                                504                 :                : %type <ival>  row_or_rows first_or_next
                                505                 :                : 
                                506                 :                : %type <list>  OptSeqOptList SeqOptList OptParenthesizedSeqOptList
                                507                 :                : %type <defelt>    SeqOptElem
                                508                 :                : 
                                509                 :                : %type <istmt> insert_rest
                                510                 :                : %type <infer> opt_conf_expr
                                511                 :                : %type <onconflict> opt_on_conflict
                                512                 :                : %type <mergewhen> merge_insert merge_update merge_delete
                                513                 :                : 
                                514                 :                : %type <mergematch> merge_when_tgt_matched merge_when_tgt_not_matched
                                515                 :                : %type <node>  merge_when_clause opt_merge_when_condition
                                516                 :                : %type <list>  merge_when_list
                                517                 :                : 
                                518                 :                : %type <vsetstmt> generic_set set_rest set_rest_more generic_reset reset_rest
                                519                 :                :                  SetResetClause FunctionSetResetClause
                                520                 :                : 
                                521                 :                : %type <node>  TableElement TypedTableElement ConstraintElem DomainConstraintElem TableFuncElement
                                522                 :                : %type <node>  columnDef columnOptions optionalPeriodName
                                523                 :                : %type <defelt>    def_elem reloption_elem old_aggr_elem operator_def_elem
                                524                 :                : %type <node>  def_arg columnElem where_clause where_or_current_clause
                                525                 :                :                 a_expr b_expr c_expr AexprConst indirection_el opt_slice_bound
                                526                 :                :                 columnref having_clause func_table xmltable array_expr
                                527                 :                :                 OptWhereClause operator_def_arg
                                528                 :                : %type <list>  opt_column_and_period_list
                                529                 :                : %type <list>  rowsfrom_item rowsfrom_list opt_col_def_list
                                530                 :                : %type <boolean> opt_ordinality opt_without_overlaps
                                531                 :                : %type <list>  ExclusionConstraintList ExclusionConstraintElem
                                532                 :                : %type <list>  func_arg_list func_arg_list_opt
                                533                 :                : %type <node>  func_arg_expr
                                534                 :                : %type <list>  row explicit_row implicit_row type_list array_expr_list
                                535                 :                : %type <node>  case_expr case_arg when_clause case_default
                                536                 :                : %type <list>  when_clause_list
                                537                 :                : %type <node>  opt_search_clause opt_cycle_clause
                                538                 :                : %type <ival>  sub_type opt_materialized
                                539                 :                : %type <node>  NumericOnly
                                540                 :                : %type <list>  NumericOnly_list
                                541                 :                : %type <alias> alias_clause opt_alias_clause opt_alias_clause_for_join_using
                                542                 :                : %type <list>  func_alias_clause
                                543                 :                : %type <sortby>    sortby
                                544                 :                : %type <ielem> index_elem index_elem_options
                                545                 :                : %type <selem> stats_param
                                546                 :                : %type <node>  table_ref
                                547                 :                : %type <jexpr> joined_table
                                548                 :                : %type <range> relation_expr
                                549                 :                : %type <range> extended_relation_expr
                                550                 :                : %type <range> relation_expr_opt_alias
                                551                 :                : %type <node>  tablesample_clause opt_repeatable_clause
                                552                 :                : %type <target>    target_el set_target insert_column_item
                                553                 :                : 
                                554                 :                : %type <str>       generic_option_name
                                555                 :                : %type <node>  generic_option_arg
                                556                 :                : %type <defelt>    generic_option_elem alter_generic_option_elem
                                557                 :                : %type <list>  generic_option_list alter_generic_option_list
                                558                 :                : 
                                559                 :                : %type <ival>  reindex_target_relation reindex_target_all
                                560                 :                : 
                                561                 :                : %type <node>  copy_generic_opt_arg copy_generic_opt_arg_list_item
                                562                 :                : %type <defelt>    copy_generic_opt_elem
                                563                 :                : %type <list>  copy_generic_opt_list copy_generic_opt_arg_list
                                564                 :                : %type <list>  copy_options
                                565                 :                : 
                                566                 :                : %type <typnam>    Typename SimpleTypename ConstTypename
                                567                 :                :                 GenericType Numeric opt_float JsonType
                                568                 :                :                 Character ConstCharacter
                                569                 :                :                 CharacterWithLength CharacterWithoutLength
                                570                 :                :                 ConstDatetime ConstInterval
                                571                 :                :                 Bit ConstBit BitWithLength BitWithoutLength
                                572                 :                : %type <str>       character
                                573                 :                : %type <str>       extract_arg
                                574                 :                : %type <boolean> opt_varying opt_timezone opt_no_inherit
                                575                 :                : 
                                576                 :                : %type <ival>  Iconst SignedIconst
                                577                 :                : %type <str>       Sconst comment_text notify_payload
                                578                 :                : %type <str>       RoleId opt_boolean_or_string
                                579                 :                : %type <list>  var_list
                                580                 :                : %type <str>       ColId ColLabel BareColLabel
                                581                 :                : %type <str>       NonReservedWord NonReservedWord_or_Sconst
                                582                 :                : %type <str>       var_name type_function_name param_name
                                583                 :                : %type <str>       createdb_opt_name plassign_target
                                584                 :                : %type <node>  var_value zone_value
                                585                 :                : %type <rolespec> auth_ident RoleSpec opt_granted_by
                                586                 :                : %type <publicationobjectspec> PublicationObjSpec
                                587                 :                : 
                                588                 :                : %type <keyword> unreserved_keyword type_func_name_keyword
                                589                 :                : %type <keyword> col_name_keyword reserved_keyword
                                590                 :                : %type <keyword> bare_label_keyword
                                591                 :                : 
                                592                 :                : %type <node>  DomainConstraint TableConstraint TableLikeClause
                                593                 :                : %type <ival>  TableLikeOptionList TableLikeOption
                                594                 :                : %type <str>       column_compression opt_column_compression column_storage opt_column_storage
                                595                 :                : %type <list>  ColQualList
                                596                 :                : %type <node>  ColConstraint ColConstraintElem ConstraintAttr
                                597                 :                : %type <ival>  key_match
                                598                 :                : %type <keyaction> key_delete key_update key_action
                                599                 :                : %type <keyactions> key_actions
                                600                 :                : %type <ival>  ConstraintAttributeSpec ConstraintAttributeElem
                                601                 :                : %type <str>       ExistingIndex
                                602                 :                : 
                                603                 :                : %type <list>  constraints_set_list
                                604                 :                : %type <boolean> constraints_set_mode
                                605                 :                : %type <str>       OptTableSpace OptConsTableSpace
                                606                 :                : %type <rolespec> OptTableSpaceOwner
                                607                 :                : %type <ival>  opt_check_option
                                608                 :                : 
                                609                 :                : %type <str>       opt_provider security_label
                                610                 :                : 
                                611                 :                : %type <target>    xml_attribute_el
                                612                 :                : %type <list>  xml_attribute_list xml_attributes
                                613                 :                : %type <node>  xml_root_version opt_xml_root_standalone
                                614                 :                : %type <node>  xmlexists_argument
                                615                 :                : %type <ival>  document_or_content
                                616                 :                : %type <boolean>   xml_indent_option xml_whitespace_option
                                617                 :                : %type <list>  xmltable_column_list xmltable_column_option_list
                                618                 :                : %type <node>  xmltable_column_el
                                619                 :                : %type <defelt>    xmltable_column_option_el
                                620                 :                : %type <list>  xml_namespace_list
                                621                 :                : %type <target>    xml_namespace_el
                                622                 :                : 
                                623                 :                : %type <node>  func_application func_expr_common_subexpr
                                624                 :                : %type <node>  func_expr func_expr_windowless
                                625                 :                : %type <node>  common_table_expr
                                626                 :                : %type <with>  with_clause opt_with_clause
                                627                 :                : %type <list>  cte_list
                                628                 :                : 
                                629                 :                : %type <list>  within_group_clause
                                630                 :                : %type <node>  filter_clause
                                631                 :                : %type <list>  window_clause window_definition_list opt_partition_clause
                                632                 :                : %type <windef>    window_definition over_clause window_specification
                                633                 :                :                 opt_frame_clause frame_extent frame_bound
                                634                 :                : %type <ival>  opt_window_exclusion_clause
                                635                 :                : %type <str>       opt_existing_window_name
                                636                 :                : %type <boolean> opt_if_not_exists
                                637                 :                : %type <boolean> opt_unique_null_treatment
                                638                 :                : %type <ival>  generated_when override_kind opt_virtual_or_stored
                                639                 :                : %type <partspec>  PartitionSpec OptPartitionSpec
                                640                 :                : %type <partelem>  part_elem
                                641                 :                : %type <list>      part_params
                                642                 :                : %type <partboundspec> PartitionBoundSpec
                                643                 :                : %type <list>      hash_partbound
                                644                 :                : %type <defelt>        hash_partbound_elem
                                645                 :                : 
                                646                 :                : %type <node>  json_format_clause
                                647                 :                :                 json_format_clause_opt
                                648                 :                :                 json_value_expr
                                649                 :                :                 json_returning_clause_opt
                                650                 :                :                 json_name_and_value
                                651                 :                :                 json_aggregate_func
                                652                 :                :                 json_argument
                                653                 :                :                 json_behavior
                                654                 :                :                 json_on_error_clause_opt
                                655                 :                :                 json_table
                                656                 :                :                 json_table_column_definition
                                657                 :                :                 json_table_column_path_clause_opt
                                658                 :                : %type <list>  json_name_and_value_list
                                659                 :                :                 json_value_expr_list
                                660                 :                :                 json_array_aggregate_order_by_clause_opt
                                661                 :                :                 json_arguments
                                662                 :                :                 json_behavior_clause_opt
                                663                 :                :                 json_passing_clause_opt
                                664                 :                :                 json_table_column_definition_list
                                665                 :                : %type <str>       json_table_path_name_opt
                                666                 :                : %type <ival>  json_behavior_type
                                667                 :                :                 json_predicate_type_constraint
                                668                 :                :                 json_quotes_clause_opt
                                669                 :                :                 json_wrapper_behavior
                                670                 :                : %type <boolean>   json_key_uniqueness_constraint_opt
                                671                 :                :                 json_object_constructor_null_clause_opt
                                672                 :                :                 json_array_constructor_null_clause_opt
                                673                 :                : 
                                674                 :                : 
                                675                 :                : /*
                                676                 :                :  * Non-keyword token types.  These are hard-wired into the "flex" lexer.
                                677                 :                :  * They must be listed first so that their numeric codes do not depend on
                                678                 :                :  * the set of keywords.  PL/pgSQL depends on this so that it can share the
                                679                 :                :  * same lexer.  If you add/change tokens here, fix PL/pgSQL to match!
                                680                 :                :  *
                                681                 :                :  * UIDENT and USCONST are reduced to IDENT and SCONST in parser.c, so that
                                682                 :                :  * they need no productions here; but we must assign token codes to them.
                                683                 :                :  *
                                684                 :                :  * DOT_DOT is unused in the core SQL grammar, and so will always provoke
                                685                 :                :  * parse errors.  It is needed by PL/pgSQL.
                                686                 :                :  */
                                687                 :                : %token <str>  IDENT UIDENT FCONST SCONST USCONST BCONST XCONST Op
                                688                 :                : %token <ival> ICONST PARAM
                                689                 :                : %token          TYPECAST DOT_DOT COLON_EQUALS EQUALS_GREATER
                                690                 :                : %token          LESS_EQUALS GREATER_EQUALS NOT_EQUALS
                                691                 :                : 
                                692                 :                : /*
                                693                 :                :  * If you want to make any keyword changes, update the keyword table in
                                694                 :                :  * src/include/parser/kwlist.h and add new keywords to the appropriate one
                                695                 :                :  * of the reserved-or-not-so-reserved keyword lists, below; search
                                696                 :                :  * this file for "Keyword category lists".
                                697                 :                :  */
                                698                 :                : 
                                699                 :                : /* ordinary key words in alphabetical order */
                                700                 :                : %token <keyword> ABORT_P ABSENT ABSOLUTE_P ACCESS ACTION ADD_P ADMIN AFTER
                                701                 :                :     AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY ARRAY AS ASC
                                702                 :                :     ASENSITIVE ASSERTION ASSIGNMENT ASYMMETRIC ATOMIC AT ATTACH ATTRIBUTE AUTHORIZATION
                                703                 :                : 
                                704                 :                :     BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
                                705                 :                :     BOOLEAN_P BOTH BREADTH BY
                                706                 :                : 
                                707                 :                :     CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
                                708                 :                :     CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
                                709                 :                :     CLUSTER COALESCE COLLATE COLLATION COLUMN COLUMNS COMMENT COMMENTS COMMIT
                                710                 :                :     COMMITTED COMPRESSION CONCURRENTLY CONDITIONAL CONFIGURATION CONFLICT
                                711                 :                :     CONNECTION CONSTRAINT CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY
                                712                 :                :     COST CREATE CROSS CSV CUBE CURRENT_P
                                713                 :                :     CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
                                714                 :                :     CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
                                715                 :                : 
                                716                 :                :     DATA_P DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS
                                717                 :                :     DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS DEPENDS DEPTH DESC
                                718                 :                :     DETACH DICTIONARY DISABLE_P DISCARD DISTINCT DO DOCUMENT_P DOMAIN_P
                                719                 :                :     DOUBLE_P DROP
                                720                 :                : 
                                721                 :                :     EACH ELSE EMPTY_P ENABLE_P ENCODING ENCRYPTED END_P ENFORCED ENUM_P ERROR_P
                                722                 :                :     ESCAPE EVENT EXCEPT EXCLUDE EXCLUDING EXCLUSIVE EXECUTE EXISTS EXPLAIN
                                723                 :                :     EXPRESSION EXTENSION EXTERNAL EXTRACT
                                724                 :                : 
                                725                 :                :     FALSE_P FAMILY FETCH FILTER FINALIZE FIRST_P FLOAT_P FOLLOWING FOR
                                726                 :                :     FORCE FOREIGN FORMAT FORWARD FREEZE FROM FULL FUNCTION FUNCTIONS
                                727                 :                : 
                                728                 :                :     GENERATED GLOBAL GRANT GRANTED GREATEST GROUP_P GROUPING GROUPS
                                729                 :                : 
                                730                 :                :     HANDLER HAVING HEADER_P HOLD HOUR_P
                                731                 :                : 
                                732                 :                :     IDENTITY_P IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P IN_P INCLUDE
                                733                 :                :     INCLUDING INCREMENT INDENT INDEX INDEXES INHERIT INHERITS INITIALLY INLINE_P
                                734                 :                :     INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER
                                735                 :                :     INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION
                                736                 :                : 
                                737                 :                :     JOIN JSON JSON_ARRAY JSON_ARRAYAGG JSON_EXISTS JSON_OBJECT JSON_OBJECTAGG
                                738                 :                :     JSON_QUERY JSON_SCALAR JSON_SERIALIZE JSON_TABLE JSON_VALUE
                                739                 :                : 
                                740                 :                :     KEEP KEY KEYS
                                741                 :                : 
                                742                 :                :     LABEL LANGUAGE LARGE_P LAST_P LATERAL_P
                                743                 :                :     LEADING LEAKPROOF LEAST LEFT LEVEL LIKE LIMIT LISTEN LOAD LOCAL
                                744                 :                :     LOCALTIME LOCALTIMESTAMP LOCATION LOCK_P LOCKED LOGGED
                                745                 :                : 
                                746                 :                :     MAPPING MATCH MATCHED MATERIALIZED MAXVALUE MERGE MERGE_ACTION METHOD
                                747                 :                :     MINUTE_P MINVALUE MODE MONTH_P MOVE
                                748                 :                : 
                                749                 :                :     NAME_P NAMES NATIONAL NATURAL NCHAR NESTED NEW NEXT NFC NFD NFKC NFKD NO
                                750                 :                :     NONE NORMALIZE NORMALIZED
                                751                 :                :     NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
                                752                 :                :     NULLS_P NUMERIC
                                753                 :                : 
                                754                 :                :     OBJECT_P OBJECTS_P OF OFF OFFSET OIDS OLD OMIT ON ONLY OPERATOR OPTION OPTIONS OR
                                755                 :                :     ORDER ORDINALITY OTHERS OUT_P OUTER_P
                                756                 :                :     OVER OVERLAPS OVERLAY OVERRIDING OWNED OWNER
                                757                 :                : 
                                758                 :                :     PARALLEL PARAMETER PARSER PARTIAL PARTITION PASSING PASSWORD PATH
                                759                 :                :     PERIOD PLACING PLAN PLANS POLICY
                                760                 :                :     POSITION PRECEDING PRECISION PRESERVE PREPARE PREPARED PRIMARY
                                761                 :                :     PRIOR PRIVILEGES PROCEDURAL PROCEDURE PROCEDURES PROGRAM PUBLICATION
                                762                 :                : 
                                763                 :                :     QUOTE QUOTES
                                764                 :                : 
                                765                 :                :     RANGE READ REAL REASSIGN RECURSIVE REF_P REFERENCES REFERENCING
                                766                 :                :     REFRESH REINDEX RELATIVE_P RELEASE RENAME REPEATABLE REPLACE REPLICA
                                767                 :                :     RESET RESTART RESTRICT RETURN RETURNING RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP
                                768                 :                :     ROUTINE ROUTINES ROW ROWS RULE
                                769                 :                : 
                                770                 :                :     SAVEPOINT SCALAR SCHEMA SCHEMAS SCROLL SEARCH SECOND_P SECURITY SELECT
                                771                 :                :     SEQUENCE SEQUENCES
                                772                 :                :     SERIALIZABLE SERVER SESSION SESSION_USER SET SETS SETOF SHARE SHOW
                                773                 :                :     SIMILAR SIMPLE SKIP SMALLINT SNAPSHOT SOME SOURCE SQL_P STABLE STANDALONE_P
                                774                 :                :     START STATEMENT STATISTICS STDIN STDOUT STORAGE STORED STRICT_P STRING_P STRIP_P
                                775                 :                :     SUBSCRIPTION SUBSTRING SUPPORT SYMMETRIC SYSID SYSTEM_P SYSTEM_USER
                                776                 :                : 
                                777                 :                :     TABLE TABLES TABLESAMPLE TABLESPACE TARGET TEMP TEMPLATE TEMPORARY TEXT_P THEN
                                778                 :                :     TIES TIME TIMESTAMP TO TRAILING TRANSACTION TRANSFORM
                                779                 :                :     TREAT TRIGGER TRIM TRUE_P
                                780                 :                :     TRUNCATE TRUSTED TYPE_P TYPES_P
                                781                 :                : 
                                782                 :                :     UESCAPE UNBOUNDED UNCONDITIONAL UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN
                                783                 :                :     UNLISTEN UNLOGGED UNTIL UPDATE USER USING
                                784                 :                : 
                                785                 :                :     VACUUM VALID VALIDATE VALIDATOR VALUE_P VALUES VARCHAR VARIADIC VARYING
                                786                 :                :     VERBOSE VERSION_P VIEW VIEWS VIRTUAL VOLATILE
                                787                 :                : 
                                788                 :                :     WHEN WHERE WHITESPACE_P WINDOW WITH WITHIN WITHOUT WORK WRAPPER WRITE
                                789                 :                : 
                                790                 :                :     XML_P XMLATTRIBUTES XMLCONCAT XMLELEMENT XMLEXISTS XMLFOREST XMLNAMESPACES
                                791                 :                :     XMLPARSE XMLPI XMLROOT XMLSERIALIZE XMLTABLE
                                792                 :                : 
                                793                 :                :     YEAR_P YES_P
                                794                 :                : 
                                795                 :                :     ZONE
                                796                 :                : 
                                797                 :                : /*
                                798                 :                :  * The grammar thinks these are keywords, but they are not in the kwlist.h
                                799                 :                :  * list and so can never be entered directly.  The filter in parser.c
                                800                 :                :  * creates these tokens when required (based on looking one token ahead).
                                801                 :                :  *
                                802                 :                :  * NOT_LA exists so that productions such as NOT LIKE can be given the same
                                803                 :                :  * precedence as LIKE; otherwise they'd effectively have the same precedence
                                804                 :                :  * as NOT, at least with respect to their left-hand subexpression.
                                805                 :                :  * FORMAT_LA, NULLS_LA, WITH_LA, and WITHOUT_LA are needed to make the grammar
                                806                 :                :  * LALR(1).
                                807                 :                :  */
                                808                 :                : %token      FORMAT_LA NOT_LA NULLS_LA WITH_LA WITHOUT_LA
                                809                 :                : 
                                810                 :                : /*
                                811                 :                :  * The grammar likewise thinks these tokens are keywords, but they are never
                                812                 :                :  * generated by the scanner.  Rather, they can be injected by parser.c as
                                813                 :                :  * the initial token of the string (using the lookahead-token mechanism
                                814                 :                :  * implemented there).  This provides a way to tell the grammar to parse
                                815                 :                :  * something other than the usual list of SQL commands.
                                816                 :                :  */
                                817                 :                : %token      MODE_TYPE_NAME
                                818                 :                : %token      MODE_PLPGSQL_EXPR
                                819                 :                : %token      MODE_PLPGSQL_ASSIGN1
                                820                 :                : %token      MODE_PLPGSQL_ASSIGN2
                                821                 :                : %token      MODE_PLPGSQL_ASSIGN3
                                822                 :                : 
                                823                 :                : 
                                824                 :                : /* Precedence: lowest to highest */
                                825                 :                : %left       UNION EXCEPT
                                826                 :                : %left       INTERSECT
                                827                 :                : %left       OR
                                828                 :                : %left       AND
                                829                 :                : %right      NOT
                                830                 :                : %nonassoc   IS ISNULL NOTNULL   /* IS sets precedence for IS NULL, etc */
                                831                 :                : %nonassoc   '<' '>' '=' LESS_EQUALS GREATER_EQUALS NOT_EQUALS
                                832                 :                : %nonassoc   BETWEEN IN_P LIKE ILIKE SIMILAR NOT_LA
                                833                 :                : %nonassoc   ESCAPE          /* ESCAPE must be just above LIKE/ILIKE/SIMILAR */
                                834                 :                : 
                                835                 :                : /*
                                836                 :                :  * Sometimes it is necessary to assign precedence to keywords that are not
                                837                 :                :  * really part of the operator hierarchy, in order to resolve grammar
                                838                 :                :  * ambiguities.  It's best to avoid doing so whenever possible, because such
                                839                 :                :  * assignments have global effect and may hide ambiguities besides the one
                                840                 :                :  * you intended to solve.  (Attaching a precedence to a single rule with
                                841                 :                :  * %prec is far safer and should be preferred.)  If you must give precedence
                                842                 :                :  * to a new keyword, try very hard to give it the same precedence as IDENT.
                                843                 :                :  * If the keyword has IDENT's precedence then it clearly acts the same as
                                844                 :                :  * non-keywords and other similar keywords, thus reducing the risk of
                                845                 :                :  * unexpected precedence effects.
                                846                 :                :  *
                                847                 :                :  * We used to need to assign IDENT an explicit precedence just less than Op,
                                848                 :                :  * to support target_el without AS.  While that's not really necessary since
                                849                 :                :  * we removed postfix operators, we continue to do so because it provides a
                                850                 :                :  * reference point for a precedence level that we can assign to other
                                851                 :                :  * keywords that lack a natural precedence level.
                                852                 :                :  *
                                853                 :                :  * We need to do this for PARTITION, RANGE, ROWS, and GROUPS to support
                                854                 :                :  * opt_existing_window_name (see comment there).
                                855                 :                :  *
                                856                 :                :  * The frame_bound productions UNBOUNDED PRECEDING and UNBOUNDED FOLLOWING
                                857                 :                :  * are even messier: since UNBOUNDED is an unreserved keyword (per spec!),
                                858                 :                :  * there is no principled way to distinguish these from the productions
                                859                 :                :  * a_expr PRECEDING/FOLLOWING.  We hack this up by giving UNBOUNDED slightly
                                860                 :                :  * lower precedence than PRECEDING and FOLLOWING.  At present this doesn't
                                861                 :                :  * appear to cause UNBOUNDED to be treated differently from other unreserved
                                862                 :                :  * keywords anywhere else in the grammar, but it's definitely risky.  We can
                                863                 :                :  * blame any funny behavior of UNBOUNDED on the SQL standard, though.
                                864                 :                :  *
                                865                 :                :  * To support CUBE and ROLLUP in GROUP BY without reserving them, we give them
                                866                 :                :  * an explicit priority lower than '(', so that a rule with CUBE '(' will shift
                                867                 :                :  * rather than reducing a conflicting rule that takes CUBE as a function name.
                                868                 :                :  * Using the same precedence as IDENT seems right for the reasons given above.
                                869                 :                :  *
                                870                 :                :  * SET is likewise assigned the same precedence as IDENT, to support the
                                871                 :                :  * relation_expr_opt_alias production (see comment there).
                                872                 :                :  *
                                873                 :                :  * KEYS, OBJECT_P, SCALAR, VALUE_P, WITH, and WITHOUT are similarly assigned
                                874                 :                :  * the same precedence as IDENT.  This allows resolving conflicts in the
                                875                 :                :  * json_predicate_type_constraint and json_key_uniqueness_constraint_opt
                                876                 :                :  * productions (see comments there).
                                877                 :                :  *
                                878                 :                :  * Like the UNBOUNDED PRECEDING/FOLLOWING case, NESTED is assigned a lower
                                879                 :                :  * precedence than PATH to fix ambiguity in the json_table production.
                                880                 :                :  */
                                881                 :                : %nonassoc   UNBOUNDED NESTED /* ideally would have same precedence as IDENT */
                                882                 :                : %nonassoc   IDENT PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE ROLLUP
                                883                 :                :             SET KEYS OBJECT_P SCALAR VALUE_P WITH WITHOUT PATH
                                884                 :                : %left       Op OPERATOR     /* multi-character ops and user-defined operators */
                                885                 :                : %left       '+' '-'
                                886                 :                : %left       '*' '/' '%'
                                887                 :                : %left       '^'
                                888                 :                : /* Unary Operators */
                                889                 :                : %left       AT              /* sets precedence for AT TIME ZONE, AT LOCAL */
                                890                 :                : %left       COLLATE
                                891                 :                : %right      UMINUS
                                892                 :                : %left       '[' ']'
                                893                 :                : %left       '(' ')'
                                894                 :                : %left       TYPECAST
                                895                 :                : %left       '.'
                                896                 :                : /*
                                897                 :                :  * These might seem to be low-precedence, but actually they are not part
                                898                 :                :  * of the arithmetic hierarchy at all in their use as JOIN operators.
                                899                 :                :  * We make them high-precedence to support their use as function names.
                                900                 :                :  * They wouldn't be given a precedence at all, were it not that we need
                                901                 :                :  * left-associativity among the JOIN rules themselves.
                                902                 :                :  */
                                903                 :                : %left       JOIN CROSS LEFT FULL RIGHT INNER_P NATURAL
                                904                 :                : 
                                905                 :                : %%
                                906                 :                : 
                                907                 :                : /*
                                908                 :                :  *  The target production for the whole parse.
                                909                 :                :  *
                                910                 :                :  * Ordinarily we parse a list of statements, but if we see one of the
                                911                 :                :  * special MODE_XXX symbols as first token, we parse something else.
                                912                 :                :  * The options here correspond to enum RawParseMode, which see for details.
                                913                 :                :  */
                                914                 :                : parse_toplevel:
                                915                 :                :             stmtmulti
                                916                 :                :             {
 5899 tgl@sss.pgh.pa.us         917                 :CBC      356369 :                 pg_yyget_extra(yyscanner)->parsetree = $1;
                                918                 :                :                 (void) yynerrs;     /* suppress compiler warning */
                                919                 :                :             }
                                920                 :                :             | MODE_TYPE_NAME Typename
                                921                 :                :             {
 1706                           922                 :           4949 :                 pg_yyget_extra(yyscanner)->parsetree = list_make1($2);
                                923                 :                :             }
                                924                 :                :             | MODE_PLPGSQL_EXPR PLpgSQL_Expr
                                925                 :                :             {
                                926                 :          17045 :                 pg_yyget_extra(yyscanner)->parsetree =
  319                           927                 :          17045 :                     list_make1(makeRawStmt($2, @2));
                                928                 :                :             }
                                929                 :                :             | MODE_PLPGSQL_ASSIGN1 PLAssignStmt
                                930                 :                :             {
 1706                           931                 :           3288 :                 PLAssignStmt *n = (PLAssignStmt *) $2;
                                932                 :                : 
                                933                 :           3288 :                 n->nnames = 1;
                                934                 :           3288 :                 pg_yyget_extra(yyscanner)->parsetree =
  319                           935                 :           3288 :                     list_make1(makeRawStmt((Node *) n, @2));
                                936                 :                :             }
                                937                 :                :             | MODE_PLPGSQL_ASSIGN2 PLAssignStmt
                                938                 :                :             {
 1706                           939                 :            337 :                 PLAssignStmt *n = (PLAssignStmt *) $2;
                                940                 :                : 
                                941                 :            337 :                 n->nnames = 2;
                                942                 :            337 :                 pg_yyget_extra(yyscanner)->parsetree =
  319                           943                 :            337 :                     list_make1(makeRawStmt((Node *) n, @2));
                                944                 :                :             }
                                945                 :                :             | MODE_PLPGSQL_ASSIGN3 PLAssignStmt
                                946                 :                :             {
 1706                           947                 :             14 :                 PLAssignStmt *n = (PLAssignStmt *) $2;
                                948                 :                : 
                                949                 :             14 :                 n->nnames = 3;
                                950                 :             14 :                 pg_yyget_extra(yyscanner)->parsetree =
  319                           951                 :             14 :                     list_make1(makeRawStmt((Node *) n, @2));
                                952                 :                :             }
                                953                 :                :         ;
                                954                 :                : 
                                955                 :                : /*
                                956                 :                :  * At top level, we wrap each stmt with a RawStmt node carrying start location
                                957                 :                :  * and length of the stmt's text.
                                958                 :                :  * We also take care to discard empty statements entirely (which among other
                                959                 :                :  * things dodges the problem of assigning them a location).
                                960                 :                :  */
                                961                 :                : stmtmulti:  stmtmulti ';' toplevel_stmt
                                962                 :                :                 {
 3157                           963         [ +  + ]:         292850 :                     if ($1 != NIL)
                                964                 :                :                     {
                                965                 :                :                         /* update length of previous stmt */
 3071                           966                 :         292487 :                         updateRawStmtEnd(llast_node(RawStmt, $1), @2);
                                967                 :                :                     }
 5899                           968         [ +  + ]:         292850 :                     if ($3 != NULL)
  319                           969                 :          28784 :                         $$ = lappend($1, makeRawStmt($3, @3));
                                970                 :                :                     else
 5899                           971                 :         264066 :                         $$ = $1;
                                972                 :                :                 }
                                973                 :                :             | toplevel_stmt
                                974                 :                :                 {
                                975         [ +  + ]:         356373 :                     if ($1 != NULL)
  319                           976                 :         355626 :                         $$ = list_make1(makeRawStmt($1, @1));
                                977                 :                :                     else
 8482 bruce@momjian.us          978                 :            747 :                         $$ = NIL;
                                979                 :                :                 }
                                980                 :                :         ;
                                981                 :                : 
                                982                 :                : /*
                                983                 :                :  * toplevel_stmt includes BEGIN and END.  stmt does not include them, because
                                984                 :                :  * those words have different meanings in function bodies.
                                985                 :                :  */
                                986                 :                : toplevel_stmt:
                                987                 :                :             stmt
                                988                 :                :             | TransactionStmtLegacy
                                989                 :                :         ;
                                990                 :                : 
                                991                 :                : stmt:
                                992                 :                :             AlterEventTrigStmt
                                993                 :                :             | AlterCollationStmt
                                994                 :                :             | AlterDatabaseStmt
                                995                 :                :             | AlterDatabaseSetStmt
                                996                 :                :             | AlterDefaultPrivilegesStmt
                                997                 :                :             | AlterDomainStmt
                                998                 :                :             | AlterEnumStmt
                                999                 :                :             | AlterExtensionStmt
                               1000                 :                :             | AlterExtensionContentsStmt
                               1001                 :                :             | AlterFdwStmt
                               1002                 :                :             | AlterForeignServerStmt
                               1003                 :                :             | AlterFunctionStmt
                               1004                 :                :             | AlterGroupStmt
                               1005                 :                :             | AlterObjectDependsStmt
                               1006                 :                :             | AlterObjectSchemaStmt
                               1007                 :                :             | AlterOwnerStmt
                               1008                 :                :             | AlterOperatorStmt
                               1009                 :                :             | AlterTypeStmt
                               1010                 :                :             | AlterPolicyStmt
                               1011                 :                :             | AlterSeqStmt
                               1012                 :                :             | AlterSystemStmt
                               1013                 :                :             | AlterTableStmt
                               1014                 :                :             | AlterTblSpcStmt
                               1015                 :                :             | AlterCompositeTypeStmt
                               1016                 :                :             | AlterPublicationStmt
                               1017                 :                :             | AlterRoleSetStmt
                               1018                 :                :             | AlterRoleStmt
                               1019                 :                :             | AlterSubscriptionStmt
                               1020                 :                :             | AlterStatsStmt
                               1021                 :                :             | AlterTSConfigurationStmt
                               1022                 :                :             | AlterTSDictionaryStmt
                               1023                 :                :             | AlterUserMappingStmt
                               1024                 :                :             | AnalyzeStmt
                               1025                 :                :             | CallStmt
                               1026                 :                :             | CheckPointStmt
                               1027                 :                :             | ClosePortalStmt
                               1028                 :                :             | ClusterStmt
                               1029                 :                :             | CommentStmt
                               1030                 :                :             | ConstraintsSetStmt
                               1031                 :                :             | CopyStmt
                               1032                 :                :             | CreateAmStmt
                               1033                 :                :             | CreateAsStmt
                               1034                 :                :             | CreateAssertionStmt
                               1035                 :                :             | CreateCastStmt
                               1036                 :                :             | CreateConversionStmt
                               1037                 :                :             | CreateDomainStmt
                               1038                 :                :             | CreateExtensionStmt
                               1039                 :                :             | CreateFdwStmt
                               1040                 :                :             | CreateForeignServerStmt
                               1041                 :                :             | CreateForeignTableStmt
                               1042                 :                :             | CreateFunctionStmt
                               1043                 :                :             | CreateGroupStmt
                               1044                 :                :             | CreateMatViewStmt
                               1045                 :                :             | CreateOpClassStmt
                               1046                 :                :             | CreateOpFamilyStmt
                               1047                 :                :             | CreatePublicationStmt
                               1048                 :                :             | AlterOpFamilyStmt
                               1049                 :                :             | CreatePolicyStmt
                               1050                 :                :             | CreatePLangStmt
                               1051                 :                :             | CreateSchemaStmt
                               1052                 :                :             | CreateSeqStmt
                               1053                 :                :             | CreateStmt
                               1054                 :                :             | CreateSubscriptionStmt
                               1055                 :                :             | CreateStatsStmt
                               1056                 :                :             | CreateTableSpaceStmt
                               1057                 :                :             | CreateTransformStmt
                               1058                 :                :             | CreateTrigStmt
                               1059                 :                :             | CreateEventTrigStmt
                               1060                 :                :             | CreateRoleStmt
                               1061                 :                :             | CreateUserStmt
                               1062                 :                :             | CreateUserMappingStmt
                               1063                 :                :             | CreatedbStmt
                               1064                 :                :             | DeallocateStmt
                               1065                 :                :             | DeclareCursorStmt
                               1066                 :                :             | DefineStmt
                               1067                 :                :             | DeleteStmt
                               1068                 :                :             | DiscardStmt
                               1069                 :                :             | DoStmt
                               1070                 :                :             | DropCastStmt
                               1071                 :                :             | DropOpClassStmt
                               1072                 :                :             | DropOpFamilyStmt
                               1073                 :                :             | DropOwnedStmt
                               1074                 :                :             | DropStmt
                               1075                 :                :             | DropSubscriptionStmt
                               1076                 :                :             | DropTableSpaceStmt
                               1077                 :                :             | DropTransformStmt
                               1078                 :                :             | DropRoleStmt
                               1079                 :                :             | DropUserMappingStmt
                               1080                 :                :             | DropdbStmt
                               1081                 :                :             | ExecuteStmt
                               1082                 :                :             | ExplainStmt
                               1083                 :                :             | FetchStmt
                               1084                 :                :             | GrantStmt
                               1085                 :                :             | GrantRoleStmt
                               1086                 :                :             | ImportForeignSchemaStmt
                               1087                 :                :             | IndexStmt
                               1088                 :                :             | InsertStmt
                               1089                 :                :             | ListenStmt
                               1090                 :                :             | RefreshMatViewStmt
                               1091                 :                :             | LoadStmt
                               1092                 :                :             | LockStmt
                               1093                 :                :             | MergeStmt
                               1094                 :                :             | NotifyStmt
                               1095                 :                :             | PrepareStmt
                               1096                 :                :             | ReassignOwnedStmt
                               1097                 :                :             | ReindexStmt
                               1098                 :                :             | RemoveAggrStmt
                               1099                 :                :             | RemoveFuncStmt
                               1100                 :                :             | RemoveOperStmt
                               1101                 :                :             | RenameStmt
                               1102                 :                :             | RevokeStmt
                               1103                 :                :             | RevokeRoleStmt
                               1104                 :                :             | RuleStmt
                               1105                 :                :             | SecLabelStmt
                               1106                 :                :             | SelectStmt
                               1107                 :                :             | TransactionStmt
                               1108                 :                :             | TruncateStmt
                               1109                 :                :             | UnlistenStmt
                               1110                 :                :             | UpdateStmt
                               1111                 :                :             | VacuumStmt
                               1112                 :                :             | VariableResetStmt
                               1113                 :                :             | VariableSetStmt
                               1114                 :                :             | VariableShowStmt
                               1115                 :                :             | ViewStmt
                               1116                 :                :             | /*EMPTY*/
 7913 neilc@samurai.com        1117                 :         264822 :                 { $$ = NULL; }
                               1118                 :                :         ;
                               1119                 :                : 
                               1120                 :                : /*
                               1121                 :                :  * Generic supporting productions for DDL
                               1122                 :                :  */
                               1123                 :                : opt_single_name:
 1142 alvherre@alvh.no-ip.     1124                 :           2671 :             ColId                           { $$ = $1; }
                               1125                 :            778 :             | /* EMPTY */                   { $$ = NULL; }
                               1126                 :                :         ;
                               1127                 :                : 
                               1128                 :                : opt_qualified_name:
                               1129                 :            938 :             any_name                        { $$ = $1; }
                               1130                 :           7607 :             | /*EMPTY*/                     { $$ = NIL; }
                               1131                 :                :         ;
                               1132                 :                : 
                               1133                 :                : opt_concurrently:
                               1134                 :            507 :             CONCURRENTLY                    { $$ = true; }
                               1135                 :           3807 :             | /*EMPTY*/                     { $$ = false; }
                               1136                 :                :         ;
                               1137                 :                : 
                               1138                 :                : opt_drop_behavior:
                               1139                 :            972 :             CASCADE                         { $$ = DROP_CASCADE; }
                               1140                 :             85 :             | RESTRICT                      { $$ = DROP_RESTRICT; }
                               1141                 :          19503 :             | /* EMPTY */                   { $$ = DROP_RESTRICT; /* default */ }
                               1142                 :                :         ;
                               1143                 :                : 
                               1144                 :                : opt_utility_option_list:
   43 alvherre@kurilemu.de     1145                 :GNC         183 :             '(' utility_option_list ')'     { $$ = $2; }
                               1146                 :           2929 :             | /* EMPTY */                   { $$ = NULL; }
                               1147                 :                :         ;
                               1148                 :                : 
                               1149                 :                : utility_option_list:
                               1150                 :                :             utility_option_elem
                               1151                 :                :                 {
                               1152                 :          11099 :                     $$ = list_make1($1);
                               1153                 :                :                 }
                               1154                 :                :             | utility_option_list ',' utility_option_elem
                               1155                 :                :                 {
                               1156                 :           6288 :                     $$ = lappend($1, $3);
                               1157                 :                :                 }
                               1158                 :                :         ;
                               1159                 :                : 
                               1160                 :                : utility_option_elem:
                               1161                 :                :             utility_option_name utility_option_arg
                               1162                 :                :                 {
                               1163                 :          17387 :                     $$ = makeDefElem($1, $2, @1);
                               1164                 :                :                 }
                               1165                 :                :         ;
                               1166                 :                : 
                               1167                 :                : utility_option_name:
                               1168                 :          15490 :             NonReservedWord                 { $$ = $1; }
                               1169                 :           1826 :             | analyze_keyword               { $$ = "analyze"; }
                               1170                 :             74 :             | FORMAT_LA                     { $$ = "format"; }
                               1171                 :                :         ;
                               1172                 :                : 
                               1173                 :                : utility_option_arg:
                               1174                 :           8846 :             opt_boolean_or_string           { $$ = (Node *) makeString($1); }
                               1175                 :            191 :             | NumericOnly                   { $$ = (Node *) $1; }
                               1176                 :           8350 :             | /* EMPTY */                   { $$ = NULL; }
                               1177                 :                :         ;
                               1178                 :                : 
                               1179                 :                : /*****************************************************************************
                               1180                 :                :  *
                               1181                 :                :  * CALL statement
                               1182                 :                :  *
                               1183                 :                :  *****************************************************************************/
                               1184                 :                : 
                               1185                 :                : CallStmt:   CALL func_application
                               1186                 :                :                 {
 1212 peter@eisentraut.org     1187                 :CBC         305 :                     CallStmt   *n = makeNode(CallStmt);
                               1188                 :                : 
 2837 peter_e@gmx.net          1189                 :            305 :                     n->funccall = castNode(FuncCall, $2);
 1212 peter@eisentraut.org     1190                 :            305 :                     $$ = (Node *) n;
                               1191                 :                :                 }
                               1192                 :                :         ;
                               1193                 :                : 
                               1194                 :                : /*****************************************************************************
                               1195                 :                :  *
                               1196                 :                :  * Create a new Postgres DBMS role
                               1197                 :                :  *
                               1198                 :                :  *****************************************************************************/
                               1199                 :                : 
                               1200                 :                : CreateRoleStmt:
                               1201                 :                :             CREATE ROLE RoleId opt_with OptRoleList
                               1202                 :                :                 {
 7375 tgl@sss.pgh.pa.us        1203                 :            671 :                     CreateRoleStmt *n = makeNode(CreateRoleStmt);
                               1204                 :                : 
 7347                          1205                 :            671 :                     n->stmt_type = ROLESTMT_ROLE;
 7375                          1206                 :            671 :                     n->role = $3;
 8824                          1207                 :            671 :                     n->options = $5;
 1212 peter@eisentraut.org     1208                 :            671 :                     $$ = (Node *) n;
                               1209                 :                :                 }
                               1210                 :                :         ;
                               1211                 :                : 
                               1212                 :                : 
                               1213                 :                : opt_with:   WITH
                               1214                 :                :             | WITH_LA
                               1215                 :                :             | /*EMPTY*/
                               1216                 :                :         ;
                               1217                 :                : 
                               1218                 :                : /*
                               1219                 :                :  * Options for CREATE ROLE and ALTER ROLE (also used by CREATE/ALTER USER
                               1220                 :                :  * for backwards compatibility).  Note: the only option required by SQL99
                               1221                 :                :  * is "WITH ADMIN name".
                               1222                 :                :  */
                               1223                 :                : OptRoleList:
 5813 alvherre@alvh.no-ip.     1224                 :            594 :             OptRoleList CreateOptRoleElem           { $$ = lappend($1, $2); }
 7375 tgl@sss.pgh.pa.us        1225                 :            910 :             | /* EMPTY */                           { $$ = NIL; }
                               1226                 :                :         ;
                               1227                 :                : 
                               1228                 :                : AlterOptRoleList:
 5813 alvherre@alvh.no-ip.     1229                 :            326 :             AlterOptRoleList AlterOptRoleElem       { $$ = lappend($1, $2); }
                               1230                 :            206 :             | /* EMPTY */                           { $$ = NIL; }
                               1231                 :                :         ;
                               1232                 :                : 
                               1233                 :                : AlterOptRoleElem:
                               1234                 :                :             PASSWORD Sconst
                               1235                 :                :                 {
 7375 tgl@sss.pgh.pa.us        1236                 :             94 :                     $$ = makeDefElem("password",
 1212 peter@eisentraut.org     1237                 :             94 :                                      (Node *) makeString($2), @1);
                               1238                 :                :                 }
                               1239                 :                :             | PASSWORD NULL_P
                               1240                 :                :                 {
 3287 peter_e@gmx.net          1241                 :              6 :                     $$ = makeDefElem("password", NULL, @1);
                               1242                 :                :                 }
                               1243                 :                :             | ENCRYPTED PASSWORD Sconst
                               1244                 :                :                 {
                               1245                 :                :                     /*
                               1246                 :                :                      * These days, passwords are always stored in encrypted
                               1247                 :                :                      * form, so there is no difference between PASSWORD and
                               1248                 :                :                      * ENCRYPTED PASSWORD.
                               1249                 :                :                      */
 3043 heikki.linnakangas@i     1250                 :              6 :                     $$ = makeDefElem("password",
 1212 peter@eisentraut.org     1251                 :              6 :                                      (Node *) makeString($3), @1);
                               1252                 :                :                 }
                               1253                 :                :             | UNENCRYPTED PASSWORD Sconst
                               1254                 :                :                 {
 3043 heikki.linnakangas@i     1255         [ #  # ]:UBC           0 :                     ereport(ERROR,
                               1256                 :                :                             (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               1257                 :                :                              errmsg("UNENCRYPTED PASSWORD is no longer supported"),
                               1258                 :                :                              errhint("Remove UNENCRYPTED to store the password in encrypted form instead."),
                               1259                 :                :                              parser_errposition(@1)));
                               1260                 :                :                 }
                               1261                 :                :             | INHERIT
                               1262                 :                :                 {
 1212 peter@eisentraut.org     1263                 :CBC          48 :                     $$ = makeDefElem("inherit", (Node *) makeBoolean(true), @1);
                               1264                 :                :                 }
                               1265                 :                :             | CONNECTION LIMIT SignedIconst
                               1266                 :                :                 {
                               1267                 :             12 :                     $$ = makeDefElem("connectionlimit", (Node *) makeInteger($3), @1);
                               1268                 :                :                 }
                               1269                 :                :             | VALID UNTIL Sconst
                               1270                 :                :                 {
                               1271                 :              1 :                     $$ = makeDefElem("validUntil", (Node *) makeString($3), @1);
                               1272                 :                :                 }
                               1273                 :                :         /*  Supported but not documented for roles, for use by ALTER GROUP. */
                               1274                 :                :             | USER role_list
                               1275                 :                :                 {
                               1276                 :              3 :                     $$ = makeDefElem("rolemembers", (Node *) $2, @1);
                               1277                 :                :                 }
                               1278                 :                :             | IDENT
                               1279                 :                :                 {
                               1280                 :                :                     /*
                               1281                 :                :                      * We handle identifiers that aren't parser keywords with
                               1282                 :                :                      * the following special-case codes, to avoid bloating the
                               1283                 :                :                      * size of the main parser.
                               1284                 :                :                      */
 5289 rhaas@postgresql.org     1285         [ +  + ]:            675 :                     if (strcmp($1, "superuser") == 0)
 1212 peter@eisentraut.org     1286                 :             96 :                         $$ = makeDefElem("superuser", (Node *) makeBoolean(true), @1);
 5289 rhaas@postgresql.org     1287         [ +  + ]:            579 :                     else if (strcmp($1, "nosuperuser") == 0)
 1212 peter@eisentraut.org     1288                 :             50 :                         $$ = makeDefElem("superuser", (Node *) makeBoolean(false), @1);
 5289 rhaas@postgresql.org     1289         [ +  + ]:            529 :                     else if (strcmp($1, "createrole") == 0)
 1212 peter@eisentraut.org     1290                 :             51 :                         $$ = makeDefElem("createrole", (Node *) makeBoolean(true), @1);
 5289 rhaas@postgresql.org     1291         [ +  + ]:            478 :                     else if (strcmp($1, "nocreaterole") == 0)
 1212 peter@eisentraut.org     1292                 :             19 :                         $$ = makeDefElem("createrole", (Node *) makeBoolean(false), @1);
 5289 rhaas@postgresql.org     1293         [ +  + ]:            459 :                     else if (strcmp($1, "replication") == 0)
 1212 peter@eisentraut.org     1294                 :             65 :                         $$ = makeDefElem("isreplication", (Node *) makeBoolean(true), @1);
 5289 rhaas@postgresql.org     1295         [ +  + ]:            394 :                     else if (strcmp($1, "noreplication") == 0)
 1212 peter@eisentraut.org     1296                 :             48 :                         $$ = makeDefElem("isreplication", (Node *) makeBoolean(false), @1);
 5289 rhaas@postgresql.org     1297         [ +  + ]:            346 :                     else if (strcmp($1, "createdb") == 0)
 1212 peter@eisentraut.org     1298                 :             46 :                         $$ = makeDefElem("createdb", (Node *) makeBoolean(true), @1);
 5289 rhaas@postgresql.org     1299         [ +  + ]:            300 :                     else if (strcmp($1, "nocreatedb") == 0)
 1212 peter@eisentraut.org     1300                 :             23 :                         $$ = makeDefElem("createdb", (Node *) makeBoolean(false), @1);
 5289 rhaas@postgresql.org     1301         [ +  + ]:            277 :                     else if (strcmp($1, "login") == 0)
 1212 peter@eisentraut.org     1302                 :            141 :                         $$ = makeDefElem("canlogin", (Node *) makeBoolean(true), @1);
 5289 rhaas@postgresql.org     1303         [ +  + ]:            136 :                     else if (strcmp($1, "nologin") == 0)
 1212 peter@eisentraut.org     1304                 :             43 :                         $$ = makeDefElem("canlogin", (Node *) makeBoolean(false), @1);
 4005 sfrost@snowman.net       1305         [ +  + ]:             93 :                     else if (strcmp($1, "bypassrls") == 0)
 1212 peter@eisentraut.org     1306                 :             41 :                         $$ = makeDefElem("bypassrls", (Node *) makeBoolean(true), @1);
 4005 sfrost@snowman.net       1307         [ +  + ]:             52 :                     else if (strcmp($1, "nobypassrls") == 0)
 1212 peter@eisentraut.org     1308                 :             34 :                         $$ = makeDefElem("bypassrls", (Node *) makeBoolean(false), @1);
 5289 rhaas@postgresql.org     1309         [ +  - ]:             18 :                     else if (strcmp($1, "noinherit") == 0)
                               1310                 :                :                     {
                               1311                 :                :                         /*
                               1312                 :                :                          * Note that INHERIT is a keyword, so it's handled by main parser, but
                               1313                 :                :                          * NOINHERIT is handled here.
                               1314                 :                :                          */
 1212 peter@eisentraut.org     1315                 :             18 :                         $$ = makeDefElem("inherit", (Node *) makeBoolean(false), @1);
                               1316                 :                :                     }
                               1317                 :                :                     else
 5289 rhaas@postgresql.org     1318         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               1319                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               1320                 :                :                                  errmsg("unrecognized role option \"%s\"", $1),
                               1321                 :                :                                      parser_errposition(@1)));
                               1322                 :                :                 }
                               1323                 :                :         ;
                               1324                 :                : 
                               1325                 :                : CreateOptRoleElem:
 5813 alvherre@alvh.no-ip.     1326                 :CBC         519 :             AlterOptRoleElem            { $$ = $1; }
                               1327                 :                :             /* The following are not supported by ALTER ROLE/USER/GROUP */
                               1328                 :                :             | SYSID Iconst
                               1329                 :                :                 {
 1212 peter@eisentraut.org     1330                 :              3 :                     $$ = makeDefElem("sysid", (Node *) makeInteger($2), @1);
                               1331                 :                :                 }
                               1332                 :                :             | ADMIN role_list
                               1333                 :                :                 {
                               1334                 :             11 :                     $$ = makeDefElem("adminmembers", (Node *) $2, @1);
                               1335                 :                :                 }
                               1336                 :                :             | ROLE role_list
                               1337                 :                :                 {
                               1338                 :             11 :                     $$ = makeDefElem("rolemembers", (Node *) $2, @1);
                               1339                 :                :                 }
                               1340                 :                :             | IN_P ROLE role_list
                               1341                 :                :                 {
                               1342                 :             50 :                     $$ = makeDefElem("addroleto", (Node *) $3, @1);
                               1343                 :                :                 }
                               1344                 :                :             | IN_P GROUP_P role_list
                               1345                 :                :                 {
 1212 peter@eisentraut.org     1346                 :UBC           0 :                     $$ = makeDefElem("addroleto", (Node *) $3, @1);
                               1347                 :                :                 }
                               1348                 :                :         ;
                               1349                 :                : 
                               1350                 :                : 
                               1351                 :                : /*****************************************************************************
                               1352                 :                :  *
                               1353                 :                :  * Create a new Postgres DBMS user (role with implied login ability)
                               1354                 :                :  *
                               1355                 :                :  *****************************************************************************/
                               1356                 :                : 
                               1357                 :                : CreateUserStmt:
                               1358                 :                :             CREATE USER RoleId opt_with OptRoleList
                               1359                 :                :                 {
 7375 tgl@sss.pgh.pa.us        1360                 :CBC         227 :                     CreateRoleStmt *n = makeNode(CreateRoleStmt);
                               1361                 :                : 
 7347                          1362                 :            227 :                     n->stmt_type = ROLESTMT_USER;
 7375                          1363                 :            227 :                     n->role = $3;
 7347                          1364                 :            227 :                     n->options = $5;
 1212 peter@eisentraut.org     1365                 :            227 :                     $$ = (Node *) n;
                               1366                 :                :                 }
                               1367                 :                :         ;
                               1368                 :                : 
                               1369                 :                : 
                               1370                 :                : /*****************************************************************************
                               1371                 :                :  *
                               1372                 :                :  * Alter a postgresql DBMS role
                               1373                 :                :  *
                               1374                 :                :  *****************************************************************************/
                               1375                 :                : 
                               1376                 :                : AlterRoleStmt:
                               1377                 :                :             ALTER ROLE RoleSpec opt_with AlterOptRoleList
                               1378                 :                :                  {
 7375 tgl@sss.pgh.pa.us        1379                 :            163 :                     AlterRoleStmt *n = makeNode(AlterRoleStmt);
                               1380                 :                : 
                               1381                 :            163 :                     n->role = $3;
 7347                          1382                 :            163 :                     n->action = +1;  /* add, if there are members */
 7375                          1383                 :            163 :                     n->options = $5;
 1212 peter@eisentraut.org     1384                 :            163 :                     $$ = (Node *) n;
                               1385                 :                :                  }
                               1386                 :                :             | ALTER USER RoleSpec opt_with AlterOptRoleList
                               1387                 :                :                  {
 2959 peter_e@gmx.net          1388                 :             43 :                     AlterRoleStmt *n = makeNode(AlterRoleStmt);
                               1389                 :                : 
                               1390                 :             43 :                     n->role = $3;
                               1391                 :             43 :                     n->action = +1;  /* add, if there are members */
                               1392                 :             43 :                     n->options = $5;
 1212 peter@eisentraut.org     1393                 :             43 :                     $$ = (Node *) n;
                               1394                 :                :                  }
                               1395                 :                :         ;
                               1396                 :                : 
                               1397                 :                : opt_in_database:
 5813 alvherre@alvh.no-ip.     1398                 :             46 :                /* EMPTY */                  { $$ = NULL; }
 1914 peter@eisentraut.org     1399                 :              2 :             | IN_P DATABASE name    { $$ = $3; }
                               1400                 :                :         ;
                               1401                 :                : 
                               1402                 :                : AlterRoleSetStmt:
                               1403                 :                :             ALTER ROLE RoleSpec opt_in_database SetResetClause
                               1404                 :                :                 {
 7375 tgl@sss.pgh.pa.us        1405                 :             29 :                     AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt);
                               1406                 :                : 
                               1407                 :             29 :                     n->role = $3;
 5813 alvherre@alvh.no-ip.     1408                 :             29 :                     n->database = $4;
                               1409                 :             29 :                     n->setstmt = $5;
 1212 peter@eisentraut.org     1410                 :             29 :                     $$ = (Node *) n;
                               1411                 :                :                 }
                               1412                 :                :             | ALTER ROLE ALL opt_in_database SetResetClause
                               1413                 :                :                 {
 4584 peter_e@gmx.net          1414                 :              2 :                     AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt);
                               1415                 :                : 
                               1416                 :              2 :                     n->role = NULL;
                               1417                 :              2 :                     n->database = $4;
                               1418                 :              2 :                     n->setstmt = $5;
 1212 peter@eisentraut.org     1419                 :              2 :                     $$ = (Node *) n;
                               1420                 :                :                 }
                               1421                 :                :             | ALTER USER RoleSpec opt_in_database SetResetClause
                               1422                 :                :                 {
 2959 peter_e@gmx.net          1423                 :             13 :                     AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt);
                               1424                 :                : 
 7375 tgl@sss.pgh.pa.us        1425                 :             13 :                     n->role = $3;
 2959 peter_e@gmx.net          1426                 :             13 :                     n->database = $4;
                               1427                 :             13 :                     n->setstmt = $5;
 1212 peter@eisentraut.org     1428                 :             13 :                     $$ = (Node *) n;
                               1429                 :                :                 }
                               1430                 :                :             | ALTER USER ALL opt_in_database SetResetClause
                               1431                 :                :                 {
 7375 tgl@sss.pgh.pa.us        1432                 :              2 :                     AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt);
                               1433                 :                : 
 2959 peter_e@gmx.net          1434                 :              2 :                     n->role = NULL;
                               1435                 :              2 :                     n->database = $4;
                               1436                 :              2 :                     n->setstmt = $5;
 1212 peter@eisentraut.org     1437                 :              2 :                     $$ = (Node *) n;
                               1438                 :                :                 }
                               1439                 :                :         ;
                               1440                 :                : 
                               1441                 :                : 
                               1442                 :                : /*****************************************************************************
                               1443                 :                :  *
                               1444                 :                :  * Drop a postgresql DBMS role
                               1445                 :                :  *
                               1446                 :                :  * XXX Ideally this would have CASCADE/RESTRICT options, but a role
                               1447                 :                :  * might own objects in multiple databases, and there is presently no way to
                               1448                 :                :  * implement cascading to other databases.  So we always behave as RESTRICT.
                               1449                 :                :  *****************************************************************************/
                               1450                 :                : 
                               1451                 :                : DropRoleStmt:
                               1452                 :                :             DROP ROLE role_list
                               1453                 :                :                 {
 7375 tgl@sss.pgh.pa.us        1454                 :            555 :                     DropRoleStmt *n = makeNode(DropRoleStmt);
                               1455                 :                : 
 2943 peter_e@gmx.net          1456                 :            555 :                     n->missing_ok = false;
 7375 tgl@sss.pgh.pa.us        1457                 :            555 :                     n->roles = $3;
 1212 peter@eisentraut.org     1458                 :            555 :                     $$ = (Node *) n;
                               1459                 :                :                 }
                               1460                 :                :             | DROP ROLE IF_P EXISTS role_list
                               1461                 :                :                 {
 7154 andrew@dunslane.net      1462                 :             67 :                     DropRoleStmt *n = makeNode(DropRoleStmt);
                               1463                 :                : 
 2943 peter_e@gmx.net          1464                 :             67 :                     n->missing_ok = true;
 7154 andrew@dunslane.net      1465                 :             67 :                     n->roles = $5;
 1212 peter@eisentraut.org     1466                 :             67 :                     $$ = (Node *) n;
                               1467                 :                :                 }
                               1468                 :                :             | DROP USER role_list
                               1469                 :                :                 {
 7375 tgl@sss.pgh.pa.us        1470                 :            203 :                     DropRoleStmt *n = makeNode(DropRoleStmt);
                               1471                 :                : 
 2943 peter_e@gmx.net          1472                 :            203 :                     n->missing_ok = false;
 7375 tgl@sss.pgh.pa.us        1473                 :            203 :                     n->roles = $3;
 1212 peter@eisentraut.org     1474                 :            203 :                     $$ = (Node *) n;
                               1475                 :                :                 }
                               1476                 :                :             | DROP USER IF_P EXISTS role_list
                               1477                 :                :                 {
 7154 andrew@dunslane.net      1478                 :             18 :                     DropRoleStmt *n = makeNode(DropRoleStmt);
                               1479                 :                : 
                               1480                 :             18 :                     n->roles = $5;
 2943 peter_e@gmx.net          1481                 :             18 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     1482                 :             18 :                     $$ = (Node *) n;
                               1483                 :                :                 }
                               1484                 :                :             | DROP GROUP_P role_list
                               1485                 :                :                 {
 2959 peter_e@gmx.net          1486                 :             18 :                     DropRoleStmt *n = makeNode(DropRoleStmt);
                               1487                 :                : 
 2943                          1488                 :             18 :                     n->missing_ok = false;
 2959                          1489                 :             18 :                     n->roles = $3;
 1212 peter@eisentraut.org     1490                 :             18 :                     $$ = (Node *) n;
                               1491                 :                :                 }
                               1492                 :                :             | DROP GROUP_P IF_P EXISTS role_list
                               1493                 :                :                 {
 2959 peter_e@gmx.net          1494                 :              3 :                     DropRoleStmt *n = makeNode(DropRoleStmt);
                               1495                 :                : 
 2943                          1496                 :              3 :                     n->missing_ok = true;
 2959                          1497                 :              3 :                     n->roles = $5;
 1212 peter@eisentraut.org     1498                 :              3 :                     $$ = (Node *) n;
                               1499                 :                :                 }
                               1500                 :                :             ;
                               1501                 :                : 
                               1502                 :                : 
                               1503                 :                : /*****************************************************************************
                               1504                 :                :  *
                               1505                 :                :  * Create a postgresql group (role without login ability)
                               1506                 :                :  *
                               1507                 :                :  *****************************************************************************/
                               1508                 :                : 
                               1509                 :                : CreateGroupStmt:
                               1510                 :                :             CREATE GROUP_P RoleId opt_with OptRoleList
                               1511                 :                :                 {
 7375 tgl@sss.pgh.pa.us        1512                 :             12 :                     CreateRoleStmt *n = makeNode(CreateRoleStmt);
                               1513                 :                : 
 7347                          1514                 :             12 :                     n->stmt_type = ROLESTMT_GROUP;
 7375                          1515                 :             12 :                     n->role = $3;
 8822                          1516                 :             12 :                     n->options = $5;
 1212 peter@eisentraut.org     1517                 :             12 :                     $$ = (Node *) n;
                               1518                 :                :                 }
                               1519                 :                :         ;
                               1520                 :                : 
                               1521                 :                : 
                               1522                 :                : /*****************************************************************************
                               1523                 :                :  *
                               1524                 :                :  * Alter a postgresql group
                               1525                 :                :  *
                               1526                 :                :  *****************************************************************************/
                               1527                 :                : 
                               1528                 :                : AlterGroupStmt:
                               1529                 :                :             ALTER GROUP_P RoleSpec add_drop USER role_list
                               1530                 :                :                 {
 7375 tgl@sss.pgh.pa.us        1531                 :             21 :                     AlterRoleStmt *n = makeNode(AlterRoleStmt);
                               1532                 :                : 
                               1533                 :             21 :                     n->role = $3;
 8482 bruce@momjian.us         1534                 :             21 :                     n->action = $4;
 7375 tgl@sss.pgh.pa.us        1535                 :             21 :                     n->options = list_make1(makeDefElem("rolemembers",
                               1536                 :                :                                                         (Node *) $6, @6));
 1212 peter@eisentraut.org     1537                 :             21 :                     $$ = (Node *) n;
                               1538                 :                :                 }
                               1539                 :                :         ;
                               1540                 :                : 
 6801 tgl@sss.pgh.pa.us        1541                 :             43 : add_drop:   ADD_P                                   { $$ = +1; }
 7375                          1542                 :            112 :             | DROP                                  { $$ = -1; }
                               1543                 :                :         ;
                               1544                 :                : 
                               1545                 :                : 
                               1546                 :                : /*****************************************************************************
                               1547                 :                :  *
                               1548                 :                :  * Manipulate a schema
                               1549                 :                :  *
                               1550                 :                :  *****************************************************************************/
                               1551                 :                : 
                               1552                 :                : CreateSchemaStmt:
                               1553                 :                :             CREATE SCHEMA opt_single_name AUTHORIZATION RoleSpec OptSchemaEltList
                               1554                 :                :                 {
 8570                          1555                 :             79 :                     CreateSchemaStmt *n = makeNode(CreateSchemaStmt);
                               1556                 :                : 
                               1557                 :                :                     /* One can omit the schema name or the authorization id. */
 3834 alvherre@alvh.no-ip.     1558                 :             79 :                     n->schemaname = $3;
                               1559                 :             79 :                     n->authrole = $5;
 7610 tgl@sss.pgh.pa.us        1560                 :             79 :                     n->schemaElts = $6;
 4721                          1561                 :             79 :                     n->if_not_exists = false;
 1212 peter@eisentraut.org     1562                 :             79 :                     $$ = (Node *) n;
                               1563                 :                :                 }
                               1564                 :                :             | CREATE SCHEMA ColId OptSchemaEltList
                               1565                 :                :                 {
 8570 tgl@sss.pgh.pa.us        1566                 :            426 :                     CreateSchemaStmt *n = makeNode(CreateSchemaStmt);
                               1567                 :                : 
                               1568                 :                :                     /* ...but not both */
                               1569                 :            426 :                     n->schemaname = $3;
 3834 alvherre@alvh.no-ip.     1570                 :            426 :                     n->authrole = NULL;
 7610 tgl@sss.pgh.pa.us        1571                 :            426 :                     n->schemaElts = $4;
 4721                          1572                 :            426 :                     n->if_not_exists = false;
 1212 peter@eisentraut.org     1573                 :            426 :                     $$ = (Node *) n;
                               1574                 :                :                 }
                               1575                 :                :             | CREATE SCHEMA IF_P NOT EXISTS opt_single_name AUTHORIZATION RoleSpec OptSchemaEltList
                               1576                 :                :                 {
 4721 tgl@sss.pgh.pa.us        1577                 :              9 :                     CreateSchemaStmt *n = makeNode(CreateSchemaStmt);
                               1578                 :                : 
                               1579                 :                :                     /* schema name can be omitted here, too */
 3834 alvherre@alvh.no-ip.     1580                 :              9 :                     n->schemaname = $6;
                               1581                 :              9 :                     n->authrole = $8;
 4721 tgl@sss.pgh.pa.us        1582         [ -  + ]:              9 :                     if ($9 != NIL)
 4721 tgl@sss.pgh.pa.us        1583         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               1584                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               1585                 :                :                                  errmsg("CREATE SCHEMA IF NOT EXISTS cannot include schema elements"),
                               1586                 :                :                                  parser_errposition(@9)));
 4721 tgl@sss.pgh.pa.us        1587                 :CBC           9 :                     n->schemaElts = $9;
                               1588                 :              9 :                     n->if_not_exists = true;
 1212 peter@eisentraut.org     1589                 :              9 :                     $$ = (Node *) n;
                               1590                 :                :                 }
                               1591                 :                :             | CREATE SCHEMA IF_P NOT EXISTS ColId OptSchemaEltList
                               1592                 :                :                 {
 4721 tgl@sss.pgh.pa.us        1593                 :             17 :                     CreateSchemaStmt *n = makeNode(CreateSchemaStmt);
                               1594                 :                : 
                               1595                 :                :                     /* ...but not here */
                               1596                 :             17 :                     n->schemaname = $6;
 3834 alvherre@alvh.no-ip.     1597                 :             17 :                     n->authrole = NULL;
 4721 tgl@sss.pgh.pa.us        1598         [ +  + ]:             17 :                     if ($7 != NIL)
                               1599         [ +  - ]:              3 :                         ereport(ERROR,
                               1600                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               1601                 :                :                                  errmsg("CREATE SCHEMA IF NOT EXISTS cannot include schema elements"),
                               1602                 :                :                                  parser_errposition(@7)));
                               1603                 :             14 :                     n->schemaElts = $7;
                               1604                 :             14 :                     n->if_not_exists = true;
 1212 peter@eisentraut.org     1605                 :             14 :                     $$ = (Node *) n;
                               1606                 :                :                 }
                               1607                 :                :         ;
                               1608                 :                : 
                               1609                 :                : OptSchemaEltList:
                               1610                 :                :             OptSchemaEltList schema_stmt
                               1611                 :                :                 {
 4720 tgl@sss.pgh.pa.us        1612                 :            282 :                     $$ = lappend($1, $2);
                               1613                 :                :                 }
                               1614                 :                :             | /* EMPTY */
                               1615                 :            531 :                 { $$ = NIL; }
                               1616                 :                :         ;
                               1617                 :                : 
                               1618                 :                : /*
                               1619                 :                :  *  schema_stmt are the ones that can show up inside a CREATE SCHEMA
                               1620                 :                :  *  statement (in addition to by themselves).
                               1621                 :                :  */
                               1622                 :                : schema_stmt:
                               1623                 :                :             CreateStmt
                               1624                 :                :             | IndexStmt
                               1625                 :                :             | CreateSeqStmt
                               1626                 :                :             | CreateTrigStmt
                               1627                 :                :             | GrantStmt
                               1628                 :                :             | ViewStmt
                               1629                 :                :         ;
                               1630                 :                : 
                               1631                 :                : 
                               1632                 :                : /*****************************************************************************
                               1633                 :                :  *
                               1634                 :                :  * Set PG internal variable
                               1635                 :                :  *    SET name TO 'var_value'
                               1636                 :                :  * Include SQL syntax (thomas 1997-10-22):
                               1637                 :                :  *    SET TIME ZONE 'var_value'
                               1638                 :                :  *
                               1639                 :                :  *****************************************************************************/
                               1640                 :                : 
                               1641                 :                : VariableSetStmt:
                               1642                 :                :             SET set_rest
                               1643                 :                :                 {
 8513                          1644                 :          10875 :                     VariableSetStmt *n = $2;
                               1645                 :                : 
                               1646                 :          10875 :                     n->is_local = false;
10225 bruce@momjian.us         1647                 :          10875 :                     $$ = (Node *) n;
                               1648                 :                :                 }
                               1649                 :                :             | SET LOCAL set_rest
                               1650                 :                :                 {
 8513 tgl@sss.pgh.pa.us        1651                 :            622 :                     VariableSetStmt *n = $3;
                               1652                 :                : 
                               1653                 :            622 :                     n->is_local = true;
10225 bruce@momjian.us         1654                 :            622 :                     $$ = (Node *) n;
                               1655                 :                :                 }
                               1656                 :                :             | SET SESSION set_rest
                               1657                 :                :                 {
 8513 tgl@sss.pgh.pa.us        1658                 :             42 :                     VariableSetStmt *n = $3;
                               1659                 :                : 
                               1660                 :             42 :                     n->is_local = false;
10225 bruce@momjian.us         1661                 :             42 :                     $$ = (Node *) n;
                               1662                 :                :                 }
                               1663                 :                :         ;
                               1664                 :                : 
                               1665                 :                : set_rest:
                               1666                 :                :             TRANSACTION transaction_mode_list
                               1667                 :                :                 {
 4952 rhaas@postgresql.org     1668                 :            294 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1669                 :                : 
                               1670                 :            294 :                     n->kind = VAR_SET_MULTI;
                               1671                 :            294 :                     n->name = "TRANSACTION";
                               1672                 :            294 :                     n->args = $2;
  341 michael@paquier.xyz      1673                 :            294 :                     n->jumble_args = true;
                               1674                 :            294 :                     n->location = -1;
 4952 rhaas@postgresql.org     1675                 :            294 :                     $$ = n;
                               1676                 :                :                 }
                               1677                 :                :             | SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list
                               1678                 :                :                 {
                               1679                 :              9 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1680                 :                : 
                               1681                 :              9 :                     n->kind = VAR_SET_MULTI;
                               1682                 :              9 :                     n->name = "SESSION CHARACTERISTICS";
                               1683                 :              9 :                     n->args = $5;
  341 michael@paquier.xyz      1684                 :              9 :                     n->jumble_args = true;
                               1685                 :              9 :                     n->location = -1;
 4952 rhaas@postgresql.org     1686                 :              9 :                     $$ = n;
                               1687                 :                :                 }
                               1688                 :                :             | set_rest_more
                               1689                 :                :             ;
                               1690                 :                : 
                               1691                 :                : generic_set:
                               1692                 :                :             var_name TO var_list
                               1693                 :                :                 {
 9759 vadim4o@yahoo.com        1694                 :           2504 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1695                 :                : 
 6578 tgl@sss.pgh.pa.us        1696                 :           2504 :                     n->kind = VAR_SET_VALUE;
 8513                          1697                 :           2504 :                     n->name = $1;
                               1698                 :           2504 :                     n->args = $3;
  341 michael@paquier.xyz      1699                 :           2504 :                     n->location = @3;
 8513 tgl@sss.pgh.pa.us        1700                 :           2504 :                     $$ = n;
                               1701                 :                :                 }
                               1702                 :                :             | var_name '=' var_list
                               1703                 :                :                 {
 9052 peter_e@gmx.net          1704                 :           7512 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1705                 :                : 
 6578 tgl@sss.pgh.pa.us        1706                 :           7512 :                     n->kind = VAR_SET_VALUE;
 8513                          1707                 :           7512 :                     n->name = $1;
                               1708                 :           7512 :                     n->args = $3;
  341 michael@paquier.xyz      1709                 :           7512 :                     n->location = @3;
 1002 akorotkov@postgresql     1710                 :           7512 :                     $$ = n;
                               1711                 :                :                 }
                               1712                 :                :             | var_name TO DEFAULT
                               1713                 :                :                 {
 6578 tgl@sss.pgh.pa.us        1714                 :             68 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1715                 :                : 
                               1716                 :             68 :                     n->kind = VAR_SET_DEFAULT;
                               1717                 :             68 :                     n->name = $1;
  341 michael@paquier.xyz      1718                 :             68 :                     n->location = -1;
 6578 tgl@sss.pgh.pa.us        1719                 :             68 :                     $$ = n;
                               1720                 :                :                 }
                               1721                 :                :             | var_name '=' DEFAULT
                               1722                 :                :                 {
                               1723                 :              5 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1724                 :                : 
                               1725                 :              5 :                     n->kind = VAR_SET_DEFAULT;
                               1726                 :              5 :                     n->name = $1;
  341 michael@paquier.xyz      1727                 :              5 :                     n->location = -1;
 6578 tgl@sss.pgh.pa.us        1728                 :              5 :                     $$ = n;
                               1729                 :                :                 }
                               1730                 :                :         ;
                               1731                 :                : 
                               1732                 :                : set_rest_more:  /* Generic SET syntaxes: */
 1760 peter@eisentraut.org     1733                 :          10016 :             generic_set                         {$$ = $1;}
                               1734                 :                :             | var_name FROM CURRENT_P
                               1735                 :                :                 {
 6578 tgl@sss.pgh.pa.us        1736                 :              2 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1737                 :                : 
                               1738                 :              2 :                     n->kind = VAR_SET_CURRENT;
                               1739                 :              2 :                     n->name = $1;
  341 michael@paquier.xyz      1740                 :              2 :                     n->location = -1;
 6578 tgl@sss.pgh.pa.us        1741                 :              2 :                     $$ = n;
                               1742                 :                :                 }
                               1743                 :                :             /* Special syntaxes mandated by SQL standard: */
                               1744                 :                :             | TIME ZONE zone_value
                               1745                 :                :                 {
 9906 scrappy@hub.org          1746                 :             51 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1747                 :                : 
 6578 tgl@sss.pgh.pa.us        1748                 :             51 :                     n->kind = VAR_SET_VALUE;
 8513                          1749                 :             51 :                     n->name = "timezone";
  341 michael@paquier.xyz      1750                 :             51 :                     n->location = -1;
                               1751                 :             51 :                     n->jumble_args = true;
 8582 lockhart@fourpalms.o     1752         [ +  + ]:             51 :                     if ($3 != NULL)
 7769 neilc@samurai.com        1753                 :             43 :                         n->args = list_make1($3);
                               1754                 :                :                     else
 6578 tgl@sss.pgh.pa.us        1755                 :              8 :                         n->kind = VAR_SET_DEFAULT;
 8513                          1756                 :             51 :                     $$ = n;
                               1757                 :                :                 }
                               1758                 :                :             | CATALOG_P Sconst
                               1759                 :                :                 {
 6158 peter_e@gmx.net          1760         [ #  # ]:UBC           0 :                     ereport(ERROR,
                               1761                 :                :                             (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               1762                 :                :                              errmsg("current database cannot be changed"),
                               1763                 :                :                              parser_errposition(@2)));
                               1764                 :                :                     $$ = NULL; /*not reached*/
                               1765                 :                :                 }
                               1766                 :                :             | SCHEMA Sconst
                               1767                 :                :                 {
 6158 peter_e@gmx.net          1768                 :CBC           2 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1769                 :                : 
                               1770                 :              2 :                     n->kind = VAR_SET_VALUE;
                               1771                 :              2 :                     n->name = "search_path";
                               1772                 :              2 :                     n->args = list_make1(makeStringConst($2, @2));
  341 michael@paquier.xyz      1773                 :              2 :                     n->location = @2;
 6158 peter_e@gmx.net          1774                 :              2 :                     $$ = n;
                               1775                 :                :                 }
                               1776                 :                :             | NAMES opt_encoding
                               1777                 :                :                 {
 8513 tgl@sss.pgh.pa.us        1778                 :UBC           0 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1779                 :                : 
 6578                          1780                 :              0 :                     n->kind = VAR_SET_VALUE;
 8513                          1781                 :              0 :                     n->name = "client_encoding";
  341 michael@paquier.xyz      1782                 :              0 :                     n->location = @2;
 8513 tgl@sss.pgh.pa.us        1783         [ #  # ]:              0 :                     if ($2 != NULL)
 6218                          1784                 :              0 :                         n->args = list_make1(makeStringConst($2, @2));
                               1785                 :                :                     else
 6578                          1786                 :              0 :                         n->kind = VAR_SET_DEFAULT;
 8513                          1787                 :              0 :                     $$ = n;
                               1788                 :                :                 }
                               1789                 :                :             | ROLE NonReservedWord_or_Sconst
                               1790                 :                :                 {
 7348 tgl@sss.pgh.pa.us        1791                 :CBC         481 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1792                 :                : 
 6578                          1793                 :            481 :                     n->kind = VAR_SET_VALUE;
 7348                          1794                 :            481 :                     n->name = "role";
 6218                          1795                 :            481 :                     n->args = list_make1(makeStringConst($2, @2));
  341 michael@paquier.xyz      1796                 :            481 :                     n->location = @2;
 7348 tgl@sss.pgh.pa.us        1797                 :            481 :                     $$ = n;
                               1798                 :                :                 }
                               1799                 :                :             | SESSION AUTHORIZATION NonReservedWord_or_Sconst
                               1800                 :                :                 {
 8513                          1801                 :           1293 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1802                 :                : 
 6578                          1803                 :           1293 :                     n->kind = VAR_SET_VALUE;
 8513                          1804                 :           1293 :                     n->name = "session_authorization";
 6218                          1805                 :           1293 :                     n->args = list_make1(makeStringConst($3, @3));
  341 michael@paquier.xyz      1806                 :           1293 :                     n->location = @3;
 8513 tgl@sss.pgh.pa.us        1807                 :           1293 :                     $$ = n;
                               1808                 :                :                 }
                               1809                 :                :             | SESSION AUTHORIZATION DEFAULT
                               1810                 :                :                 {
 8524                          1811                 :              2 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1812                 :                : 
 6578                          1813                 :              2 :                     n->kind = VAR_SET_DEFAULT;
 8524                          1814                 :              2 :                     n->name = "session_authorization";
  341 michael@paquier.xyz      1815                 :              2 :                     n->location = -1;
 8513 tgl@sss.pgh.pa.us        1816                 :              2 :                     $$ = n;
                               1817                 :                :                 }
                               1818                 :                :             | XML_P OPTION document_or_content
                               1819                 :                :                 {
 6799 peter_e@gmx.net          1820                 :              8 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1821                 :                : 
 6578 tgl@sss.pgh.pa.us        1822                 :              8 :                     n->kind = VAR_SET_VALUE;
 6799 peter_e@gmx.net          1823                 :              8 :                     n->name = "xmloption";
 6218 tgl@sss.pgh.pa.us        1824         [ +  + ]:              8 :                     n->args = list_make1(makeStringConst($3 == XMLOPTION_DOCUMENT ? "DOCUMENT" : "CONTENT", @3));
  341 michael@paquier.xyz      1825                 :              8 :                     n->jumble_args = true;
                               1826                 :              8 :                     n->location = -1;
 6799 peter_e@gmx.net          1827                 :              8 :                     $$ = n;
                               1828                 :                :                 }
                               1829                 :                :             /* Special syntaxes invented by PostgreSQL: */
                               1830                 :                :             | TRANSACTION SNAPSHOT Sconst
                               1831                 :                :                 {
 5068 tgl@sss.pgh.pa.us        1832                 :             24 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1833                 :                : 
                               1834                 :             24 :                     n->kind = VAR_SET_MULTI;
                               1835                 :             24 :                     n->name = "TRANSACTION SNAPSHOT";
                               1836                 :             24 :                     n->args = list_make1(makeStringConst($3, @3));
  341 michael@paquier.xyz      1837                 :             24 :                     n->location = @3;
 5068 tgl@sss.pgh.pa.us        1838                 :             24 :                     $$ = n;
                               1839                 :                :                 }
                               1840                 :                :         ;
                               1841                 :                : 
 6578                          1842                 :          12449 : var_name:   ColId                               { $$ = $1; }
                               1843                 :                :             | var_name '.' ColId
 4346 peter_e@gmx.net          1844                 :            255 :                 { $$ = psprintf("%s.%s", $1, $3); }
                               1845                 :                :         ;
                               1846                 :                : 
 7769 neilc@samurai.com        1847                 :          10016 : var_list:   var_value                               { $$ = list_make1($1); }
 8482 bruce@momjian.us         1848                 :             91 :             | var_list ',' var_value                { $$ = lappend($1, $3); }
                               1849                 :                :         ;
                               1850                 :                : 
                               1851                 :                : var_value:  opt_boolean_or_string
 6218 tgl@sss.pgh.pa.us        1852                 :           7436 :                 { $$ = makeStringConst($1, @1); }
                               1853                 :                :             | NumericOnly
                               1854                 :           2671 :                 { $$ = makeAConst($1, @1); }
                               1855                 :                :         ;
                               1856                 :                : 
 7975 peter_e@gmx.net          1857                 :UBC           0 : iso_level:  READ UNCOMMITTED                        { $$ = "read uncommitted"; }
 7975 peter_e@gmx.net          1858                 :CBC         465 :             | READ COMMITTED                        { $$ = "read committed"; }
                               1859                 :           1309 :             | REPEATABLE READ                       { $$ = "repeatable read"; }
 8482 bruce@momjian.us         1860                 :           1598 :             | SERIALIZABLE                          { $$ = "serializable"; }
                               1861                 :                :         ;
                               1862                 :                : 
                               1863                 :                : opt_boolean_or_string:
                               1864                 :            348 :             TRUE_P                                  { $$ = "true"; }
                               1865                 :            746 :             | FALSE_P                               { $$ = "false"; }
                               1866                 :           1124 :             | ON                                    { $$ = "on"; }
                               1867                 :                :             /*
                               1868                 :                :              * OFF is also accepted as a boolean value, but is handled by
                               1869                 :                :              * the NonReservedWord rule.  The action for booleans and strings
                               1870                 :                :              * is the same, so we don't need to distinguish them here.
                               1871                 :                :              */
 4479 tgl@sss.pgh.pa.us        1872                 :          15219 :             | NonReservedWord_or_Sconst             { $$ = $1; }
                               1873                 :                :         ;
                               1874                 :                : 
                               1875                 :                : /* Timezone values can be:
                               1876                 :                :  * - a string such as 'pst8pdt'
                               1877                 :                :  * - an identifier such as "pst8pdt"
                               1878                 :                :  * - an integer or floating point number
                               1879                 :                :  * - a time interval per SQL99
                               1880                 :                :  * ColId gives reduce/reduce errors against ConstInterval and LOCAL,
                               1881                 :                :  * so use IDENT (meaning we reject anything that is a key word).
                               1882                 :                :  */
                               1883                 :                : zone_value:
                               1884                 :                :             Sconst
                               1885                 :                :                 {
 6218                          1886                 :             30 :                     $$ = makeStringConst($1, @1);
                               1887                 :                :                 }
                               1888                 :                :             | IDENT
                               1889                 :                :                 {
                               1890                 :              1 :                     $$ = makeStringConst($1, @1);
                               1891                 :                :                 }
                               1892                 :                :             | ConstInterval Sconst opt_interval
                               1893                 :                :                 {
 1212 peter@eisentraut.org     1894                 :UBC           0 :                     TypeName   *t = $1;
                               1895                 :                : 
 6204 tgl@sss.pgh.pa.us        1896         [ #  # ]:              0 :                     if ($3 != NIL)
                               1897                 :                :                     {
 1212 peter@eisentraut.org     1898                 :              0 :                         A_Const    *n = (A_Const *) linitial($3);
                               1899                 :                : 
 1331                          1900         [ #  # ]:              0 :                         if ((n->val.ival.ival & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0)
 8085 tgl@sss.pgh.pa.us        1901         [ #  # ]:              0 :                             ereport(ERROR,
                               1902                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                               1903                 :                :                                      errmsg("time zone interval must be HOUR or HOUR TO MINUTE"),
                               1904                 :                :                                      parser_errposition(@3)));
                               1905                 :                :                     }
 6204                          1906                 :              0 :                     t->typmods = $3;
 6218                          1907                 :              0 :                     $$ = makeStringConstCast($2, @2, t);
                               1908                 :                :                 }
                               1909                 :                :             | ConstInterval '(' Iconst ')' Sconst
                               1910                 :                :                 {
 1212 peter@eisentraut.org     1911                 :              0 :                     TypeName   *t = $1;
                               1912                 :                : 
 3976 bruce@momjian.us         1913                 :              0 :                     t->typmods = list_make2(makeIntConst(INTERVAL_FULL_RANGE, -1),
                               1914                 :                :                                             makeIntConst($3, @3));
 6218 tgl@sss.pgh.pa.us        1915                 :              0 :                     $$ = makeStringConstCast($5, @5, t);
                               1916                 :                :                 }
 6218 tgl@sss.pgh.pa.us        1917                 :CBC          12 :             | NumericOnly                           { $$ = makeAConst($1, @1); }
 8482 bruce@momjian.us         1918                 :              7 :             | DEFAULT                               { $$ = NULL; }
                               1919                 :              1 :             | LOCAL                                 { $$ = NULL; }
                               1920                 :                :         ;
                               1921                 :                : 
                               1922                 :                : opt_encoding:
 8482 bruce@momjian.us         1923                 :UBC           0 :             Sconst                                  { $$ = $1; }
                               1924                 :              0 :             | DEFAULT                               { $$ = NULL; }
                               1925                 :              0 :             | /*EMPTY*/                             { $$ = NULL; }
                               1926                 :                :         ;
                               1927                 :                : 
                               1928                 :                : NonReservedWord_or_Sconst:
 4479 tgl@sss.pgh.pa.us        1929                 :CBC       26719 :             NonReservedWord                         { $$ = $1; }
 6142 meskes@postgresql.or     1930                 :           2734 :             | Sconst                                { $$ = $1; }
                               1931                 :                :         ;
                               1932                 :                : 
                               1933                 :                : VariableResetStmt:
 4022 fujii@postgresql.org     1934                 :           2315 :             RESET reset_rest                        { $$ = (Node *) $2; }
                               1935                 :                :         ;
                               1936                 :                : 
                               1937                 :                : reset_rest:
                               1938                 :           1913 :             generic_reset                           { $$ = $1; }
                               1939                 :                :             | TIME ZONE
                               1940                 :                :                 {
 6578 tgl@sss.pgh.pa.us        1941                 :              7 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1942                 :                : 
                               1943                 :              7 :                     n->kind = VAR_RESET;
 4022 fujii@postgresql.org     1944                 :              7 :                     n->name = "timezone";
  341 michael@paquier.xyz      1945                 :              7 :                     n->location = -1;
 4022 fujii@postgresql.org     1946                 :              7 :                     $$ = n;
                               1947                 :                :                 }
                               1948                 :                :             | TRANSACTION ISOLATION LEVEL
                               1949                 :                :                 {
 6578 tgl@sss.pgh.pa.us        1950                 :UBC           0 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1951                 :                : 
                               1952                 :              0 :                     n->kind = VAR_RESET;
 4022 fujii@postgresql.org     1953                 :              0 :                     n->name = "transaction_isolation";
  341 michael@paquier.xyz      1954                 :              0 :                     n->location = -1;
 4022 fujii@postgresql.org     1955                 :              0 :                     $$ = n;
                               1956                 :                :                 }
                               1957                 :                :             | SESSION AUTHORIZATION
                               1958                 :                :                 {
 6578 tgl@sss.pgh.pa.us        1959                 :CBC         395 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1960                 :                : 
                               1961                 :            395 :                     n->kind = VAR_RESET;
 4022 fujii@postgresql.org     1962                 :            395 :                     n->name = "session_authorization";
  341 michael@paquier.xyz      1963                 :            395 :                     n->location = -1;
 4022 fujii@postgresql.org     1964                 :            395 :                     $$ = n;
                               1965                 :                :                 }
                               1966                 :                :         ;
                               1967                 :                : 
                               1968                 :                : generic_reset:
                               1969                 :                :             var_name
                               1970                 :                :                 {
 6578 tgl@sss.pgh.pa.us        1971                 :           1930 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1972                 :                : 
                               1973                 :           1930 :                     n->kind = VAR_RESET;
 4022 fujii@postgresql.org     1974                 :           1930 :                     n->name = $1;
  341 michael@paquier.xyz      1975                 :           1930 :                     n->location = -1;
 4022 fujii@postgresql.org     1976                 :           1930 :                     $$ = n;
                               1977                 :                :                 }
                               1978                 :                :             | ALL
                               1979                 :                :                 {
 6578 tgl@sss.pgh.pa.us        1980                 :             14 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1981                 :                : 
                               1982                 :             14 :                     n->kind = VAR_RESET_ALL;
  341 michael@paquier.xyz      1983                 :             14 :                     n->location = -1;
 4022 fujii@postgresql.org     1984                 :             14 :                     $$ = n;
                               1985                 :                :                 }
                               1986                 :                :         ;
                               1987                 :                : 
                               1988                 :                : /* SetResetClause allows SET or RESET without LOCAL */
                               1989                 :                : SetResetClause:
 6578 tgl@sss.pgh.pa.us        1990                 :            586 :             SET set_rest                    { $$ = $2; }
                               1991                 :             25 :             | VariableResetStmt             { $$ = (VariableSetStmt *) $1; }
                               1992                 :                :         ;
                               1993                 :                : 
                               1994                 :                : /* SetResetClause allows SET or RESET without LOCAL */
                               1995                 :                : FunctionSetResetClause:
 4952 rhaas@postgresql.org     1996                 :             57 :             SET set_rest_more               { $$ = $2; }
                               1997                 :              6 :             | VariableResetStmt             { $$ = (VariableSetStmt *) $1; }
                               1998                 :                :         ;
                               1999                 :                : 
                               2000                 :                : 
                               2001                 :                : VariableShowStmt:
                               2002                 :                :             SHOW var_name
                               2003                 :                :                 {
 6578 tgl@sss.pgh.pa.us        2004                 :            428 :                     VariableShowStmt *n = makeNode(VariableShowStmt);
                               2005                 :                : 
 8513                          2006                 :            428 :                     n->name = $2;
10225 bruce@momjian.us         2007                 :            428 :                     $$ = (Node *) n;
                               2008                 :                :                 }
                               2009                 :                :             | SHOW TIME ZONE
                               2010                 :                :                 {
 6578 tgl@sss.pgh.pa.us        2011                 :              4 :                     VariableShowStmt *n = makeNode(VariableShowStmt);
                               2012                 :                : 
 8513                          2013                 :              4 :                     n->name = "timezone";
10173 lockhart@fourpalms.o     2014                 :              4 :                     $$ = (Node *) n;
                               2015                 :                :                 }
                               2016                 :                :             | SHOW TRANSACTION ISOLATION LEVEL
                               2017                 :                :                 {
 6578 tgl@sss.pgh.pa.us        2018                 :              1 :                     VariableShowStmt *n = makeNode(VariableShowStmt);
                               2019                 :                : 
 8275 peter_e@gmx.net          2020                 :              1 :                     n->name = "transaction_isolation";
 9759 vadim4o@yahoo.com        2021                 :              1 :                     $$ = (Node *) n;
                               2022                 :                :                 }
                               2023                 :                :             | SHOW SESSION AUTHORIZATION
                               2024                 :                :                 {
 6578 tgl@sss.pgh.pa.us        2025                 :UBC           0 :                     VariableShowStmt *n = makeNode(VariableShowStmt);
                               2026                 :                : 
 8524                          2027                 :              0 :                     n->name = "session_authorization";
                               2028                 :              0 :                     $$ = (Node *) n;
                               2029                 :                :                 }
                               2030                 :                :             | SHOW ALL
                               2031                 :                :                 {
 6578                          2032                 :              0 :                     VariableShowStmt *n = makeNode(VariableShowStmt);
                               2033                 :                : 
 8513                          2034                 :              0 :                     n->name = "all";
 8857 bruce@momjian.us         2035                 :              0 :                     $$ = (Node *) n;
                               2036                 :                :                 }
                               2037                 :                :         ;
                               2038                 :                : 
                               2039                 :                : 
                               2040                 :                : ConstraintsSetStmt:
                               2041                 :                :             SET CONSTRAINTS constraints_set_list constraints_set_mode
                               2042                 :                :                 {
 9474 JanWieck@Yahoo.com       2043                 :CBC          52 :                     ConstraintsSetStmt *n = makeNode(ConstraintsSetStmt);
                               2044                 :                : 
                               2045                 :             52 :                     n->constraints = $3;
 5058 peter_e@gmx.net          2046                 :             52 :                     n->deferred = $4;
 9474 JanWieck@Yahoo.com       2047                 :             52 :                     $$ = (Node *) n;
                               2048                 :                :                 }
                               2049                 :                :         ;
                               2050                 :                : 
                               2051                 :                : constraints_set_list:
 8482 bruce@momjian.us         2052                 :             28 :             ALL                                     { $$ = NIL; }
 7072                          2053                 :             24 :             | qualified_name_list                   { $$ = $1; }
                               2054                 :                :         ;
                               2055                 :                : 
                               2056                 :                : constraints_set_mode:
 2943 peter_e@gmx.net          2057                 :             34 :             DEFERRED                                { $$ = true; }
                               2058                 :             18 :             | IMMEDIATE                             { $$ = false; }
                               2059                 :                :         ;
                               2060                 :                : 
                               2061                 :                : 
                               2062                 :                : /*
                               2063                 :                :  * Checkpoint statement
                               2064                 :                :  */
                               2065                 :                : CheckPointStmt:
                               2066                 :                :             CHECKPOINT opt_utility_option_list
                               2067                 :                :                 {
 9071 vadim4o@yahoo.com        2068                 :            125 :                     CheckPointStmt *n = makeNode(CheckPointStmt);
                               2069                 :                : 
 1212 peter@eisentraut.org     2070                 :            125 :                     $$ = (Node *) n;
   43 alvherre@kurilemu.de     2071                 :GNC         125 :                     n->options = $2;
                               2072                 :                :                 }
                               2073                 :                :         ;
                               2074                 :                : 
                               2075                 :                : 
                               2076                 :                : /*****************************************************************************
                               2077                 :                :  *
                               2078                 :                :  * DISCARD { ALL | TEMP | PLANS | SEQUENCES }
                               2079                 :                :  *
                               2080                 :                :  *****************************************************************************/
                               2081                 :                : 
                               2082                 :                : DiscardStmt:
                               2083                 :                :             DISCARD ALL
                               2084                 :                :                 {
 6708 neilc@samurai.com        2085                 :CBC           3 :                     DiscardStmt *n = makeNode(DiscardStmt);
                               2086                 :                : 
                               2087                 :              3 :                     n->target = DISCARD_ALL;
                               2088                 :              3 :                     $$ = (Node *) n;
                               2089                 :                :                 }
                               2090                 :                :             | DISCARD TEMP
                               2091                 :                :                 {
                               2092                 :              4 :                     DiscardStmt *n = makeNode(DiscardStmt);
                               2093                 :                : 
                               2094                 :              4 :                     n->target = DISCARD_TEMP;
                               2095                 :              4 :                     $$ = (Node *) n;
                               2096                 :                :                 }
                               2097                 :                :             | DISCARD TEMPORARY
                               2098                 :                :                 {
 6708 neilc@samurai.com        2099                 :UBC           0 :                     DiscardStmt *n = makeNode(DiscardStmt);
                               2100                 :                : 
                               2101                 :              0 :                     n->target = DISCARD_TEMP;
                               2102                 :              0 :                     $$ = (Node *) n;
                               2103                 :                :                 }
                               2104                 :                :             | DISCARD PLANS
                               2105                 :                :                 {
 6708 neilc@samurai.com        2106                 :CBC           2 :                     DiscardStmt *n = makeNode(DiscardStmt);
                               2107                 :                : 
                               2108                 :              2 :                     n->target = DISCARD_PLANS;
                               2109                 :              2 :                     $$ = (Node *) n;
                               2110                 :                :                 }
                               2111                 :                :             | DISCARD SEQUENCES
                               2112                 :                :                 {
 4356 rhaas@postgresql.org     2113                 :              6 :                     DiscardStmt *n = makeNode(DiscardStmt);
                               2114                 :                : 
                               2115                 :              6 :                     n->target = DISCARD_SEQUENCES;
                               2116                 :              6 :                     $$ = (Node *) n;
                               2117                 :                :                 }
                               2118                 :                : 
                               2119                 :                :         ;
                               2120                 :                : 
                               2121                 :                : 
                               2122                 :                : /*****************************************************************************
                               2123                 :                :  *
                               2124                 :                :  *  ALTER [ TABLE | INDEX | SEQUENCE | VIEW | MATERIALIZED VIEW | FOREIGN TABLE ] variations
                               2125                 :                :  *
                               2126                 :                :  * Note: we accept all subcommands for each of the variants, and sort
                               2127                 :                :  * out what's really legal at execution time.
                               2128                 :                :  *****************************************************************************/
                               2129                 :                : 
                               2130                 :                : AlterTableStmt:
                               2131                 :                :             ALTER TABLE relation_expr alter_table_cmds
                               2132                 :                :                 {
 9335 lockhart@fourpalms.o     2133                 :          13184 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2134                 :                : 
 8570 tgl@sss.pgh.pa.us        2135                 :          13184 :                     n->relation = $3;
 7794                          2136                 :          13184 :                     n->cmds = $4;
 1883 michael@paquier.xyz      2137                 :          13184 :                     n->objtype = OBJECT_TABLE;
 4975 simon@2ndQuadrant.co     2138                 :          13184 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     2139                 :          13184 :                     $$ = (Node *) n;
                               2140                 :                :                 }
                               2141                 :                :         |   ALTER TABLE IF_P EXISTS relation_expr alter_table_cmds
                               2142                 :                :                 {
 4975 simon@2ndQuadrant.co     2143                 :             27 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2144                 :                : 
                               2145                 :             27 :                     n->relation = $5;
                               2146                 :             27 :                     n->cmds = $6;
 1883 michael@paquier.xyz      2147                 :             27 :                     n->objtype = OBJECT_TABLE;
 4975 simon@2ndQuadrant.co     2148                 :             27 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     2149                 :             27 :                     $$ = (Node *) n;
                               2150                 :                :                 }
                               2151                 :                :         |   ALTER TABLE relation_expr partition_cmd
                               2152                 :                :                 {
 3195 rhaas@postgresql.org     2153                 :           1526 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2154                 :                : 
                               2155                 :           1526 :                     n->relation = $3;
                               2156                 :           1526 :                     n->cmds = list_make1($4);
 1883 michael@paquier.xyz      2157                 :           1526 :                     n->objtype = OBJECT_TABLE;
 3195 rhaas@postgresql.org     2158                 :           1526 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     2159                 :           1526 :                     $$ = (Node *) n;
                               2160                 :                :                 }
                               2161                 :                :         |   ALTER TABLE IF_P EXISTS relation_expr partition_cmd
                               2162                 :                :                 {
 3195 rhaas@postgresql.org     2163                 :UBC           0 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2164                 :                : 
                               2165                 :              0 :                     n->relation = $5;
                               2166                 :              0 :                     n->cmds = list_make1($6);
 1883 michael@paquier.xyz      2167                 :              0 :                     n->objtype = OBJECT_TABLE;
 3195 rhaas@postgresql.org     2168                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     2169                 :              0 :                     $$ = (Node *) n;
                               2170                 :                :                 }
                               2171                 :                :         |   ALTER TABLE ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
                               2172                 :                :                 {
                               2173                 :                :                     AlterTableMoveAllStmt *n =
 4034 sfrost@snowman.net       2174                 :CBC           6 :                         makeNode(AlterTableMoveAllStmt);
                               2175                 :                : 
                               2176                 :              6 :                     n->orig_tablespacename = $6;
                               2177                 :              6 :                     n->objtype = OBJECT_TABLE;
                               2178                 :              6 :                     n->roles = NIL;
                               2179                 :              6 :                     n->new_tablespacename = $9;
                               2180                 :              6 :                     n->nowait = $10;
 1212 peter@eisentraut.org     2181                 :              6 :                     $$ = (Node *) n;
                               2182                 :                :                 }
                               2183                 :                :         |   ALTER TABLE ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
                               2184                 :                :                 {
                               2185                 :                :                     AlterTableMoveAllStmt *n =
 4034 sfrost@snowman.net       2186                 :UBC           0 :                         makeNode(AlterTableMoveAllStmt);
                               2187                 :                : 
                               2188                 :              0 :                     n->orig_tablespacename = $6;
                               2189                 :              0 :                     n->objtype = OBJECT_TABLE;
                               2190                 :              0 :                     n->roles = $9;
                               2191                 :              0 :                     n->new_tablespacename = $12;
                               2192                 :              0 :                     n->nowait = $13;
 1212 peter@eisentraut.org     2193                 :              0 :                     $$ = (Node *) n;
                               2194                 :                :                 }
                               2195                 :                :         |   ALTER INDEX qualified_name alter_table_cmds
                               2196                 :                :                 {
 7687 bruce@momjian.us         2197                 :CBC         114 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2198                 :                : 
                               2199                 :            114 :                     n->relation = $3;
                               2200                 :            114 :                     n->cmds = $4;
 1883 michael@paquier.xyz      2201                 :            114 :                     n->objtype = OBJECT_INDEX;
 4975 simon@2ndQuadrant.co     2202                 :            114 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     2203                 :            114 :                     $$ = (Node *) n;
                               2204                 :                :                 }
                               2205                 :                :         |   ALTER INDEX IF_P EXISTS qualified_name alter_table_cmds
                               2206                 :                :                 {
 4975 simon@2ndQuadrant.co     2207                 :UBC           0 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2208                 :                : 
                               2209                 :              0 :                     n->relation = $5;
                               2210                 :              0 :                     n->cmds = $6;
 1883 michael@paquier.xyz      2211                 :              0 :                     n->objtype = OBJECT_INDEX;
 4975 simon@2ndQuadrant.co     2212                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     2213                 :              0 :                     $$ = (Node *) n;
                               2214                 :                :                 }
                               2215                 :                :         |   ALTER INDEX qualified_name index_partition_cmd
                               2216                 :                :                 {
 2787 alvherre@alvh.no-ip.     2217                 :CBC         199 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2218                 :                : 
                               2219                 :            199 :                     n->relation = $3;
                               2220                 :            199 :                     n->cmds = list_make1($4);
 1883 michael@paquier.xyz      2221                 :            199 :                     n->objtype = OBJECT_INDEX;
 2787 alvherre@alvh.no-ip.     2222                 :            199 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     2223                 :            199 :                     $$ = (Node *) n;
                               2224                 :                :                 }
                               2225                 :                :         |   ALTER INDEX ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
                               2226                 :                :                 {
                               2227                 :                :                     AlterTableMoveAllStmt *n =
 4034 sfrost@snowman.net       2228                 :              3 :                         makeNode(AlterTableMoveAllStmt);
                               2229                 :                : 
                               2230                 :              3 :                     n->orig_tablespacename = $6;
                               2231                 :              3 :                     n->objtype = OBJECT_INDEX;
                               2232                 :              3 :                     n->roles = NIL;
                               2233                 :              3 :                     n->new_tablespacename = $9;
                               2234                 :              3 :                     n->nowait = $10;
 1212 peter@eisentraut.org     2235                 :              3 :                     $$ = (Node *) n;
                               2236                 :                :                 }
                               2237                 :                :         |   ALTER INDEX ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
                               2238                 :                :                 {
                               2239                 :                :                     AlterTableMoveAllStmt *n =
 4034 sfrost@snowman.net       2240                 :UBC           0 :                         makeNode(AlterTableMoveAllStmt);
                               2241                 :                : 
                               2242                 :              0 :                     n->orig_tablespacename = $6;
                               2243                 :              0 :                     n->objtype = OBJECT_INDEX;
                               2244                 :              0 :                     n->roles = $9;
                               2245                 :              0 :                     n->new_tablespacename = $12;
                               2246                 :              0 :                     n->nowait = $13;
 1212 peter@eisentraut.org     2247                 :              0 :                     $$ = (Node *) n;
                               2248                 :                :                 }
                               2249                 :                :         |   ALTER SEQUENCE qualified_name alter_table_cmds
                               2250                 :                :                 {
 6292 tgl@sss.pgh.pa.us        2251                 :CBC          47 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2252                 :                : 
                               2253                 :             47 :                     n->relation = $3;
                               2254                 :             47 :                     n->cmds = $4;
 1883 michael@paquier.xyz      2255                 :             47 :                     n->objtype = OBJECT_SEQUENCE;
 4975 simon@2ndQuadrant.co     2256                 :             47 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     2257                 :             47 :                     $$ = (Node *) n;
                               2258                 :                :                 }
                               2259                 :                :         |   ALTER SEQUENCE IF_P EXISTS qualified_name alter_table_cmds
                               2260                 :                :                 {
 4975 simon@2ndQuadrant.co     2261                 :UBC           0 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2262                 :                : 
                               2263                 :              0 :                     n->relation = $5;
                               2264                 :              0 :                     n->cmds = $6;
 1883 michael@paquier.xyz      2265                 :              0 :                     n->objtype = OBJECT_SEQUENCE;
 4975 simon@2ndQuadrant.co     2266                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     2267                 :              0 :                     $$ = (Node *) n;
                               2268                 :                :                 }
                               2269                 :                :         |   ALTER VIEW qualified_name alter_table_cmds
                               2270                 :                :                 {
 6292 tgl@sss.pgh.pa.us        2271                 :CBC         127 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2272                 :                : 
                               2273                 :            127 :                     n->relation = $3;
                               2274                 :            127 :                     n->cmds = $4;
 1883 michael@paquier.xyz      2275                 :            127 :                     n->objtype = OBJECT_VIEW;
 4975 simon@2ndQuadrant.co     2276                 :            127 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     2277                 :            127 :                     $$ = (Node *) n;
                               2278                 :                :                 }
                               2279                 :                :         |   ALTER VIEW IF_P EXISTS qualified_name alter_table_cmds
                               2280                 :                :                 {
 4975 simon@2ndQuadrant.co     2281                 :UBC           0 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2282                 :                : 
                               2283                 :              0 :                     n->relation = $5;
                               2284                 :              0 :                     n->cmds = $6;
 1883 michael@paquier.xyz      2285                 :              0 :                     n->objtype = OBJECT_VIEW;
 4975 simon@2ndQuadrant.co     2286                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     2287                 :              0 :                     $$ = (Node *) n;
                               2288                 :                :                 }
                               2289                 :                :         |   ALTER MATERIALIZED VIEW qualified_name alter_table_cmds
                               2290                 :                :                 {
 4570 kgrittn@postgresql.o     2291                 :CBC          24 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2292                 :                : 
                               2293                 :             24 :                     n->relation = $4;
                               2294                 :             24 :                     n->cmds = $5;
 1883 michael@paquier.xyz      2295                 :             24 :                     n->objtype = OBJECT_MATVIEW;
 4570 kgrittn@postgresql.o     2296                 :             24 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     2297                 :             24 :                     $$ = (Node *) n;
                               2298                 :                :                 }
                               2299                 :                :         |   ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name alter_table_cmds
                               2300                 :                :                 {
 4570 kgrittn@postgresql.o     2301                 :UBC           0 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2302                 :                : 
                               2303                 :              0 :                     n->relation = $6;
                               2304                 :              0 :                     n->cmds = $7;
 1883 michael@paquier.xyz      2305                 :              0 :                     n->objtype = OBJECT_MATVIEW;
 4570 kgrittn@postgresql.o     2306                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     2307                 :              0 :                     $$ = (Node *) n;
                               2308                 :                :                 }
                               2309                 :                :         |   ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
                               2310                 :                :                 {
                               2311                 :                :                     AlterTableMoveAllStmt *n =
 4034 sfrost@snowman.net       2312                 :CBC           6 :                         makeNode(AlterTableMoveAllStmt);
                               2313                 :                : 
                               2314                 :              6 :                     n->orig_tablespacename = $7;
                               2315                 :              6 :                     n->objtype = OBJECT_MATVIEW;
                               2316                 :              6 :                     n->roles = NIL;
                               2317                 :              6 :                     n->new_tablespacename = $10;
                               2318                 :              6 :                     n->nowait = $11;
 1212 peter@eisentraut.org     2319                 :              6 :                     $$ = (Node *) n;
                               2320                 :                :                 }
                               2321                 :                :         |   ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
                               2322                 :                :                 {
                               2323                 :                :                     AlterTableMoveAllStmt *n =
 4034 sfrost@snowman.net       2324                 :UBC           0 :                         makeNode(AlterTableMoveAllStmt);
                               2325                 :                : 
                               2326                 :              0 :                     n->orig_tablespacename = $7;
                               2327                 :              0 :                     n->objtype = OBJECT_MATVIEW;
                               2328                 :              0 :                     n->roles = $10;
                               2329                 :              0 :                     n->new_tablespacename = $13;
                               2330                 :              0 :                     n->nowait = $14;
 1212 peter@eisentraut.org     2331                 :              0 :                     $$ = (Node *) n;
                               2332                 :                :                 }
                               2333                 :                :         |   ALTER FOREIGN TABLE relation_expr alter_table_cmds
                               2334                 :                :                 {
 1913 peter@eisentraut.org     2335                 :CBC         189 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2336                 :                : 
                               2337                 :            189 :                     n->relation = $4;
                               2338                 :            189 :                     n->cmds = $5;
 1883 michael@paquier.xyz      2339                 :            189 :                     n->objtype = OBJECT_FOREIGN_TABLE;
 1913 peter@eisentraut.org     2340                 :            189 :                     n->missing_ok = false;
 1212                          2341                 :            189 :                     $$ = (Node *) n;
                               2342                 :                :                 }
                               2343                 :                :         |   ALTER FOREIGN TABLE IF_P EXISTS relation_expr alter_table_cmds
                               2344                 :                :                 {
 1913                          2345                 :             54 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2346                 :                : 
                               2347                 :             54 :                     n->relation = $6;
                               2348                 :             54 :                     n->cmds = $7;
 1883 michael@paquier.xyz      2349                 :             54 :                     n->objtype = OBJECT_FOREIGN_TABLE;
 1913 peter@eisentraut.org     2350                 :             54 :                     n->missing_ok = true;
 1212                          2351                 :             54 :                     $$ = (Node *) n;
                               2352                 :                :                 }
                               2353                 :                :         ;
                               2354                 :                : 
                               2355                 :                : alter_table_cmds:
 7769 neilc@samurai.com        2356                 :          13766 :             alter_table_cmd                         { $$ = list_make1($1); }
 7794 tgl@sss.pgh.pa.us        2357                 :            510 :             | alter_table_cmds ',' alter_table_cmd  { $$ = lappend($1, $3); }
                               2358                 :                :         ;
                               2359                 :                : 
                               2360                 :                : partition_cmd:
                               2361                 :                :             /* ALTER TABLE <name> ATTACH PARTITION <table_name> FOR VALUES */
                               2362                 :                :             ATTACH PARTITION qualified_name PartitionBoundSpec
                               2363                 :                :                 {
 3195 rhaas@postgresql.org     2364                 :           1215 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2365                 :           1215 :                     PartitionCmd *cmd = makeNode(PartitionCmd);
                               2366                 :                : 
                               2367                 :           1215 :                     n->subtype = AT_AttachPartition;
                               2368                 :           1215 :                     cmd->name = $3;
 3023 tgl@sss.pgh.pa.us        2369                 :           1215 :                     cmd->bound = $4;
 1626 alvherre@alvh.no-ip.     2370                 :           1215 :                     cmd->concurrent = false;
 3195 rhaas@postgresql.org     2371                 :           1215 :                     n->def = (Node *) cmd;
                               2372                 :                : 
                               2373                 :           1215 :                     $$ = (Node *) n;
                               2374                 :                :                 }
                               2375                 :                :             /* ALTER TABLE <name> DETACH PARTITION <partition_name> [CONCURRENTLY] */
                               2376                 :                :             | DETACH PARTITION qualified_name opt_concurrently
                               2377                 :                :                 {
                               2378                 :            301 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2379                 :            301 :                     PartitionCmd *cmd = makeNode(PartitionCmd);
                               2380                 :                : 
                               2381                 :            301 :                     n->subtype = AT_DetachPartition;
                               2382                 :            301 :                     cmd->name = $3;
 3023 tgl@sss.pgh.pa.us        2383                 :            301 :                     cmd->bound = NULL;
 1626 alvherre@alvh.no-ip.     2384                 :            301 :                     cmd->concurrent = $4;
 3195 rhaas@postgresql.org     2385                 :            301 :                     n->def = (Node *) cmd;
                               2386                 :                : 
 1626 alvherre@alvh.no-ip.     2387                 :            301 :                     $$ = (Node *) n;
                               2388                 :                :                 }
                               2389                 :                :             | DETACH PARTITION qualified_name FINALIZE
                               2390                 :                :                 {
                               2391                 :             10 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2392                 :             10 :                     PartitionCmd *cmd = makeNode(PartitionCmd);
                               2393                 :                : 
                               2394                 :             10 :                     n->subtype = AT_DetachPartitionFinalize;
                               2395                 :             10 :                     cmd->name = $3;
                               2396                 :             10 :                     cmd->bound = NULL;
                               2397                 :             10 :                     cmd->concurrent = false;
                               2398                 :             10 :                     n->def = (Node *) cmd;
 3195 rhaas@postgresql.org     2399                 :             10 :                     $$ = (Node *) n;
                               2400                 :                :                 }
                               2401                 :                :         ;
                               2402                 :                : 
                               2403                 :                : index_partition_cmd:
                               2404                 :                :             /* ALTER INDEX <name> ATTACH PARTITION <index_name> */
                               2405                 :                :             ATTACH PARTITION qualified_name
                               2406                 :                :                 {
 2787 alvherre@alvh.no-ip.     2407                 :            199 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2408                 :            199 :                     PartitionCmd *cmd = makeNode(PartitionCmd);
                               2409                 :                : 
                               2410                 :            199 :                     n->subtype = AT_AttachPartition;
                               2411                 :            199 :                     cmd->name = $3;
                               2412                 :            199 :                     cmd->bound = NULL;
 1626                          2413                 :            199 :                     cmd->concurrent = false;
 2787                          2414                 :            199 :                     n->def = (Node *) cmd;
                               2415                 :                : 
                               2416                 :            199 :                     $$ = (Node *) n;
                               2417                 :                :                 }
                               2418                 :                :         ;
                               2419                 :                : 
                               2420                 :                : alter_table_cmd:
                               2421                 :                :             /* ALTER TABLE <name> ADD <coldef> */
                               2422                 :                :             ADD_P columnDef
                               2423                 :                :                 {
 5752 tgl@sss.pgh.pa.us        2424                 :             96 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2425                 :                : 
                               2426                 :             96 :                     n->subtype = AT_AddColumn;
                               2427                 :             96 :                     n->def = $2;
 3692 andrew@dunslane.net      2428                 :             96 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     2429                 :             96 :                     $$ = (Node *) n;
                               2430                 :                :                 }
                               2431                 :                :             /* ALTER TABLE <name> ADD IF NOT EXISTS <coldef> */
                               2432                 :                :             | ADD_P IF_P NOT EXISTS columnDef
                               2433                 :                :                 {
 3692 andrew@dunslane.net      2434                 :UBC           0 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2435                 :                : 
                               2436                 :              0 :                     n->subtype = AT_AddColumn;
                               2437                 :              0 :                     n->def = $5;
                               2438                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     2439                 :              0 :                     $$ = (Node *) n;
                               2440                 :                :                 }
                               2441                 :                :             /* ALTER TABLE <name> ADD COLUMN <coldef> */
                               2442                 :                :             | ADD_P COLUMN columnDef
                               2443                 :                :                 {
 7794 tgl@sss.pgh.pa.us        2444                 :CBC         948 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2445                 :                : 
                               2446                 :            948 :                     n->subtype = AT_AddColumn;
                               2447                 :            948 :                     n->def = $3;
 3692 andrew@dunslane.net      2448                 :            948 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     2449                 :            948 :                     $$ = (Node *) n;
                               2450                 :                :                 }
                               2451                 :                :             /* ALTER TABLE <name> ADD COLUMN IF NOT EXISTS <coldef> */
                               2452                 :                :             | ADD_P COLUMN IF_P NOT EXISTS columnDef
                               2453                 :                :                 {
 3692 andrew@dunslane.net      2454                 :             30 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2455                 :                : 
                               2456                 :             30 :                     n->subtype = AT_AddColumn;
                               2457                 :             30 :                     n->def = $6;
                               2458                 :             30 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     2459                 :             30 :                     $$ = (Node *) n;
                               2460                 :                :                 }
                               2461                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> {SET DEFAULT <expr>|DROP DEFAULT} */
                               2462                 :                :             | ALTER opt_column ColId alter_column_default
                               2463                 :                :                 {
 7794 tgl@sss.pgh.pa.us        2464                 :            275 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2465                 :                : 
                               2466                 :            275 :                     n->subtype = AT_ColumnDefault;
                               2467                 :            275 :                     n->name = $3;
                               2468                 :            275 :                     n->def = $4;
 1212 peter@eisentraut.org     2469                 :            275 :                     $$ = (Node *) n;
                               2470                 :                :                 }
                               2471                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> DROP NOT NULL */
                               2472                 :                :             | ALTER opt_column ColId DROP NOT NULL_P
                               2473                 :                :                 {
 7794 tgl@sss.pgh.pa.us        2474                 :            147 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2475                 :                : 
                               2476                 :            147 :                     n->subtype = AT_DropNotNull;
                               2477                 :            147 :                     n->name = $3;
 1212 peter@eisentraut.org     2478                 :            147 :                     $$ = (Node *) n;
                               2479                 :                :                 }
                               2480                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET NOT NULL */
                               2481                 :                :             | ALTER opt_column ColId SET NOT NULL_P
                               2482                 :                :                 {
 7794 tgl@sss.pgh.pa.us        2483                 :            217 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2484                 :                : 
                               2485                 :            217 :                     n->subtype = AT_SetNotNull;
                               2486                 :            217 :                     n->name = $3;
 1212 peter@eisentraut.org     2487                 :            217 :                     $$ = (Node *) n;
                               2488                 :                :                 }
                               2489                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET EXPRESSION AS <expr> */
                               2490                 :                :             | ALTER opt_column ColId SET EXPRESSION AS '(' a_expr ')'
                               2491                 :                :                 {
  611                          2492                 :             84 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2493                 :                : 
                               2494                 :             84 :                     n->subtype = AT_SetExpression;
                               2495                 :             84 :                     n->name = $3;
                               2496                 :             84 :                     n->def = $8;
                               2497                 :             84 :                     $$ = (Node *) n;
                               2498                 :                :                 }
                               2499                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> DROP EXPRESSION */
                               2500                 :                :             | ALTER opt_column ColId DROP EXPRESSION
                               2501                 :                :                 {
 2062                          2502                 :             31 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2503                 :                : 
                               2504                 :             31 :                     n->subtype = AT_DropExpression;
                               2505                 :             31 :                     n->name = $3;
 1212                          2506                 :             31 :                     $$ = (Node *) n;
                               2507                 :                :                 }
                               2508                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> DROP EXPRESSION IF EXISTS */
                               2509                 :                :             | ALTER opt_column ColId DROP EXPRESSION IF_P EXISTS
                               2510                 :                :                 {
 2062                          2511                 :              6 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2512                 :                : 
                               2513                 :              6 :                     n->subtype = AT_DropExpression;
                               2514                 :              6 :                     n->name = $3;
                               2515                 :              6 :                     n->missing_ok = true;
 1212                          2516                 :              6 :                     $$ = (Node *) n;
                               2517                 :                :                 }
                               2518                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET STATISTICS */
                               2519                 :                :             | ALTER opt_column ColId SET STATISTICS set_statistics_value
                               2520                 :                :                 {
 7794 tgl@sss.pgh.pa.us        2521                 :             31 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2522                 :                : 
                               2523                 :             31 :                     n->subtype = AT_SetStatistics;
                               2524                 :             31 :                     n->name = $3;
  602 peter@eisentraut.org     2525                 :             31 :                     n->def = $6;
 1212                          2526                 :             31 :                     $$ = (Node *) n;
                               2527                 :                :                 }
                               2528                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colnum> SET STATISTICS */
                               2529                 :                :             | ALTER opt_column Iconst SET STATISTICS set_statistics_value
                               2530                 :                :                 {
 2922 simon@2ndQuadrant.co     2531                 :             35 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2532                 :                : 
                               2533   [ +  +  -  + ]:             35 :                     if ($3 <= 0 || $3 > PG_INT16_MAX)
                               2534         [ +  - ]:              3 :                         ereport(ERROR,
                               2535                 :                :                                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                               2536                 :                :                                  errmsg("column number must be in range from 1 to %d", PG_INT16_MAX),
                               2537                 :                :                                  parser_errposition(@3)));
                               2538                 :                : 
                               2539                 :             32 :                     n->subtype = AT_SetStatistics;
                               2540                 :             32 :                     n->num = (int16) $3;
  602 peter@eisentraut.org     2541                 :             32 :                     n->def = $6;
 1212                          2542                 :             32 :                     $$ = (Node *) n;
                               2543                 :                :                 }
                               2544                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET ( column_parameter = value [, ... ] ) */
                               2545                 :                :             | ALTER opt_column ColId SET reloptions
                               2546                 :                :                 {
 5879 tgl@sss.pgh.pa.us        2547                 :             19 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2548                 :                : 
 5706 rhaas@postgresql.org     2549                 :             19 :                     n->subtype = AT_SetOptions;
 5879 tgl@sss.pgh.pa.us        2550                 :             19 :                     n->name = $3;
 5706 rhaas@postgresql.org     2551                 :             19 :                     n->def = (Node *) $5;
 1212 peter@eisentraut.org     2552                 :             19 :                     $$ = (Node *) n;
                               2553                 :                :                 }
                               2554                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> RESET ( column_parameter [, ... ] ) */
                               2555                 :                :             | ALTER opt_column ColId RESET reloptions
                               2556                 :                :                 {
 5706 rhaas@postgresql.org     2557                 :              3 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2558                 :                : 
                               2559                 :              3 :                     n->subtype = AT_ResetOptions;
                               2560                 :              3 :                     n->name = $3;
                               2561                 :              3 :                     n->def = (Node *) $5;
 1212 peter@eisentraut.org     2562                 :              3 :                     $$ = (Node *) n;
                               2563                 :                :                 }
                               2564                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET STORAGE <storagemode> */
                               2565                 :                :             | ALTER opt_column ColId SET column_storage
                               2566                 :                :                 {
 7794 tgl@sss.pgh.pa.us        2567                 :            119 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2568                 :                : 
                               2569                 :            119 :                     n->subtype = AT_SetStorage;
                               2570                 :            119 :                     n->name = $3;
 1151 peter@eisentraut.org     2571                 :            119 :                     n->def = (Node *) makeString($5);
 1212                          2572                 :            119 :                     $$ = (Node *) n;
                               2573                 :                :                 }
                               2574                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET COMPRESSION <cm> */
                               2575                 :                :             | ALTER opt_column ColId SET column_compression
                               2576                 :                :                 {
 1563 tgl@sss.pgh.pa.us        2577                 :             39 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2578                 :                : 
                               2579                 :             39 :                     n->subtype = AT_SetCompression;
                               2580                 :             39 :                     n->name = $3;
                               2581                 :             39 :                     n->def = (Node *) makeString($5);
 1212 peter@eisentraut.org     2582                 :             39 :                     $$ = (Node *) n;
                               2583                 :                :                 }
                               2584                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> ADD GENERATED ... AS IDENTITY ... */
                               2585                 :                :             | ALTER opt_column ColId ADD_P GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
                               2586                 :                :                 {
 3075 peter_e@gmx.net          2587                 :             83 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2588                 :             83 :                     Constraint *c = makeNode(Constraint);
                               2589                 :                : 
                               2590                 :             83 :                     c->contype = CONSTR_IDENTITY;
                               2591                 :             83 :                     c->generated_when = $6;
                               2592                 :             83 :                     c->options = $9;
                               2593                 :             83 :                     c->location = @5;
                               2594                 :                : 
                               2595                 :             83 :                     n->subtype = AT_AddIdentity;
                               2596                 :             83 :                     n->name = $3;
                               2597                 :             83 :                     n->def = (Node *) c;
                               2598                 :                : 
 1212 peter@eisentraut.org     2599                 :             83 :                     $$ = (Node *) n;
                               2600                 :                :                 }
                               2601                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET <sequence options>/RESET */
                               2602                 :                :             | ALTER opt_column ColId alter_identity_column_option_list
                               2603                 :                :                 {
 3075 peter_e@gmx.net          2604                 :             31 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2605                 :                : 
                               2606                 :             31 :                     n->subtype = AT_SetIdentity;
                               2607                 :             31 :                     n->name = $3;
                               2608                 :             31 :                     n->def = (Node *) $4;
 1212 peter@eisentraut.org     2609                 :             31 :                     $$ = (Node *) n;
                               2610                 :                :                 }
                               2611                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> DROP IDENTITY */
                               2612                 :                :             | ALTER opt_column ColId DROP IDENTITY_P
                               2613                 :                :                 {
 3075 peter_e@gmx.net          2614                 :             25 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2615                 :                : 
                               2616                 :             25 :                     n->subtype = AT_DropIdentity;
                               2617                 :             25 :                     n->name = $3;
                               2618                 :             25 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     2619                 :             25 :                     $$ = (Node *) n;
                               2620                 :                :                 }
                               2621                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> DROP IDENTITY IF EXISTS */
                               2622                 :                :             | ALTER opt_column ColId DROP IDENTITY_P IF_P EXISTS
                               2623                 :                :                 {
 3075 peter_e@gmx.net          2624                 :              3 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2625                 :                : 
                               2626                 :              3 :                     n->subtype = AT_DropIdentity;
                               2627                 :              3 :                     n->name = $3;
                               2628                 :              3 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     2629                 :              3 :                     $$ = (Node *) n;
                               2630                 :                :                 }
                               2631                 :                :             /* ALTER TABLE <name> DROP [COLUMN] IF EXISTS <colname> [RESTRICT|CASCADE] */
                               2632                 :                :             | DROP opt_column IF_P EXISTS ColId opt_drop_behavior
                               2633                 :                :                 {
 5892 andrew@dunslane.net      2634                 :              9 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2635                 :                : 
                               2636                 :              9 :                     n->subtype = AT_DropColumn;
                               2637                 :              9 :                     n->name = $5;
                               2638                 :              9 :                     n->behavior = $6;
 2943 peter_e@gmx.net          2639                 :              9 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     2640                 :              9 :                     $$ = (Node *) n;
                               2641                 :                :                 }
                               2642                 :                :             /* ALTER TABLE <name> DROP [COLUMN] <colname> [RESTRICT|CASCADE] */
                               2643                 :                :             | DROP opt_column ColId opt_drop_behavior
                               2644                 :                :                 {
 7794 tgl@sss.pgh.pa.us        2645                 :            787 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2646                 :                : 
                               2647                 :            787 :                     n->subtype = AT_DropColumn;
                               2648                 :            787 :                     n->name = $3;
                               2649                 :            787 :                     n->behavior = $4;
 2943 peter_e@gmx.net          2650                 :            787 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     2651                 :            787 :                     $$ = (Node *) n;
                               2652                 :                :                 }
                               2653                 :                :             /*
                               2654                 :                :              * ALTER TABLE <name> ALTER [COLUMN] <colname> [SET DATA] TYPE <typename>
                               2655                 :                :              *      [ USING <expression> ]
                               2656                 :                :              */
                               2657                 :                :             | ALTER opt_column ColId opt_set_data TYPE_P Typename opt_collate_clause alter_using
                               2658                 :                :                 {
 7794 tgl@sss.pgh.pa.us        2659                 :            510 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
 5295                          2660                 :            510 :                     ColumnDef *def = makeNode(ColumnDef);
                               2661                 :                : 
 7794                          2662                 :            510 :                     n->subtype = AT_AlterColumnType;
                               2663                 :            510 :                     n->name = $3;
 5295                          2664                 :            510 :                     n->def = (Node *) def;
                               2665                 :                :                     /* We only use these fields of the ColumnDef node */
                               2666                 :            510 :                     def->typeName = $6;
                               2667                 :            510 :                     def->collClause = (CollateClause *) $7;
                               2668                 :            510 :                     def->raw_default = $8;
 4307                          2669                 :            510 :                     def->location = @3;
 1212 peter@eisentraut.org     2670                 :            510 :                     $$ = (Node *) n;
                               2671                 :                :                 }
                               2672                 :                :             /* ALTER FOREIGN TABLE <name> ALTER [COLUMN] <colname> OPTIONS */
                               2673                 :                :             | ALTER opt_column ColId alter_generic_options
                               2674                 :                :                 {
 5146 rhaas@postgresql.org     2675                 :             25 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2676                 :                : 
                               2677                 :             25 :                     n->subtype = AT_AlterColumnGenericOptions;
                               2678                 :             25 :                     n->name = $3;
                               2679                 :             25 :                     n->def = (Node *) $4;
 1212 peter@eisentraut.org     2680                 :             25 :                     $$ = (Node *) n;
                               2681                 :                :                 }
                               2682                 :                :             /* ALTER TABLE <name> ADD CONSTRAINT ... */
                               2683                 :                :             | ADD_P TableConstraint
                               2684                 :                :                 {
 7794 tgl@sss.pgh.pa.us        2685                 :           7286 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2686                 :                : 
                               2687                 :           7286 :                     n->subtype = AT_AddConstraint;
                               2688                 :           7286 :                     n->def = $2;
 1212 peter@eisentraut.org     2689                 :           7286 :                     $$ = (Node *) n;
                               2690                 :                :                 }
                               2691                 :                :             /* ALTER TABLE <name> ALTER CONSTRAINT ... */
                               2692                 :                :             | ALTER CONSTRAINT name ConstraintAttributeSpec
                               2693                 :                :                 {
 4452 simon@2ndQuadrant.co     2694                 :            120 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
  199 alvherre@alvh.no-ip.     2695                 :            120 :                     ATAlterConstraint *c = makeNode(ATAlterConstraint);
                               2696                 :                : 
 4452 simon@2ndQuadrant.co     2697                 :            120 :                     n->subtype = AT_AlterConstraint;
                               2698                 :            120 :                     n->def = (Node *) c;
                               2699                 :            120 :                     c->conname = $3;
  157 peter@eisentraut.org     2700         [ +  + ]:            120 :                     if ($4 & (CAS_NOT_ENFORCED | CAS_ENFORCED))
                               2701                 :             42 :                         c->alterEnforceability = true;
  163 alvherre@alvh.no-ip.     2702         [ +  + ]:            120 :                     if ($4 & (CAS_DEFERRABLE | CAS_NOT_DEFERRABLE |
                               2703                 :                :                               CAS_INITIALLY_DEFERRED | CAS_INITIALLY_IMMEDIATE))
                               2704                 :             60 :                         c->alterDeferrability = true;
                               2705         [ +  + ]:            120 :                     if ($4 & CAS_NO_INHERIT)
                               2706                 :             15 :                         c->alterInheritability = true;
                               2707                 :                :                     /* handle unsupported case with specific error message */
   66 alvherre@kurilemu.de     2708         [ +  + ]:            120 :                     if ($4 & CAS_NOT_VALID)
                               2709         [ +  - ]:              6 :                         ereport(ERROR,
                               2710                 :                :                                 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               2711                 :                :                                 errmsg("constraints cannot be altered to be NOT VALID"),
                               2712                 :                :                                 parser_errposition(@4));
  186 alvherre@alvh.no-ip.     2713                 :            114 :                     processCASbits($4, @4, "FOREIGN KEY",
                               2714                 :                :                                     &c->deferrable,
                               2715                 :                :                                     &c->initdeferred,
                               2716                 :                :                                     &c->is_enforced,
                               2717                 :                :                                     NULL,
                               2718                 :                :                                     &c->noinherit,
                               2719                 :                :                                     yyscanner);
 1212 peter@eisentraut.org     2720                 :            114 :                     $$ = (Node *) n;
                               2721                 :                :                 }
                               2722                 :                :             /* ALTER TABLE <name> ALTER CONSTRAINT INHERIT */
                               2723                 :                :             | ALTER CONSTRAINT name INHERIT
                               2724                 :                :                 {
  185 alvherre@alvh.no-ip.     2725                 :             33 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2726                 :             33 :                     ATAlterConstraint *c = makeNode(ATAlterConstraint);
                               2727                 :                : 
                               2728                 :             33 :                     n->subtype = AT_AlterConstraint;
                               2729                 :             33 :                     n->def = (Node *) c;
                               2730                 :             33 :                     c->conname = $3;
                               2731                 :             33 :                     c->alterInheritability = true;
                               2732                 :             33 :                     c->noinherit = false;
                               2733                 :                : 
                               2734                 :             33 :                     $$ = (Node *) n;
                               2735                 :                :                 }
                               2736                 :                :             /* ALTER TABLE <name> VALIDATE CONSTRAINT ... */
                               2737                 :                :             | VALIDATE CONSTRAINT name
                               2738                 :                :                 {
 5324 simon@2ndQuadrant.co     2739                 :            238 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2740                 :                : 
                               2741                 :            238 :                     n->subtype = AT_ValidateConstraint;
                               2742                 :            238 :                     n->name = $3;
 1212 peter@eisentraut.org     2743                 :            238 :                     $$ = (Node *) n;
                               2744                 :                :                 }
                               2745                 :                :             /* ALTER TABLE <name> DROP CONSTRAINT IF EXISTS <name> [RESTRICT|CASCADE] */
                               2746                 :                :             | DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
                               2747                 :                :                 {
 5892 andrew@dunslane.net      2748                 :              9 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2749                 :                : 
                               2750                 :              9 :                     n->subtype = AT_DropConstraint;
                               2751                 :              9 :                     n->name = $5;
                               2752                 :              9 :                     n->behavior = $6;
 2943 peter_e@gmx.net          2753                 :              9 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     2754                 :              9 :                     $$ = (Node *) n;
                               2755                 :                :                 }
                               2756                 :                :             /* ALTER TABLE <name> DROP CONSTRAINT <name> [RESTRICT|CASCADE] */
                               2757                 :                :             | DROP CONSTRAINT name opt_drop_behavior
                               2758                 :                :                 {
 7794 tgl@sss.pgh.pa.us        2759                 :            409 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2760                 :                : 
                               2761                 :            409 :                     n->subtype = AT_DropConstraint;
                               2762                 :            409 :                     n->name = $3;
                               2763                 :            409 :                     n->behavior = $4;
 2943 peter_e@gmx.net          2764                 :            409 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     2765                 :            409 :                     $$ = (Node *) n;
                               2766                 :                :                 }
                               2767                 :                :             /* ALTER TABLE <name> SET WITHOUT OIDS, for backward compat */
                               2768                 :                :             | SET WITHOUT OIDS
                               2769                 :                :                 {
 7794 tgl@sss.pgh.pa.us        2770                 :              3 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2771                 :                : 
                               2772                 :              3 :                     n->subtype = AT_DropOids;
 1212 peter@eisentraut.org     2773                 :              3 :                     $$ = (Node *) n;
                               2774                 :                :                 }
                               2775                 :                :             /* ALTER TABLE <name> CLUSTER ON <indexname> */
                               2776                 :                :             | CLUSTER ON name
                               2777                 :                :                 {
 7794 tgl@sss.pgh.pa.us        2778                 :             23 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2779                 :                : 
                               2780                 :             23 :                     n->subtype = AT_ClusterOn;
                               2781                 :             23 :                     n->name = $3;
 1212 peter@eisentraut.org     2782                 :             23 :                     $$ = (Node *) n;
                               2783                 :                :                 }
                               2784                 :                :             /* ALTER TABLE <name> SET WITHOUT CLUSTER */
                               2785                 :                :             | SET WITHOUT CLUSTER
                               2786                 :                :                 {
 7766 bruce@momjian.us         2787                 :              9 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2788                 :                : 
                               2789                 :              9 :                     n->subtype = AT_DropCluster;
                               2790                 :              9 :                     n->name = NULL;
 1212 peter@eisentraut.org     2791                 :              9 :                     $$ = (Node *) n;
                               2792                 :                :                 }
                               2793                 :                :             /* ALTER TABLE <name> SET LOGGED */
                               2794                 :                :             | SET LOGGED
                               2795                 :                :                 {
 4033 alvherre@alvh.no-ip.     2796                 :             25 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2797                 :                : 
                               2798                 :             25 :                     n->subtype = AT_SetLogged;
 1212 peter@eisentraut.org     2799                 :             25 :                     $$ = (Node *) n;
                               2800                 :                :                 }
                               2801                 :                :             /* ALTER TABLE <name> SET UNLOGGED */
                               2802                 :                :             | SET UNLOGGED
                               2803                 :                :                 {
 4033 alvherre@alvh.no-ip.     2804                 :             31 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2805                 :                : 
                               2806                 :             31 :                     n->subtype = AT_SetUnLogged;
 1212 peter@eisentraut.org     2807                 :             31 :                     $$ = (Node *) n;
                               2808                 :                :                 }
                               2809                 :                :             /* ALTER TABLE <name> ENABLE TRIGGER <trig> */
                               2810                 :                :             | ENABLE_P TRIGGER name
                               2811                 :                :                 {
 7319 tgl@sss.pgh.pa.us        2812                 :             61 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2813                 :                : 
                               2814                 :             61 :                     n->subtype = AT_EnableTrig;
                               2815                 :             61 :                     n->name = $3;
 1212 peter@eisentraut.org     2816                 :             61 :                     $$ = (Node *) n;
                               2817                 :                :                 }
                               2818                 :                :             /* ALTER TABLE <name> ENABLE ALWAYS TRIGGER <trig> */
                               2819                 :                :             | ENABLE_P ALWAYS TRIGGER name
                               2820                 :                :                 {
 6746 JanWieck@Yahoo.com       2821                 :             21 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2822                 :                : 
                               2823                 :             21 :                     n->subtype = AT_EnableAlwaysTrig;
                               2824                 :             21 :                     n->name = $4;
 1212 peter@eisentraut.org     2825                 :             21 :                     $$ = (Node *) n;
                               2826                 :                :                 }
                               2827                 :                :             /* ALTER TABLE <name> ENABLE REPLICA TRIGGER <trig> */
                               2828                 :                :             | ENABLE_P REPLICA TRIGGER name
                               2829                 :                :                 {
 6746 JanWieck@Yahoo.com       2830                 :              8 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2831                 :                : 
                               2832                 :              8 :                     n->subtype = AT_EnableReplicaTrig;
                               2833                 :              8 :                     n->name = $4;
 1212 peter@eisentraut.org     2834                 :              8 :                     $$ = (Node *) n;
                               2835                 :                :                 }
                               2836                 :                :             /* ALTER TABLE <name> ENABLE TRIGGER ALL */
                               2837                 :                :             | ENABLE_P TRIGGER ALL
                               2838                 :                :                 {
 7319 tgl@sss.pgh.pa.us        2839                 :UBC           0 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2840                 :                : 
                               2841                 :              0 :                     n->subtype = AT_EnableTrigAll;
 1212 peter@eisentraut.org     2842                 :              0 :                     $$ = (Node *) n;
                               2843                 :                :                 }
                               2844                 :                :             /* ALTER TABLE <name> ENABLE TRIGGER USER */
                               2845                 :                :             | ENABLE_P TRIGGER USER
                               2846                 :                :                 {
 7319 tgl@sss.pgh.pa.us        2847                 :              0 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2848                 :                : 
                               2849                 :              0 :                     n->subtype = AT_EnableTrigUser;
 1212 peter@eisentraut.org     2850                 :              0 :                     $$ = (Node *) n;
                               2851                 :                :                 }
                               2852                 :                :             /* ALTER TABLE <name> DISABLE TRIGGER <trig> */
                               2853                 :                :             | DISABLE_P TRIGGER name
                               2854                 :                :                 {
 7319 tgl@sss.pgh.pa.us        2855                 :CBC          69 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2856                 :                : 
                               2857                 :             69 :                     n->subtype = AT_DisableTrig;
                               2858                 :             69 :                     n->name = $3;
 1212 peter@eisentraut.org     2859                 :             69 :                     $$ = (Node *) n;
                               2860                 :                :                 }
                               2861                 :                :             /* ALTER TABLE <name> DISABLE TRIGGER ALL */
                               2862                 :                :             | DISABLE_P TRIGGER ALL
                               2863                 :                :                 {
 7319 tgl@sss.pgh.pa.us        2864                 :              6 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2865                 :                : 
                               2866                 :              6 :                     n->subtype = AT_DisableTrigAll;
 1212 peter@eisentraut.org     2867                 :              6 :                     $$ = (Node *) n;
                               2868                 :                :                 }
                               2869                 :                :             /* ALTER TABLE <name> DISABLE TRIGGER USER */
                               2870                 :                :             | DISABLE_P TRIGGER USER
                               2871                 :                :                 {
 7319 tgl@sss.pgh.pa.us        2872                 :              6 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2873                 :                : 
                               2874                 :              6 :                     n->subtype = AT_DisableTrigUser;
 1212 peter@eisentraut.org     2875                 :              6 :                     $$ = (Node *) n;
                               2876                 :                :                 }
                               2877                 :                :             /* ALTER TABLE <name> ENABLE RULE <rule> */
                               2878                 :                :             | ENABLE_P RULE name
                               2879                 :                :                 {
 6746 JanWieck@Yahoo.com       2880                 :              4 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2881                 :                : 
                               2882                 :              4 :                     n->subtype = AT_EnableRule;
                               2883                 :              4 :                     n->name = $3;
 1212 peter@eisentraut.org     2884                 :              4 :                     $$ = (Node *) n;
                               2885                 :                :                 }
                               2886                 :                :             /* ALTER TABLE <name> ENABLE ALWAYS RULE <rule> */
                               2887                 :                :             | ENABLE_P ALWAYS RULE name
                               2888                 :                :                 {
 6746 JanWieck@Yahoo.com       2889                 :UBC           0 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2890                 :                : 
                               2891                 :              0 :                     n->subtype = AT_EnableAlwaysRule;
                               2892                 :              0 :                     n->name = $4;
 1212 peter@eisentraut.org     2893                 :              0 :                     $$ = (Node *) n;
                               2894                 :                :                 }
                               2895                 :                :             /* ALTER TABLE <name> ENABLE REPLICA RULE <rule> */
                               2896                 :                :             | ENABLE_P REPLICA RULE name
                               2897                 :                :                 {
 6746 JanWieck@Yahoo.com       2898                 :CBC           3 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2899                 :                : 
                               2900                 :              3 :                     n->subtype = AT_EnableReplicaRule;
                               2901                 :              3 :                     n->name = $4;
 1212 peter@eisentraut.org     2902                 :              3 :                     $$ = (Node *) n;
                               2903                 :                :                 }
                               2904                 :                :             /* ALTER TABLE <name> DISABLE RULE <rule> */
                               2905                 :                :             | DISABLE_P RULE name
                               2906                 :                :                 {
 6746 JanWieck@Yahoo.com       2907                 :             16 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2908                 :                : 
                               2909                 :             16 :                     n->subtype = AT_DisableRule;
                               2910                 :             16 :                     n->name = $3;
 1212 peter@eisentraut.org     2911                 :             16 :                     $$ = (Node *) n;
                               2912                 :                :                 }
                               2913                 :                :             /* ALTER TABLE <name> INHERIT <parent> */
                               2914                 :                :             | INHERIT qualified_name
                               2915                 :                :                 {
 7006 bruce@momjian.us         2916                 :            230 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2917                 :                : 
 6903 tgl@sss.pgh.pa.us        2918                 :            230 :                     n->subtype = AT_AddInherit;
                               2919                 :            230 :                     n->def = (Node *) $2;
 1212 peter@eisentraut.org     2920                 :            230 :                     $$ = (Node *) n;
                               2921                 :                :                 }
                               2922                 :                :             /* ALTER TABLE <name> NO INHERIT <parent> */
                               2923                 :                :             | NO INHERIT qualified_name
                               2924                 :                :                 {
 7006 bruce@momjian.us         2925                 :             47 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2926                 :                : 
 6903 tgl@sss.pgh.pa.us        2927                 :             47 :                     n->subtype = AT_DropInherit;
                               2928                 :             47 :                     n->def = (Node *) $3;
 1212 peter@eisentraut.org     2929                 :             47 :                     $$ = (Node *) n;
                               2930                 :                :                 }
                               2931                 :                :             /* ALTER TABLE <name> OF <type_name> */
                               2932                 :                :             | OF any_name
                               2933                 :                :                 {
 5253 rhaas@postgresql.org     2934                 :             33 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
 1212 peter@eisentraut.org     2935                 :             33 :                     TypeName   *def = makeTypeNameFromNameList($2);
                               2936                 :                : 
 5253 rhaas@postgresql.org     2937                 :             33 :                     def->location = @2;
                               2938                 :             33 :                     n->subtype = AT_AddOf;
                               2939                 :             33 :                     n->def = (Node *) def;
 1212 peter@eisentraut.org     2940                 :             33 :                     $$ = (Node *) n;
                               2941                 :                :                 }
                               2942                 :                :             /* ALTER TABLE <name> NOT OF */
                               2943                 :                :             | NOT OF
                               2944                 :                :                 {
 5253 rhaas@postgresql.org     2945                 :              3 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2946                 :                : 
                               2947                 :              3 :                     n->subtype = AT_DropOf;
 1212 peter@eisentraut.org     2948                 :              3 :                     $$ = (Node *) n;
                               2949                 :                :                 }
                               2950                 :                :             /* ALTER TABLE <name> OWNER TO RoleSpec */
                               2951                 :                :             | OWNER TO RoleSpec
                               2952                 :                :                 {
 7687 bruce@momjian.us         2953                 :           1011 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2954                 :                : 
                               2955                 :           1011 :                     n->subtype = AT_ChangeOwner;
 3834 alvherre@alvh.no-ip.     2956                 :           1011 :                     n->newowner = $3;
 1212 peter@eisentraut.org     2957                 :           1011 :                     $$ = (Node *) n;
                               2958                 :                :                 }
                               2959                 :                :             /* ALTER TABLE <name> SET ACCESS METHOD { <amname> | DEFAULT } */
                               2960                 :                :             | SET ACCESS METHOD set_access_method_name
                               2961                 :                :                 {
 1501 michael@paquier.xyz      2962                 :             64 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2963                 :                : 
                               2964                 :             64 :                     n->subtype = AT_SetAccessMethod;
                               2965                 :             64 :                     n->name = $4;
 1212 peter@eisentraut.org     2966                 :             64 :                     $$ = (Node *) n;
                               2967                 :                :                 }
                               2968                 :                :             /* ALTER TABLE <name> SET TABLESPACE <tablespacename> */
                               2969                 :                :             | SET TABLESPACE name
                               2970                 :                :                 {
 7727 tgl@sss.pgh.pa.us        2971                 :             66 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2972                 :                : 
                               2973                 :             66 :                     n->subtype = AT_SetTableSpace;
                               2974                 :             66 :                     n->name = $3;
 1212 peter@eisentraut.org     2975                 :             66 :                     $$ = (Node *) n;
                               2976                 :                :                 }
                               2977                 :                :             /* ALTER TABLE <name> SET (...) */
                               2978                 :                :             | SET reloptions
                               2979                 :                :                 {
 7006 bruce@momjian.us         2980                 :            300 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2981                 :                : 
 7005 tgl@sss.pgh.pa.us        2982                 :            300 :                     n->subtype = AT_SetRelOptions;
 1212 peter@eisentraut.org     2983                 :            300 :                     n->def = (Node *) $2;
                               2984                 :            300 :                     $$ = (Node *) n;
                               2985                 :                :                 }
                               2986                 :                :             /* ALTER TABLE <name> RESET (...) */
                               2987                 :                :             | RESET reloptions
                               2988                 :                :                 {
 7005 tgl@sss.pgh.pa.us        2989                 :             85 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2990                 :                : 
                               2991                 :             85 :                     n->subtype = AT_ResetRelOptions;
 1212 peter@eisentraut.org     2992                 :             85 :                     n->def = (Node *) $2;
                               2993                 :             85 :                     $$ = (Node *) n;
                               2994                 :                :                 }
                               2995                 :                :             /* ALTER TABLE <name> REPLICA IDENTITY */
                               2996                 :                :             | REPLICA IDENTITY_P replica_identity
                               2997                 :                :                 {
 4320 rhaas@postgresql.org     2998                 :            247 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2999                 :                : 
                               3000                 :            247 :                     n->subtype = AT_ReplicaIdentity;
                               3001                 :            247 :                     n->def = $3;
 1212 peter@eisentraut.org     3002                 :            247 :                     $$ = (Node *) n;
                               3003                 :                :                 }
                               3004                 :                :             /* ALTER TABLE <name> ENABLE ROW LEVEL SECURITY */
                               3005                 :                :             | ENABLE_P ROW LEVEL SECURITY
                               3006                 :                :                 {
 4005 sfrost@snowman.net       3007                 :            163 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3008                 :                : 
                               3009                 :            163 :                     n->subtype = AT_EnableRowSecurity;
 1212 peter@eisentraut.org     3010                 :            163 :                     $$ = (Node *) n;
                               3011                 :                :                 }
                               3012                 :                :             /* ALTER TABLE <name> DISABLE ROW LEVEL SECURITY */
                               3013                 :                :             | DISABLE_P ROW LEVEL SECURITY
                               3014                 :                :                 {
 4005 sfrost@snowman.net       3015                 :              5 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3016                 :                : 
                               3017                 :              5 :                     n->subtype = AT_DisableRowSecurity;
 1212 peter@eisentraut.org     3018                 :              5 :                     $$ = (Node *) n;
                               3019                 :                :                 }
                               3020                 :                :             /* ALTER TABLE <name> FORCE ROW LEVEL SECURITY */
                               3021                 :                :             | FORCE ROW LEVEL SECURITY
                               3022                 :                :                 {
 3625 sfrost@snowman.net       3023                 :             50 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3024                 :                : 
                               3025                 :             50 :                     n->subtype = AT_ForceRowSecurity;
 1212 peter@eisentraut.org     3026                 :             50 :                     $$ = (Node *) n;
                               3027                 :                :                 }
                               3028                 :                :             /* ALTER TABLE <name> NO FORCE ROW LEVEL SECURITY */
                               3029                 :                :             | NO FORCE ROW LEVEL SECURITY
                               3030                 :                :                 {
 3625 sfrost@snowman.net       3031                 :             16 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3032                 :                : 
                               3033                 :             16 :                     n->subtype = AT_NoForceRowSecurity;
 1212 peter@eisentraut.org     3034                 :             16 :                     $$ = (Node *) n;
                               3035                 :                :                 }
                               3036                 :                :             | alter_generic_options
                               3037                 :                :                 {
 5362 rhaas@postgresql.org     3038                 :             32 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3039                 :                : 
                               3040                 :             32 :                     n->subtype = AT_GenericOptions;
 1212 peter@eisentraut.org     3041                 :             32 :                     n->def = (Node *) $1;
 5362 rhaas@postgresql.org     3042                 :             32 :                     $$ = (Node *) n;
                               3043                 :                :                 }
                               3044                 :                :         ;
                               3045                 :                : 
                               3046                 :                : alter_column_default:
 6522 tgl@sss.pgh.pa.us        3047                 :            189 :             SET DEFAULT a_expr          { $$ = $3; }
 7794                          3048                 :             93 :             | DROP DEFAULT              { $$ = NULL; }
                               3049                 :                :         ;
                               3050                 :                : 
                               3051                 :                : opt_collate_clause:
                               3052                 :                :             COLLATE any_name
                               3053                 :                :                 {
 5295                          3054                 :              9 :                     CollateClause *n = makeNode(CollateClause);
                               3055                 :                : 
                               3056                 :              9 :                     n->arg = NULL;
 5293                          3057                 :              9 :                     n->collname = $2;
 5295                          3058                 :              9 :                     n->location = @1;
                               3059                 :              9 :                     $$ = (Node *) n;
                               3060                 :                :                 }
                               3061                 :           2373 :             | /* EMPTY */               { $$ = NULL; }
                               3062                 :                :         ;
                               3063                 :                : 
                               3064                 :                : alter_using:
 7794                          3065                 :             90 :             USING a_expr                { $$ = $2; }
                               3066                 :            420 :             | /* EMPTY */               { $$ = NULL; }
                               3067                 :                :         ;
                               3068                 :                : 
                               3069                 :                : replica_identity:
                               3070                 :                :             NOTHING
                               3071                 :                :                 {
 4320 rhaas@postgresql.org     3072                 :             24 :                     ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
                               3073                 :                : 
                               3074                 :             24 :                     n->identity_type = REPLICA_IDENTITY_NOTHING;
                               3075                 :             24 :                     n->name = NULL;
                               3076                 :             24 :                     $$ = (Node *) n;
                               3077                 :                :                 }
                               3078                 :                :             | FULL
                               3079                 :                :                 {
                               3080                 :             85 :                     ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
                               3081                 :                : 
                               3082                 :             85 :                     n->identity_type = REPLICA_IDENTITY_FULL;
                               3083                 :             85 :                     n->name = NULL;
                               3084                 :             85 :                     $$ = (Node *) n;
                               3085                 :                :                 }
                               3086                 :                :             | DEFAULT
                               3087                 :                :                 {
                               3088                 :              3 :                     ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
                               3089                 :                : 
                               3090                 :              3 :                     n->identity_type = REPLICA_IDENTITY_DEFAULT;
                               3091                 :              3 :                     n->name = NULL;
                               3092                 :              3 :                     $$ = (Node *) n;
                               3093                 :                :                 }
                               3094                 :                :             | USING INDEX name
                               3095                 :                :                 {
                               3096                 :            135 :                     ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
                               3097                 :                : 
                               3098                 :            135 :                     n->identity_type = REPLICA_IDENTITY_INDEX;
                               3099                 :            135 :                     n->name = $3;
                               3100                 :            135 :                     $$ = (Node *) n;
                               3101                 :                :                 }
                               3102                 :                : ;
                               3103                 :                : 
                               3104                 :                : reloptions:
 5058 peter_e@gmx.net          3105                 :           1350 :             '(' reloption_list ')'                  { $$ = $2; }
                               3106                 :                :         ;
                               3107                 :                : 
 6060 alvherre@alvh.no-ip.     3108                 :            481 : opt_reloptions:     WITH reloptions                 { $$ = $2; }
                               3109                 :          11691 :              |      /* EMPTY */                     { $$ = NIL; }
                               3110                 :                :         ;
                               3111                 :                : 
                               3112                 :                : reloption_list:
                               3113                 :           1350 :             reloption_elem                          { $$ = list_make1($1); }
                               3114                 :            114 :             | reloption_list ',' reloption_elem     { $$ = lappend($1, $3); }
                               3115                 :                :         ;
                               3116                 :                : 
                               3117                 :                : /* This should match def_elem and also allow qualified names */
                               3118                 :                : reloption_elem:
                               3119                 :                :             ColLabel '=' def_arg
                               3120                 :                :                 {
 3287 peter_e@gmx.net          3121                 :           1138 :                     $$ = makeDefElem($1, (Node *) $3, @1);
                               3122                 :                :                 }
                               3123                 :                :             | ColLabel
                               3124                 :                :                 {
                               3125                 :            292 :                     $$ = makeDefElem($1, NULL, @1);
                               3126                 :                :                 }
                               3127                 :                :             | ColLabel '.' ColLabel '=' def_arg
                               3128                 :                :                 {
 5999 tgl@sss.pgh.pa.us        3129                 :             31 :                     $$ = makeDefElemExtended($1, $3, (Node *) $5,
 3287 peter_e@gmx.net          3130                 :             31 :                                              DEFELEM_UNSPEC, @1);
                               3131                 :                :                 }
                               3132                 :                :             | ColLabel '.' ColLabel
                               3133                 :                :                 {
                               3134                 :              3 :                     $$ = makeDefElemExtended($1, $3, NULL, DEFELEM_UNSPEC, @1);
                               3135                 :                :                 }
                               3136                 :                :         ;
                               3137                 :                : 
                               3138                 :                : alter_identity_column_option_list:
                               3139                 :                :             alter_identity_column_option
 3075                          3140                 :             31 :                 { $$ = list_make1($1); }
                               3141                 :                :             | alter_identity_column_option_list alter_identity_column_option
                               3142                 :             30 :                 { $$ = lappend($1, $2); }
                               3143                 :                :         ;
                               3144                 :                : 
                               3145                 :                : alter_identity_column_option:
                               3146                 :                :             RESTART
                               3147                 :                :                 {
                               3148                 :             12 :                     $$ = makeDefElem("restart", NULL, @1);
                               3149                 :                :                 }
                               3150                 :                :             | RESTART opt_with NumericOnly
                               3151                 :                :                 {
 1212 peter@eisentraut.org     3152                 :UBC           0 :                     $$ = makeDefElem("restart", (Node *) $3, @1);
                               3153                 :                :                 }
                               3154                 :                :             | SET SeqOptElem
                               3155                 :                :                 {
 3075 peter_e@gmx.net          3156         [ +  - ]:CBC          27 :                     if (strcmp($2->defname, "as") == 0 ||
                               3157         [ +  - ]:             27 :                         strcmp($2->defname, "restart") == 0 ||
                               3158         [ -  + ]:             27 :                         strcmp($2->defname, "owned_by") == 0)
 3075 peter_e@gmx.net          3159         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               3160                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               3161                 :                :                                  errmsg("sequence option \"%s\" not supported here", $2->defname),
                               3162                 :                :                                  parser_errposition(@2)));
 3075 peter_e@gmx.net          3163                 :CBC          27 :                     $$ = $2;
                               3164                 :                :                 }
                               3165                 :                :             | SET GENERATED generated_when
                               3166                 :                :                 {
                               3167                 :             22 :                     $$ = makeDefElem("generated", (Node *) makeInteger($3), @1);
                               3168                 :                :                 }
                               3169                 :                :         ;
                               3170                 :                : 
                               3171                 :                : set_statistics_value:
  602 peter@eisentraut.org     3172                 :             79 :             SignedIconst                    { $$ = (Node *) makeInteger($1); }
  602 peter@eisentraut.org     3173                 :UBC           0 :             | DEFAULT                       { $$ = NULL; }
                               3174                 :                :         ;
                               3175                 :                : 
                               3176                 :                : set_access_method_name:
  547 michael@paquier.xyz      3177                 :CBC          46 :             ColId                           { $$ = $1; }
                               3178                 :             18 :             | DEFAULT                       { $$ = NULL; }
                               3179                 :                :         ;
                               3180                 :                : 
                               3181                 :                : PartitionBoundSpec:
                               3182                 :                :             /* a HASH partition */
                               3183                 :                :             FOR VALUES WITH '(' hash_partbound ')'
                               3184                 :                :                 {
                               3185                 :                :                     ListCell   *lc;
 2858 rhaas@postgresql.org     3186                 :            363 :                     PartitionBoundSpec *n = makeNode(PartitionBoundSpec);
                               3187                 :                : 
                               3188                 :            363 :                     n->strategy = PARTITION_STRATEGY_HASH;
                               3189                 :            363 :                     n->modulus = n->remainder = -1;
                               3190                 :                : 
                               3191   [ +  -  +  +  :           1089 :                     foreach (lc, $5)
                                              +  + ]
                               3192                 :                :                     {
                               3193                 :            726 :                         DefElem    *opt = lfirst_node(DefElem, lc);
                               3194                 :                : 
                               3195         [ +  + ]:            726 :                         if (strcmp(opt->defname, "modulus") == 0)
                               3196                 :                :                         {
                               3197         [ -  + ]:            363 :                             if (n->modulus != -1)
 2858 rhaas@postgresql.org     3198         [ #  # ]:UBC           0 :                                 ereport(ERROR,
                               3199                 :                :                                         (errcode(ERRCODE_DUPLICATE_OBJECT),
                               3200                 :                :                                          errmsg("modulus for hash partition provided more than once"),
                               3201                 :                :                                          parser_errposition(opt->location)));
 2858 rhaas@postgresql.org     3202                 :CBC         363 :                             n->modulus = defGetInt32(opt);
                               3203                 :                :                         }
                               3204         [ +  - ]:            363 :                         else if (strcmp(opt->defname, "remainder") == 0)
                               3205                 :                :                         {
                               3206         [ -  + ]:            363 :                             if (n->remainder != -1)
 2858 rhaas@postgresql.org     3207         [ #  # ]:UBC           0 :                                 ereport(ERROR,
                               3208                 :                :                                         (errcode(ERRCODE_DUPLICATE_OBJECT),
                               3209                 :                :                                          errmsg("remainder for hash partition provided more than once"),
                               3210                 :                :                                          parser_errposition(opt->location)));
 2858 rhaas@postgresql.org     3211                 :CBC         363 :                             n->remainder = defGetInt32(opt);
                               3212                 :                :                         }
                               3213                 :                :                         else
 2858 rhaas@postgresql.org     3214         [ #  # ]:UBC           0 :                             ereport(ERROR,
                               3215                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                               3216                 :                :                                      errmsg("unrecognized hash partition bound specification \"%s\"",
                               3217                 :                :                                             opt->defname),
                               3218                 :                :                                      parser_errposition(opt->location)));
                               3219                 :                :                     }
                               3220                 :                : 
 2858 rhaas@postgresql.org     3221         [ -  + ]:CBC         363 :                     if (n->modulus == -1)
 2858 rhaas@postgresql.org     3222         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               3223                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               3224                 :                :                                  errmsg("modulus for hash partition must be specified"),
                               3225                 :                :                                  parser_errposition(@3)));
 2858 rhaas@postgresql.org     3226         [ -  + ]:CBC         363 :                     if (n->remainder == -1)
 2858 rhaas@postgresql.org     3227         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               3228                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               3229                 :                :                                  errmsg("remainder for hash partition must be specified"),
                               3230                 :                :                                  parser_errposition(@3)));
                               3231                 :                : 
 2858 rhaas@postgresql.org     3232                 :CBC         363 :                     n->location = @3;
                               3233                 :                : 
                               3234                 :            363 :                     $$ = n;
                               3235                 :                :                 }
                               3236                 :                : 
                               3237                 :                :             /* a LIST partition */
                               3238                 :                :             | FOR VALUES IN_P '(' expr_list ')'
                               3239                 :                :                 {
 3195                          3240                 :           2473 :                     PartitionBoundSpec *n = makeNode(PartitionBoundSpec);
                               3241                 :                : 
                               3242                 :           2473 :                     n->strategy = PARTITION_STRATEGY_LIST;
 2920                          3243                 :           2473 :                     n->is_default = false;
 3195                          3244                 :           2473 :                     n->listdatums = $5;
                               3245                 :           2473 :                     n->location = @3;
                               3246                 :                : 
 3023 tgl@sss.pgh.pa.us        3247                 :           2473 :                     $$ = n;
                               3248                 :                :                 }
                               3249                 :                : 
                               3250                 :                :             /* a RANGE partition */
                               3251                 :                :             | FOR VALUES FROM '(' expr_list ')' TO '(' expr_list ')'
                               3252                 :                :                 {
 3195 rhaas@postgresql.org     3253                 :           2113 :                     PartitionBoundSpec *n = makeNode(PartitionBoundSpec);
                               3254                 :                : 
                               3255                 :           2113 :                     n->strategy = PARTITION_STRATEGY_RANGE;
 2920                          3256                 :           2113 :                     n->is_default = false;
 3195                          3257                 :           2113 :                     n->lowerdatums = $5;
                               3258                 :           2113 :                     n->upperdatums = $9;
                               3259                 :           2113 :                     n->location = @3;
                               3260                 :                : 
 2920                          3261                 :           2113 :                     $$ = n;
                               3262                 :                :                 }
                               3263                 :                : 
                               3264                 :                :             /* a DEFAULT partition */
                               3265                 :                :             | DEFAULT
                               3266                 :                :                 {
                               3267                 :            299 :                     PartitionBoundSpec *n = makeNode(PartitionBoundSpec);
                               3268                 :                : 
                               3269                 :            299 :                     n->is_default = true;
                               3270                 :            299 :                     n->location = @1;
                               3271                 :                : 
 3023 tgl@sss.pgh.pa.us        3272                 :            299 :                     $$ = n;
                               3273                 :                :                 }
                               3274                 :                :         ;
                               3275                 :                : 
                               3276                 :                : hash_partbound_elem:
                               3277                 :                :         NonReservedWord Iconst
                               3278                 :                :             {
 1212 peter@eisentraut.org     3279                 :            726 :                 $$ = makeDefElem($1, (Node *) makeInteger($2), @1);
                               3280                 :                :             }
                               3281                 :                :         ;
                               3282                 :                : 
                               3283                 :                : hash_partbound:
                               3284                 :                :         hash_partbound_elem
                               3285                 :                :             {
 2858 rhaas@postgresql.org     3286                 :            363 :                 $$ = list_make1($1);
                               3287                 :                :             }
                               3288                 :                :         | hash_partbound ',' hash_partbound_elem
                               3289                 :                :             {
                               3290                 :            363 :                 $$ = lappend($1, $3);
                               3291                 :                :             }
                               3292                 :                :         ;
                               3293                 :                : 
                               3294                 :                : /*****************************************************************************
                               3295                 :                :  *
                               3296                 :                :  *  ALTER TYPE
                               3297                 :                :  *
                               3298                 :                :  * really variants of the ALTER TABLE subcommands with different spellings
                               3299                 :                :  *****************************************************************************/
                               3300                 :                : 
                               3301                 :                : AlterCompositeTypeStmt:
                               3302                 :                :             ALTER TYPE_P any_name alter_type_cmds
                               3303                 :                :                 {
 5459 peter_e@gmx.net          3304                 :            105 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               3305                 :                : 
                               3306                 :                :                     /* can't use qualified_name, sigh */
                               3307                 :            105 :                     n->relation = makeRangeVarFromAnyName($3, @3, yyscanner);
                               3308                 :            105 :                     n->cmds = $4;
 1883 michael@paquier.xyz      3309                 :            105 :                     n->objtype = OBJECT_TYPE;
 1212 peter@eisentraut.org     3310                 :            105 :                     $$ = (Node *) n;
                               3311                 :                :                 }
                               3312                 :                :             ;
                               3313                 :                : 
                               3314                 :                : alter_type_cmds:
 5459 peter_e@gmx.net          3315                 :            105 :             alter_type_cmd                          { $$ = list_make1($1); }
                               3316                 :              6 :             | alter_type_cmds ',' alter_type_cmd    { $$ = lappend($1, $3); }
                               3317                 :                :         ;
                               3318                 :                : 
                               3319                 :                : alter_type_cmd:
                               3320                 :                :             /* ALTER TYPE <name> ADD ATTRIBUTE <coldef> [RESTRICT|CASCADE] */
                               3321                 :                :             ADD_P ATTRIBUTE TableFuncElement opt_drop_behavior
                               3322                 :                :                 {
                               3323                 :             32 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3324                 :                : 
                               3325                 :             32 :                     n->subtype = AT_AddColumn;
                               3326                 :             32 :                     n->def = $3;
 5401                          3327                 :             32 :                     n->behavior = $4;
 1212 peter@eisentraut.org     3328                 :             32 :                     $$ = (Node *) n;
                               3329                 :                :                 }
                               3330                 :                :             /* ALTER TYPE <name> DROP ATTRIBUTE IF EXISTS <attname> [RESTRICT|CASCADE] */
                               3331                 :                :             | DROP ATTRIBUTE IF_P EXISTS ColId opt_drop_behavior
                               3332                 :                :                 {
 5459 peter_e@gmx.net          3333                 :              3 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3334                 :                : 
                               3335                 :              3 :                     n->subtype = AT_DropColumn;
                               3336                 :              3 :                     n->name = $5;
 5401                          3337                 :              3 :                     n->behavior = $6;
 2943                          3338                 :              3 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     3339                 :              3 :                     $$ = (Node *) n;
                               3340                 :                :                 }
                               3341                 :                :             /* ALTER TYPE <name> DROP ATTRIBUTE <attname> [RESTRICT|CASCADE] */
                               3342                 :                :             | DROP ATTRIBUTE ColId opt_drop_behavior
                               3343                 :                :                 {
 5459 peter_e@gmx.net          3344                 :             39 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3345                 :                : 
                               3346                 :             39 :                     n->subtype = AT_DropColumn;
                               3347                 :             39 :                     n->name = $3;
 5401                          3348                 :             39 :                     n->behavior = $4;
 2943                          3349                 :             39 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     3350                 :             39 :                     $$ = (Node *) n;
                               3351                 :                :                 }
                               3352                 :                :             /* ALTER TYPE <name> ALTER ATTRIBUTE <attname> [SET DATA] TYPE <typename> [RESTRICT|CASCADE] */
                               3353                 :                :             | ALTER ATTRIBUTE ColId opt_set_data TYPE_P Typename opt_collate_clause opt_drop_behavior
                               3354                 :                :                 {
 5459 peter_e@gmx.net          3355                 :             37 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
 5295 tgl@sss.pgh.pa.us        3356                 :             37 :                     ColumnDef *def = makeNode(ColumnDef);
                               3357                 :                : 
 5459 peter_e@gmx.net          3358                 :             37 :                     n->subtype = AT_AlterColumnType;
                               3359                 :             37 :                     n->name = $3;
 5295 tgl@sss.pgh.pa.us        3360                 :             37 :                     n->def = (Node *) def;
                               3361                 :             37 :                     n->behavior = $8;
                               3362                 :                :                     /* We only use these fields of the ColumnDef node */
                               3363                 :             37 :                     def->typeName = $6;
                               3364                 :             37 :                     def->collClause = (CollateClause *) $7;
                               3365                 :             37 :                     def->raw_default = NULL;
 4307                          3366                 :             37 :                     def->location = @3;
 1212 peter@eisentraut.org     3367                 :             37 :                     $$ = (Node *) n;
                               3368                 :                :                 }
                               3369                 :                :         ;
                               3370                 :                : 
                               3371                 :                : 
                               3372                 :                : /*****************************************************************************
                               3373                 :                :  *
                               3374                 :                :  *      QUERY :
                               3375                 :                :  *              close <portalname>
                               3376                 :                :  *
                               3377                 :                :  *****************************************************************************/
                               3378                 :                : 
                               3379                 :                : ClosePortalStmt:
                               3380                 :                :             CLOSE cursor_name
                               3381                 :                :                 {
10225 bruce@momjian.us         3382                 :           1079 :                     ClosePortalStmt *n = makeNode(ClosePortalStmt);
                               3383                 :                : 
                               3384                 :           1079 :                     n->portalname = $2;
 1212 peter@eisentraut.org     3385                 :           1079 :                     $$ = (Node *) n;
                               3386                 :                :                 }
                               3387                 :                :             | CLOSE ALL
                               3388                 :                :                 {
 6722 neilc@samurai.com        3389                 :              6 :                     ClosePortalStmt *n = makeNode(ClosePortalStmt);
                               3390                 :                : 
                               3391                 :              6 :                     n->portalname = NULL;
 1212 peter@eisentraut.org     3392                 :              6 :                     $$ = (Node *) n;
                               3393                 :                :                 }
                               3394                 :                :         ;
                               3395                 :                : 
                               3396                 :                : 
                               3397                 :                : /*****************************************************************************
                               3398                 :                :  *
                               3399                 :                :  *      QUERY :
                               3400                 :                :  *              COPY relname [(columnList)] FROM/TO file [WITH] [(options)]
                               3401                 :                :  *              COPY ( query ) TO file  [WITH] [(options)]
                               3402                 :                :  *
                               3403                 :                :  *              where 'query' can be one of:
                               3404                 :                :  *              { SELECT | UPDATE | INSERT | DELETE }
                               3405                 :                :  *
                               3406                 :                :  *              and 'file' can be one of:
                               3407                 :                :  *              { PROGRAM 'command' | STDIN | STDOUT | 'filename' }
                               3408                 :                :  *
                               3409                 :                :  *              In the preferred syntax the options are comma-separated
                               3410                 :                :  *              and use generic identifiers instead of keywords.  The pre-9.0
                               3411                 :                :  *              syntax had a hard-wired, space-separated set of options.
                               3412                 :                :  *
                               3413                 :                :  *              Really old syntax, from versions 7.2 and prior:
                               3414                 :                :  *              COPY [ BINARY ] table FROM/TO file
                               3415                 :                :  *                  [ [ USING ] DELIMITERS 'delimiter' ] ]
                               3416                 :                :  *                  [ WITH NULL AS 'null string' ]
                               3417                 :                :  *              This option placement is not supported with COPY (query...).
                               3418                 :                :  *
                               3419                 :                :  *****************************************************************************/
                               3420                 :                : 
                               3421                 :                : CopyStmt:   COPY opt_binary qualified_name opt_column_list
                               3422                 :                :             copy_from opt_program copy_file_name copy_delimiter opt_with
                               3423                 :                :             copy_options where_clause
                               3424                 :                :                 {
10225 bruce@momjian.us         3425                 :           5664 :                     CopyStmt *n = makeNode(CopyStmt);
                               3426                 :                : 
 8570 tgl@sss.pgh.pa.us        3427                 :           5664 :                     n->relation = $3;
 6947                          3428                 :           5664 :                     n->query = NULL;
 8451 bruce@momjian.us         3429                 :           5664 :                     n->attlist = $4;
 2482 andres@anarazel.de       3430                 :           5664 :                     n->is_from = $5;
                               3431                 :           5664 :                     n->is_program = $6;
                               3432                 :           5664 :                     n->filename = $7;
 2422 tomas.vondra@postgre     3433                 :           5664 :                     n->whereClause = $11;
                               3434                 :                : 
 4574 heikki.linnakangas@i     3435   [ -  +  -  - ]:           5664 :                     if (n->is_program && n->filename == NULL)
 4574 heikki.linnakangas@i     3436         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               3437                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               3438                 :                :                                  errmsg("STDIN/STDOUT not allowed with PROGRAM"),
                               3439                 :                :                                  parser_errposition(@8)));
                               3440                 :                : 
 2422 tomas.vondra@postgre     3441   [ +  +  +  + ]:CBC        5664 :                     if (!n->is_from && n->whereClause != NULL)
                               3442         [ +  - ]:              3 :                         ereport(ERROR,
                               3443                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               3444                 :                :                                  errmsg("WHERE clause not allowed with COPY TO"),
                               3445                 :                :                                  errhint("Try the COPY (SELECT ... WHERE ...) TO variant."),
                               3446                 :                :                                  parser_errposition(@11)));
                               3447                 :                : 
 8479 bruce@momjian.us         3448                 :           5661 :                     n->options = NIL;
                               3449                 :                :                     /* Concatenate user-supplied flags */
                               3450         [ +  + ]:           5661 :                     if ($2)
                               3451                 :              6 :                         n->options = lappend(n->options, $2);
 2482 andres@anarazel.de       3452         [ -  + ]:           5661 :                     if ($8)
 2482 andres@anarazel.de       3453                 :UBC           0 :                         n->options = lappend(n->options, $8);
 2482 andres@anarazel.de       3454         [ +  + ]:CBC        5661 :                     if ($10)
                               3455                 :            501 :                         n->options = list_concat(n->options, $10);
 1212 peter@eisentraut.org     3456                 :           5661 :                     $$ = (Node *) n;
                               3457                 :                :                 }
                               3458                 :                :             | COPY '(' PreparableStmt ')' TO opt_program copy_file_name opt_with copy_options
                               3459                 :                :                 {
 6947 tgl@sss.pgh.pa.us        3460                 :            268 :                     CopyStmt *n = makeNode(CopyStmt);
                               3461                 :                : 
                               3462                 :            268 :                     n->relation = NULL;
 3571 teodor@sigaev.ru         3463                 :            268 :                     n->query = $3;
 6947 tgl@sss.pgh.pa.us        3464                 :            268 :                     n->attlist = NIL;
                               3465                 :            268 :                     n->is_from = false;
 3571 teodor@sigaev.ru         3466                 :            268 :                     n->is_program = $6;
                               3467                 :            268 :                     n->filename = $7;
                               3468                 :            268 :                     n->options = $9;
                               3469                 :                : 
 4574 heikki.linnakangas@i     3470   [ -  +  -  - ]:            268 :                     if (n->is_program && n->filename == NULL)
 4574 heikki.linnakangas@i     3471         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               3472                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               3473                 :                :                                  errmsg("STDIN/STDOUT not allowed with PROGRAM"),
                               3474                 :                :                                  parser_errposition(@5)));
                               3475                 :                : 
 1212 peter@eisentraut.org     3476                 :CBC         268 :                     $$ = (Node *) n;
                               3477                 :                :                 }
                               3478                 :                :         ;
                               3479                 :                : 
                               3480                 :                : copy_from:
 2943 peter_e@gmx.net          3481                 :            947 :             FROM                                    { $$ = true; }
                               3482                 :           4717 :             | TO                                    { $$ = false; }
                               3483                 :                :         ;
                               3484                 :                : 
                               3485                 :                : opt_program:
 2943 peter_e@gmx.net          3486                 :UBC           0 :             PROGRAM                                 { $$ = true; }
 2943 peter_e@gmx.net          3487                 :CBC        5932 :             | /* EMPTY */                           { $$ = false; }
                               3488                 :                :         ;
                               3489                 :                : 
                               3490                 :                : /*
                               3491                 :                :  * copy_file_name NULL indicates stdio is used. Whether stdin or stdout is
                               3492                 :                :  * used depends on the direction. (It really doesn't make sense to copy from
                               3493                 :                :  * stdout. We silently correct the "typo".)        - AY 9/94
                               3494                 :                :  */
                               3495                 :                : copy_file_name:
 8482 bruce@momjian.us         3496                 :            244 :             Sconst                                  { $$ = $1; }
                               3497                 :            735 :             | STDIN                                 { $$ = NULL; }
                               3498                 :           4953 :             | STDOUT                                { $$ = NULL; }
                               3499                 :                :         ;
                               3500                 :                : 
 5829 tgl@sss.pgh.pa.us        3501                 :           5583 : copy_options: copy_opt_list                         { $$ = $1; }
                               3502                 :            349 :             | '(' copy_generic_opt_list ')'         { $$ = $2; }
                               3503                 :                :         ;
                               3504                 :                : 
                               3505                 :                : /* old COPY option syntax */
                               3506                 :                : copy_opt_list:
 8479 bruce@momjian.us         3507                 :            269 :             copy_opt_list copy_opt_item             { $$ = lappend($1, $2); }
                               3508                 :           5583 :             | /* EMPTY */                           { $$ = NIL; }
                               3509                 :                :         ;
                               3510                 :                : 
                               3511                 :                : copy_opt_item:
                               3512                 :                :             BINARY
                               3513                 :                :                 {
 1212 peter@eisentraut.org     3514                 :UBC           0 :                     $$ = makeDefElem("format", (Node *) makeString("binary"), @1);
                               3515                 :                :                 }
                               3516                 :                :             | FREEZE
                               3517                 :                :                 {
 1212 peter@eisentraut.org     3518                 :CBC          25 :                     $$ = makeDefElem("freeze", (Node *) makeBoolean(true), @1);
                               3519                 :                :                 }
                               3520                 :                :             | DELIMITER opt_as Sconst
                               3521                 :                :                 {
                               3522                 :            103 :                     $$ = makeDefElem("delimiter", (Node *) makeString($3), @1);
                               3523                 :                :                 }
                               3524                 :                :             | NULL_P opt_as Sconst
                               3525                 :                :                 {
                               3526                 :             24 :                     $$ = makeDefElem("null", (Node *) makeString($3), @1);
                               3527                 :                :                 }
                               3528                 :                :             | CSV
                               3529                 :                :                 {
                               3530                 :             75 :                     $$ = makeDefElem("format", (Node *) makeString("csv"), @1);
                               3531                 :                :                 }
                               3532                 :                :             | HEADER_P
                               3533                 :                :                 {
                               3534                 :              9 :                     $$ = makeDefElem("header", (Node *) makeBoolean(true), @1);
                               3535                 :                :                 }
                               3536                 :                :             | QUOTE opt_as Sconst
                               3537                 :                :                 {
                               3538                 :              9 :                     $$ = makeDefElem("quote", (Node *) makeString($3), @1);
                               3539                 :                :                 }
                               3540                 :                :             | ESCAPE opt_as Sconst
                               3541                 :                :                 {
                               3542                 :              9 :                     $$ = makeDefElem("escape", (Node *) makeString($3), @1);
                               3543                 :                :                 }
                               3544                 :                :             | FORCE QUOTE columnList
                               3545                 :                :                 {
                               3546                 :              6 :                     $$ = makeDefElem("force_quote", (Node *) $3, @1);
                               3547                 :                :                 }
                               3548                 :                :             | FORCE QUOTE '*'
                               3549                 :                :                 {
                               3550                 :              3 :                     $$ = makeDefElem("force_quote", (Node *) makeNode(A_Star), @1);
                               3551                 :                :                 }
                               3552                 :                :             | FORCE NOT NULL_P columnList
                               3553                 :                :                 {
 1212 peter@eisentraut.org     3554                 :UBC           0 :                     $$ = makeDefElem("force_not_null", (Node *) $4, @1);
                               3555                 :                :                 }
                               3556                 :                :             | FORCE NOT NULL_P '*'
                               3557                 :                :                 {
  707 andrew@dunslane.net      3558                 :              0 :                     $$ = makeDefElem("force_not_null", (Node *) makeNode(A_Star), @1);
                               3559                 :                :                 }
                               3560                 :                :             | FORCE NULL_P columnList
                               3561                 :                :                 {
 1212 peter@eisentraut.org     3562                 :              0 :                     $$ = makeDefElem("force_null", (Node *) $3, @1);
                               3563                 :                :                 }
                               3564                 :                :             | FORCE NULL_P '*'
                               3565                 :                :                 {
  707 andrew@dunslane.net      3566                 :              0 :                     $$ = makeDefElem("force_null", (Node *) makeNode(A_Star), @1);
                               3567                 :                :                 }
                               3568                 :                :             | ENCODING Sconst
                               3569                 :                :                 {
 1212 peter@eisentraut.org     3570                 :CBC           6 :                     $$ = makeDefElem("encoding", (Node *) makeString($2), @1);
                               3571                 :                :                 }
                               3572                 :                :         ;
                               3573                 :                : 
                               3574                 :                : /* The following exist for backward compatibility with very old versions */
                               3575                 :                : 
                               3576                 :                : opt_binary:
                               3577                 :                :             BINARY
                               3578                 :                :                 {
                               3579                 :              6 :                     $$ = makeDefElem("format", (Node *) makeString("binary"), @1);
                               3580                 :                :                 }
 8479 bruce@momjian.us         3581                 :           5658 :             | /*EMPTY*/                             { $$ = NULL; }
                               3582                 :                :         ;
                               3583                 :                : 
                               3584                 :                : copy_delimiter:
                               3585                 :                :             opt_using DELIMITERS Sconst
                               3586                 :                :                 {
 1212 peter@eisentraut.org     3587                 :UBC           0 :                     $$ = makeDefElem("delimiter", (Node *) makeString($3), @2);
                               3588                 :                :                 }
 8479 bruce@momjian.us         3589                 :CBC        5664 :             | /*EMPTY*/                             { $$ = NULL; }
                               3590                 :                :         ;
                               3591                 :                : 
                               3592                 :                : opt_using:
                               3593                 :                :             USING
                               3594                 :                :             | /*EMPTY*/
                               3595                 :                :         ;
                               3596                 :                : 
                               3597                 :                : /* new COPY option syntax */
                               3598                 :                : copy_generic_opt_list:
                               3599                 :                :             copy_generic_opt_elem
                               3600                 :                :                 {
 5829 tgl@sss.pgh.pa.us        3601                 :            349 :                     $$ = list_make1($1);
                               3602                 :                :                 }
                               3603                 :                :             | copy_generic_opt_list ',' copy_generic_opt_elem
                               3604                 :                :                 {
                               3605                 :            234 :                     $$ = lappend($1, $3);
                               3606                 :                :                 }
                               3607                 :                :         ;
                               3608                 :                : 
                               3609                 :                : copy_generic_opt_elem:
                               3610                 :                :             ColLabel copy_generic_opt_arg
                               3611                 :                :                 {
 3287 peter_e@gmx.net          3612                 :            583 :                     $$ = makeDefElem($1, $2, @1);
                               3613                 :                :                 }
                               3614                 :                :         ;
                               3615                 :                : 
                               3616                 :                : copy_generic_opt_arg:
 5433 heikki.linnakangas@i     3617                 :            409 :             opt_boolean_or_string           { $$ = (Node *) makeString($1); }
 5829 tgl@sss.pgh.pa.us        3618                 :             30 :             | NumericOnly                   { $$ = (Node *) $1; }
                               3619                 :             45 :             | '*'                           { $$ = (Node *) makeNode(A_Star); }
  523 msawada@postgresql.o     3620                 :              3 :             | DEFAULT                       { $$ = (Node *) makeString("default"); }
 5829 tgl@sss.pgh.pa.us        3621                 :             75 :             | '(' copy_generic_opt_arg_list ')'     { $$ = (Node *) $2; }
                               3622                 :             21 :             | /* EMPTY */                   { $$ = NULL; }
                               3623                 :                :         ;
                               3624                 :                : 
                               3625                 :                : copy_generic_opt_arg_list:
                               3626                 :                :               copy_generic_opt_arg_list_item
                               3627                 :                :                 {
                               3628                 :             75 :                     $$ = list_make1($1);
                               3629                 :                :                 }
                               3630                 :                :             | copy_generic_opt_arg_list ',' copy_generic_opt_arg_list_item
                               3631                 :                :                 {
                               3632                 :              6 :                     $$ = lappend($1, $3);
                               3633                 :                :                 }
                               3634                 :                :         ;
                               3635                 :                : 
                               3636                 :                : /* beware of emitting non-string list elements here; see commands/define.c */
                               3637                 :                : copy_generic_opt_arg_list_item:
 5433 heikki.linnakangas@i     3638                 :             81 :             opt_boolean_or_string   { $$ = (Node *) makeString($1); }
                               3639                 :                :         ;
                               3640                 :                : 
                               3641                 :                : 
                               3642                 :                : /*****************************************************************************
                               3643                 :                :  *
                               3644                 :                :  *      QUERY :
                               3645                 :                :  *              CREATE TABLE relname
                               3646                 :                :  *
                               3647                 :                :  *****************************************************************************/
                               3648                 :                : 
                               3649                 :                : CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
                               3650                 :                :             OptInherit OptPartitionSpec table_access_method_clause OptWith
                               3651                 :                :             OnCommitOption OptTableSpace
                               3652                 :                :                 {
10225 bruce@momjian.us         3653                 :          14783 :                     CreateStmt *n = makeNode(CreateStmt);
                               3654                 :                : 
 5381 rhaas@postgresql.org     3655                 :          14783 :                     $4->relpersistence = $2;
 8570 tgl@sss.pgh.pa.us        3656                 :          14783 :                     n->relation = $4;
 9010                          3657                 :          14783 :                     n->tableElts = $6;
 8570                          3658                 :          14783 :                     n->inhRelations = $8;
 3195 rhaas@postgresql.org     3659                 :          14783 :                     n->partspec = $9;
 3821 tgl@sss.pgh.pa.us        3660                 :          14783 :                     n->ofTypename = NULL;
10138 lockhart@fourpalms.o     3661                 :          14783 :                     n->constraints = NIL;
 2376 andres@anarazel.de       3662                 :          14783 :                     n->accessMethod = $10;
                               3663                 :          14783 :                     n->options = $11;
                               3664                 :          14783 :                     n->oncommit = $12;
                               3665                 :          14783 :                     n->tablespacename = $13;
 5522 rhaas@postgresql.org     3666                 :          14783 :                     n->if_not_exists = false;
 1212 peter@eisentraut.org     3667                 :          14783 :                     $$ = (Node *) n;
                               3668                 :                :                 }
                               3669                 :                :         | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name '('
                               3670                 :                :             OptTableElementList ')' OptInherit OptPartitionSpec table_access_method_clause
                               3671                 :                :             OptWith OnCommitOption OptTableSpace
                               3672                 :                :                 {
 5522 rhaas@postgresql.org     3673                 :             14 :                     CreateStmt *n = makeNode(CreateStmt);
                               3674                 :                : 
 5381                          3675                 :             14 :                     $7->relpersistence = $2;
 5522                          3676                 :             14 :                     n->relation = $7;
                               3677                 :             14 :                     n->tableElts = $9;
                               3678                 :             14 :                     n->inhRelations = $11;
 3195                          3679                 :             14 :                     n->partspec = $12;
 3821 tgl@sss.pgh.pa.us        3680                 :             14 :                     n->ofTypename = NULL;
 5522 rhaas@postgresql.org     3681                 :             14 :                     n->constraints = NIL;
 2376 andres@anarazel.de       3682                 :             14 :                     n->accessMethod = $13;
                               3683                 :             14 :                     n->options = $14;
                               3684                 :             14 :                     n->oncommit = $15;
                               3685                 :             14 :                     n->tablespacename = $16;
 5522 rhaas@postgresql.org     3686                 :             14 :                     n->if_not_exists = true;
 1212 peter@eisentraut.org     3687                 :             14 :                     $$ = (Node *) n;
                               3688                 :                :                 }
                               3689                 :                :         | CREATE OptTemp TABLE qualified_name OF any_name
                               3690                 :                :             OptTypedTableElementList OptPartitionSpec table_access_method_clause
                               3691                 :                :             OptWith OnCommitOption OptTableSpace
                               3692                 :                :                 {
 8434 lockhart@fourpalms.o     3693                 :             61 :                     CreateStmt *n = makeNode(CreateStmt);
                               3694                 :                : 
 5381 rhaas@postgresql.org     3695                 :             61 :                     $4->relpersistence = $2;
 8434 lockhart@fourpalms.o     3696                 :             61 :                     n->relation = $4;
 5700 peter_e@gmx.net          3697                 :             61 :                     n->tableElts = $7;
 3821 tgl@sss.pgh.pa.us        3698                 :             61 :                     n->inhRelations = NIL;
 3195 rhaas@postgresql.org     3699                 :             61 :                     n->partspec = $8;
 5700 peter_e@gmx.net          3700                 :             61 :                     n->ofTypename = makeTypeNameFromNameList($6);
                               3701                 :             61 :                     n->ofTypename->location = @6;
 8434 lockhart@fourpalms.o     3702                 :             61 :                     n->constraints = NIL;
 2376 andres@anarazel.de       3703                 :             61 :                     n->accessMethod = $9;
                               3704                 :             61 :                     n->options = $10;
                               3705                 :             61 :                     n->oncommit = $11;
                               3706                 :             61 :                     n->tablespacename = $12;
 5522 rhaas@postgresql.org     3707                 :             61 :                     n->if_not_exists = false;
 1212 peter@eisentraut.org     3708                 :             61 :                     $$ = (Node *) n;
                               3709                 :                :                 }
                               3710                 :                :         | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name OF any_name
                               3711                 :                :             OptTypedTableElementList OptPartitionSpec table_access_method_clause
                               3712                 :                :             OptWith OnCommitOption OptTableSpace
                               3713                 :                :                 {
 5522 rhaas@postgresql.org     3714                 :              3 :                     CreateStmt *n = makeNode(CreateStmt);
                               3715                 :                : 
 5381                          3716                 :              3 :                     $7->relpersistence = $2;
 5522                          3717                 :              3 :                     n->relation = $7;
                               3718                 :              3 :                     n->tableElts = $10;
 3821 tgl@sss.pgh.pa.us        3719                 :              3 :                     n->inhRelations = NIL;
 3195 rhaas@postgresql.org     3720                 :              3 :                     n->partspec = $11;
 5522                          3721                 :              3 :                     n->ofTypename = makeTypeNameFromNameList($9);
                               3722                 :              3 :                     n->ofTypename->location = @9;
                               3723                 :              3 :                     n->constraints = NIL;
 2376 andres@anarazel.de       3724                 :              3 :                     n->accessMethod = $12;
                               3725                 :              3 :                     n->options = $13;
                               3726                 :              3 :                     n->oncommit = $14;
                               3727                 :              3 :                     n->tablespacename = $15;
 3195 rhaas@postgresql.org     3728                 :              3 :                     n->if_not_exists = true;
 1212 peter@eisentraut.org     3729                 :              3 :                     $$ = (Node *) n;
                               3730                 :                :                 }
                               3731                 :                :         | CREATE OptTemp TABLE qualified_name PARTITION OF qualified_name
                               3732                 :                :             OptTypedTableElementList PartitionBoundSpec OptPartitionSpec
                               3733                 :                :             table_access_method_clause OptWith OnCommitOption OptTableSpace
                               3734                 :                :                 {
 3195 rhaas@postgresql.org     3735                 :           3988 :                     CreateStmt *n = makeNode(CreateStmt);
                               3736                 :                : 
                               3737                 :           3988 :                     $4->relpersistence = $2;
                               3738                 :           3988 :                     n->relation = $4;
                               3739                 :           3988 :                     n->tableElts = $8;
                               3740                 :           3988 :                     n->inhRelations = list_make1($7);
 3023 tgl@sss.pgh.pa.us        3741                 :           3988 :                     n->partbound = $9;
 3195 rhaas@postgresql.org     3742                 :           3988 :                     n->partspec = $10;
                               3743                 :           3988 :                     n->ofTypename = NULL;
                               3744                 :           3988 :                     n->constraints = NIL;
 2376 andres@anarazel.de       3745                 :           3988 :                     n->accessMethod = $11;
                               3746                 :           3988 :                     n->options = $12;
                               3747                 :           3988 :                     n->oncommit = $13;
                               3748                 :           3988 :                     n->tablespacename = $14;
 3195 rhaas@postgresql.org     3749                 :           3988 :                     n->if_not_exists = false;
 1212 peter@eisentraut.org     3750                 :           3988 :                     $$ = (Node *) n;
                               3751                 :                :                 }
                               3752                 :                :         | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name PARTITION OF
                               3753                 :                :             qualified_name OptTypedTableElementList PartitionBoundSpec OptPartitionSpec
                               3754                 :                :             table_access_method_clause OptWith OnCommitOption OptTableSpace
                               3755                 :                :                 {
 3195 rhaas@postgresql.org     3756                 :UBC           0 :                     CreateStmt *n = makeNode(CreateStmt);
                               3757                 :                : 
                               3758                 :              0 :                     $7->relpersistence = $2;
                               3759                 :              0 :                     n->relation = $7;
                               3760                 :              0 :                     n->tableElts = $11;
                               3761                 :              0 :                     n->inhRelations = list_make1($10);
 3023 tgl@sss.pgh.pa.us        3762                 :              0 :                     n->partbound = $12;
 3195 rhaas@postgresql.org     3763                 :              0 :                     n->partspec = $13;
                               3764                 :              0 :                     n->ofTypename = NULL;
                               3765                 :              0 :                     n->constraints = NIL;
 2376 andres@anarazel.de       3766                 :              0 :                     n->accessMethod = $14;
                               3767                 :              0 :                     n->options = $15;
                               3768                 :              0 :                     n->oncommit = $16;
                               3769                 :              0 :                     n->tablespacename = $17;
 5522 rhaas@postgresql.org     3770                 :              0 :                     n->if_not_exists = true;
 1212 peter@eisentraut.org     3771                 :              0 :                     $$ = (Node *) n;
                               3772                 :                :                 }
                               3773                 :                :         ;
                               3774                 :                : 
                               3775                 :                : /*
                               3776                 :                :  * Redundancy here is needed to avoid shift/reduce conflicts,
                               3777                 :                :  * since TEMP is not a reserved word.  See also OptTempTableName.
                               3778                 :                :  *
                               3779                 :                :  * NOTE: we accept both GLOBAL and LOCAL options.  They currently do nothing,
                               3780                 :                :  * but future versions might consider GLOBAL to request SQL-spec-compliant
                               3781                 :                :  * temp table behavior, so warn about that.  Since we have no modules the
                               3782                 :                :  * LOCAL keyword is really meaningless; furthermore, some other products
                               3783                 :                :  * implement LOCAL as meaning the same as our default temp table behavior,
                               3784                 :                :  * so we'll probably continue to treat LOCAL as a noise word.
                               3785                 :                :  */
 5381 rhaas@postgresql.org     3786                 :CBC         179 : OptTemp:    TEMPORARY                   { $$ = RELPERSISTENCE_TEMP; }
                               3787                 :           1386 :             | TEMP                      { $$ = RELPERSISTENCE_TEMP; }
 4836 simon@2ndQuadrant.co     3788                 :UBC           0 :             | LOCAL TEMPORARY           { $$ = RELPERSISTENCE_TEMP; }
                               3789                 :              0 :             | LOCAL TEMP                { $$ = RELPERSISTENCE_TEMP; }
                               3790                 :                :             | GLOBAL TEMPORARY
                               3791                 :                :                 {
 4833 tgl@sss.pgh.pa.us        3792         [ #  # ]:              0 :                     ereport(WARNING,
                               3793                 :                :                             (errmsg("GLOBAL is deprecated in temporary table creation"),
                               3794                 :                :                              parser_errposition(@1)));
                               3795                 :              0 :                     $$ = RELPERSISTENCE_TEMP;
                               3796                 :                :                 }
                               3797                 :                :             | GLOBAL TEMP
                               3798                 :                :                 {
                               3799         [ #  # ]:              0 :                     ereport(WARNING,
                               3800                 :                :                             (errmsg("GLOBAL is deprecated in temporary table creation"),
                               3801                 :                :                              parser_errposition(@1)));
                               3802                 :              0 :                     $$ = RELPERSISTENCE_TEMP;
                               3803                 :                :                 }
 5365 rhaas@postgresql.org     3804                 :CBC          82 :             | UNLOGGED                  { $$ = RELPERSISTENCE_UNLOGGED; }
 5381                          3805                 :          26763 :             | /*EMPTY*/                 { $$ = RELPERSISTENCE_PERMANENT; }
                               3806                 :                :         ;
                               3807                 :                : 
                               3808                 :                : OptTableElementList:
 8433 tgl@sss.pgh.pa.us        3809                 :          14212 :             TableElementList                    { $$ = $1; }
                               3810                 :            806 :             | /*EMPTY*/                         { $$ = NIL; }
                               3811                 :                :         ;
                               3812                 :                : 
                               3813                 :                : OptTypedTableElementList:
 5700 peter_e@gmx.net          3814                 :            174 :             '(' TypedTableElementList ')'       { $$ = $2; }
                               3815                 :           3926 :             | /*EMPTY*/                         { $$ = NIL; }
                               3816                 :                :         ;
                               3817                 :                : 
                               3818                 :                : TableElementList:
                               3819                 :                :             TableElement
                               3820                 :                :                 {
 7769 neilc@samurai.com        3821                 :          14239 :                     $$ = list_make1($1);
                               3822                 :                :                 }
                               3823                 :                :             | TableElementList ',' TableElement
                               3824                 :                :                 {
 8409 tgl@sss.pgh.pa.us        3825                 :          20073 :                     $$ = lappend($1, $3);
                               3826                 :                :                 }
                               3827                 :                :         ;
                               3828                 :                : 
                               3829                 :                : TypedTableElementList:
                               3830                 :                :             TypedTableElement
                               3831                 :                :                 {
 5700 peter_e@gmx.net          3832                 :            174 :                     $$ = list_make1($1);
                               3833                 :                :                 }
                               3834                 :                :             | TypedTableElementList ',' TypedTableElement
                               3835                 :                :                 {
                               3836                 :             34 :                     $$ = lappend($1, $3);
                               3837                 :                :                 }
                               3838                 :                :         ;
                               3839                 :                : 
                               3840                 :                : TableElement:
 8482 bruce@momjian.us         3841                 :          32585 :             columnDef                           { $$ = $1; }
 8477 lockhart@fourpalms.o     3842                 :            387 :             | TableLikeClause                   { $$ = $1; }
10138                          3843                 :           1340 :             | TableConstraint                   { $$ = $1; }
                               3844                 :                :         ;
                               3845                 :                : 
                               3846                 :                : TypedTableElement:
 5700 peter_e@gmx.net          3847                 :            173 :             columnOptions                       { $$ = $1; }
                               3848                 :             35 :             | TableConstraint                   { $$ = $1; }
                               3849                 :                :         ;
                               3850                 :                : 
                               3851                 :                : columnDef:  ColId Typename opt_column_storage opt_column_compression create_generic_options ColQualList
                               3852                 :                :                 {
10138 lockhart@fourpalms.o     3853                 :          33659 :                     ColumnDef *n = makeNode(ColumnDef);
                               3854                 :                : 
                               3855                 :          33659 :                     n->colname = $1;
 5896 peter_e@gmx.net          3856                 :          33659 :                     n->typeName = $2;
 1151 peter@eisentraut.org     3857                 :          33659 :                     n->storage_name = $3;
                               3858                 :          33659 :                     n->compression = $4;
 5295 tgl@sss.pgh.pa.us        3859                 :          33659 :                     n->inhcount = 0;
 8385                          3860                 :          33659 :                     n->is_local = true;
 5295                          3861                 :          33659 :                     n->is_not_null = false;
                               3862                 :          33659 :                     n->is_from_type = false;
  564 peter@eisentraut.org     3863                 :          33659 :                     n->storage = 0;
 5295 tgl@sss.pgh.pa.us        3864                 :          33659 :                     n->raw_default = NULL;
                               3865                 :          33659 :                     n->cooked_default = NULL;
                               3866                 :          33659 :                     n->collOid = InvalidOid;
 1151 peter@eisentraut.org     3867                 :          33659 :                     n->fdwoptions = $5;
                               3868                 :          33659 :                     SplitColQualList($6, &n->constraints, &n->collClause,
                               3869                 :                :                                      yyscanner);
 4307 tgl@sss.pgh.pa.us        3870                 :          33659 :                     n->location = @1;
 1212 peter@eisentraut.org     3871                 :          33659 :                     $$ = (Node *) n;
                               3872                 :                :                 }
                               3873                 :                :         ;
                               3874                 :                : 
                               3875                 :                : columnOptions:  ColId ColQualList
                               3876                 :                :                 {
 3054 sfrost@snowman.net       3877                 :             69 :                     ColumnDef *n = makeNode(ColumnDef);
                               3878                 :                : 
                               3879                 :             69 :                     n->colname = $1;
                               3880                 :             69 :                     n->typeName = NULL;
                               3881                 :             69 :                     n->inhcount = 0;
                               3882                 :             69 :                     n->is_local = true;
                               3883                 :             69 :                     n->is_not_null = false;
                               3884                 :             69 :                     n->is_from_type = false;
  564 peter@eisentraut.org     3885                 :             69 :                     n->storage = 0;
 3054 sfrost@snowman.net       3886                 :             69 :                     n->raw_default = NULL;
                               3887                 :             69 :                     n->cooked_default = NULL;
                               3888                 :             69 :                     n->collOid = InvalidOid;
                               3889                 :             69 :                     SplitColQualList($2, &n->constraints, &n->collClause,
                               3890                 :                :                                      yyscanner);
                               3891                 :             69 :                     n->location = @1;
 1212 peter@eisentraut.org     3892                 :             69 :                     $$ = (Node *) n;
                               3893                 :                :                 }
                               3894                 :                :                 | ColId WITH OPTIONS ColQualList
                               3895                 :                :                 {
 5700 peter_e@gmx.net          3896                 :            104 :                     ColumnDef *n = makeNode(ColumnDef);
                               3897                 :                : 
                               3898                 :            104 :                     n->colname = $1;
 5295 tgl@sss.pgh.pa.us        3899                 :            104 :                     n->typeName = NULL;
                               3900                 :            104 :                     n->inhcount = 0;
 5700 peter_e@gmx.net          3901                 :            104 :                     n->is_local = true;
 5295 tgl@sss.pgh.pa.us        3902                 :            104 :                     n->is_not_null = false;
                               3903                 :            104 :                     n->is_from_type = false;
  564 peter@eisentraut.org     3904                 :            104 :                     n->storage = 0;
 5295 tgl@sss.pgh.pa.us        3905                 :            104 :                     n->raw_default = NULL;
                               3906                 :            104 :                     n->cooked_default = NULL;
                               3907                 :            104 :                     n->collOid = InvalidOid;
                               3908                 :            104 :                     SplitColQualList($4, &n->constraints, &n->collClause,
                               3909                 :                :                                      yyscanner);
 4307                          3910                 :            104 :                     n->location = @1;
 1212 peter@eisentraut.org     3911                 :            104 :                     $$ = (Node *) n;
                               3912                 :                :                 }
                               3913                 :                :         ;
                               3914                 :                : 
                               3915                 :                : column_compression:
 1563 tgl@sss.pgh.pa.us        3916                 :             83 :             COMPRESSION ColId                       { $$ = $2; }
                               3917                 :              3 :             | COMPRESSION DEFAULT                   { $$ = pstrdup("default"); }
                               3918                 :                :         ;
                               3919                 :                : 
                               3920                 :                : opt_column_compression:
                               3921                 :             47 :             column_compression                      { $$ = $1; }
                               3922                 :          33645 :             | /*EMPTY*/                             { $$ = NULL; }
                               3923                 :                :         ;
                               3924                 :                : 
                               3925                 :                : column_storage:
 1151 peter@eisentraut.org     3926                 :            129 :             STORAGE ColId                           { $$ = $2; }
 1031 tgl@sss.pgh.pa.us        3927                 :              3 :             | STORAGE DEFAULT                       { $$ = pstrdup("default"); }
                               3928                 :                :         ;
                               3929                 :                : 
                               3930                 :                : opt_column_storage:
 1151 peter@eisentraut.org     3931                 :             13 :             column_storage                          { $$ = $1; }
                               3932                 :          33679 :             | /*EMPTY*/                             { $$ = NULL; }
                               3933                 :                :         ;
                               3934                 :                : 
                               3935                 :                : ColQualList:
 8482 bruce@momjian.us         3936                 :           9920 :             ColQualList ColConstraint               { $$ = lappend($1, $2); }
                               3937                 :          34591 :             | /*EMPTY*/                             { $$ = NIL; }
                               3938                 :                :         ;
                               3939                 :                : 
                               3940                 :                : ColConstraint:
                               3941                 :                :             CONSTRAINT name ColConstraintElem
                               3942                 :                :                 {
 3119 peter_e@gmx.net          3943                 :            401 :                     Constraint *n = castNode(Constraint, $3);
                               3944                 :                : 
 5882 tgl@sss.pgh.pa.us        3945                 :            401 :                     n->conname = $2;
                               3946                 :            401 :                     n->location = @1;
                               3947                 :            401 :                     $$ = (Node *) n;
                               3948                 :                :                 }
 8482 bruce@momjian.us         3949                 :           8991 :             | ColConstraintElem                     { $$ = $1; }
                               3950                 :            147 :             | ConstraintAttr                        { $$ = $1; }
                               3951                 :                :             | COLLATE any_name
                               3952                 :                :                 {
                               3953                 :                :                     /*
                               3954                 :                :                      * Note: the CollateClause is momentarily included in
                               3955                 :                :                      * the list built by ColQualList, but we split it out
                               3956                 :                :                      * again in SplitColQualList.
                               3957                 :                :                      */
 5295 tgl@sss.pgh.pa.us        3958                 :            381 :                     CollateClause *n = makeNode(CollateClause);
                               3959                 :                : 
                               3960                 :            381 :                     n->arg = NULL;
 5293                          3961                 :            381 :                     n->collname = $2;
 5295                          3962                 :            381 :                     n->location = @1;
                               3963                 :            381 :                     $$ = (Node *) n;
                               3964                 :                :                 }
                               3965                 :                :         ;
                               3966                 :                : 
                               3967                 :                : /* DEFAULT NULL is already the default for Postgres.
                               3968                 :                :  * But define it here and carry it forward into the system
                               3969                 :                :  * to make it explicit.
                               3970                 :                :  * - thomas 1998-09-13
                               3971                 :                :  *
                               3972                 :                :  * WITH NULL and NULL are not SQL-standard syntax elements,
                               3973                 :                :  * so leave them out. Use DEFAULT NULL to explicitly indicate
                               3974                 :                :  * that a column may have that value. WITH NULL leads to
                               3975                 :                :  * shift/reduce conflicts with WITH TIME ZONE anyway.
                               3976                 :                :  * - thomas 1999-01-08
                               3977                 :                :  *
                               3978                 :                :  * DEFAULT expression must be b_expr not a_expr to prevent shift/reduce
                               3979                 :                :  * conflict on NOT (since NOT might start a subsequent NOT NULL constraint,
                               3980                 :                :  * or be part of a_expr NOT LIKE or similar constructs).
                               3981                 :                :  */
                               3982                 :                : ColConstraintElem:
                               3983                 :                :             NOT NULL_P opt_no_inherit
                               3984                 :                :                 {
 9320                          3985                 :           3354 :                     Constraint *n = makeNode(Constraint);
                               3986                 :                : 
                               3987                 :           3354 :                     n->contype = CONSTR_NOTNULL;
 5882                          3988                 :           3354 :                     n->location = @1;
  302 alvherre@alvh.no-ip.     3989                 :           3354 :                     n->is_no_inherit = $3;
  238 peter@eisentraut.org     3990                 :           3354 :                     n->is_enforced = true;
  302 alvherre@alvh.no-ip.     3991                 :           3354 :                     n->skip_validation = false;
                               3992                 :           3354 :                     n->initially_valid = true;
 1212 peter@eisentraut.org     3993                 :           3354 :                     $$ = (Node *) n;
                               3994                 :                :                 }
                               3995                 :                :             | NULL_P
                               3996                 :                :                 {
 9320 tgl@sss.pgh.pa.us        3997                 :             14 :                     Constraint *n = makeNode(Constraint);
                               3998                 :                : 
                               3999                 :             14 :                     n->contype = CONSTR_NULL;
 5882                          4000                 :             14 :                     n->location = @1;
 1212 peter@eisentraut.org     4001                 :             14 :                     $$ = (Node *) n;
                               4002                 :                :                 }
                               4003                 :                :             | UNIQUE opt_unique_null_treatment opt_definition OptConsTableSpace
                               4004                 :                :                 {
 9852 lockhart@fourpalms.o     4005                 :            232 :                     Constraint *n = makeNode(Constraint);
                               4006                 :                : 
 9335                          4007                 :            232 :                     n->contype = CONSTR_UNIQUE;
 5882 tgl@sss.pgh.pa.us        4008                 :            232 :                     n->location = @1;
 1311 peter@eisentraut.org     4009                 :            232 :                     n->nulls_not_distinct = !$2;
 9852 lockhart@fourpalms.o     4010                 :            232 :                     n->keys = NULL;
 1311 peter@eisentraut.org     4011                 :            232 :                     n->options = $3;
 5338 tgl@sss.pgh.pa.us        4012                 :            232 :                     n->indexname = NULL;
 1311 peter@eisentraut.org     4013                 :            232 :                     n->indexspace = $4;
 1212                          4014                 :            232 :                     $$ = (Node *) n;
                               4015                 :                :                 }
                               4016                 :                :             | PRIMARY KEY opt_definition OptConsTableSpace
                               4017                 :                :                 {
 9320 tgl@sss.pgh.pa.us        4018                 :           2919 :                     Constraint *n = makeNode(Constraint);
                               4019                 :                : 
                               4020                 :           2919 :                     n->contype = CONSTR_PRIMARY;
 5882                          4021                 :           2919 :                     n->location = @1;
 9320                          4022                 :           2919 :                     n->keys = NULL;
 7006 bruce@momjian.us         4023                 :           2919 :                     n->options = $3;
 5338 tgl@sss.pgh.pa.us        4024                 :           2919 :                     n->indexname = NULL;
 7006 bruce@momjian.us         4025                 :           2919 :                     n->indexspace = $4;
 1212 peter@eisentraut.org     4026                 :           2919 :                     $$ = (Node *) n;
                               4027                 :                :                 }
                               4028                 :                :             | CHECK '(' a_expr ')' opt_no_inherit
                               4029                 :                :                 {
10138 lockhart@fourpalms.o     4030                 :            543 :                     Constraint *n = makeNode(Constraint);
                               4031                 :                : 
 9335                          4032                 :            543 :                     n->contype = CONSTR_CHECK;
 5882 tgl@sss.pgh.pa.us        4033                 :            543 :                     n->location = @1;
 4792 alvherre@alvh.no-ip.     4034                 :            543 :                     n->is_no_inherit = $5;
                               4035                 :            543 :                     n->raw_expr = $3;
 9470 tgl@sss.pgh.pa.us        4036                 :            543 :                     n->cooked_expr = NULL;
  238 peter@eisentraut.org     4037                 :            543 :                     n->is_enforced = true;
 3552 rhaas@postgresql.org     4038                 :            543 :                     n->skip_validation = false;
                               4039                 :            543 :                     n->initially_valid = true;
 1212 peter@eisentraut.org     4040                 :            543 :                     $$ = (Node *) n;
                               4041                 :                :                 }
                               4042                 :                :             | DEFAULT b_expr
                               4043                 :                :                 {
 9320 tgl@sss.pgh.pa.us        4044                 :            901 :                     Constraint *n = makeNode(Constraint);
                               4045                 :                : 
                               4046                 :            901 :                     n->contype = CONSTR_DEFAULT;
 5882                          4047                 :            901 :                     n->location = @1;
 6522                          4048                 :            901 :                     n->raw_expr = $2;
 9320                          4049                 :            901 :                     n->cooked_expr = NULL;
 1212 peter@eisentraut.org     4050                 :            901 :                     $$ = (Node *) n;
                               4051                 :                :                 }
                               4052                 :                :             | GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
                               4053                 :                :                 {
 3075 peter_e@gmx.net          4054                 :            166 :                     Constraint *n = makeNode(Constraint);
                               4055                 :                : 
                               4056                 :            166 :                     n->contype = CONSTR_IDENTITY;
                               4057                 :            166 :                     n->generated_when = $2;
                               4058                 :            166 :                     n->options = $5;
                               4059                 :            166 :                     n->location = @1;
 1212 peter@eisentraut.org     4060                 :            166 :                     $$ = (Node *) n;
                               4061                 :                :                 }
                               4062                 :                :             | GENERATED generated_when AS '(' a_expr ')' opt_virtual_or_stored
                               4063                 :                :                 {
 2352                          4064                 :            855 :                     Constraint *n = makeNode(Constraint);
                               4065                 :                : 
                               4066                 :            855 :                     n->contype = CONSTR_GENERATED;
                               4067                 :            855 :                     n->generated_when = $2;
                               4068                 :            855 :                     n->raw_expr = $5;
                               4069                 :            855 :                     n->cooked_expr = NULL;
  211                          4070                 :            855 :                     n->generated_kind = $7;
 2352                          4071                 :            855 :                     n->location = @1;
                               4072                 :                : 
                               4073                 :                :                     /*
                               4074                 :                :                      * Can't do this in the grammar because of shift/reduce
                               4075                 :                :                      * conflicts.  (IDENTITY allows both ALWAYS and BY
                               4076                 :                :                      * DEFAULT, but generated columns only allow ALWAYS.)  We
                               4077                 :                :                      * can also give a more useful error message and location.
                               4078                 :                :                      */
 2350                          4079         [ +  + ]:            855 :                     if ($2 != ATTRIBUTE_IDENTITY_ALWAYS)
                               4080         [ +  - ]:              6 :                         ereport(ERROR,
                               4081                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               4082                 :                :                                  errmsg("for a generated column, GENERATED ALWAYS must be specified"),
                               4083                 :                :                                  parser_errposition(@2)));
                               4084                 :                : 
 1212                          4085                 :            849 :                     $$ = (Node *) n;
                               4086                 :                :                 }
                               4087                 :                :             | REFERENCES qualified_name opt_column_list key_match key_actions
                               4088                 :                :                 {
 5882 tgl@sss.pgh.pa.us        4089                 :            414 :                     Constraint *n = makeNode(Constraint);
                               4090                 :                : 
                               4091                 :            414 :                     n->contype = CONSTR_FOREIGN;
                               4092                 :            414 :                     n->location = @1;
 1515 peter@eisentraut.org     4093                 :            414 :                     n->pktable = $2;
                               4094                 :            414 :                     n->fk_attrs = NIL;
                               4095                 :            414 :                     n->pk_attrs = $3;
                               4096                 :            414 :                     n->fk_matchtype = $4;
 1368                          4097                 :            414 :                     n->fk_upd_action = ($5)->updateAction->action;
                               4098                 :            414 :                     n->fk_del_action = ($5)->deleteAction->action;
                               4099                 :            414 :                     n->fk_del_set_cols = ($5)->deleteAction->cols;
  238                          4100                 :            414 :                     n->is_enforced = true;
 1515                          4101                 :            414 :                     n->skip_validation = false;
                               4102                 :            414 :                     n->initially_valid = true;
 1212                          4103                 :            414 :                     $$ = (Node *) n;
                               4104                 :                :                 }
                               4105                 :                :         ;
                               4106                 :                : 
                               4107                 :                : opt_unique_null_treatment:
 1311                          4108                 :              6 :             NULLS_P DISTINCT        { $$ = true; }
                               4109                 :             18 :             | NULLS_P NOT DISTINCT  { $$ = false; }
                               4110                 :           3848 :             | /*EMPTY*/             { $$ = true; }
                               4111                 :                :         ;
                               4112                 :                : 
                               4113                 :                : generated_when:
 3075 peter_e@gmx.net          4114                 :           1035 :             ALWAYS          { $$ = ATTRIBUTE_IDENTITY_ALWAYS; }
                               4115                 :             91 :             | BY DEFAULT    { $$ = ATTRIBUTE_IDENTITY_BY_DEFAULT; }
                               4116                 :                :         ;
                               4117                 :                : 
                               4118                 :                : opt_virtual_or_stored:
  211 peter@eisentraut.org     4119                 :            484 :             STORED          { $$ = ATTRIBUTE_GENERATED_STORED; }
                               4120                 :            317 :             | VIRTUAL       { $$ = ATTRIBUTE_GENERATED_VIRTUAL; }
                               4121                 :             54 :             | /*EMPTY*/     { $$ = ATTRIBUTE_GENERATED_VIRTUAL; }
                               4122                 :                :         ;
                               4123                 :                : 
                               4124                 :                : /*
                               4125                 :                :  * ConstraintAttr represents constraint attributes, which we parse as if
                               4126                 :                :  * they were independent constraint clauses, in order to avoid shift/reduce
                               4127                 :                :  * conflicts (since NOT might start either an independent NOT NULL clause
                               4128                 :                :  * or an attribute).  parse_utilcmd.c is responsible for attaching the
                               4129                 :                :  * attribute information to the preceding "real" constraint node, and for
                               4130                 :                :  * complaining if attribute clauses appear in the wrong place or wrong
                               4131                 :                :  * combinations.
                               4132                 :                :  *
                               4133                 :                :  * See also ConstraintAttributeSpec, which can be used in places where
                               4134                 :                :  * there is no parsing conflict.  (Note: currently, NOT VALID and NO INHERIT
                               4135                 :                :  * are allowed clauses in ConstraintAttributeSpec, but not here.  Someday we
                               4136                 :                :  * might need to allow them here too, but for the moment it doesn't seem
                               4137                 :                :  * useful in the statements that use ConstraintAttr.)
                               4138                 :                :  */
                               4139                 :                : ConstraintAttr:
                               4140                 :                :             DEFERRABLE
                               4141                 :                :                 {
 9331 lockhart@fourpalms.o     4142                 :             51 :                     Constraint *n = makeNode(Constraint);
                               4143                 :                : 
 9320 tgl@sss.pgh.pa.us        4144                 :             51 :                     n->contype = CONSTR_ATTR_DEFERRABLE;
 5882                          4145                 :             51 :                     n->location = @1;
 1212 peter@eisentraut.org     4146                 :             51 :                     $$ = (Node *) n;
                               4147                 :                :                 }
                               4148                 :                :             | NOT DEFERRABLE
                               4149                 :                :                 {
 9331 lockhart@fourpalms.o     4150                 :UBC           0 :                     Constraint *n = makeNode(Constraint);
                               4151                 :                : 
 9320 tgl@sss.pgh.pa.us        4152                 :              0 :                     n->contype = CONSTR_ATTR_NOT_DEFERRABLE;
 5882                          4153                 :              0 :                     n->location = @1;
 1212 peter@eisentraut.org     4154                 :              0 :                     $$ = (Node *) n;
                               4155                 :                :                 }
                               4156                 :                :             | INITIALLY DEFERRED
                               4157                 :                :                 {
 9320 tgl@sss.pgh.pa.us        4158                 :CBC          39 :                     Constraint *n = makeNode(Constraint);
                               4159                 :                : 
                               4160                 :             39 :                     n->contype = CONSTR_ATTR_DEFERRED;
 5882                          4161                 :             39 :                     n->location = @1;
 1212 peter@eisentraut.org     4162                 :             39 :                     $$ = (Node *) n;
                               4163                 :                :                 }
                               4164                 :                :             | INITIALLY IMMEDIATE
                               4165                 :                :                 {
 9320 tgl@sss.pgh.pa.us        4166                 :              3 :                     Constraint *n = makeNode(Constraint);
                               4167                 :                : 
                               4168                 :              3 :                     n->contype = CONSTR_ATTR_IMMEDIATE;
 5882                          4169                 :              3 :                     n->location = @1;
 1212 peter@eisentraut.org     4170                 :              3 :                     $$ = (Node *) n;
                               4171                 :                :                 }
                               4172                 :                :             | ENFORCED
                               4173                 :                :                 {
  238                          4174                 :             21 :                     Constraint *n = makeNode(Constraint);
                               4175                 :                : 
                               4176                 :             21 :                     n->contype = CONSTR_ATTR_ENFORCED;
                               4177                 :             21 :                     n->location = @1;
                               4178                 :             21 :                     $$ = (Node *) n;
                               4179                 :                :                 }
                               4180                 :                :             | NOT ENFORCED
                               4181                 :                :                 {
                               4182                 :             33 :                     Constraint *n = makeNode(Constraint);
                               4183                 :                : 
                               4184                 :             33 :                     n->contype = CONSTR_ATTR_NOT_ENFORCED;
                               4185                 :             33 :                     n->location = @1;
                               4186                 :             33 :                     $$ = (Node *) n;
                               4187                 :                :                 }
                               4188                 :                :         ;
                               4189                 :                : 
                               4190                 :                : 
                               4191                 :                : TableLikeClause:
                               4192                 :                :             LIKE qualified_name TableLikeOptionList
                               4193                 :                :                 {
 4991 peter_e@gmx.net          4194                 :            387 :                     TableLikeClause *n = makeNode(TableLikeClause);
                               4195                 :                : 
 8109 bruce@momjian.us         4196                 :            387 :                     n->relation = $2;
 7011                          4197                 :            387 :                     n->options = $3;
 1740 tgl@sss.pgh.pa.us        4198                 :            387 :                     n->relationOid = InvalidOid;
 1212 peter@eisentraut.org     4199                 :            387 :                     $$ = (Node *) n;
                               4200                 :                :                 }
                               4201                 :                :         ;
                               4202                 :                : 
                               4203                 :                : TableLikeOptionList:
 5808 andrew@dunslane.net      4204                 :            144 :                 TableLikeOptionList INCLUDING TableLikeOption   { $$ = $1 | $3; }
                               4205                 :              4 :                 | TableLikeOptionList EXCLUDING TableLikeOption { $$ = $1 & ~$3; }
                               4206                 :            387 :                 | /* EMPTY */                       { $$ = 0; }
                               4207                 :                :         ;
                               4208                 :                : 
                               4209                 :                : TableLikeOption:
 2742 alvherre@alvh.no-ip.     4210                 :             15 :                 COMMENTS            { $$ = CREATE_TABLE_LIKE_COMMENTS; }
 1597 fujii@postgresql.org     4211                 :              3 :                 | COMPRESSION       { $$ = CREATE_TABLE_LIKE_COMPRESSION; }
 5808 andrew@dunslane.net      4212                 :             27 :                 | CONSTRAINTS       { $$ = CREATE_TABLE_LIKE_CONSTRAINTS; }
 2742 alvherre@alvh.no-ip.     4213                 :             10 :                 | DEFAULTS          { $$ = CREATE_TABLE_LIKE_DEFAULTS; }
 3075 peter_e@gmx.net          4214                 :              6 :                 | IDENTITY_P        { $$ = CREATE_TABLE_LIKE_IDENTITY; }
 2352 peter@eisentraut.org     4215                 :             15 :                 | GENERATED         { $$ = CREATE_TABLE_LIKE_GENERATED; }
 5808 andrew@dunslane.net      4216                 :             25 :                 | INDEXES           { $$ = CREATE_TABLE_LIKE_INDEXES; }
 2742 alvherre@alvh.no-ip.     4217                 :UBC           0 :                 | STATISTICS        { $$ = CREATE_TABLE_LIKE_STATISTICS; }
 5808 andrew@dunslane.net      4218                 :CBC          13 :                 | STORAGE           { $$ = CREATE_TABLE_LIKE_STORAGE; }
                               4219                 :             34 :                 | ALL               { $$ = CREATE_TABLE_LIKE_ALL; }
                               4220                 :                :         ;
                               4221                 :                : 
                               4222                 :                : 
                               4223                 :                : /* ConstraintElem specifies constraint syntax which is not embedded into
                               4224                 :                :  *  a column definition. ColConstraintElem specifies the embedded form.
                               4225                 :                :  * - thomas 1997-12-03
                               4226                 :                :  */
                               4227                 :                : TableConstraint:
                               4228                 :                :             CONSTRAINT name ConstraintElem
                               4229                 :                :                 {
 3119 peter_e@gmx.net          4230                 :           2060 :                     Constraint *n = castNode(Constraint, $3);
                               4231                 :                : 
 5882 tgl@sss.pgh.pa.us        4232                 :           2060 :                     n->conname = $2;
                               4233                 :           2060 :                     n->location = @1;
                               4234                 :           2060 :                     $$ = (Node *) n;
                               4235                 :                :                 }
 8482 bruce@momjian.us         4236                 :           6601 :             | ConstraintElem                        { $$ = $1; }
                               4237                 :                :         ;
                               4238                 :                : 
                               4239                 :                : ConstraintElem:
                               4240                 :                :             CHECK '(' a_expr ')' ConstraintAttributeSpec
                               4241                 :                :                 {
10138 lockhart@fourpalms.o     4242                 :            633 :                     Constraint *n = makeNode(Constraint);
                               4243                 :                : 
                               4244                 :            633 :                     n->contype = CONSTR_CHECK;
 5882 tgl@sss.pgh.pa.us        4245                 :            633 :                     n->location = @1;
 4792 alvherre@alvh.no-ip.     4246                 :            633 :                     n->raw_expr = $3;
 9470 tgl@sss.pgh.pa.us        4247                 :            633 :                     n->cooked_expr = NULL;
 4792 alvherre@alvh.no-ip.     4248                 :            633 :                     processCASbits($5, @5, "CHECK",
                               4249                 :                :                                    NULL, NULL, &n->is_enforced, &n->skip_validation,
                               4250                 :                :                                    &n->is_no_inherit, yyscanner);
 5211                          4251                 :            633 :                     n->initially_valid = !n->skip_validation;
 1212 peter@eisentraut.org     4252                 :            633 :                     $$ = (Node *) n;
                               4253                 :                :                 }
                               4254                 :                :             | NOT NULL_P ColId ConstraintAttributeSpec
                               4255                 :                :                 {
  302 alvherre@alvh.no-ip.     4256                 :            299 :                     Constraint *n = makeNode(Constraint);
                               4257                 :                : 
                               4258                 :            299 :                     n->contype = CONSTR_NOTNULL;
                               4259                 :            299 :                     n->location = @1;
                               4260                 :            299 :                     n->keys = list_make1(makeString($3));
                               4261                 :            299 :                     processCASbits($4, @4, "NOT NULL",
                               4262                 :                :                                    NULL, NULL, NULL, &n->skip_validation,
                               4263                 :                :                                    &n->is_no_inherit, yyscanner);
  152                          4264                 :            299 :                     n->initially_valid = !n->skip_validation;
  302                          4265                 :            299 :                     $$ = (Node *) n;
                               4266                 :                :                 }
                               4267                 :                :             | UNIQUE opt_unique_null_treatment '(' columnList opt_without_overlaps ')' opt_c_include opt_definition OptConsTableSpace
                               4268                 :                :                 ConstraintAttributeSpec
                               4269                 :                :                 {
10138 lockhart@fourpalms.o     4270                 :            308 :                     Constraint *n = makeNode(Constraint);
                               4271                 :                : 
                               4272                 :            308 :                     n->contype = CONSTR_UNIQUE;
 5882 tgl@sss.pgh.pa.us        4273                 :            308 :                     n->location = @1;
 1311 peter@eisentraut.org     4274                 :            308 :                     n->nulls_not_distinct = !$2;
                               4275                 :            308 :                     n->keys = $4;
  354                          4276                 :            308 :                     n->without_overlaps = $5;
                               4277                 :            308 :                     n->including = $7;
                               4278                 :            308 :                     n->options = $8;
 5338 tgl@sss.pgh.pa.us        4279                 :            308 :                     n->indexname = NULL;
  354 peter@eisentraut.org     4280                 :            308 :                     n->indexspace = $9;
                               4281                 :            308 :                     processCASbits($10, @10, "UNIQUE",
                               4282                 :                :                                    &n->deferrable, &n->initdeferred, NULL,
                               4283                 :                :                                    NULL, NULL, yyscanner);
 1212                          4284                 :            308 :                     $$ = (Node *) n;
                               4285                 :                :                 }
                               4286                 :                :             | UNIQUE ExistingIndex ConstraintAttributeSpec
                               4287                 :                :                 {
 5338 tgl@sss.pgh.pa.us        4288                 :           2324 :                     Constraint *n = makeNode(Constraint);
                               4289                 :                : 
                               4290                 :           2324 :                     n->contype = CONSTR_UNIQUE;
                               4291                 :           2324 :                     n->location = @1;
                               4292                 :           2324 :                     n->keys = NIL;
 2709 teodor@sigaev.ru         4293                 :           2324 :                     n->including = NIL;
 5338 tgl@sss.pgh.pa.us        4294                 :           2324 :                     n->options = NIL;
                               4295                 :           2324 :                     n->indexname = $2;
                               4296                 :           2324 :                     n->indexspace = NULL;
 5197                          4297                 :           2324 :                     processCASbits($3, @3, "UNIQUE",
                               4298                 :                :                                    &n->deferrable, &n->initdeferred, NULL,
                               4299                 :                :                                    NULL, NULL, yyscanner);
 1212 peter@eisentraut.org     4300                 :           2324 :                     $$ = (Node *) n;
                               4301                 :                :                 }
                               4302                 :                :             | PRIMARY KEY '(' columnList opt_without_overlaps ')' opt_c_include opt_definition OptConsTableSpace
                               4303                 :                :                 ConstraintAttributeSpec
                               4304                 :                :                 {
 9320 tgl@sss.pgh.pa.us        4305                 :           1067 :                     Constraint *n = makeNode(Constraint);
                               4306                 :                : 
                               4307                 :           1067 :                     n->contype = CONSTR_PRIMARY;
 5882                          4308                 :           1067 :                     n->location = @1;
 9320                          4309                 :           1067 :                     n->keys = $4;
  354 peter@eisentraut.org     4310                 :           1067 :                     n->without_overlaps = $5;
                               4311                 :           1067 :                     n->including = $7;
                               4312                 :           1067 :                     n->options = $8;
 5338 tgl@sss.pgh.pa.us        4313                 :           1067 :                     n->indexname = NULL;
  354 peter@eisentraut.org     4314                 :           1067 :                     n->indexspace = $9;
                               4315                 :           1067 :                     processCASbits($10, @10, "PRIMARY KEY",
                               4316                 :                :                                    &n->deferrable, &n->initdeferred, NULL,
                               4317                 :                :                                    NULL, NULL, yyscanner);
 1212                          4318                 :           1067 :                     $$ = (Node *) n;
                               4319                 :                :                 }
                               4320                 :                :             | PRIMARY KEY ExistingIndex ConstraintAttributeSpec
                               4321                 :                :                 {
 5338 tgl@sss.pgh.pa.us        4322                 :           3009 :                     Constraint *n = makeNode(Constraint);
                               4323                 :                : 
                               4324                 :           3009 :                     n->contype = CONSTR_PRIMARY;
                               4325                 :           3009 :                     n->location = @1;
                               4326                 :           3009 :                     n->keys = NIL;
 2709 teodor@sigaev.ru         4327                 :           3009 :                     n->including = NIL;
 5338 tgl@sss.pgh.pa.us        4328                 :           3009 :                     n->options = NIL;
                               4329                 :           3009 :                     n->indexname = $3;
                               4330                 :           3009 :                     n->indexspace = NULL;
 5197                          4331                 :           3009 :                     processCASbits($4, @4, "PRIMARY KEY",
                               4332                 :                :                                    &n->deferrable, &n->initdeferred, NULL,
                               4333                 :                :                                    NULL, NULL, yyscanner);
 1212 peter@eisentraut.org     4334                 :           3009 :                     $$ = (Node *) n;
                               4335                 :                :                 }
                               4336                 :                :             | EXCLUDE access_method_clause '(' ExclusionConstraintList ')'
                               4337                 :                :                 opt_c_include opt_definition OptConsTableSpace OptWhereClause
                               4338                 :                :                 ConstraintAttributeSpec
                               4339                 :                :                 {
 5752 tgl@sss.pgh.pa.us        4340                 :            117 :                     Constraint *n = makeNode(Constraint);
                               4341                 :                : 
                               4342                 :            117 :                     n->contype = CONSTR_EXCLUSION;
                               4343                 :            117 :                     n->location = @1;
 1515 peter@eisentraut.org     4344                 :            117 :                     n->access_method = $2;
                               4345                 :            117 :                     n->exclusions = $4;
                               4346                 :            117 :                     n->including = $6;
                               4347                 :            117 :                     n->options = $7;
                               4348                 :            117 :                     n->indexname = NULL;
                               4349                 :            117 :                     n->indexspace = $8;
                               4350                 :            117 :                     n->where_clause = $9;
 2709 teodor@sigaev.ru         4351                 :            117 :                     processCASbits($10, @10, "EXCLUDE",
                               4352                 :                :                                    &n->deferrable, &n->initdeferred, NULL,
                               4353                 :                :                                    NULL, NULL, yyscanner);
 1212 peter@eisentraut.org     4354                 :            117 :                     $$ = (Node *) n;
                               4355                 :                :                 }
                               4356                 :                :             | FOREIGN KEY '(' columnList optionalPeriodName ')' REFERENCES qualified_name
                               4357                 :                :                 opt_column_and_period_list key_match key_actions ConstraintAttributeSpec
                               4358                 :                :                 {
 5882 tgl@sss.pgh.pa.us        4359                 :            904 :                     Constraint *n = makeNode(Constraint);
                               4360                 :                : 
                               4361                 :            904 :                     n->contype = CONSTR_FOREIGN;
                               4362                 :            904 :                     n->location = @1;
  354 peter@eisentraut.org     4363                 :            904 :                     n->pktable = $8;
 1515                          4364                 :            904 :                     n->fk_attrs = $4;
  354                          4365         [ +  + ]:            904 :                     if ($5)
                               4366                 :                :                     {
                               4367                 :            145 :                         n->fk_attrs = lappend(n->fk_attrs, $5);
                               4368                 :            145 :                         n->fk_with_period = true;
                               4369                 :                :                     }
                               4370                 :            904 :                     n->pk_attrs = linitial($9);
                               4371         [ +  + ]:            904 :                     if (lsecond($9))
                               4372                 :                :                     {
                               4373                 :             85 :                         n->pk_attrs = lappend(n->pk_attrs, lsecond($9));
                               4374                 :             85 :                         n->pk_with_period = true;
                               4375                 :                :                     }
                               4376                 :            904 :                     n->fk_matchtype = $10;
                               4377                 :            904 :                     n->fk_upd_action = ($11)->updateAction->action;
                               4378                 :            904 :                     n->fk_del_action = ($11)->deleteAction->action;
                               4379                 :            904 :                     n->fk_del_set_cols = ($11)->deleteAction->cols;
                               4380                 :            904 :                     processCASbits($12, @12, "FOREIGN KEY",
                               4381                 :                :                                    &n->deferrable, &n->initdeferred,
                               4382                 :                :                                    &n->is_enforced, &n->skip_validation, NULL,
                               4383                 :                :                                    yyscanner);
 5197 tgl@sss.pgh.pa.us        4384                 :            904 :                     n->initially_valid = !n->skip_validation;
 1212 peter@eisentraut.org     4385                 :            904 :                     $$ = (Node *) n;
                               4386                 :                :                 }
                               4387                 :                :         ;
                               4388                 :                : 
                               4389                 :                : /*
                               4390                 :                :  * DomainConstraint is separate from TableConstraint because the syntax for
                               4391                 :                :  * NOT NULL constraints is different.  For table constraints, we need to
                               4392                 :                :  * accept a column name, but for domain constraints, we don't.  (We could
                               4393                 :                :  * accept something like NOT NULL VALUE, but that seems weird.)  CREATE DOMAIN
                               4394                 :                :  * (which uses ColQualList) has for a long time accepted NOT NULL without a
                               4395                 :                :  * column name, so it makes sense that ALTER DOMAIN (which uses
                               4396                 :                :  * DomainConstraint) does as well.  None of these syntaxes are per SQL
                               4397                 :                :  * standard; we are just living with the bits of inconsistency that have built
                               4398                 :                :  * up over time.
                               4399                 :                :  */
                               4400                 :                : DomainConstraint:
                               4401                 :                :             CONSTRAINT name DomainConstraintElem
                               4402                 :                :                 {
  509                          4403                 :             82 :                     Constraint *n = castNode(Constraint, $3);
                               4404                 :                : 
                               4405                 :             82 :                     n->conname = $2;
                               4406                 :             82 :                     n->location = @1;
                               4407                 :             82 :                     $$ = (Node *) n;
                               4408                 :                :                 }
                               4409                 :              9 :             | DomainConstraintElem                  { $$ = $1; }
                               4410                 :                :         ;
                               4411                 :                : 
                               4412                 :                : DomainConstraintElem:
                               4413                 :                :             CHECK '(' a_expr ')' ConstraintAttributeSpec
                               4414                 :                :                 {
                               4415                 :             82 :                     Constraint *n = makeNode(Constraint);
                               4416                 :                : 
                               4417                 :             82 :                     n->contype = CONSTR_CHECK;
                               4418                 :             82 :                     n->location = @1;
                               4419                 :             82 :                     n->raw_expr = $3;
                               4420                 :             82 :                     n->cooked_expr = NULL;
                               4421                 :             82 :                     processCASbits($5, @5, "CHECK",
                               4422                 :                :                                    NULL, NULL, NULL, &n->skip_validation,
                               4423                 :                :                                    &n->is_no_inherit, yyscanner);
  238                          4424                 :             76 :                     n->is_enforced = true;
  509                          4425                 :             76 :                     n->initially_valid = !n->skip_validation;
                               4426                 :             76 :                     $$ = (Node *) n;
                               4427                 :                :                 }
                               4428                 :                :             | NOT NULL_P ConstraintAttributeSpec
                               4429                 :                :                 {
                               4430                 :             15 :                     Constraint *n = makeNode(Constraint);
                               4431                 :                : 
                               4432                 :             15 :                     n->contype = CONSTR_NOTNULL;
                               4433                 :             15 :                     n->location = @1;
                               4434                 :             15 :                     n->keys = list_make1(makeString("value"));
                               4435                 :                :                     /* no NOT VALID, NO INHERIT support */
                               4436                 :             15 :                     processCASbits($3, @3, "NOT NULL",
                               4437                 :                :                                    NULL, NULL, NULL,
                               4438                 :                :                                    NULL, NULL, yyscanner);
                               4439                 :             15 :                     n->initially_valid = true;
                               4440                 :             15 :                     $$ = (Node *) n;
                               4441                 :                :                 }
                               4442                 :                :         ;
                               4443                 :                : 
 2943 peter_e@gmx.net          4444                 :             69 : opt_no_inherit: NO INHERIT                          {  $$ = true; }
                               4445                 :           3828 :             | /* EMPTY */                           {  $$ = false; }
                               4446                 :                :         ;
                               4447                 :                : 
                               4448                 :                : opt_without_overlaps:
  354 peter@eisentraut.org     4449                 :            277 :             WITHOUT OVERLAPS                        { $$ = true; }
                               4450                 :           1098 :             | /*EMPTY*/                             { $$ = false; }
                               4451                 :                :     ;
                               4452                 :                : 
                               4453                 :                : opt_column_list:
 8482 bruce@momjian.us         4454                 :           5413 :             '(' columnList ')'                      { $$ = $2; }
                               4455                 :          21504 :             | /*EMPTY*/                             { $$ = NIL; }
                               4456                 :                :         ;
                               4457                 :                : 
                               4458                 :                : columnList:
 7769 neilc@samurai.com        4459                 :           8539 :             columnElem                              { $$ = list_make1($1); }
 8481 bruce@momjian.us         4460                 :          14541 :             | columnList ',' columnElem             { $$ = lappend($1, $3); }
                               4461                 :                :         ;
                               4462                 :                : 
                               4463                 :                : optionalPeriodName:
  354 peter@eisentraut.org     4464                 :            230 :             ',' PERIOD columnElem { $$ = $3; }
                               4465                 :           1239 :             | /*EMPTY*/               { $$ = NULL; }
                               4466                 :                :     ;
                               4467                 :                : 
                               4468                 :                : opt_column_and_period_list:
                               4469                 :            562 :             '(' columnList optionalPeriodName ')'           { $$ = list_make2($2, $3); }
                               4470                 :            345 :             | /*EMPTY*/                             { $$ = list_make2(NIL, NULL); }
                               4471                 :                :         ;
                               4472                 :                : 
                               4473                 :                : columnElem: ColId
                               4474                 :                :                 {
 8419 tgl@sss.pgh.pa.us        4475                 :          23310 :                     $$ = (Node *) makeString($1);
                               4476                 :                :                 }
                               4477                 :                :         ;
                               4478                 :                : 
 2709 teodor@sigaev.ru         4479                 :             84 : opt_c_include:  INCLUDE '(' columnList ')'          { $$ = $3; }
                               4480                 :           1408 :              |      /* EMPTY */                     { $$ = NIL; }
                               4481                 :                :         ;
                               4482                 :                : 
                               4483                 :                : key_match:  MATCH FULL
                               4484                 :                :             {
 8457 tgl@sss.pgh.pa.us        4485                 :             49 :                 $$ = FKCONSTR_MATCH_FULL;
                               4486                 :                :             }
                               4487                 :                :         | MATCH PARTIAL
                               4488                 :                :             {
 8085 tgl@sss.pgh.pa.us        4489         [ #  # ]:UBC           0 :                 ereport(ERROR,
                               4490                 :                :                         (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               4491                 :                :                          errmsg("MATCH PARTIAL not yet implemented"),
                               4492                 :                :                          parser_errposition(@1)));
                               4493                 :                :                 $$ = FKCONSTR_MATCH_PARTIAL;
                               4494                 :                :             }
                               4495                 :                :         | MATCH SIMPLE
                               4496                 :                :             {
 4829 tgl@sss.pgh.pa.us        4497                 :CBC           3 :                 $$ = FKCONSTR_MATCH_SIMPLE;
                               4498                 :                :             }
                               4499                 :                :         | /*EMPTY*/
                               4500                 :                :             {
                               4501                 :           1269 :                 $$ = FKCONSTR_MATCH_SIMPLE;
                               4502                 :                :             }
                               4503                 :                :         ;
                               4504                 :                : 
                               4505                 :                : ExclusionConstraintList:
 5752                          4506                 :            117 :             ExclusionConstraintElem                 { $$ = list_make1($1); }
                               4507                 :                :             | ExclusionConstraintList ',' ExclusionConstraintElem
                               4508                 :             53 :                                                     { $$ = lappend($1, $3); }
                               4509                 :                :         ;
                               4510                 :                : 
                               4511                 :                : ExclusionConstraintElem: index_elem WITH any_operator
                               4512                 :                :             {
                               4513                 :            170 :                 $$ = list_make2($1, $3);
                               4514                 :                :             }
                               4515                 :                :             /* allow OPERATOR() decoration for the benefit of ruleutils.c */
                               4516                 :                :             | index_elem WITH OPERATOR '(' any_operator ')'
                               4517                 :                :             {
 5752 tgl@sss.pgh.pa.us        4518                 :UBC           0 :                 $$ = list_make2($1, $5);
                               4519                 :                :             }
                               4520                 :                :         ;
                               4521                 :                : 
                               4522                 :                : OptWhereClause:
 5752 tgl@sss.pgh.pa.us        4523                 :CBC         232 :             WHERE '(' a_expr ')'                    { $$ = $3; }
                               4524                 :            630 :             | /*EMPTY*/                             { $$ = NULL; }
                               4525                 :                :         ;
                               4526                 :                : 
                               4527                 :                : key_actions:
                               4528                 :                :             key_update
                               4529                 :                :                 {
 1368 peter@eisentraut.org     4530                 :             37 :                     KeyActions *n = palloc(sizeof(KeyActions));
                               4531                 :                : 
                               4532                 :             37 :                     n->updateAction = $1;
                               4533                 :             37 :                     n->deleteAction = palloc(sizeof(KeyAction));
                               4534                 :             37 :                     n->deleteAction->action = FKCONSTR_ACTION_NOACTION;
                               4535                 :             37 :                     n->deleteAction->cols = NIL;
                               4536                 :             37 :                     $$ = n;
                               4537                 :                :                 }
                               4538                 :                :             | key_delete
                               4539                 :                :                 {
                               4540                 :             75 :                     KeyActions *n = palloc(sizeof(KeyActions));
                               4541                 :                : 
                               4542                 :             75 :                     n->updateAction = palloc(sizeof(KeyAction));
                               4543                 :             75 :                     n->updateAction->action = FKCONSTR_ACTION_NOACTION;
                               4544                 :             75 :                     n->updateAction->cols = NIL;
                               4545                 :             75 :                     n->deleteAction = $1;
                               4546                 :             75 :                     $$ = n;
                               4547                 :                :                 }
                               4548                 :                :             | key_update key_delete
                               4549                 :                :                 {
                               4550                 :             78 :                     KeyActions *n = palloc(sizeof(KeyActions));
                               4551                 :                : 
                               4552                 :             78 :                     n->updateAction = $1;
                               4553                 :             78 :                     n->deleteAction = $2;
                               4554                 :             78 :                     $$ = n;
                               4555                 :                :                 }
                               4556                 :                :             | key_delete key_update
                               4557                 :                :                 {
                               4558                 :             75 :                     KeyActions *n = palloc(sizeof(KeyActions));
                               4559                 :                : 
                               4560                 :             75 :                     n->updateAction = $2;
                               4561                 :             75 :                     n->deleteAction = $1;
                               4562                 :             75 :                     $$ = n;
                               4563                 :                :                 }
                               4564                 :                :             | /*EMPTY*/
                               4565                 :                :                 {
                               4566                 :           1053 :                     KeyActions *n = palloc(sizeof(KeyActions));
                               4567                 :                : 
                               4568                 :           1053 :                     n->updateAction = palloc(sizeof(KeyAction));
                               4569                 :           1053 :                     n->updateAction->action = FKCONSTR_ACTION_NOACTION;
                               4570                 :           1053 :                     n->updateAction->cols = NIL;
                               4571                 :           1053 :                     n->deleteAction = palloc(sizeof(KeyAction));
                               4572                 :           1053 :                     n->deleteAction->action = FKCONSTR_ACTION_NOACTION;
                               4573                 :           1053 :                     n->deleteAction->cols = NIL;
                               4574                 :           1053 :                     $$ = n;
                               4575                 :                :                 }
                               4576                 :                :         ;
                               4577                 :                : 
                               4578                 :                : key_update: ON UPDATE key_action
                               4579                 :                :                 {
                               4580         [ +  + ]:            193 :                     if (($3)->cols)
                               4581   [ +  -  +  - ]:              3 :                         ereport(ERROR,
                               4582                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               4583                 :                :                                  errmsg("a column list with %s is only supported for ON DELETE actions",
                               4584                 :                :                                         ($3)->action == FKCONSTR_ACTION_SETNULL ? "SET NULL" : "SET DEFAULT"),
                               4585                 :                :                                  parser_errposition(@1)));
                               4586                 :            190 :                     $$ = $3;
                               4587                 :                :                 }
                               4588                 :                :         ;
                               4589                 :                : 
                               4590                 :                : key_delete: ON DELETE_P key_action
                               4591                 :                :                 {
                               4592                 :            228 :                     $$ = $3;
                               4593                 :                :                 }
                               4594                 :                :         ;
                               4595                 :                : 
                               4596                 :                : key_action:
                               4597                 :                :             NO ACTION
                               4598                 :                :                 {
                               4599                 :             40 :                     KeyAction *n = palloc(sizeof(KeyAction));
                               4600                 :                : 
                               4601                 :             40 :                     n->action = FKCONSTR_ACTION_NOACTION;
                               4602                 :             40 :                     n->cols = NIL;
                               4603                 :             40 :                     $$ = n;
                               4604                 :                :                 }
                               4605                 :                :             | RESTRICT
                               4606                 :                :                 {
                               4607                 :             24 :                     KeyAction *n = palloc(sizeof(KeyAction));
                               4608                 :                : 
                               4609                 :             24 :                     n->action = FKCONSTR_ACTION_RESTRICT;
                               4610                 :             24 :                     n->cols = NIL;
                               4611                 :             24 :                     $$ = n;
                               4612                 :                :                 }
                               4613                 :                :             | CASCADE
                               4614                 :                :                 {
                               4615                 :            211 :                     KeyAction *n = palloc(sizeof(KeyAction));
                               4616                 :                : 
                               4617                 :            211 :                     n->action = FKCONSTR_ACTION_CASCADE;
                               4618                 :            211 :                     n->cols = NIL;
                               4619                 :            211 :                     $$ = n;
                               4620                 :                :                 }
                               4621                 :                :             | SET NULL_P opt_column_list
                               4622                 :                :                 {
                               4623                 :             95 :                     KeyAction *n = palloc(sizeof(KeyAction));
                               4624                 :                : 
                               4625                 :             95 :                     n->action = FKCONSTR_ACTION_SETNULL;
                               4626                 :             95 :                     n->cols = $3;
                               4627                 :             95 :                     $$ = n;
                               4628                 :                :                 }
                               4629                 :                :             | SET DEFAULT opt_column_list
                               4630                 :                :                 {
                               4631                 :             51 :                     KeyAction *n = palloc(sizeof(KeyAction));
                               4632                 :                : 
                               4633                 :             51 :                     n->action = FKCONSTR_ACTION_SETDEFAULT;
                               4634                 :             51 :                     n->cols = $3;
                               4635                 :             51 :                     $$ = n;
                               4636                 :                :                 }
                               4637                 :                :         ;
                               4638                 :                : 
 8482 bruce@momjian.us         4639                 :           1045 : OptInherit: INHERITS '(' qualified_name_list ')'    { $$ = $3; }
                               4640                 :          13964 :             | /*EMPTY*/                             { $$ = NIL; }
                               4641                 :                :         ;
                               4642                 :                : 
                               4643                 :                : /* Optional partition key specification */
 3195 rhaas@postgresql.org     4644                 :           2514 : OptPartitionSpec: PartitionSpec { $$ = $1; }
                               4645                 :          16341 :             | /*EMPTY*/         { $$ = NULL; }
                               4646                 :                :         ;
                               4647                 :                : 
                               4648                 :                : PartitionSpec: PARTITION BY ColId '(' part_params ')'
                               4649                 :                :                 {
                               4650                 :           2517 :                     PartitionSpec *n = makeNode(PartitionSpec);
                               4651                 :                : 
  310 tgl@sss.pgh.pa.us        4652                 :           2517 :                     n->strategy = parsePartitionStrategy($3, @3, yyscanner);
 3195 rhaas@postgresql.org     4653                 :           2514 :                     n->partParams = $5;
                               4654                 :           2514 :                     n->location = @1;
                               4655                 :                : 
                               4656                 :           2514 :                     $$ = n;
                               4657                 :                :                 }
                               4658                 :                :         ;
                               4659                 :                : 
                               4660                 :           2517 : part_params:    part_elem                       { $$ = list_make1($1); }
                               4661                 :            228 :             | part_params ',' part_elem         { $$ = lappend($1, $3); }
                               4662                 :                :         ;
                               4663                 :                : 
                               4664                 :                : part_elem: ColId opt_collate opt_qualified_name
                               4665                 :                :                 {
                               4666                 :           2593 :                     PartitionElem *n = makeNode(PartitionElem);
                               4667                 :                : 
                               4668                 :           2593 :                     n->name = $1;
                               4669                 :           2593 :                     n->expr = NULL;
                               4670                 :           2593 :                     n->collation = $2;
                               4671                 :           2593 :                     n->opclass = $3;
                               4672                 :           2593 :                     n->location = @1;
                               4673                 :           2593 :                     $$ = n;
                               4674                 :                :                 }
                               4675                 :                :             | func_expr_windowless opt_collate opt_qualified_name
                               4676                 :                :                 {
                               4677                 :             65 :                     PartitionElem *n = makeNode(PartitionElem);
                               4678                 :                : 
                               4679                 :             65 :                     n->name = NULL;
                               4680                 :             65 :                     n->expr = $1;
                               4681                 :             65 :                     n->collation = $2;
                               4682                 :             65 :                     n->opclass = $3;
                               4683                 :             65 :                     n->location = @1;
                               4684                 :             65 :                     $$ = n;
                               4685                 :                :                 }
                               4686                 :                :             | '(' a_expr ')' opt_collate opt_qualified_name
                               4687                 :                :                 {
                               4688                 :             87 :                     PartitionElem *n = makeNode(PartitionElem);
                               4689                 :                : 
                               4690                 :             87 :                     n->name = NULL;
                               4691                 :             87 :                     n->expr = $2;
                               4692                 :             87 :                     n->collation = $4;
                               4693                 :             87 :                     n->opclass = $5;
                               4694                 :             87 :                     n->location = @1;
                               4695                 :             87 :                     $$ = n;
                               4696                 :                :                 }
                               4697                 :                :         ;
                               4698                 :                : 
                               4699                 :                : table_access_method_clause:
 1914 peter@eisentraut.org     4700                 :             61 :             USING name                          { $$ = $2; }
 2376 andres@anarazel.de       4701                 :          19758 :             | /*EMPTY*/                         { $$ = NULL; }
                               4702                 :                :         ;
                               4703                 :                : 
                               4704                 :                : /* WITHOUT OIDS is legacy only */
                               4705                 :                : OptWith:
 6060 alvherre@alvh.no-ip.     4706                 :            379 :             WITH reloptions             { $$ = $2; }
 2482 andres@anarazel.de       4707                 :             12 :             | WITHOUT OIDS              { $$ = NIL; }
 7005 tgl@sss.pgh.pa.us        4708                 :          19134 :             | /*EMPTY*/                 { $$ = NIL; }
                               4709                 :                :         ;
                               4710                 :                : 
 8335                          4711                 :             30 : OnCommitOption:  ON COMMIT DROP             { $$ = ONCOMMIT_DROP; }
                               4712                 :             52 :             | ON COMMIT DELETE_P ROWS       { $$ = ONCOMMIT_DELETE_ROWS; }
                               4713                 :             12 :             | ON COMMIT PRESERVE ROWS       { $$ = ONCOMMIT_PRESERVE_ROWS; }
                               4714                 :          19431 :             | /*EMPTY*/                     { $$ = ONCOMMIT_NOOP; }
                               4715                 :                :         ;
                               4716                 :                : 
 7750                          4717                 :            110 : OptTableSpace:   TABLESPACE name                    { $$ = $2; }
                               4718                 :          23038 :             | /*EMPTY*/                             { $$ = NULL; }
                               4719                 :                :         ;
                               4720                 :                : 
 7705                          4721                 :             33 : OptConsTableSpace:   USING INDEX TABLESPACE name    { $$ = $4; }
                               4722                 :           4610 :             | /*EMPTY*/                             { $$ = NULL; }
                               4723                 :                :         ;
                               4724                 :                : 
 1914 peter@eisentraut.org     4725                 :           5333 : ExistingIndex:   USING INDEX name                   { $$ = $3; }
                               4726                 :                :         ;
                               4727                 :                : 
                               4728                 :                : /*****************************************************************************
                               4729                 :                :  *
                               4730                 :                :  *      QUERY :
                               4731                 :                :  *              CREATE STATISTICS [[IF NOT EXISTS] stats_name] [(stat types)]
                               4732                 :                :  *                  ON expression-list FROM from_list
                               4733                 :                :  *
                               4734                 :                :  * Note: the expectation here is that the clauses after ON are a subset of
                               4735                 :                :  * SELECT syntax, allowing for expressions and joined tables, and probably
                               4736                 :                :  * someday a WHERE clause.  Much less than that is currently implemented,
                               4737                 :                :  * but the grammar accepts it and then we'll throw FEATURE_NOT_SUPPORTED
                               4738                 :                :  * errors as necessary at execution.
                               4739                 :                :  *
                               4740                 :                :  * Statistics name is optional unless IF NOT EXISTS is specified.
                               4741                 :                :  *
                               4742                 :                :  *****************************************************************************/
                               4743                 :                : 
                               4744                 :                : CreateStatsStmt:
                               4745                 :                :             CREATE STATISTICS opt_qualified_name
                               4746                 :                :             opt_name_list ON stats_params FROM from_list
                               4747                 :                :                 {
 3039 alvherre@alvh.no-ip.     4748                 :            362 :                     CreateStatsStmt *n = makeNode(CreateStatsStmt);
                               4749                 :                : 
 2998                          4750                 :            362 :                     n->defnames = $3;
                               4751                 :            362 :                     n->stat_types = $4;
                               4752                 :            362 :                     n->exprs = $6;
                               4753                 :            362 :                     n->relations = $8;
 2742                          4754                 :            362 :                     n->stxcomment = NULL;
 2998                          4755                 :            362 :                     n->if_not_exists = false;
 1212 peter@eisentraut.org     4756                 :            362 :                     $$ = (Node *) n;
                               4757                 :                :                 }
                               4758                 :                :             | CREATE STATISTICS IF_P NOT EXISTS any_name
                               4759                 :                :             opt_name_list ON stats_params FROM from_list
                               4760                 :                :                 {
 2998 alvherre@alvh.no-ip.     4761                 :              6 :                     CreateStatsStmt *n = makeNode(CreateStatsStmt);
                               4762                 :                : 
                               4763                 :              6 :                     n->defnames = $6;
                               4764                 :              6 :                     n->stat_types = $7;
                               4765                 :              6 :                     n->exprs = $9;
                               4766                 :              6 :                     n->relations = $11;
 2742                          4767                 :              6 :                     n->stxcomment = NULL;
 2998                          4768                 :              6 :                     n->if_not_exists = true;
 1212 peter@eisentraut.org     4769                 :              6 :                     $$ = (Node *) n;
                               4770                 :                :                 }
                               4771                 :                :             ;
                               4772                 :                : 
                               4773                 :                : /*
                               4774                 :                :  * Statistics attributes can be either simple column references, or arbitrary
                               4775                 :                :  * expressions in parens.  For compatibility with index attributes permitted
                               4776                 :                :  * in CREATE INDEX, we allow an expression that's just a function call to be
                               4777                 :                :  * written without parens.
                               4778                 :                :  */
                               4779                 :                : 
 1625 tomas.vondra@postgre     4780                 :            374 : stats_params:   stats_param                         { $$ = list_make1($1); }
                               4781                 :            486 :             | stats_params ',' stats_param          { $$ = lappend($1, $3); }
                               4782                 :                :         ;
                               4783                 :                : 
                               4784                 :                : stats_param:    ColId
                               4785                 :                :                 {
                               4786                 :            608 :                     $$ = makeNode(StatsElem);
                               4787                 :            608 :                     $$->name = $1;
                               4788                 :            608 :                     $$->expr = NULL;
                               4789                 :                :                 }
                               4790                 :                :             | func_expr_windowless
                               4791                 :                :                 {
                               4792                 :             16 :                     $$ = makeNode(StatsElem);
                               4793                 :             16 :                     $$->name = NULL;
                               4794                 :             16 :                     $$->expr = $1;
                               4795                 :                :                 }
                               4796                 :                :             | '(' a_expr ')'
                               4797                 :                :                 {
                               4798                 :            236 :                     $$ = makeNode(StatsElem);
                               4799                 :            236 :                     $$->name = NULL;
                               4800                 :            236 :                     $$->expr = $2;
                               4801                 :                :                 }
                               4802                 :                :         ;
                               4803                 :                : 
                               4804                 :                : /*****************************************************************************
                               4805                 :                :  *
                               4806                 :                :  *      QUERY :
                               4807                 :                :  *              ALTER STATISTICS [IF EXISTS] stats_name
                               4808                 :                :  *                  SET STATISTICS  <SignedIconst>
                               4809                 :                :  *
                               4810                 :                :  *****************************************************************************/
                               4811                 :                : 
                               4812                 :                : AlterStatsStmt:
                               4813                 :                :             ALTER STATISTICS any_name SET STATISTICS set_statistics_value
                               4814                 :                :                 {
 2188                          4815                 :             10 :                     AlterStatsStmt *n = makeNode(AlterStatsStmt);
                               4816                 :                : 
                               4817                 :             10 :                     n->defnames = $3;
                               4818                 :             10 :                     n->missing_ok = false;
                               4819                 :             10 :                     n->stxstattarget = $6;
 1212 peter@eisentraut.org     4820                 :             10 :                     $$ = (Node *) n;
                               4821                 :                :                 }
                               4822                 :                :             | ALTER STATISTICS IF_P EXISTS any_name SET STATISTICS set_statistics_value
                               4823                 :                :                 {
 2188 tomas.vondra@postgre     4824                 :              3 :                     AlterStatsStmt *n = makeNode(AlterStatsStmt);
                               4825                 :                : 
                               4826                 :              3 :                     n->defnames = $5;
                               4827                 :              3 :                     n->missing_ok = true;
                               4828                 :              3 :                     n->stxstattarget = $8;
 1212 peter@eisentraut.org     4829                 :              3 :                     $$ = (Node *) n;
                               4830                 :                :                 }
                               4831                 :                :             ;
                               4832                 :                : 
                               4833                 :                : /*****************************************************************************
                               4834                 :                :  *
                               4835                 :                :  *      QUERY :
                               4836                 :                :  *              CREATE TABLE relname AS SelectStmt [ WITH [NO] DATA ]
                               4837                 :                :  *
                               4838                 :                :  *
                               4839                 :                :  * Note: SELECT ... INTO is a now-deprecated alternative for this.
                               4840                 :                :  *
                               4841                 :                :  *****************************************************************************/
                               4842                 :                : 
                               4843                 :                : CreateAsStmt:
                               4844                 :                :         CREATE OptTemp TABLE create_as_target AS SelectStmt opt_with_data
                               4845                 :                :                 {
 4919 tgl@sss.pgh.pa.us        4846                 :            607 :                     CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
                               4847                 :                : 
                               4848                 :            607 :                     ctas->query = $6;
                               4849                 :            607 :                     ctas->into = $4;
 1883 michael@paquier.xyz      4850                 :            607 :                     ctas->objtype = OBJECT_TABLE;
 4919 tgl@sss.pgh.pa.us        4851                 :            607 :                     ctas->is_select_into = false;
 3920 andrew@dunslane.net      4852                 :            607 :                     ctas->if_not_exists = false;
                               4853                 :                :                     /* cram additional flags into the IntoClause */
 5035 tgl@sss.pgh.pa.us        4854                 :            607 :                     $4->rel->relpersistence = $2;
                               4855                 :            607 :                     $4->skipData = !($7);
 4919                          4856                 :            607 :                     $$ = (Node *) ctas;
                               4857                 :                :                 }
                               4858                 :                :         | CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS SelectStmt opt_with_data
                               4859                 :                :                 {
 3920 andrew@dunslane.net      4860                 :             25 :                     CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
                               4861                 :                : 
                               4862                 :             25 :                     ctas->query = $9;
                               4863                 :             25 :                     ctas->into = $7;
 1883 michael@paquier.xyz      4864                 :             25 :                     ctas->objtype = OBJECT_TABLE;
 3920 andrew@dunslane.net      4865                 :             25 :                     ctas->is_select_into = false;
                               4866                 :             25 :                     ctas->if_not_exists = true;
                               4867                 :                :                     /* cram additional flags into the IntoClause */
                               4868                 :             25 :                     $7->rel->relpersistence = $2;
                               4869                 :             25 :                     $7->skipData = !($10);
                               4870                 :             25 :                     $$ = (Node *) ctas;
                               4871                 :                :                 }
                               4872                 :                :         ;
                               4873                 :                : 
                               4874                 :                : create_as_target:
                               4875                 :                :             qualified_name opt_column_list table_access_method_clause
                               4876                 :                :             OptWith OnCommitOption OptTableSpace
                               4877                 :                :                 {
 6773 tgl@sss.pgh.pa.us        4878                 :            676 :                     $$ = makeNode(IntoClause);
                               4879                 :            676 :                     $$->rel = $1;
                               4880                 :            676 :                     $$->colNames = $2;
 2376 andres@anarazel.de       4881                 :            676 :                     $$->accessMethod = $3;
                               4882                 :            676 :                     $$->options = $4;
                               4883                 :            676 :                     $$->onCommit = $5;
                               4884                 :            676 :                     $$->tableSpaceName = $6;
 4530 tgl@sss.pgh.pa.us        4885                 :            676 :                     $$->viewQuery = NULL;
 5035                          4886                 :            676 :                     $$->skipData = false;        /* might get changed later */
                               4887                 :                :                 }
                               4888                 :                :         ;
                               4889                 :                : 
                               4890                 :                : opt_with_data:
 2943 peter_e@gmx.net          4891                 :             18 :             WITH DATA_P                             { $$ = true; }
                               4892                 :            108 :             | WITH NO DATA_P                        { $$ = false; }
                               4893                 :            975 :             | /*EMPTY*/                             { $$ = true; }
                               4894                 :                :         ;
                               4895                 :                : 
                               4896                 :                : 
                               4897                 :                : /*****************************************************************************
                               4898                 :                :  *
                               4899                 :                :  *      QUERY :
                               4900                 :                :  *              CREATE MATERIALIZED VIEW relname AS SelectStmt
                               4901                 :                :  *
                               4902                 :                :  *****************************************************************************/
                               4903                 :                : 
                               4904                 :                : CreateMatViewStmt:
                               4905                 :                :         CREATE OptNoLog MATERIALIZED VIEW create_mv_target AS SelectStmt opt_with_data
                               4906                 :                :                 {
 4570 kgrittn@postgresql.o     4907                 :            267 :                     CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
                               4908                 :                : 
                               4909                 :            267 :                     ctas->query = $7;
                               4910                 :            267 :                     ctas->into = $5;
 1883 michael@paquier.xyz      4911                 :            267 :                     ctas->objtype = OBJECT_MATVIEW;
 4570 kgrittn@postgresql.o     4912                 :            267 :                     ctas->is_select_into = false;
 3920 andrew@dunslane.net      4913                 :            267 :                     ctas->if_not_exists = false;
                               4914                 :                :                     /* cram additional flags into the IntoClause */
 4570 kgrittn@postgresql.o     4915                 :            267 :                     $5->rel->relpersistence = $2;
                               4916                 :            267 :                     $5->skipData = !($8);
                               4917                 :            267 :                     $$ = (Node *) ctas;
                               4918                 :                :                 }
                               4919                 :                :         | CREATE OptNoLog MATERIALIZED VIEW IF_P NOT EXISTS create_mv_target AS SelectStmt opt_with_data
                               4920                 :                :                 {
 3920 andrew@dunslane.net      4921                 :             24 :                     CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
                               4922                 :                : 
                               4923                 :             24 :                     ctas->query = $10;
                               4924                 :             24 :                     ctas->into = $8;
 1883 michael@paquier.xyz      4925                 :             24 :                     ctas->objtype = OBJECT_MATVIEW;
 3920 andrew@dunslane.net      4926                 :             24 :                     ctas->is_select_into = false;
                               4927                 :             24 :                     ctas->if_not_exists = true;
                               4928                 :                :                     /* cram additional flags into the IntoClause */
                               4929                 :             24 :                     $8->rel->relpersistence = $2;
                               4930                 :             24 :                     $8->skipData = !($11);
                               4931                 :             24 :                     $$ = (Node *) ctas;
                               4932                 :                :                 }
                               4933                 :                :         ;
                               4934                 :                : 
                               4935                 :                : create_mv_target:
                               4936                 :                :             qualified_name opt_column_list table_access_method_clause opt_reloptions OptTableSpace
                               4937                 :                :                 {
 4570 kgrittn@postgresql.o     4938                 :            291 :                     $$ = makeNode(IntoClause);
                               4939                 :            291 :                     $$->rel = $1;
                               4940                 :            291 :                     $$->colNames = $2;
 2376 andres@anarazel.de       4941                 :            291 :                     $$->accessMethod = $3;
                               4942                 :            291 :                     $$->options = $4;
 4570 kgrittn@postgresql.o     4943                 :            291 :                     $$->onCommit = ONCOMMIT_NOOP;
 2376 andres@anarazel.de       4944                 :            291 :                     $$->tableSpaceName = $5;
 4530 tgl@sss.pgh.pa.us        4945                 :            291 :                     $$->viewQuery = NULL;        /* filled at analysis time */
 4570 kgrittn@postgresql.o     4946                 :            291 :                     $$->skipData = false;        /* might get changed later */
                               4947                 :                :                 }
                               4948                 :                :         ;
                               4949                 :                : 
 4570 kgrittn@postgresql.o     4950                 :UBC           0 : OptNoLog:   UNLOGGED                    { $$ = RELPERSISTENCE_UNLOGGED; }
 4570 kgrittn@postgresql.o     4951                 :CBC         291 :             | /*EMPTY*/                 { $$ = RELPERSISTENCE_PERMANENT; }
                               4952                 :                :         ;
                               4953                 :                : 
                               4954                 :                : 
                               4955                 :                : /*****************************************************************************
                               4956                 :                :  *
                               4957                 :                :  *      QUERY :
                               4958                 :                :  *              REFRESH MATERIALIZED VIEW qualified_name
                               4959                 :                :  *
                               4960                 :                :  *****************************************************************************/
                               4961                 :                : 
                               4962                 :                : RefreshMatViewStmt:
                               4963                 :                :             REFRESH MATERIALIZED VIEW opt_concurrently qualified_name opt_with_data
                               4964                 :                :                 {
                               4965                 :            134 :                     RefreshMatViewStmt *n = makeNode(RefreshMatViewStmt);
                               4966                 :                : 
 4435                          4967                 :            134 :                     n->concurrent = $4;
                               4968                 :            134 :                     n->relation = $5;
                               4969                 :            134 :                     n->skipData = !($6);
 4570                          4970                 :            134 :                     $$ = (Node *) n;
                               4971                 :                :                 }
                               4972                 :                :         ;
                               4973                 :                : 
                               4974                 :                : 
                               4975                 :                : /*****************************************************************************
                               4976                 :                :  *
                               4977                 :                :  *      QUERY :
                               4978                 :                :  *              CREATE SEQUENCE seqname
                               4979                 :                :  *              ALTER SEQUENCE seqname
                               4980                 :                :  *
                               4981                 :                :  *****************************************************************************/
                               4982                 :                : 
                               4983                 :                : CreateSeqStmt:
                               4984                 :                :             CREATE OptTemp SEQUENCE qualified_name OptSeqOptList
                               4985                 :                :                 {
10225 bruce@momjian.us         4986                 :            328 :                     CreateSeqStmt *n = makeNode(CreateSeqStmt);
                               4987                 :                : 
 5381 rhaas@postgresql.org     4988                 :            328 :                     $4->relpersistence = $2;
 8570 tgl@sss.pgh.pa.us        4989                 :            328 :                     n->sequence = $4;
 8841 bruce@momjian.us         4990                 :            328 :                     n->options = $5;
 5498 tgl@sss.pgh.pa.us        4991                 :            328 :                     n->ownerId = InvalidOid;
 4029 heikki.linnakangas@i     4992                 :            328 :                     n->if_not_exists = false;
 1212 peter@eisentraut.org     4993                 :            328 :                     $$ = (Node *) n;
                               4994                 :                :                 }
                               4995                 :                :             | CREATE OptTemp SEQUENCE IF_P NOT EXISTS qualified_name OptSeqOptList
                               4996                 :                :                 {
 4029 heikki.linnakangas@i     4997                 :             12 :                     CreateSeqStmt *n = makeNode(CreateSeqStmt);
                               4998                 :                : 
                               4999                 :             12 :                     $7->relpersistence = $2;
                               5000                 :             12 :                     n->sequence = $7;
                               5001                 :             12 :                     n->options = $8;
                               5002                 :             12 :                     n->ownerId = InvalidOid;
                               5003                 :             12 :                     n->if_not_exists = true;
 1212 peter@eisentraut.org     5004                 :             12 :                     $$ = (Node *) n;
                               5005                 :                :                 }
                               5006                 :                :         ;
                               5007                 :                : 
                               5008                 :                : AlterSeqStmt:
                               5009                 :                :             ALTER SEQUENCE qualified_name SeqOptList
                               5010                 :                :                 {
 8206 bruce@momjian.us         5011                 :             92 :                     AlterSeqStmt *n = makeNode(AlterSeqStmt);
                               5012                 :                : 
                               5013                 :             92 :                     n->sequence = $3;
                               5014                 :             92 :                     n->options = $4;
 4975 simon@2ndQuadrant.co     5015                 :             92 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     5016                 :             92 :                     $$ = (Node *) n;
                               5017                 :                :                 }
                               5018                 :                :             | ALTER SEQUENCE IF_P EXISTS qualified_name SeqOptList
                               5019                 :                :                 {
 4975 simon@2ndQuadrant.co     5020                 :              6 :                     AlterSeqStmt *n = makeNode(AlterSeqStmt);
                               5021                 :                : 
                               5022                 :              6 :                     n->sequence = $5;
                               5023                 :              6 :                     n->options = $6;
                               5024                 :              6 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     5025                 :              6 :                     $$ = (Node *) n;
                               5026                 :                :                 }
                               5027                 :                : 
                               5028                 :                :         ;
                               5029                 :                : 
 6292 tgl@sss.pgh.pa.us        5030                 :            131 : OptSeqOptList: SeqOptList                           { $$ = $1; }
 8433                          5031                 :            209 :             | /*EMPTY*/                             { $$ = NIL; }
                               5032                 :                :         ;
                               5033                 :                : 
 3075 peter_e@gmx.net          5034                 :             37 : OptParenthesizedSeqOptList: '(' SeqOptList ')'      { $$ = $2; }
                               5035                 :            212 :             | /*EMPTY*/                             { $$ = NIL; }
                               5036                 :                :         ;
                               5037                 :                : 
 6292 tgl@sss.pgh.pa.us        5038                 :            266 : SeqOptList: SeqOptElem                              { $$ = list_make1($1); }
                               5039                 :            401 :             | SeqOptList SeqOptElem                 { $$ = lappend($1, $2); }
                               5040                 :                :         ;
                               5041                 :                : 
                               5042                 :                : SeqOptElem: AS SimpleTypename
                               5043                 :                :                 {
 1212 peter@eisentraut.org     5044                 :             95 :                     $$ = makeDefElem("as", (Node *) $2, @1);
                               5045                 :                :                 }
                               5046                 :                :             | CACHE NumericOnly
                               5047                 :                :                 {
                               5048                 :             65 :                     $$ = makeDefElem("cache", (Node *) $2, @1);
                               5049                 :                :                 }
                               5050                 :                :             | CYCLE
                               5051                 :                :                 {
                               5052                 :             17 :                     $$ = makeDefElem("cycle", (Node *) makeBoolean(true), @1);
                               5053                 :                :                 }
                               5054                 :                :             | NO CYCLE
                               5055                 :                :                 {
                               5056                 :              7 :                     $$ = makeDefElem("cycle", (Node *) makeBoolean(false), @1);
                               5057                 :                :                 }
                               5058                 :                :             | INCREMENT opt_by NumericOnly
                               5059                 :                :                 {
                               5060                 :            123 :                     $$ = makeDefElem("increment", (Node *) $3, @1);
                               5061                 :                :                 }
                               5062                 :                :             | LOGGED
                               5063                 :                :                 {
  354 tgl@sss.pgh.pa.us        5064                 :              1 :                     $$ = makeDefElem("logged", NULL, @1);
                               5065                 :                :                 }
                               5066                 :                :             | MAXVALUE NumericOnly
                               5067                 :                :                 {
 1212 peter@eisentraut.org     5068                 :             34 :                     $$ = makeDefElem("maxvalue", (Node *) $2, @1);
                               5069                 :                :                 }
                               5070                 :                :             | MINVALUE NumericOnly
                               5071                 :                :                 {
                               5072                 :             34 :                     $$ = makeDefElem("minvalue", (Node *) $2, @1);
                               5073                 :                :                 }
                               5074                 :                :             | NO MAXVALUE
                               5075                 :                :                 {
 3287 peter_e@gmx.net          5076                 :             54 :                     $$ = makeDefElem("maxvalue", NULL, @1);
                               5077                 :                :                 }
                               5078                 :                :             | NO MINVALUE
                               5079                 :                :                 {
                               5080                 :             54 :                     $$ = makeDefElem("minvalue", NULL, @1);
                               5081                 :                :                 }
                               5082                 :                :             | OWNED BY any_name
                               5083                 :                :                 {
 1212 peter@eisentraut.org     5084                 :             36 :                     $$ = makeDefElem("owned_by", (Node *) $3, @1);
                               5085                 :                :                 }
                               5086                 :                :             | SEQUENCE NAME_P any_name
                               5087                 :                :                 {
                               5088                 :             22 :                     $$ = makeDefElem("sequence_name", (Node *) $3, @1);
                               5089                 :                :                 }
                               5090                 :                :             | START opt_with NumericOnly
                               5091                 :                :                 {
                               5092                 :            118 :                     $$ = makeDefElem("start", (Node *) $3, @1);
                               5093                 :                :                 }
                               5094                 :                :             | RESTART
                               5095                 :                :                 {
 3287 peter_e@gmx.net          5096                 :              3 :                     $$ = makeDefElem("restart", NULL, @1);
                               5097                 :                :                 }
                               5098                 :                :             | RESTART opt_with NumericOnly
                               5099                 :                :                 {
 1212 peter@eisentraut.org     5100                 :             30 :                     $$ = makeDefElem("restart", (Node *) $3, @1);
                               5101                 :                :                 }
                               5102                 :                :             | UNLOGGED
                               5103                 :                :                 {
  354 tgl@sss.pgh.pa.us        5104                 :              1 :                     $$ = makeDefElem("unlogged", NULL, @1);
                               5105                 :                :                 }
                               5106                 :                :         ;
                               5107                 :                : 
                               5108                 :                : opt_by:     BY
                               5109                 :                :             | /* EMPTY */
                               5110                 :                :       ;
                               5111                 :                : 
                               5112                 :                : NumericOnly:
 1458 peter@eisentraut.org     5113                 :            162 :             FCONST                              { $$ = (Node *) makeFloat($1); }
 1458 peter@eisentraut.org     5114                 :UBC           0 :             | '+' FCONST                        { $$ = (Node *) makeFloat($2); }
                               5115                 :                :             | '-' FCONST
                               5116                 :                :                 {
 1212 peter@eisentraut.org     5117                 :CBC          10 :                     Float      *f = makeFloat($2);
                               5118                 :                : 
 1458                          5119                 :             10 :                     doNegateFloat(f);
                               5120                 :             10 :                     $$ = (Node *) f;
                               5121                 :                :                 }
                               5122                 :           6477 :             | SignedIconst                      { $$ = (Node *) makeInteger($1); }
                               5123                 :                :         ;
                               5124                 :                : 
 5564 rhaas@postgresql.org     5125                 :             40 : NumericOnly_list:   NumericOnly                     { $$ = list_make1($1); }
                               5126                 :              3 :                 | NumericOnly_list ',' NumericOnly  { $$ = lappend($1, $3); }
                               5127                 :                :         ;
                               5128                 :                : 
                               5129                 :                : /*****************************************************************************
                               5130                 :                :  *
                               5131                 :                :  *      QUERIES :
                               5132                 :                :  *              CREATE [OR REPLACE] [TRUSTED] [PROCEDURAL] LANGUAGE ...
                               5133                 :                :  *              DROP [PROCEDURAL] LANGUAGE ...
                               5134                 :                :  *
                               5135                 :                :  *****************************************************************************/
                               5136                 :                : 
                               5137                 :                : CreatePLangStmt:
                               5138                 :                :             CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE name
                               5139                 :                :             {
                               5140                 :                :                 /*
                               5141                 :                :                  * We now interpret parameterless CREATE LANGUAGE as
                               5142                 :                :                  * CREATE EXTENSION.  "OR REPLACE" is silently translated
                               5143                 :                :                  * to "IF NOT EXISTS", which isn't quite the same, but
                               5144                 :                :                  * seems more useful than throwing an error.  We just
                               5145                 :                :                  * ignore TRUSTED, as the previous code would have too.
                               5146                 :                :                  */
 2047 tgl@sss.pgh.pa.us        5147                 :UBC           0 :                 CreateExtensionStmt *n = makeNode(CreateExtensionStmt);
                               5148                 :                : 
                               5149                 :              0 :                 n->if_not_exists = $2;
                               5150                 :              0 :                 n->extname = $6;
                               5151                 :              0 :                 n->options = NIL;
 1212 peter@eisentraut.org     5152                 :              0 :                 $$ = (Node *) n;
                               5153                 :                :             }
                               5154                 :                :             | CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE name
                               5155                 :                :               HANDLER handler_name opt_inline_handler opt_validator
                               5156                 :                :             {
10175 vadim4o@yahoo.com        5157                 :CBC          71 :                 CreatePLangStmt *n = makeNode(CreatePLangStmt);
                               5158                 :                : 
 5674 tgl@sss.pgh.pa.us        5159                 :             71 :                 n->replace = $2;
                               5160                 :             71 :                 n->plname = $6;
                               5161                 :             71 :                 n->plhandler = $8;
                               5162                 :             71 :                 n->plinline = $9;
                               5163                 :             71 :                 n->plvalidator = $10;
                               5164                 :             71 :                 n->pltrusted = $3;
 1212 peter@eisentraut.org     5165                 :             71 :                 $$ = (Node *) n;
                               5166                 :                :             }
                               5167                 :                :         ;
                               5168                 :                : 
                               5169                 :                : opt_trusted:
 2943 peter_e@gmx.net          5170                 :             56 :             TRUSTED                                 { $$ = true; }
                               5171                 :             19 :             | /*EMPTY*/                             { $$ = false; }
                               5172                 :                :         ;
                               5173                 :                : 
                               5174                 :                : /* This ought to be just func_name, but that causes reduce/reduce conflicts
                               5175                 :                :  * (CREATE LANGUAGE is the only place where func_name isn't followed by '(').
                               5176                 :                :  * Work around by using simple names, instead.
                               5177                 :                :  */
                               5178                 :                : handler_name:
 7759 tgl@sss.pgh.pa.us        5179                 :            280 :             name                        { $$ = list_make1(makeString($1)); }
                               5180                 :              1 :             | name attrs                { $$ = lcons(makeString($1), $2); }
                               5181                 :                :         ;
                               5182                 :                : 
                               5183                 :                : opt_inline_handler:
 5828                          5184                 :             62 :             INLINE_P handler_name                   { $$ = $2; }
                               5185                 :              9 :             | /*EMPTY*/                             { $$ = NIL; }
                               5186                 :                :         ;
                               5187                 :                : 
                               5188                 :                : validator_clause:
 7306                          5189                 :             62 :             VALIDATOR handler_name                  { $$ = $2; }
 6038 peter_e@gmx.net          5190                 :UBC           0 :             | NO VALIDATOR                          { $$ = NIL; }
                               5191                 :                :         ;
                               5192                 :                : 
                               5193                 :                : opt_validator:
 6038 peter_e@gmx.net          5194                 :CBC          62 :             validator_clause                        { $$ = $1; }
 7306 tgl@sss.pgh.pa.us        5195                 :              9 :             | /*EMPTY*/                             { $$ = NIL; }
                               5196                 :                :         ;
                               5197                 :                : 
                               5198                 :                : opt_procedural:
                               5199                 :                :             PROCEDURAL
                               5200                 :                :             | /*EMPTY*/
                               5201                 :                :         ;
                               5202                 :                : 
                               5203                 :                : /*****************************************************************************
                               5204                 :                :  *
                               5205                 :                :  *      QUERY:
                               5206                 :                :  *             CREATE TABLESPACE tablespace LOCATION '/path/to/tablespace/'
                               5207                 :                :  *
                               5208                 :                :  *****************************************************************************/
                               5209                 :                : 
                               5210                 :                : CreateTableSpaceStmt: CREATE TABLESPACE name OptTableSpaceOwner LOCATION Sconst opt_reloptions
                               5211                 :                :                 {
 7750                          5212                 :             67 :                     CreateTableSpaceStmt *n = makeNode(CreateTableSpaceStmt);
                               5213                 :                : 
                               5214                 :             67 :                     n->tablespacename = $3;
                               5215                 :             67 :                     n->owner = $4;
                               5216                 :             67 :                     n->location = $6;
 4249 sfrost@snowman.net       5217                 :             67 :                     n->options = $7;
 7750 tgl@sss.pgh.pa.us        5218                 :             67 :                     $$ = (Node *) n;
                               5219                 :                :                 }
                               5220                 :                :         ;
                               5221                 :                : 
 3834 alvherre@alvh.no-ip.     5222                 :              5 : OptTableSpaceOwner: OWNER RoleSpec      { $$ = $2; }
 7750 tgl@sss.pgh.pa.us        5223                 :             62 :             | /*EMPTY */                { $$ = NULL; }
                               5224                 :                :         ;
                               5225                 :                : 
                               5226                 :                : /*****************************************************************************
                               5227                 :                :  *
                               5228                 :                :  *      QUERY :
                               5229                 :                :  *              DROP TABLESPACE <tablespace>
                               5230                 :                :  *
                               5231                 :                :  *      No need for drop behaviour as we cannot implement dependencies for
                               5232                 :                :  *      objects in other databases; we can only support RESTRICT.
                               5233                 :                :  *
                               5234                 :                :  ****************************************************************************/
                               5235                 :                : 
                               5236                 :                : DropTableSpaceStmt: DROP TABLESPACE name
                               5237                 :                :                 {
                               5238                 :             32 :                     DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt);
                               5239                 :                : 
                               5240                 :             32 :                     n->tablespacename = $3;
 7022 andrew@dunslane.net      5241                 :             32 :                     n->missing_ok = false;
                               5242                 :             32 :                     $$ = (Node *) n;
                               5243                 :                :                 }
                               5244                 :                :                 |  DROP TABLESPACE IF_P EXISTS name
                               5245                 :                :                 {
 7022 andrew@dunslane.net      5246                 :UBC           0 :                     DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt);
                               5247                 :                : 
                               5248                 :              0 :                     n->tablespacename = $5;
                               5249                 :              0 :                     n->missing_ok = true;
 7750 tgl@sss.pgh.pa.us        5250                 :              0 :                     $$ = (Node *) n;
                               5251                 :                :                 }
                               5252                 :                :         ;
                               5253                 :                : 
                               5254                 :                : /*****************************************************************************
                               5255                 :                :  *
                               5256                 :                :  *      QUERY:
                               5257                 :                :  *             CREATE EXTENSION extension
                               5258                 :                :  *             [ WITH ] [ SCHEMA schema ] [ VERSION version ]
                               5259                 :                :  *
                               5260                 :                :  *****************************************************************************/
                               5261                 :                : 
                               5262                 :                : CreateExtensionStmt: CREATE EXTENSION name opt_with create_extension_opt_list
                               5263                 :                :                 {
 5324 tgl@sss.pgh.pa.us        5264                 :CBC         231 :                     CreateExtensionStmt *n = makeNode(CreateExtensionStmt);
                               5265                 :                : 
                               5266                 :            231 :                     n->extname = $3;
 5300                          5267                 :            231 :                     n->if_not_exists = false;
 5324                          5268                 :            231 :                     n->options = $5;
                               5269                 :            231 :                     $$ = (Node *) n;
                               5270                 :                :                 }
                               5271                 :                :                 | CREATE EXTENSION IF_P NOT EXISTS name opt_with create_extension_opt_list
                               5272                 :                :                 {
 5300                          5273                 :              9 :                     CreateExtensionStmt *n = makeNode(CreateExtensionStmt);
                               5274                 :                : 
                               5275                 :              9 :                     n->extname = $6;
                               5276                 :              9 :                     n->if_not_exists = true;
                               5277                 :              9 :                     n->options = $8;
                               5278                 :              9 :                     $$ = (Node *) n;
                               5279                 :                :                 }
                               5280                 :                :         ;
                               5281                 :                : 
                               5282                 :                : create_extension_opt_list:
                               5283                 :                :             create_extension_opt_list create_extension_opt_item
 5324                          5284                 :             49 :                 { $$ = lappend($1, $2); }
                               5285                 :                :             | /* EMPTY */
                               5286                 :            240 :                 { $$ = NIL; }
                               5287                 :                :         ;
                               5288                 :                : 
                               5289                 :                : create_extension_opt_item:
                               5290                 :                :             SCHEMA name
                               5291                 :                :                 {
 1212 peter@eisentraut.org     5292                 :             23 :                     $$ = makeDefElem("schema", (Node *) makeString($2), @1);
                               5293                 :                :                 }
                               5294                 :                :             | VERSION_P NonReservedWord_or_Sconst
                               5295                 :                :                 {
                               5296                 :              6 :                     $$ = makeDefElem("new_version", (Node *) makeString($2), @1);
                               5297                 :                :                 }
                               5298                 :                :             | FROM NonReservedWord_or_Sconst
                               5299                 :                :                 {
 2026 tgl@sss.pgh.pa.us        5300         [ #  # ]:UBC           0 :                     ereport(ERROR,
                               5301                 :                :                             (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               5302                 :                :                              errmsg("CREATE EXTENSION ... FROM is no longer supported"),
                               5303                 :                :                              parser_errposition(@1)));
                               5304                 :                :                 }
                               5305                 :                :             | CASCADE
                               5306                 :                :                 {
 1212 peter@eisentraut.org     5307                 :CBC          20 :                     $$ = makeDefElem("cascade", (Node *) makeBoolean(true), @1);
                               5308                 :                :                 }
                               5309                 :                :         ;
                               5310                 :                : 
                               5311                 :                : /*****************************************************************************
                               5312                 :                :  *
                               5313                 :                :  * ALTER EXTENSION name UPDATE [ TO version ]
                               5314                 :                :  *
                               5315                 :                :  *****************************************************************************/
                               5316                 :                : 
                               5317                 :                : AlterExtensionStmt: ALTER EXTENSION name UPDATE alter_extension_opt_list
                               5318                 :                :                 {
 5321 tgl@sss.pgh.pa.us        5319                 :             20 :                     AlterExtensionStmt *n = makeNode(AlterExtensionStmt);
                               5320                 :                : 
                               5321                 :             20 :                     n->extname = $3;
                               5322                 :             20 :                     n->options = $5;
                               5323                 :             20 :                     $$ = (Node *) n;
                               5324                 :                :                 }
                               5325                 :                :         ;
                               5326                 :                : 
                               5327                 :                : alter_extension_opt_list:
                               5328                 :                :             alter_extension_opt_list alter_extension_opt_item
                               5329                 :             20 :                 { $$ = lappend($1, $2); }
                               5330                 :                :             | /* EMPTY */
                               5331                 :             20 :                 { $$ = NIL; }
                               5332                 :                :         ;
                               5333                 :                : 
                               5334                 :                : alter_extension_opt_item:
                               5335                 :                :             TO NonReservedWord_or_Sconst
                               5336                 :                :                 {
 1212 peter@eisentraut.org     5337                 :             20 :                     $$ = makeDefElem("new_version", (Node *) makeString($2), @1);
                               5338                 :                :                 }
                               5339                 :                :         ;
                               5340                 :                : 
                               5341                 :                : /*****************************************************************************
                               5342                 :                :  *
                               5343                 :                :  * ALTER EXTENSION name ADD/DROP object-identifier
                               5344                 :                :  *
                               5345                 :                :  *****************************************************************************/
                               5346                 :                : 
                               5347                 :                : AlterExtensionContentsStmt:
                               5348                 :                :             ALTER EXTENSION name add_drop object_type_name name
                               5349                 :                :                 {
 3261 tgl@sss.pgh.pa.us        5350                 :              9 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5351                 :                : 
                               5352                 :              9 :                     n->extname = $3;
                               5353                 :              9 :                     n->action = $4;
 1911 peter@eisentraut.org     5354                 :              9 :                     n->objtype = $5;
                               5355                 :              9 :                     n->object = (Node *) makeString($6);
 1212                          5356                 :              9 :                     $$ = (Node *) n;
                               5357                 :                :                 }
                               5358                 :                :             | ALTER EXTENSION name add_drop object_type_any_name any_name
                               5359                 :                :                 {
 5322 tgl@sss.pgh.pa.us        5360                 :             44 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5361                 :                : 
 5323                          5362                 :             44 :                     n->extname = $3;
 5322                          5363                 :             44 :                     n->action = $4;
 1911 peter@eisentraut.org     5364                 :             44 :                     n->objtype = $5;
 3220 peter_e@gmx.net          5365                 :             44 :                     n->object = (Node *) $6;
 1212 peter@eisentraut.org     5366                 :             44 :                     $$ = (Node *) n;
                               5367                 :                :                 }
                               5368                 :                :             | ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes
                               5369                 :                :                 {
 5320 peter_e@gmx.net          5370                 :              4 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5371                 :                : 
                               5372                 :              4 :                     n->extname = $3;
                               5373                 :              4 :                     n->action = $4;
 1911 peter@eisentraut.org     5374                 :              4 :                     n->objtype = OBJECT_AGGREGATE;
 3220 peter_e@gmx.net          5375                 :              4 :                     n->object = (Node *) $6;
 1212 peter@eisentraut.org     5376                 :              4 :                     $$ = (Node *) n;
                               5377                 :                :                 }
                               5378                 :                :             | ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
                               5379                 :                :                 {
 5322 tgl@sss.pgh.pa.us        5380                 :              2 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5381                 :                : 
 5323                          5382                 :              2 :                     n->extname = $3;
 5322                          5383                 :              2 :                     n->action = $4;
 1911 peter@eisentraut.org     5384                 :              2 :                     n->objtype = OBJECT_CAST;
                               5385                 :              2 :                     n->object = (Node *) list_make2($7, $9);
                               5386                 :              2 :                     $$ = (Node *) n;
                               5387                 :                :                 }
                               5388                 :                :             | ALTER EXTENSION name add_drop DOMAIN_P Typename
                               5389                 :                :                 {
 5322 tgl@sss.pgh.pa.us        5390                 :UBC           0 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5391                 :                : 
 5323                          5392                 :              0 :                     n->extname = $3;
 5322                          5393                 :              0 :                     n->action = $4;
 5323                          5394                 :              0 :                     n->objtype = OBJECT_DOMAIN;
 3220 peter_e@gmx.net          5395                 :              0 :                     n->object = (Node *) $6;
 1212 peter@eisentraut.org     5396                 :              0 :                     $$ = (Node *) n;
                               5397                 :                :                 }
                               5398                 :                :             | ALTER EXTENSION name add_drop FUNCTION function_with_argtypes
                               5399                 :                :                 {
 5322 tgl@sss.pgh.pa.us        5400                 :CBC          56 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5401                 :                : 
 5323                          5402                 :             56 :                     n->extname = $3;
 5322                          5403                 :             56 :                     n->action = $4;
 5323                          5404                 :             56 :                     n->objtype = OBJECT_FUNCTION;
 3220 peter_e@gmx.net          5405                 :             56 :                     n->object = (Node *) $6;
 1212 peter@eisentraut.org     5406                 :             56 :                     $$ = (Node *) n;
                               5407                 :                :                 }
                               5408                 :                :             | ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes
                               5409                 :                :                 {
 5322 tgl@sss.pgh.pa.us        5410                 :              9 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5411                 :                : 
 5323                          5412                 :              9 :                     n->extname = $3;
 5322                          5413                 :              9 :                     n->action = $4;
 5323                          5414                 :              9 :                     n->objtype = OBJECT_OPERATOR;
 3220 peter_e@gmx.net          5415                 :              9 :                     n->object = (Node *) $6;
 1212 peter@eisentraut.org     5416                 :              9 :                     $$ = (Node *) n;
                               5417                 :                :                 }
                               5418                 :                :             | ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING name
                               5419                 :                :                 {
 5322 tgl@sss.pgh.pa.us        5420                 :              2 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5421                 :                : 
 5323                          5422                 :              2 :                     n->extname = $3;
 5322                          5423                 :              2 :                     n->action = $4;
 5323                          5424                 :              2 :                     n->objtype = OBJECT_OPCLASS;
 3220 peter_e@gmx.net          5425                 :              2 :                     n->object = (Node *) lcons(makeString($9), $7);
 1212 peter@eisentraut.org     5426                 :              2 :                     $$ = (Node *) n;
                               5427                 :                :                 }
                               5428                 :                :             | ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING name
                               5429                 :                :                 {
 5322 tgl@sss.pgh.pa.us        5430                 :              2 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5431                 :                : 
 5323                          5432                 :              2 :                     n->extname = $3;
 5322                          5433                 :              2 :                     n->action = $4;
 5323                          5434                 :              2 :                     n->objtype = OBJECT_OPFAMILY;
 3220 peter_e@gmx.net          5435                 :              2 :                     n->object = (Node *) lcons(makeString($9), $7);
 1212 peter@eisentraut.org     5436                 :              2 :                     $$ = (Node *) n;
                               5437                 :                :                 }
                               5438                 :                :             | ALTER EXTENSION name add_drop PROCEDURE function_with_argtypes
                               5439                 :                :                 {
 2837 peter_e@gmx.net          5440                 :UBC           0 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5441                 :                : 
                               5442                 :              0 :                     n->extname = $3;
                               5443                 :              0 :                     n->action = $4;
                               5444                 :              0 :                     n->objtype = OBJECT_PROCEDURE;
                               5445                 :              0 :                     n->object = (Node *) $6;
 1212 peter@eisentraut.org     5446                 :              0 :                     $$ = (Node *) n;
                               5447                 :                :                 }
                               5448                 :                :             | ALTER EXTENSION name add_drop ROUTINE function_with_argtypes
                               5449                 :                :                 {
 2837 peter_e@gmx.net          5450                 :              0 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5451                 :                : 
                               5452                 :              0 :                     n->extname = $3;
                               5453                 :              0 :                     n->action = $4;
                               5454                 :              0 :                     n->objtype = OBJECT_ROUTINE;
                               5455                 :              0 :                     n->object = (Node *) $6;
 1212 peter@eisentraut.org     5456                 :              0 :                     $$ = (Node *) n;
                               5457                 :                :                 }
                               5458                 :                :             | ALTER EXTENSION name add_drop TRANSFORM FOR Typename LANGUAGE name
                               5459                 :                :                 {
 3786 peter_e@gmx.net          5460                 :CBC           2 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5461                 :                : 
                               5462                 :              2 :                     n->extname = $3;
                               5463                 :              2 :                     n->action = $4;
                               5464                 :              2 :                     n->objtype = OBJECT_TRANSFORM;
 3220                          5465                 :              2 :                     n->object = (Node *) list_make2($7, makeString($9));
 1212 peter@eisentraut.org     5466                 :              2 :                     $$ = (Node *) n;
                               5467                 :                :                 }
                               5468                 :                :             | ALTER EXTENSION name add_drop TYPE_P Typename
                               5469                 :                :                 {
 5322 tgl@sss.pgh.pa.us        5470                 :              4 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5471                 :                : 
 5323                          5472                 :              4 :                     n->extname = $3;
 5322                          5473                 :              4 :                     n->action = $4;
 5323                          5474                 :              4 :                     n->objtype = OBJECT_TYPE;
 3220 peter_e@gmx.net          5475                 :              4 :                     n->object = (Node *) $6;
 1212 peter@eisentraut.org     5476                 :              4 :                     $$ = (Node *) n;
                               5477                 :                :                 }
                               5478                 :                :         ;
                               5479                 :                : 
                               5480                 :                : /*****************************************************************************
                               5481                 :                :  *
                               5482                 :                :  *      QUERY:
                               5483                 :                :  *             CREATE FOREIGN DATA WRAPPER name options
                               5484                 :                :  *
                               5485                 :                :  *****************************************************************************/
                               5486                 :                : 
                               5487                 :                : CreateFdwStmt: CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic_options
                               5488                 :                :                 {
 6105 peter_e@gmx.net          5489                 :            105 :                     CreateFdwStmt *n = makeNode(CreateFdwStmt);
                               5490                 :                : 
                               5491                 :            105 :                     n->fdwname = $5;
 5313 tgl@sss.pgh.pa.us        5492                 :            105 :                     n->func_options = $6;
 6038 peter_e@gmx.net          5493                 :            105 :                     n->options = $7;
 6105                          5494                 :            105 :                     $$ = (Node *) n;
                               5495                 :                :                 }
                               5496                 :                :         ;
                               5497                 :                : 
                               5498                 :                : fdw_option:
 1212 peter@eisentraut.org     5499                 :             29 :             HANDLER handler_name                { $$ = makeDefElem("handler", (Node *) $2, @1); }
 3287 peter_e@gmx.net          5500                 :UBC           0 :             | NO HANDLER                        { $$ = makeDefElem("handler", NULL, @1); }
 1212 peter@eisentraut.org     5501                 :CBC          26 :             | VALIDATOR handler_name            { $$ = makeDefElem("validator", (Node *) $2, @1); }
 3287 peter_e@gmx.net          5502                 :              3 :             | NO VALIDATOR                      { $$ = makeDefElem("validator", NULL, @1); }
                               5503                 :                :         ;
                               5504                 :                : 
                               5505                 :                : fdw_options:
 5313 tgl@sss.pgh.pa.us        5506                 :             47 :             fdw_option                          { $$ = list_make1($1); }
                               5507                 :             11 :             | fdw_options fdw_option            { $$ = lappend($1, $2); }
                               5508                 :                :         ;
                               5509                 :                : 
                               5510                 :                : opt_fdw_options:
                               5511                 :             29 :             fdw_options                         { $$ = $1; }
                               5512                 :            122 :             | /*EMPTY*/                         { $$ = NIL; }
                               5513                 :                :         ;
                               5514                 :                : 
                               5515                 :                : /*****************************************************************************
                               5516                 :                :  *
                               5517                 :                :  *      QUERY :
                               5518                 :                :  *              ALTER FOREIGN DATA WRAPPER name options
                               5519                 :                :  *
                               5520                 :                :  ****************************************************************************/
                               5521                 :                : 
                               5522                 :                : AlterFdwStmt: ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_options
                               5523                 :                :                 {
 6105 peter_e@gmx.net          5524                 :             43 :                     AlterFdwStmt *n = makeNode(AlterFdwStmt);
                               5525                 :                : 
                               5526                 :             43 :                     n->fdwname = $5;
 5313 tgl@sss.pgh.pa.us        5527                 :             43 :                     n->func_options = $6;
 6038 peter_e@gmx.net          5528                 :             43 :                     n->options = $7;
 6105                          5529                 :             43 :                     $$ = (Node *) n;
                               5530                 :                :                 }
                               5531                 :                :             | ALTER FOREIGN DATA_P WRAPPER name fdw_options
                               5532                 :                :                 {
                               5533                 :             18 :                     AlterFdwStmt *n = makeNode(AlterFdwStmt);
                               5534                 :                : 
                               5535                 :             18 :                     n->fdwname = $5;
 5313 tgl@sss.pgh.pa.us        5536                 :             18 :                     n->func_options = $6;
                               5537                 :             18 :                     n->options = NIL;
 6105 peter_e@gmx.net          5538                 :             18 :                     $$ = (Node *) n;
                               5539                 :                :                 }
                               5540                 :                :         ;
                               5541                 :                : 
                               5542                 :                : /* Options definition for CREATE FDW, SERVER and USER MAPPING */
                               5543                 :                : create_generic_options:
 5999 tgl@sss.pgh.pa.us        5544                 :            376 :             OPTIONS '(' generic_option_list ')'         { $$ = $3; }
                               5545                 :          33968 :             | /*EMPTY*/                                 { $$ = NIL; }
                               5546                 :                :         ;
                               5547                 :                : 
                               5548                 :                : generic_option_list:
                               5549                 :                :             generic_option_elem
                               5550                 :                :                 {
                               5551                 :            376 :                     $$ = list_make1($1);
                               5552                 :                :                 }
                               5553                 :                :             | generic_option_list ',' generic_option_elem
                               5554                 :                :                 {
                               5555                 :            247 :                     $$ = lappend($1, $3);
                               5556                 :                :                 }
                               5557                 :                :         ;
                               5558                 :                : 
                               5559                 :                : /* Options definition for ALTER FDW, SERVER and USER MAPPING */
                               5560                 :                : alter_generic_options:
                               5561                 :            254 :             OPTIONS '(' alter_generic_option_list ')'       { $$ = $3; }
                               5562                 :                :         ;
                               5563                 :                : 
                               5564                 :                : alter_generic_option_list:
                               5565                 :                :             alter_generic_option_elem
                               5566                 :                :                 {
                               5567                 :            254 :                     $$ = list_make1($1);
                               5568                 :                :                 }
                               5569                 :                :             | alter_generic_option_list ',' alter_generic_option_elem
                               5570                 :                :                 {
                               5571                 :             84 :                     $$ = lappend($1, $3);
                               5572                 :                :                 }
                               5573                 :                :         ;
                               5574                 :                : 
                               5575                 :                : alter_generic_option_elem:
                               5576                 :                :             generic_option_elem
                               5577                 :                :                 {
                               5578                 :            100 :                     $$ = $1;
                               5579                 :                :                 }
                               5580                 :                :             | SET generic_option_elem
                               5581                 :                :                 {
                               5582                 :             64 :                     $$ = $2;
                               5583                 :             64 :                     $$->defaction = DEFELEM_SET;
                               5584                 :                :                 }
                               5585                 :                :             | ADD_P generic_option_elem
                               5586                 :                :                 {
                               5587                 :            110 :                     $$ = $2;
                               5588                 :            110 :                     $$->defaction = DEFELEM_ADD;
                               5589                 :                :                 }
                               5590                 :                :             | DROP generic_option_name
                               5591                 :                :                 {
 3287 peter_e@gmx.net          5592                 :             64 :                     $$ = makeDefElemExtended(NULL, $2, NULL, DEFELEM_DROP, @2);
                               5593                 :                :                 }
                               5594                 :                :         ;
                               5595                 :                : 
                               5596                 :                : generic_option_elem:
                               5597                 :                :             generic_option_name generic_option_arg
                               5598                 :                :                 {
                               5599                 :            897 :                     $$ = makeDefElem($1, $2, @1);
                               5600                 :                :                 }
                               5601                 :                :         ;
                               5602                 :                : 
                               5603                 :                : generic_option_name:
 5999 tgl@sss.pgh.pa.us        5604                 :            961 :                 ColLabel            { $$ = $1; }
                               5605                 :                :         ;
                               5606                 :                : 
                               5607                 :                : /* We could use def_arg here, but the spec only requires string literals */
                               5608                 :                : generic_option_arg:
                               5609                 :            897 :                 Sconst              { $$ = (Node *) makeString($1); }
                               5610                 :                :         ;
                               5611                 :                : 
                               5612                 :                : /*****************************************************************************
                               5613                 :                :  *
                               5614                 :                :  *      QUERY:
                               5615                 :                :  *             CREATE SERVER name [TYPE] [VERSION] [OPTIONS]
                               5616                 :                :  *
                               5617                 :                :  *****************************************************************************/
                               5618                 :                : 
                               5619                 :                : CreateForeignServerStmt: CREATE SERVER name opt_type opt_foreign_server_version
                               5620                 :                :                          FOREIGN DATA_P WRAPPER name create_generic_options
                               5621                 :                :                 {
 6105 peter_e@gmx.net          5622                 :            138 :                     CreateForeignServerStmt *n = makeNode(CreateForeignServerStmt);
                               5623                 :                : 
                               5624                 :            138 :                     n->servername = $3;
                               5625                 :            138 :                     n->servertype = $4;
                               5626                 :            138 :                     n->version = $5;
                               5627                 :            138 :                     n->fdwname = $9;
                               5628                 :            138 :                     n->options = $10;
 3092 andrew@dunslane.net      5629                 :            138 :                     n->if_not_exists = false;
                               5630                 :            138 :                     $$ = (Node *) n;
                               5631                 :                :                 }
                               5632                 :                :                 | CREATE SERVER IF_P NOT EXISTS name opt_type opt_foreign_server_version
                               5633                 :                :                          FOREIGN DATA_P WRAPPER name create_generic_options
                               5634                 :                :                 {
                               5635                 :             12 :                     CreateForeignServerStmt *n = makeNode(CreateForeignServerStmt);
                               5636                 :                : 
                               5637                 :             12 :                     n->servername = $6;
                               5638                 :             12 :                     n->servertype = $7;
                               5639                 :             12 :                     n->version = $8;
                               5640                 :             12 :                     n->fdwname = $12;
                               5641                 :             12 :                     n->options = $13;
                               5642                 :             12 :                     n->if_not_exists = true;
 6105 peter_e@gmx.net          5643                 :             12 :                     $$ = (Node *) n;
                               5644                 :                :                 }
                               5645                 :                :         ;
                               5646                 :                : 
                               5647                 :                : opt_type:
                               5648                 :              9 :             TYPE_P Sconst           { $$ = $2; }
                               5649                 :            141 :             | /*EMPTY*/             { $$ = NULL; }
                               5650                 :                :         ;
                               5651                 :                : 
                               5652                 :                : 
                               5653                 :                : foreign_server_version:
                               5654                 :             33 :             VERSION_P Sconst        { $$ = $2; }
 6105 peter_e@gmx.net          5655                 :UBC           0 :         |   VERSION_P NULL_P        { $$ = NULL; }
                               5656                 :                :         ;
                               5657                 :                : 
                               5658                 :                : opt_foreign_server_version:
 5058 peter_e@gmx.net          5659                 :CBC           9 :             foreign_server_version  { $$ = $1; }
 6105                          5660                 :            141 :             | /*EMPTY*/             { $$ = NULL; }
                               5661                 :                :         ;
                               5662                 :                : 
                               5663                 :                : /*****************************************************************************
                               5664                 :                :  *
                               5665                 :                :  *      QUERY :
                               5666                 :                :  *              ALTER SERVER name [VERSION] [OPTIONS]
                               5667                 :                :  *
                               5668                 :                :  ****************************************************************************/
                               5669                 :                : 
                               5670                 :                : AlterForeignServerStmt: ALTER SERVER name foreign_server_version alter_generic_options
                               5671                 :                :                 {
                               5672                 :              3 :                     AlterForeignServerStmt *n = makeNode(AlterForeignServerStmt);
                               5673                 :                : 
                               5674                 :              3 :                     n->servername = $3;
                               5675                 :              3 :                     n->version = $4;
                               5676                 :              3 :                     n->options = $5;
                               5677                 :              3 :                     n->has_version = true;
                               5678                 :              3 :                     $$ = (Node *) n;
                               5679                 :                :                 }
                               5680                 :                :             | ALTER SERVER name foreign_server_version
                               5681                 :                :                 {
                               5682                 :             21 :                     AlterForeignServerStmt *n = makeNode(AlterForeignServerStmt);
                               5683                 :                : 
                               5684                 :             21 :                     n->servername = $3;
                               5685                 :             21 :                     n->version = $4;
                               5686                 :             21 :                     n->has_version = true;
                               5687                 :             21 :                     $$ = (Node *) n;
                               5688                 :                :                 }
                               5689                 :                :             | ALTER SERVER name alter_generic_options
                               5690                 :                :                 {
                               5691                 :             92 :                     AlterForeignServerStmt *n = makeNode(AlterForeignServerStmt);
                               5692                 :                : 
                               5693                 :             92 :                     n->servername = $3;
                               5694                 :             92 :                     n->options = $4;
                               5695                 :             92 :                     $$ = (Node *) n;
                               5696                 :                :                 }
                               5697                 :                :         ;
                               5698                 :                : 
                               5699                 :                : /*****************************************************************************
                               5700                 :                :  *
                               5701                 :                :  *      QUERY:
                               5702                 :                :  *             CREATE FOREIGN TABLE relname (...) SERVER name (...)
                               5703                 :                :  *
                               5704                 :                :  *****************************************************************************/
                               5705                 :                : 
                               5706                 :                : CreateForeignTableStmt:
                               5707                 :                :         CREATE FOREIGN TABLE qualified_name
                               5708                 :                :             '(' OptTableElementList ')'
                               5709                 :                :             OptInherit SERVER name create_generic_options
                               5710                 :                :                 {
 5362 rhaas@postgresql.org     5711                 :            200 :                     CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
                               5712                 :                : 
                               5713                 :            200 :                     $4->relpersistence = RELPERSISTENCE_PERMANENT;
                               5714                 :            200 :                     n->base.relation = $4;
 4561 tgl@sss.pgh.pa.us        5715                 :            200 :                     n->base.tableElts = $6;
 3821                          5716                 :            200 :                     n->base.inhRelations = $8;
                               5717                 :            200 :                     n->base.ofTypename = NULL;
                               5718                 :            200 :                     n->base.constraints = NIL;
                               5719                 :            200 :                     n->base.options = NIL;
                               5720                 :            200 :                     n->base.oncommit = ONCOMMIT_NOOP;
                               5721                 :            200 :                     n->base.tablespacename = NULL;
 5362 rhaas@postgresql.org     5722                 :            200 :                     n->base.if_not_exists = false;
                               5723                 :                :                     /* FDW-specific data */
 3821 tgl@sss.pgh.pa.us        5724                 :            200 :                     n->servername = $10;
                               5725                 :            200 :                     n->options = $11;
 5362 rhaas@postgresql.org     5726                 :            200 :                     $$ = (Node *) n;
                               5727                 :                :                 }
                               5728                 :                :         | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name
                               5729                 :                :             '(' OptTableElementList ')'
                               5730                 :                :             OptInherit SERVER name create_generic_options
                               5731                 :                :                 {
 5362 rhaas@postgresql.org     5732                 :UBC           0 :                     CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
                               5733                 :                : 
                               5734                 :              0 :                     $7->relpersistence = RELPERSISTENCE_PERMANENT;
                               5735                 :              0 :                     n->base.relation = $7;
 4561 tgl@sss.pgh.pa.us        5736                 :              0 :                     n->base.tableElts = $9;
 3821                          5737                 :              0 :                     n->base.inhRelations = $11;
                               5738                 :              0 :                     n->base.ofTypename = NULL;
                               5739                 :              0 :                     n->base.constraints = NIL;
                               5740                 :              0 :                     n->base.options = NIL;
                               5741                 :              0 :                     n->base.oncommit = ONCOMMIT_NOOP;
                               5742                 :              0 :                     n->base.tablespacename = NULL;
 5362 rhaas@postgresql.org     5743                 :              0 :                     n->base.if_not_exists = true;
                               5744                 :                :                     /* FDW-specific data */
 3821 tgl@sss.pgh.pa.us        5745                 :              0 :                     n->servername = $13;
                               5746                 :              0 :                     n->options = $14;
 5362 rhaas@postgresql.org     5747                 :              0 :                     $$ = (Node *) n;
                               5748                 :                :                 }
                               5749                 :                :         | CREATE FOREIGN TABLE qualified_name
                               5750                 :                :             PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec
                               5751                 :                :             SERVER name create_generic_options
                               5752                 :                :                 {
 3195 rhaas@postgresql.org     5753                 :CBC          45 :                     CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
                               5754                 :                : 
                               5755                 :             45 :                     $4->relpersistence = RELPERSISTENCE_PERMANENT;
                               5756                 :             45 :                     n->base.relation = $4;
                               5757                 :             45 :                     n->base.inhRelations = list_make1($7);
                               5758                 :             45 :                     n->base.tableElts = $8;
 3023 tgl@sss.pgh.pa.us        5759                 :             45 :                     n->base.partbound = $9;
 3195 rhaas@postgresql.org     5760                 :             45 :                     n->base.ofTypename = NULL;
                               5761                 :             45 :                     n->base.constraints = NIL;
                               5762                 :             45 :                     n->base.options = NIL;
                               5763                 :             45 :                     n->base.oncommit = ONCOMMIT_NOOP;
                               5764                 :             45 :                     n->base.tablespacename = NULL;
                               5765                 :             45 :                     n->base.if_not_exists = false;
                               5766                 :                :                     /* FDW-specific data */
                               5767                 :             45 :                     n->servername = $11;
                               5768                 :             45 :                     n->options = $12;
                               5769                 :             45 :                     $$ = (Node *) n;
                               5770                 :                :                 }
                               5771                 :                :         | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name
                               5772                 :                :             PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec
                               5773                 :                :             SERVER name create_generic_options
                               5774                 :                :                 {
 3195 rhaas@postgresql.org     5775                 :UBC           0 :                     CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
                               5776                 :                : 
                               5777                 :              0 :                     $7->relpersistence = RELPERSISTENCE_PERMANENT;
                               5778                 :              0 :                     n->base.relation = $7;
                               5779                 :              0 :                     n->base.inhRelations = list_make1($10);
                               5780                 :              0 :                     n->base.tableElts = $11;
 3023 tgl@sss.pgh.pa.us        5781                 :              0 :                     n->base.partbound = $12;
 3195 rhaas@postgresql.org     5782                 :              0 :                     n->base.ofTypename = NULL;
                               5783                 :              0 :                     n->base.constraints = NIL;
                               5784                 :              0 :                     n->base.options = NIL;
                               5785                 :              0 :                     n->base.oncommit = ONCOMMIT_NOOP;
                               5786                 :              0 :                     n->base.tablespacename = NULL;
                               5787                 :              0 :                     n->base.if_not_exists = true;
                               5788                 :                :                     /* FDW-specific data */
                               5789                 :              0 :                     n->servername = $14;
                               5790                 :              0 :                     n->options = $15;
                               5791                 :              0 :                     $$ = (Node *) n;
                               5792                 :                :                 }
                               5793                 :                :         ;
                               5794                 :                : 
                               5795                 :                : /*****************************************************************************
                               5796                 :                :  *
                               5797                 :                :  *      QUERY:
                               5798                 :                :  *              IMPORT FOREIGN SCHEMA remote_schema
                               5799                 :                :  *              [ { LIMIT TO | EXCEPT } ( table_list ) ]
                               5800                 :                :  *              FROM SERVER server_name INTO local_schema [ OPTIONS (...) ]
                               5801                 :                :  *
                               5802                 :                :  ****************************************************************************/
                               5803                 :                : 
                               5804                 :                : ImportForeignSchemaStmt:
                               5805                 :                :         IMPORT_P FOREIGN SCHEMA name import_qualification
                               5806                 :                :           FROM SERVER name INTO name create_generic_options
                               5807                 :                :             {
 4076 tgl@sss.pgh.pa.us        5808                 :CBC          24 :                 ImportForeignSchemaStmt *n = makeNode(ImportForeignSchemaStmt);
                               5809                 :                : 
                               5810                 :             24 :                 n->server_name = $8;
                               5811                 :             24 :                 n->remote_schema = $4;
                               5812                 :             24 :                 n->local_schema = $10;
                               5813                 :             24 :                 n->list_type = $5->type;
                               5814                 :             24 :                 n->table_list = $5->table_names;
                               5815                 :             24 :                 n->options = $11;
                               5816                 :             24 :                 $$ = (Node *) n;
                               5817                 :                :             }
                               5818                 :                :         ;
                               5819                 :                : 
                               5820                 :                : import_qualification_type:
 1760 peter@eisentraut.org     5821                 :              7 :         LIMIT TO                { $$ = FDW_IMPORT_SCHEMA_LIMIT_TO; }
                               5822                 :              7 :         | EXCEPT                { $$ = FDW_IMPORT_SCHEMA_EXCEPT; }
                               5823                 :                :         ;
                               5824                 :                : 
                               5825                 :                : import_qualification:
                               5826                 :                :         import_qualification_type '(' relation_expr_list ')'
                               5827                 :                :             {
 4076 tgl@sss.pgh.pa.us        5828                 :             14 :                 ImportQual *n = (ImportQual *) palloc(sizeof(ImportQual));
                               5829                 :                : 
                               5830                 :             14 :                 n->type = $1;
                               5831                 :             14 :                 n->table_names = $3;
                               5832                 :             14 :                 $$ = n;
                               5833                 :                :             }
                               5834                 :                :         | /*EMPTY*/
                               5835                 :                :             {
                               5836                 :             10 :                 ImportQual *n = (ImportQual *) palloc(sizeof(ImportQual));
                               5837                 :             10 :                 n->type = FDW_IMPORT_SCHEMA_ALL;
                               5838                 :             10 :                 n->table_names = NIL;
                               5839                 :             10 :                 $$ = n;
                               5840                 :                :             }
                               5841                 :                :         ;
                               5842                 :                : 
                               5843                 :                : /*****************************************************************************
                               5844                 :                :  *
                               5845                 :                :  *      QUERY:
                               5846                 :                :  *             CREATE USER MAPPING FOR auth_ident SERVER name [OPTIONS]
                               5847                 :                :  *
                               5848                 :                :  *****************************************************************************/
                               5849                 :                : 
                               5850                 :                : CreateUserMappingStmt: CREATE USER MAPPING FOR auth_ident SERVER name create_generic_options
                               5851                 :                :                 {
 6105 peter_e@gmx.net          5852                 :            125 :                     CreateUserMappingStmt *n = makeNode(CreateUserMappingStmt);
                               5853                 :                : 
 3834 alvherre@alvh.no-ip.     5854                 :            125 :                     n->user = $5;
 6105 peter_e@gmx.net          5855                 :            125 :                     n->servername = $7;
                               5856                 :            125 :                     n->options = $8;
 3092 andrew@dunslane.net      5857                 :            125 :                     n->if_not_exists = false;
                               5858                 :            125 :                     $$ = (Node *) n;
                               5859                 :                :                 }
                               5860                 :                :                 | CREATE USER MAPPING IF_P NOT EXISTS FOR auth_ident SERVER name create_generic_options
                               5861                 :                :                 {
                               5862                 :              3 :                     CreateUserMappingStmt *n = makeNode(CreateUserMappingStmt);
                               5863                 :                : 
                               5864                 :              3 :                     n->user = $8;
                               5865                 :              3 :                     n->servername = $10;
                               5866                 :              3 :                     n->options = $11;
                               5867                 :              3 :                     n->if_not_exists = true;
 6105 peter_e@gmx.net          5868                 :              3 :                     $$ = (Node *) n;
                               5869                 :                :                 }
                               5870                 :                :         ;
                               5871                 :                : 
                               5872                 :                : /* User mapping authorization identifier */
 3834 alvherre@alvh.no-ip.     5873                 :            227 : auth_ident: RoleSpec            { $$ = $1; }
                               5874                 :             23 :             | USER              { $$ = makeRoleSpec(ROLESPEC_CURRENT_USER, @1); }
                               5875                 :                :         ;
                               5876                 :                : 
                               5877                 :                : /*****************************************************************************
                               5878                 :                :  *
                               5879                 :                :  *      QUERY :
                               5880                 :                :  *              DROP USER MAPPING FOR auth_ident SERVER name
                               5881                 :                :  *
                               5882                 :                :  * XXX you'd think this should have a CASCADE/RESTRICT option, even if it's
                               5883                 :                :  * only pro forma; but the SQL standard doesn't show one.
                               5884                 :                :  ****************************************************************************/
                               5885                 :                : 
                               5886                 :                : DropUserMappingStmt: DROP USER MAPPING FOR auth_ident SERVER name
                               5887                 :                :                 {
 6105 peter_e@gmx.net          5888                 :             44 :                     DropUserMappingStmt *n = makeNode(DropUserMappingStmt);
                               5889                 :                : 
 3834 alvherre@alvh.no-ip.     5890                 :             44 :                     n->user = $5;
 6105 peter_e@gmx.net          5891                 :             44 :                     n->servername = $7;
                               5892                 :             44 :                     n->missing_ok = false;
                               5893                 :             44 :                     $$ = (Node *) n;
                               5894                 :                :                 }
                               5895                 :                :                 |  DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name
                               5896                 :                :                 {
                               5897                 :             19 :                     DropUserMappingStmt *n = makeNode(DropUserMappingStmt);
                               5898                 :                : 
 3834 alvherre@alvh.no-ip.     5899                 :             19 :                     n->user = $7;
 6105 peter_e@gmx.net          5900                 :             19 :                     n->servername = $9;
                               5901                 :             19 :                     n->missing_ok = true;
                               5902                 :             19 :                     $$ = (Node *) n;
                               5903                 :                :                 }
                               5904                 :                :         ;
                               5905                 :                : 
                               5906                 :                : /*****************************************************************************
                               5907                 :                :  *
                               5908                 :                :  *      QUERY :
                               5909                 :                :  *              ALTER USER MAPPING FOR auth_ident SERVER name OPTIONS
                               5910                 :                :  *
                               5911                 :                :  ****************************************************************************/
                               5912                 :                : 
                               5913                 :                : AlterUserMappingStmt: ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options
                               5914                 :                :                 {
                               5915                 :             59 :                     AlterUserMappingStmt *n = makeNode(AlterUserMappingStmt);
                               5916                 :                : 
 3834 alvherre@alvh.no-ip.     5917                 :             59 :                     n->user = $5;
 6105 peter_e@gmx.net          5918                 :             59 :                     n->servername = $7;
                               5919                 :             59 :                     n->options = $8;
                               5920                 :             59 :                     $$ = (Node *) n;
                               5921                 :                :                 }
                               5922                 :                :         ;
                               5923                 :                : 
                               5924                 :                : /*****************************************************************************
                               5925                 :                :  *
                               5926                 :                :  *      QUERIES:
                               5927                 :                :  *              CREATE POLICY name ON table
                               5928                 :                :  *                  [AS { PERMISSIVE | RESTRICTIVE } ]
                               5929                 :                :  *                  [FOR { SELECT | INSERT | UPDATE | DELETE } ]
                               5930                 :                :  *                  [TO role, ...]
                               5931                 :                :  *                  [USING (qual)] [WITH CHECK (with check qual)]
                               5932                 :                :  *              ALTER POLICY name ON table [TO role, ...]
                               5933                 :                :  *                  [USING (qual)] [WITH CHECK (with check qual)]
                               5934                 :                :  *
                               5935                 :                :  *****************************************************************************/
                               5936                 :                : 
                               5937                 :                : CreatePolicyStmt:
                               5938                 :                :             CREATE POLICY name ON qualified_name RowSecurityDefaultPermissive
                               5939                 :                :                 RowSecurityDefaultForCmd RowSecurityDefaultToRole
                               5940                 :                :                 RowSecurityOptionalExpr RowSecurityOptionalWithCheck
                               5941                 :                :                 {
 4005 sfrost@snowman.net       5942                 :            362 :                     CreatePolicyStmt *n = makeNode(CreatePolicyStmt);
                               5943                 :                : 
                               5944                 :            362 :                     n->policy_name = $3;
                               5945                 :            362 :                     n->table = $5;
 3197                          5946                 :            362 :                     n->permissive = $6;
                               5947                 :            362 :                     n->cmd_name = $7;
                               5948                 :            362 :                     n->roles = $8;
                               5949                 :            362 :                     n->qual = $9;
                               5950                 :            362 :                     n->with_check = $10;
 4005                          5951                 :            362 :                     $$ = (Node *) n;
                               5952                 :                :                 }
                               5953                 :                :         ;
                               5954                 :                : 
                               5955                 :                : AlterPolicyStmt:
                               5956                 :                :             ALTER POLICY name ON qualified_name RowSecurityOptionalToRole
                               5957                 :                :                 RowSecurityOptionalExpr RowSecurityOptionalWithCheck
                               5958                 :                :                 {
                               5959                 :             42 :                     AlterPolicyStmt *n = makeNode(AlterPolicyStmt);
                               5960                 :                : 
                               5961                 :             42 :                     n->policy_name = $3;
                               5962                 :             42 :                     n->table = $5;
                               5963                 :             42 :                     n->roles = $6;
                               5964                 :             42 :                     n->qual = $7;
                               5965                 :             42 :                     n->with_check = $8;
                               5966                 :             42 :                     $$ = (Node *) n;
                               5967                 :                :                 }
                               5968                 :                :         ;
                               5969                 :                : 
                               5970                 :                : RowSecurityOptionalExpr:
                               5971                 :            375 :             USING '(' a_expr ')'    { $$ = $3; }
                               5972                 :             29 :             | /* EMPTY */           { $$ = NULL; }
                               5973                 :                :         ;
                               5974                 :                : 
                               5975                 :                : RowSecurityOptionalWithCheck:
                               5976                 :             61 :             WITH CHECK '(' a_expr ')'       { $$ = $4; }
                               5977                 :            343 :             | /* EMPTY */                   { $$ = NULL; }
                               5978                 :                :         ;
                               5979                 :                : 
                               5980                 :                : RowSecurityDefaultToRole:
                               5981                 :             65 :             TO role_list            { $$ = $2; }
 3834 alvherre@alvh.no-ip.     5982                 :            297 :             | /* EMPTY */           { $$ = list_make1(makeRoleSpec(ROLESPEC_PUBLIC, -1)); }
                               5983                 :                :         ;
                               5984                 :                : 
                               5985                 :                : RowSecurityOptionalToRole:
 4005 sfrost@snowman.net       5986                 :              6 :             TO role_list            { $$ = $2; }
                               5987                 :             36 :             | /* EMPTY */           { $$ = NULL; }
                               5988                 :                :         ;
                               5989                 :                : 
                               5990                 :                : RowSecurityDefaultPermissive:
                               5991                 :                :             AS IDENT
                               5992                 :                :                 {
 3197                          5993         [ +  + ]:             49 :                     if (strcmp($2, "permissive") == 0)
                               5994                 :             12 :                         $$ = true;
                               5995         [ +  + ]:             37 :                     else if (strcmp($2, "restrictive") == 0)
                               5996                 :             34 :                         $$ = false;
                               5997                 :                :                     else
                               5998         [ +  - ]:              3 :                         ereport(ERROR,
                               5999                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               6000                 :                :                                  errmsg("unrecognized row security option \"%s\"", $2),
                               6001                 :                :                                  errhint("Only PERMISSIVE or RESTRICTIVE policies are supported currently."),
                               6002                 :                :                                  parser_errposition(@2)));
                               6003                 :                : 
                               6004                 :                :                 }
                               6005                 :            316 :             | /* EMPTY */           { $$ = true; }
                               6006                 :                :         ;
                               6007                 :                : 
                               6008                 :                : RowSecurityDefaultForCmd:
 4005                          6009                 :            160 :             FOR row_security_cmd    { $$ = $2; }
                               6010                 :            202 :             | /* EMPTY */           { $$ = "all"; }
                               6011                 :                :         ;
                               6012                 :                : 
                               6013                 :                : row_security_cmd:
                               6014                 :             22 :             ALL             { $$ = "all"; }
                               6015                 :             56 :         |   SELECT          { $$ = "select"; }
                               6016                 :             22 :         |   INSERT          { $$ = "insert"; }
                               6017                 :             39 :         |   UPDATE          { $$ = "update"; }
                               6018                 :             21 :         |   DELETE_P        { $$ = "delete"; }
                               6019                 :                :         ;
                               6020                 :                : 
                               6021                 :                : /*****************************************************************************
                               6022                 :                :  *
                               6023                 :                :  *      QUERY:
                               6024                 :                :  *             CREATE ACCESS METHOD name HANDLER handler_name
                               6025                 :                :  *
                               6026                 :                :  *****************************************************************************/
                               6027                 :                : 
                               6028                 :                : CreateAmStmt: CREATE ACCESS METHOD name TYPE_P am_type HANDLER handler_name
                               6029                 :                :                 {
 3454 alvherre@alvh.no-ip.     6030                 :             31 :                     CreateAmStmt *n = makeNode(CreateAmStmt);
                               6031                 :                : 
                               6032                 :             31 :                     n->amname = $4;
                               6033                 :             31 :                     n->handler_name = $8;
 2376 andres@anarazel.de       6034                 :             31 :                     n->amtype = $6;
 3454 alvherre@alvh.no-ip.     6035                 :             31 :                     $$ = (Node *) n;
                               6036                 :                :                 }
                               6037                 :                :         ;
                               6038                 :                : 
                               6039                 :                : am_type:
 2376 andres@anarazel.de       6040                 :             17 :             INDEX           { $$ = AMTYPE_INDEX; }
                               6041                 :             14 :         |   TABLE           { $$ = AMTYPE_TABLE; }
                               6042                 :                :         ;
                               6043                 :                : 
                               6044                 :                : /*****************************************************************************
                               6045                 :                :  *
                               6046                 :                :  *      QUERIES :
                               6047                 :                :  *              CREATE TRIGGER ...
                               6048                 :                :  *
                               6049                 :                :  *****************************************************************************/
                               6050                 :                : 
                               6051                 :                : CreateTrigStmt:
                               6052                 :                :             CREATE opt_or_replace TRIGGER name TriggerActionTime TriggerEvents ON
                               6053                 :                :             qualified_name TriggerReferencing TriggerForSpec TriggerWhen
                               6054                 :                :             EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')'
                               6055                 :                :                 {
10225 bruce@momjian.us         6056                 :           1582 :                     CreateTrigStmt *n = makeNode(CreateTrigStmt);
                               6057                 :                : 
 1757 tgl@sss.pgh.pa.us        6058                 :           1582 :                     n->replace = $2;
                               6059                 :           1582 :                     n->isconstraint = false;
                               6060                 :           1582 :                     n->trigname = $4;
                               6061                 :           1582 :                     n->relation = $8;
                               6062                 :           1582 :                     n->funcname = $14;
                               6063                 :           1582 :                     n->args = $16;
                               6064                 :           1582 :                     n->row = $10;
                               6065                 :           1582 :                     n->timing = $5;
                               6066                 :           1582 :                     n->events = intVal(linitial($6));
                               6067                 :           1582 :                     n->columns = (List *) lsecond($6);
                               6068                 :           1582 :                     n->whenClause = $11;
                               6069                 :           1582 :                     n->transitionRels = $9;
 1626 peter@eisentraut.org     6070                 :           1582 :                     n->deferrable = false;
                               6071                 :           1582 :                     n->initdeferred = false;
 8570 tgl@sss.pgh.pa.us        6072                 :           1582 :                     n->constrrel = NULL;
 1212 peter@eisentraut.org     6073                 :           1582 :                     $$ = (Node *) n;
                               6074                 :                :                 }
                               6075                 :                :           | CREATE opt_or_replace CONSTRAINT TRIGGER name AFTER TriggerEvents ON
                               6076                 :                :             qualified_name OptConstrFromTable ConstraintAttributeSpec
                               6077                 :                :             FOR EACH ROW TriggerWhen
                               6078                 :                :             EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')'
                               6079                 :                :                 {
 9474 JanWieck@Yahoo.com       6080                 :             40 :                     CreateTrigStmt *n = makeNode(CreateTrigStmt);
                               6081                 :                :                     bool        dummy;
                               6082                 :                : 
   65 alvherre@kurilemu.de     6083         [ +  + ]:GNC          40 :                     if (($11 & CAS_NOT_VALID) != 0)
                               6084         [ +  - ]:              3 :                         ereport(ERROR,
                               6085                 :                :                                 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               6086                 :                :                                 errmsg("constraint triggers cannot be marked %s",
                               6087                 :                :                                        "NOT VALID"),
                               6088                 :                :                                 parser_errposition(@11));
                               6089         [ +  + ]:             37 :                     if (($11 & CAS_NO_INHERIT) != 0)
                               6090         [ +  - ]:              3 :                         ereport(ERROR,
                               6091                 :                :                                 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               6092                 :                :                                 errmsg("constraint triggers cannot be marked %s",
                               6093                 :                :                                        "NO INHERIT"),
                               6094                 :                :                                 parser_errposition(@11));
                               6095         [ +  + ]:             34 :                     if (($11 & CAS_NOT_ENFORCED) != 0)
                               6096         [ +  - ]:              3 :                         ereport(ERROR,
                               6097                 :                :                                 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               6098                 :                :                                 errmsg("constraint triggers cannot be marked %s",
                               6099                 :                :                                        "NOT ENFORCED"),
                               6100                 :                :                                 parser_errposition(@11));
                               6101                 :                : 
 1757 tgl@sss.pgh.pa.us        6102                 :CBC          31 :                     n->replace = $2;
                               6103         [ -  + ]:             31 :                     if (n->replace) /* not supported, see CreateTrigger */
 1757 tgl@sss.pgh.pa.us        6104         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               6105                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               6106                 :                :                                  errmsg("CREATE OR REPLACE CONSTRAINT TRIGGER is not supported"),
                               6107                 :                :                                  parser_errposition(@1)));
 1757 tgl@sss.pgh.pa.us        6108                 :CBC          31 :                     n->isconstraint = true;
                               6109                 :             31 :                     n->trigname = $5;
                               6110                 :             31 :                     n->relation = $9;
                               6111                 :             31 :                     n->funcname = $18;
                               6112                 :             31 :                     n->args = $20;
 2943 peter_e@gmx.net          6113                 :             31 :                     n->row = true;
 5445 tgl@sss.pgh.pa.us        6114                 :             31 :                     n->timing = TRIGGER_TYPE_AFTER;
 1757                          6115                 :             31 :                     n->events = intVal(linitial($7));
                               6116                 :             31 :                     n->columns = (List *) lsecond($7);
                               6117                 :             31 :                     n->whenClause = $15;
 3228 kgrittn@postgresql.o     6118                 :             31 :                     n->transitionRels = NIL;
 1757 tgl@sss.pgh.pa.us        6119                 :             31 :                     processCASbits($11, @11, "TRIGGER",
                               6120                 :                :                                    &n->deferrable, &n->initdeferred, &dummy,
                               6121                 :                :                                    NULL, NULL, yyscanner);
                               6122                 :             31 :                     n->constrrel = $10;
 1212 peter@eisentraut.org     6123                 :             31 :                     $$ = (Node *) n;
                               6124                 :                :                 }
                               6125                 :                :         ;
                               6126                 :                : 
                               6127                 :                : TriggerActionTime:
 5445 tgl@sss.pgh.pa.us        6128                 :            712 :             BEFORE                              { $$ = TRIGGER_TYPE_BEFORE; }
                               6129                 :            804 :             | AFTER                             { $$ = TRIGGER_TYPE_AFTER; }
                               6130                 :             72 :             | INSTEAD OF                        { $$ = TRIGGER_TYPE_INSTEAD; }
                               6131                 :                :         ;
                               6132                 :                : 
                               6133                 :                : TriggerEvents:
                               6134                 :                :             TriggerOneEvent
 5924                          6135                 :           1628 :                 { $$ = $1; }
                               6136                 :                :             | TriggerEvents OR TriggerOneEvent
                               6137                 :                :                 {
 1212 peter@eisentraut.org     6138                 :            578 :                     int         events1 = intVal(linitial($1));
                               6139                 :            578 :                     int         events2 = intVal(linitial($3));
                               6140                 :            578 :                     List       *columns1 = (List *) lsecond($1);
                               6141                 :            578 :                     List       *columns2 = (List *) lsecond($3);
                               6142                 :                : 
 5806 tgl@sss.pgh.pa.us        6143         [ +  + ]:            578 :                     if (events1 & events2)
 5899                          6144                 :              3 :                         parser_yyerror("duplicate trigger events specified");
                               6145                 :                :                     /*
                               6146                 :                :                      * concat'ing the columns lists loses information about
                               6147                 :                :                      * which columns went with which event, but so long as
                               6148                 :                :                      * only UPDATE carries columns and we disallow multiple
                               6149                 :                :                      * UPDATE items, it doesn't matter.  Command execution
                               6150                 :                :                      * should just ignore the columns for non-UPDATE events.
                               6151                 :                :                      */
 5806                          6152                 :            575 :                     $$ = list_make2(makeInteger(events1 | events2),
                               6153                 :                :                                     list_concat(columns1, columns2));
                               6154                 :                :                 }
                               6155                 :                :         ;
                               6156                 :                : 
                               6157                 :                : TriggerOneEvent:
                               6158                 :                :             INSERT
                               6159                 :            834 :                 { $$ = list_make2(makeInteger(TRIGGER_TYPE_INSERT), NIL); }
                               6160                 :                :             | DELETE_P
                               6161                 :            443 :                 { $$ = list_make2(makeInteger(TRIGGER_TYPE_DELETE), NIL); }
                               6162                 :                :             | UPDATE
                               6163                 :            856 :                 { $$ = list_make2(makeInteger(TRIGGER_TYPE_UPDATE), NIL); }
                               6164                 :                :             | UPDATE OF columnList
                               6165                 :             50 :                 { $$ = list_make2(makeInteger(TRIGGER_TYPE_UPDATE), $3); }
                               6166                 :                :             | TRUNCATE
                               6167                 :             23 :                 { $$ = list_make2(makeInteger(TRIGGER_TYPE_TRUNCATE), NIL); }
                               6168                 :                :         ;
                               6169                 :                : 
                               6170                 :                : TriggerReferencing:
 3228 kgrittn@postgresql.o     6171                 :            232 :             REFERENCING TriggerTransitions          { $$ = $2; }
                               6172                 :           1350 :             | /*EMPTY*/                             { $$ = NIL; }
                               6173                 :                :         ;
                               6174                 :                : 
                               6175                 :                : TriggerTransitions:
                               6176                 :            232 :             TriggerTransition                       { $$ = list_make1($1); }
                               6177                 :             71 :             | TriggerTransitions TriggerTransition  { $$ = lappend($1, $2); }
                               6178                 :                :         ;
                               6179                 :                : 
                               6180                 :                : TriggerTransition:
                               6181                 :                :             TransitionOldOrNew TransitionRowOrTable opt_as TransitionRelName
                               6182                 :                :                 {
                               6183                 :            303 :                     TriggerTransition *n = makeNode(TriggerTransition);
                               6184                 :                : 
                               6185                 :            303 :                     n->name = $4;
                               6186                 :            303 :                     n->isNew = $1;
                               6187                 :            303 :                     n->isTable = $2;
 1212 peter@eisentraut.org     6188                 :            303 :                     $$ = (Node *) n;
                               6189                 :                :                 }
                               6190                 :                :         ;
                               6191                 :                : 
                               6192                 :                : TransitionOldOrNew:
 2943 peter_e@gmx.net          6193                 :            165 :             NEW                                     { $$ = true; }
                               6194                 :            138 :             | OLD                                   { $$ = false; }
                               6195                 :                :         ;
                               6196                 :                : 
                               6197                 :                : TransitionRowOrTable:
                               6198                 :            303 :             TABLE                                   { $$ = true; }
                               6199                 :                :             /*
                               6200                 :                :              * According to the standard, lack of a keyword here implies ROW.
                               6201                 :                :              * Support for that would require prohibiting ROW entirely here,
                               6202                 :                :              * reserving the keyword ROW, and/or requiring AS (instead of
                               6203                 :                :              * allowing it to be optional, as the standard specifies) as the
                               6204                 :                :              * next token.  Requiring ROW seems cleanest and easiest to
                               6205                 :                :              * explain.
                               6206                 :                :              */
 2943 peter_e@gmx.net          6207                 :UBC           0 :             | ROW                                   { $$ = false; }
                               6208                 :                :         ;
                               6209                 :                : 
                               6210                 :                : TransitionRelName:
 3228 kgrittn@postgresql.o     6211                 :CBC         303 :             ColId                                   { $$ = $1; }
                               6212                 :                :         ;
                               6213                 :                : 
                               6214                 :                : TriggerForSpec:
                               6215                 :                :             FOR TriggerForOptEach TriggerForType
                               6216                 :                :                 {
10069 lockhart@fourpalms.o     6217                 :           1468 :                     $$ = $3;
                               6218                 :                :                 }
                               6219                 :                :             | /* EMPTY */
                               6220                 :                :                 {
                               6221                 :                :                     /*
                               6222                 :                :                      * If ROW/STATEMENT not specified, default to
                               6223                 :                :                      * STATEMENT, per SQL
                               6224                 :                :                      */
 2943 peter_e@gmx.net          6225                 :            114 :                     $$ = false;
                               6226                 :                :                 }
                               6227                 :                :         ;
                               6228                 :                : 
                               6229                 :                : TriggerForOptEach:
                               6230                 :                :             EACH
                               6231                 :                :             | /*EMPTY*/
                               6232                 :                :         ;
                               6233                 :                : 
                               6234                 :                : TriggerForType:
                               6235                 :           1054 :             ROW                                     { $$ = true; }
                               6236                 :            414 :             | STATEMENT                             { $$ = false; }
                               6237                 :                :         ;
                               6238                 :                : 
                               6239                 :                : TriggerWhen:
 5769 tgl@sss.pgh.pa.us        6240                 :             95 :             WHEN '(' a_expr ')'                     { $$ = $3; }
                               6241                 :           1527 :             | /*EMPTY*/                             { $$ = NULL; }
                               6242                 :                :         ;
                               6243                 :                : 
                               6244                 :                : FUNCTION_or_PROCEDURE:
                               6245                 :                :             FUNCTION
                               6246                 :                :         |   PROCEDURE
                               6247                 :                :         ;
                               6248                 :                : 
                               6249                 :                : TriggerFuncArgs:
 7769 neilc@samurai.com        6250                 :            273 :             TriggerFuncArg                          { $$ = list_make1($1); }
 8481 bruce@momjian.us         6251                 :             81 :             | TriggerFuncArgs ',' TriggerFuncArg    { $$ = lappend($1, $3); }
 8482                          6252                 :           1349 :             | /*EMPTY*/                             { $$ = NIL; }
                               6253                 :                :         ;
                               6254                 :                : 
                               6255                 :                : TriggerFuncArg:
                               6256                 :                :             Iconst
                               6257                 :                :                 {
 1458 peter@eisentraut.org     6258                 :             47 :                     $$ = (Node *) makeString(psprintf("%d", $1));
                               6259                 :                :                 }
 1458 peter@eisentraut.org     6260                 :UBC           0 :             | FCONST                                { $$ = (Node *) makeString($1); }
 1458 peter@eisentraut.org     6261                 :CBC         296 :             | Sconst                                { $$ = (Node *) makeString($1); }
                               6262                 :             11 :             | ColLabel                              { $$ = (Node *) makeString($1); }
                               6263                 :                :         ;
                               6264                 :                : 
                               6265                 :                : OptConstrFromTable:
 8482 bruce@momjian.us         6266                 :              6 :             FROM qualified_name                     { $$ = $2; }
                               6267                 :             34 :             | /*EMPTY*/                             { $$ = NULL; }
                               6268                 :                :         ;
                               6269                 :                : 
                               6270                 :                : ConstraintAttributeSpec:
                               6271                 :                :             /*EMPTY*/
 5197 tgl@sss.pgh.pa.us        6272                 :           8924 :                 { $$ = 0; }
                               6273                 :                :             | ConstraintAttributeSpec ConstraintAttributeElem
                               6274                 :                :                 {
                               6275                 :                :                     /*
                               6276                 :                :                      * We must complain about conflicting options.
                               6277                 :                :                      * We could, but choose not to, complain about redundant
                               6278                 :                :                      * options (ie, where $2's bit is already set in $1).
                               6279                 :                :                      */
                               6280                 :            838 :                     int     newspec = $1 | $2;
                               6281                 :                : 
                               6282                 :                :                     /* special message for this case */
                               6283         [ +  + ]:            838 :                     if ((newspec & (CAS_NOT_DEFERRABLE | CAS_INITIALLY_DEFERRED)) == (CAS_NOT_DEFERRABLE | CAS_INITIALLY_DEFERRED))
 8085                          6284         [ +  - ]:              3 :                         ereport(ERROR,
                               6285                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               6286                 :                :                                  errmsg("constraint declared INITIALLY DEFERRED must be DEFERRABLE"),
                               6287                 :                :                                  parser_errposition(@2)));
                               6288                 :                :                     /* generic message for other conflicts */
 5197                          6289         [ +  - ]:            835 :                     if ((newspec & (CAS_NOT_DEFERRABLE | CAS_DEFERRABLE)) == (CAS_NOT_DEFERRABLE | CAS_DEFERRABLE) ||
  238 peter@eisentraut.org     6290         [ +  - ]:            835 :                         (newspec & (CAS_INITIALLY_IMMEDIATE | CAS_INITIALLY_DEFERRED)) == (CAS_INITIALLY_IMMEDIATE | CAS_INITIALLY_DEFERRED) ||
                               6291         [ +  + ]:            835 :                         (newspec & (CAS_NOT_ENFORCED | CAS_ENFORCED)) == (CAS_NOT_ENFORCED | CAS_ENFORCED))
 8085 tgl@sss.pgh.pa.us        6292         [ +  - ]:              3 :                         ereport(ERROR,
                               6293                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               6294                 :                :                                  errmsg("conflicting constraint properties"),
                               6295                 :                :                                  parser_errposition(@2)));
 5197                          6296                 :            832 :                     $$ = newspec;
                               6297                 :                :                 }
                               6298                 :                :         ;
                               6299                 :                : 
                               6300                 :                : ConstraintAttributeElem:
                               6301                 :             21 :             NOT DEFERRABLE                  { $$ = CAS_NOT_DEFERRABLE; }
                               6302                 :            100 :             | DEFERRABLE                    { $$ = CAS_DEFERRABLE; }
                               6303                 :             15 :             | INITIALLY IMMEDIATE           { $$ = CAS_INITIALLY_IMMEDIATE; }
                               6304                 :             76 :             | INITIALLY DEFERRED            { $$ = CAS_INITIALLY_DEFERRED; }
                               6305                 :            363 :             | NOT VALID                     { $$ = CAS_NOT_VALID; }
 4792 alvherre@alvh.no-ip.     6306                 :            125 :             | NO INHERIT                    { $$ = CAS_NO_INHERIT; }
  238 peter@eisentraut.org     6307                 :             84 :             | NOT ENFORCED                  { $$ = CAS_NOT_ENFORCED; }
                               6308                 :             54 :             | ENFORCED                      { $$ = CAS_ENFORCED; }
                               6309                 :                :         ;
                               6310                 :                : 
                               6311                 :                : 
                               6312                 :                : /*****************************************************************************
                               6313                 :                :  *
                               6314                 :                :  *      QUERIES :
                               6315                 :                :  *              CREATE EVENT TRIGGER ...
                               6316                 :                :  *              ALTER EVENT TRIGGER ...
                               6317                 :                :  *
                               6318                 :                :  *****************************************************************************/
                               6319                 :                : 
                               6320                 :                : CreateEventTrigStmt:
                               6321                 :                :             CREATE EVENT TRIGGER name ON ColLabel
                               6322                 :                :             EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')'
                               6323                 :                :                 {
 4798 rhaas@postgresql.org     6324                 :             51 :                     CreateEventTrigStmt *n = makeNode(CreateEventTrigStmt);
                               6325                 :                : 
                               6326                 :             51 :                     n->trigname = $4;
                               6327                 :             51 :                     n->eventname = $6;
                               6328                 :             51 :                     n->whenclause = NULL;
                               6329                 :             51 :                     n->funcname = $9;
 1212 peter@eisentraut.org     6330                 :             51 :                     $$ = (Node *) n;
                               6331                 :                :                 }
                               6332                 :                :           | CREATE EVENT TRIGGER name ON ColLabel
                               6333                 :                :             WHEN event_trigger_when_list
                               6334                 :                :             EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')'
                               6335                 :                :                 {
 4798 rhaas@postgresql.org     6336                 :             49 :                     CreateEventTrigStmt *n = makeNode(CreateEventTrigStmt);
                               6337                 :                : 
                               6338                 :             49 :                     n->trigname = $4;
                               6339                 :             49 :                     n->eventname = $6;
                               6340                 :             49 :                     n->whenclause = $8;
                               6341                 :             49 :                     n->funcname = $11;
 1212 peter@eisentraut.org     6342                 :             49 :                     $$ = (Node *) n;
                               6343                 :                :                 }
                               6344                 :                :         ;
                               6345                 :                : 
                               6346                 :                : event_trigger_when_list:
                               6347                 :                :           event_trigger_when_item
 4798 rhaas@postgresql.org     6348                 :             49 :             { $$ = list_make1($1); }
                               6349                 :                :         | event_trigger_when_list AND event_trigger_when_item
                               6350                 :              3 :             { $$ = lappend($1, $3); }
                               6351                 :                :         ;
                               6352                 :                : 
                               6353                 :                : event_trigger_when_item:
                               6354                 :                :         ColId IN_P '(' event_trigger_value_list ')'
 3287 peter_e@gmx.net          6355                 :             52 :             { $$ = makeDefElem($1, (Node *) $4, @1); }
                               6356                 :                :         ;
                               6357                 :                : 
                               6358                 :                : event_trigger_value_list:
                               6359                 :                :           SCONST
 4798 rhaas@postgresql.org     6360                 :             52 :             { $$ = list_make1(makeString($1)); }
                               6361                 :                :         | event_trigger_value_list ',' SCONST
                               6362                 :             33 :             { $$ = lappend($1, makeString($3)); }
                               6363                 :                :         ;
                               6364                 :                : 
                               6365                 :                : AlterEventTrigStmt:
                               6366                 :                :             ALTER EVENT TRIGGER name enable_trigger
                               6367                 :                :                 {
                               6368                 :             24 :                     AlterEventTrigStmt *n = makeNode(AlterEventTrigStmt);
                               6369                 :                : 
                               6370                 :             24 :                     n->trigname = $4;
                               6371                 :             24 :                     n->tgenabled = $5;
                               6372                 :             24 :                     $$ = (Node *) n;
                               6373                 :                :                 }
                               6374                 :                :         ;
                               6375                 :                : 
                               6376                 :                : enable_trigger:
                               6377                 :              3 :             ENABLE_P                    { $$ = TRIGGER_FIRES_ON_ORIGIN; }
                               6378                 :              3 :             | ENABLE_P REPLICA          { $$ = TRIGGER_FIRES_ON_REPLICA; }
                               6379                 :              8 :             | ENABLE_P ALWAYS           { $$ = TRIGGER_FIRES_ALWAYS; }
                               6380                 :             10 :             | DISABLE_P                 { $$ = TRIGGER_DISABLED; }
                               6381                 :                :         ;
                               6382                 :                : 
                               6383                 :                : /*****************************************************************************
                               6384                 :                :  *
                               6385                 :                :  *      QUERY :
                               6386                 :                :  *              CREATE ASSERTION ...
                               6387                 :                :  *
                               6388                 :                :  *****************************************************************************/
                               6389                 :                : 
                               6390                 :                : CreateAssertionStmt:
                               6391                 :                :             CREATE ASSERTION any_name CHECK '(' a_expr ')' ConstraintAttributeSpec
                               6392                 :                :                 {
 8085 tgl@sss.pgh.pa.us        6393         [ #  # ]:UBC           0 :                     ereport(ERROR,
                               6394                 :                :                             (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               6395                 :                :                              errmsg("CREATE ASSERTION is not yet implemented"),
                               6396                 :                :                              parser_errposition(@1)));
                               6397                 :                : 
                               6398                 :                :                     $$ = NULL;
                               6399                 :                :                 }
                               6400                 :                :         ;
                               6401                 :                : 
                               6402                 :                : 
                               6403                 :                : /*****************************************************************************
                               6404                 :                :  *
                               6405                 :                :  *      QUERY :
                               6406                 :                :  *              define (aggregate,operator,type)
                               6407                 :                :  *
                               6408                 :                :  *****************************************************************************/
                               6409                 :                : 
                               6410                 :                : DefineStmt:
                               6411                 :                :             CREATE opt_or_replace AGGREGATE func_name aggr_args definition
                               6412                 :                :                 {
 9283 lockhart@fourpalms.o     6413                 :CBC         272 :                     DefineStmt *n = makeNode(DefineStmt);
                               6414                 :                : 
 8107 peter_e@gmx.net          6415                 :            272 :                     n->kind = OBJECT_AGGREGATE;
 7084 tgl@sss.pgh.pa.us        6416                 :            272 :                     n->oldstyle = false;
 2363 rhodiumtoad@postgres     6417                 :            272 :                     n->replace = $2;
                               6418                 :            272 :                     n->defnames = $4;
                               6419                 :            272 :                     n->args = $5;
                               6420                 :            272 :                     n->definition = $6;
 1212 peter@eisentraut.org     6421                 :            272 :                     $$ = (Node *) n;
                               6422                 :                :                 }
                               6423                 :                :             | CREATE opt_or_replace AGGREGATE func_name old_aggr_definition
                               6424                 :                :                 {
                               6425                 :                :                     /* old-style (pre-8.2) syntax for CREATE AGGREGATE */
 7084 tgl@sss.pgh.pa.us        6426                 :            181 :                     DefineStmt *n = makeNode(DefineStmt);
                               6427                 :                : 
                               6428                 :            181 :                     n->kind = OBJECT_AGGREGATE;
                               6429                 :            181 :                     n->oldstyle = true;
 2363 rhodiumtoad@postgres     6430                 :            181 :                     n->replace = $2;
                               6431                 :            181 :                     n->defnames = $4;
 7084 tgl@sss.pgh.pa.us        6432                 :            181 :                     n->args = NIL;
 2363 rhodiumtoad@postgres     6433                 :            181 :                     n->definition = $5;
 1212 peter@eisentraut.org     6434                 :            181 :                     $$ = (Node *) n;
                               6435                 :                :                 }
                               6436                 :                :             | CREATE OPERATOR any_operator definition
                               6437                 :                :                 {
 9024 tgl@sss.pgh.pa.us        6438                 :            821 :                     DefineStmt *n = makeNode(DefineStmt);
                               6439                 :                : 
 8107 peter_e@gmx.net          6440                 :            821 :                     n->kind = OBJECT_OPERATOR;
 7084 tgl@sss.pgh.pa.us        6441                 :            821 :                     n->oldstyle = false;
 8544                          6442                 :            821 :                     n->defnames = $3;
 7084                          6443                 :            821 :                     n->args = NIL;
 9024                          6444                 :            821 :                     n->definition = $4;
 1212 peter@eisentraut.org     6445                 :            821 :                     $$ = (Node *) n;
                               6446                 :                :                 }
                               6447                 :                :             | CREATE TYPE_P any_name definition
                               6448                 :                :                 {
 9024 tgl@sss.pgh.pa.us        6449                 :            120 :                     DefineStmt *n = makeNode(DefineStmt);
                               6450                 :                : 
 8107 peter_e@gmx.net          6451                 :            120 :                     n->kind = OBJECT_TYPE;
 7084 tgl@sss.pgh.pa.us        6452                 :            120 :                     n->oldstyle = false;
 8562                          6453                 :            120 :                     n->defnames = $3;
 7084                          6454                 :            120 :                     n->args = NIL;
 9283 lockhart@fourpalms.o     6455                 :            120 :                     n->definition = $4;
 1212 peter@eisentraut.org     6456                 :            120 :                     $$ = (Node *) n;
                               6457                 :                :                 }
                               6458                 :                :             | CREATE TYPE_P any_name
                               6459                 :                :                 {
                               6460                 :                :                     /* Shell type (identified by lack of definition) */
 7130 tgl@sss.pgh.pa.us        6461                 :             78 :                     DefineStmt *n = makeNode(DefineStmt);
                               6462                 :                : 
                               6463                 :             78 :                     n->kind = OBJECT_TYPE;
 7084                          6464                 :             78 :                     n->oldstyle = false;
 7130                          6465                 :             78 :                     n->defnames = $3;
 7084                          6466                 :             78 :                     n->args = NIL;
 7130                          6467                 :             78 :                     n->definition = NIL;
 1212 peter@eisentraut.org     6468                 :             78 :                     $$ = (Node *) n;
                               6469                 :                :                 }
                               6470                 :                :             | CREATE TYPE_P any_name AS '(' OptTableFuncElementList ')'
                               6471                 :                :                 {
 8423 bruce@momjian.us         6472                 :            362 :                     CompositeTypeStmt *n = makeNode(CompositeTypeStmt);
                               6473                 :                : 
                               6474                 :                :                     /* can't use qualified_name, sigh */
 5459 peter_e@gmx.net          6475                 :            362 :                     n->typevar = makeRangeVarFromAnyName($3, @3, yyscanner);
 8409 tgl@sss.pgh.pa.us        6476                 :            362 :                     n->coldeflist = $6;
 1212 peter@eisentraut.org     6477                 :            362 :                     $$ = (Node *) n;
                               6478                 :                :                 }
                               6479                 :                :             | CREATE TYPE_P any_name AS ENUM_P '(' opt_enum_val_list ')'
                               6480                 :                :                 {
 6732 tgl@sss.pgh.pa.us        6481                 :            104 :                     CreateEnumStmt *n = makeNode(CreateEnumStmt);
                               6482                 :                : 
 5896 peter_e@gmx.net          6483                 :            104 :                     n->typeName = $3;
 6732 tgl@sss.pgh.pa.us        6484                 :            104 :                     n->vals = $7;
 1212 peter@eisentraut.org     6485                 :            104 :                     $$ = (Node *) n;
                               6486                 :                :                 }
                               6487                 :                :             | CREATE TYPE_P any_name AS RANGE definition
                               6488                 :                :                 {
 5056 heikki.linnakangas@i     6489                 :             92 :                     CreateRangeStmt *n = makeNode(CreateRangeStmt);
                               6490                 :                : 
                               6491                 :             92 :                     n->typeName = $3;
 1515 peter@eisentraut.org     6492                 :             92 :                     n->params = $6;
 1212                          6493                 :             92 :                     $$ = (Node *) n;
                               6494                 :                :                 }
                               6495                 :                :             | CREATE TEXT_P SEARCH PARSER any_name definition
                               6496                 :                :                 {
 6591 tgl@sss.pgh.pa.us        6497                 :             20 :                     DefineStmt *n = makeNode(DefineStmt);
                               6498                 :                : 
                               6499                 :             20 :                     n->kind = OBJECT_TSPARSER;
                               6500                 :             20 :                     n->args = NIL;
                               6501                 :             20 :                     n->defnames = $5;
                               6502                 :             20 :                     n->definition = $6;
 1212 peter@eisentraut.org     6503                 :             20 :                     $$ = (Node *) n;
                               6504                 :                :                 }
                               6505                 :                :             | CREATE TEXT_P SEARCH DICTIONARY any_name definition
                               6506                 :                :                 {
 6591 tgl@sss.pgh.pa.us        6507                 :           1465 :                     DefineStmt *n = makeNode(DefineStmt);
                               6508                 :                : 
                               6509                 :           1465 :                     n->kind = OBJECT_TSDICTIONARY;
                               6510                 :           1465 :                     n->args = NIL;
                               6511                 :           1465 :                     n->defnames = $5;
                               6512                 :           1465 :                     n->definition = $6;
 1212 peter@eisentraut.org     6513                 :           1465 :                     $$ = (Node *) n;
                               6514                 :                :                 }
                               6515                 :                :             | CREATE TEXT_P SEARCH TEMPLATE any_name definition
                               6516                 :                :                 {
 6591 tgl@sss.pgh.pa.us        6517                 :             70 :                     DefineStmt *n = makeNode(DefineStmt);
                               6518                 :                : 
                               6519                 :             70 :                     n->kind = OBJECT_TSTEMPLATE;
                               6520                 :             70 :                     n->args = NIL;
                               6521                 :             70 :                     n->defnames = $5;
                               6522                 :             70 :                     n->definition = $6;
 1212 peter@eisentraut.org     6523                 :             70 :                     $$ = (Node *) n;
                               6524                 :                :                 }
                               6525                 :                :             | CREATE TEXT_P SEARCH CONFIGURATION any_name definition
                               6526                 :                :                 {
 6591 tgl@sss.pgh.pa.us        6527                 :           1436 :                     DefineStmt *n = makeNode(DefineStmt);
                               6528                 :                : 
                               6529                 :           1436 :                     n->kind = OBJECT_TSCONFIGURATION;
                               6530                 :           1436 :                     n->args = NIL;
                               6531                 :           1436 :                     n->defnames = $5;
                               6532                 :           1436 :                     n->definition = $6;
 1212 peter@eisentraut.org     6533                 :           1436 :                     $$ = (Node *) n;
                               6534                 :                :                 }
                               6535                 :                :             | CREATE COLLATION any_name definition
                               6536                 :                :                 {
 5320 peter_e@gmx.net          6537                 :            146 :                     DefineStmt *n = makeNode(DefineStmt);
                               6538                 :                : 
                               6539                 :            146 :                     n->kind = OBJECT_COLLATION;
                               6540                 :            146 :                     n->args = NIL;
                               6541                 :            146 :                     n->defnames = $3;
                               6542                 :            146 :                     n->definition = $4;
 1212 peter@eisentraut.org     6543                 :            146 :                     $$ = (Node *) n;
                               6544                 :                :                 }
                               6545                 :                :             | CREATE COLLATION IF_P NOT EXISTS any_name definition
                               6546                 :                :                 {
 3132 peter_e@gmx.net          6547                 :              9 :                     DefineStmt *n = makeNode(DefineStmt);
                               6548                 :                : 
                               6549                 :              9 :                     n->kind = OBJECT_COLLATION;
                               6550                 :              9 :                     n->args = NIL;
                               6551                 :              9 :                     n->defnames = $6;
                               6552                 :              9 :                     n->definition = $7;
                               6553                 :              9 :                     n->if_not_exists = true;
 1212 peter@eisentraut.org     6554                 :              9 :                     $$ = (Node *) n;
                               6555                 :                :                 }
                               6556                 :                :             | CREATE COLLATION any_name FROM any_name
                               6557                 :                :                 {
 5320 peter_e@gmx.net          6558                 :             27 :                     DefineStmt *n = makeNode(DefineStmt);
                               6559                 :                : 
                               6560                 :             27 :                     n->kind = OBJECT_COLLATION;
                               6561                 :             27 :                     n->args = NIL;
                               6562                 :             27 :                     n->defnames = $3;
 3287                          6563                 :             27 :                     n->definition = list_make1(makeDefElem("from", (Node *) $5, @5));
 1212 peter@eisentraut.org     6564                 :             27 :                     $$ = (Node *) n;
                               6565                 :                :                 }
                               6566                 :                :             | CREATE COLLATION IF_P NOT EXISTS any_name FROM any_name
                               6567                 :                :                 {
 3132 peter_e@gmx.net          6568                 :UBC           0 :                     DefineStmt *n = makeNode(DefineStmt);
                               6569                 :                : 
                               6570                 :              0 :                     n->kind = OBJECT_COLLATION;
                               6571                 :              0 :                     n->args = NIL;
                               6572                 :              0 :                     n->defnames = $6;
                               6573                 :              0 :                     n->definition = list_make1(makeDefElem("from", (Node *) $8, @8));
                               6574                 :              0 :                     n->if_not_exists = true;
 1212 peter@eisentraut.org     6575                 :              0 :                     $$ = (Node *) n;
                               6576                 :                :                 }
                               6577                 :                :         ;
                               6578                 :                : 
 8482 bruce@momjian.us         6579                 :CBC        4975 : definition: '(' def_list ')'                        { $$ = $2; }
                               6580                 :                :         ;
                               6581                 :                : 
 5058 peter_e@gmx.net          6582                 :           4975 : def_list:   def_elem                                { $$ = list_make1($1); }
 8482 bruce@momjian.us         6583                 :           7407 :             | def_list ',' def_elem                 { $$ = lappend($1, $3); }
                               6584                 :                :         ;
                               6585                 :                : 
                               6586                 :                : def_elem:   ColLabel '=' def_arg
                               6587                 :                :                 {
 3287 peter_e@gmx.net          6588                 :          12213 :                     $$ = makeDefElem($1, (Node *) $3, @1);
                               6589                 :                :                 }
                               6590                 :                :             | ColLabel
                               6591                 :                :                 {
                               6592                 :            169 :                     $$ = makeDefElem($1, NULL, @1);
                               6593                 :                :                 }
                               6594                 :                :         ;
                               6595                 :                : 
                               6596                 :                : /* Note: any simple identifier will be returned as a type name! */
 1212 peter@eisentraut.org     6597                 :           9849 : def_arg:    func_type                       { $$ = (Node *) $1; }
                               6598                 :           2065 :             | reserved_keyword              { $$ = (Node *) makeString(pstrdup($1)); }
                               6599                 :            588 :             | qual_all_Op                   { $$ = (Node *) $1; }
                               6600                 :            670 :             | NumericOnly                   { $$ = (Node *) $1; }
                               6601                 :            946 :             | Sconst                        { $$ = (Node *) makeString($1); }
                               6602                 :             91 :             | NONE                          { $$ = (Node *) makeString(pstrdup($1)); }
                               6603                 :                :         ;
                               6604                 :                : 
 7084 tgl@sss.pgh.pa.us        6605                 :            181 : old_aggr_definition: '(' old_aggr_list ')'          { $$ = $2; }
                               6606                 :                :         ;
                               6607                 :                : 
                               6608                 :            181 : old_aggr_list: old_aggr_elem                        { $$ = list_make1($1); }
                               6609                 :            646 :             | old_aggr_list ',' old_aggr_elem       { $$ = lappend($1, $3); }
                               6610                 :                :         ;
                               6611                 :                : 
                               6612                 :                : /*
                               6613                 :                :  * Must use IDENT here to avoid reduce/reduce conflicts; fortunately none of
                               6614                 :                :  * the item names needed in old aggregate definitions are likely to become
                               6615                 :                :  * SQL keywords.
                               6616                 :                :  */
                               6617                 :                : old_aggr_elem:  IDENT '=' def_arg
                               6618                 :                :                 {
 1212 peter@eisentraut.org     6619                 :            827 :                     $$ = makeDefElem($1, (Node *) $3, @1);
                               6620                 :                :                 }
                               6621                 :                :         ;
                               6622                 :                : 
                               6623                 :                : opt_enum_val_list:
 5733 bruce@momjian.us         6624                 :            100 :         enum_val_list                           { $$ = $1; }
                               6625                 :              4 :         | /*EMPTY*/                             { $$ = NIL; }
                               6626                 :                :         ;
                               6627                 :                : 
                               6628                 :                : enum_val_list:  Sconst
 6732 tgl@sss.pgh.pa.us        6629                 :            100 :                 { $$ = list_make1(makeString($1)); }
                               6630                 :                :             | enum_val_list ',' Sconst
                               6631                 :           5210 :                 { $$ = lappend($1, makeString($3)); }
                               6632                 :                :         ;
                               6633                 :                : 
                               6634                 :                : /*****************************************************************************
                               6635                 :                :  *
                               6636                 :                :  *  ALTER TYPE enumtype ADD ...
                               6637                 :                :  *
                               6638                 :                :  *****************************************************************************/
                               6639                 :                : 
                               6640                 :                : AlterEnumStmt:
                               6641                 :                :         ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists Sconst
                               6642                 :                :             {
 5058 peter_e@gmx.net          6643                 :             77 :                 AlterEnumStmt *n = makeNode(AlterEnumStmt);
                               6644                 :                : 
                               6645                 :             77 :                 n->typeName = $3;
 3286 tgl@sss.pgh.pa.us        6646                 :             77 :                 n->oldVal = NULL;
 4732 andrew@dunslane.net      6647                 :             77 :                 n->newVal = $7;
 5058 peter_e@gmx.net          6648                 :             77 :                 n->newValNeighbor = NULL;
                               6649                 :             77 :                 n->newValIsAfter = true;
 3286 tgl@sss.pgh.pa.us        6650                 :             77 :                 n->skipIfNewValExists = $6;
 5058 peter_e@gmx.net          6651                 :             77 :                 $$ = (Node *) n;
                               6652                 :                :             }
                               6653                 :                :          | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists Sconst BEFORE Sconst
                               6654                 :                :             {
                               6655                 :             98 :                 AlterEnumStmt *n = makeNode(AlterEnumStmt);
                               6656                 :                : 
                               6657                 :             98 :                 n->typeName = $3;
 3286 tgl@sss.pgh.pa.us        6658                 :             98 :                 n->oldVal = NULL;
 4732 andrew@dunslane.net      6659                 :             98 :                 n->newVal = $7;
                               6660                 :             98 :                 n->newValNeighbor = $9;
 5058 peter_e@gmx.net          6661                 :             98 :                 n->newValIsAfter = false;
 3286 tgl@sss.pgh.pa.us        6662                 :             98 :                 n->skipIfNewValExists = $6;
 5058 peter_e@gmx.net          6663                 :             98 :                 $$ = (Node *) n;
                               6664                 :                :             }
                               6665                 :                :          | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists Sconst AFTER Sconst
                               6666                 :                :             {
                               6667                 :             11 :                 AlterEnumStmt *n = makeNode(AlterEnumStmt);
                               6668                 :                : 
                               6669                 :             11 :                 n->typeName = $3;
 3286 tgl@sss.pgh.pa.us        6670                 :             11 :                 n->oldVal = NULL;
 4732 andrew@dunslane.net      6671                 :             11 :                 n->newVal = $7;
                               6672                 :             11 :                 n->newValNeighbor = $9;
 5058 peter_e@gmx.net          6673                 :             11 :                 n->newValIsAfter = true;
 3286 tgl@sss.pgh.pa.us        6674                 :             11 :                 n->skipIfNewValExists = $6;
                               6675                 :             11 :                 $$ = (Node *) n;
                               6676                 :                :             }
                               6677                 :                :          | ALTER TYPE_P any_name RENAME VALUE_P Sconst TO Sconst
                               6678                 :                :             {
                               6679                 :             12 :                 AlterEnumStmt *n = makeNode(AlterEnumStmt);
                               6680                 :                : 
                               6681                 :             12 :                 n->typeName = $3;
                               6682                 :             12 :                 n->oldVal = $6;
                               6683                 :             12 :                 n->newVal = $8;
                               6684                 :             12 :                 n->newValNeighbor = NULL;
                               6685                 :             12 :                 n->newValIsAfter = false;
                               6686                 :             12 :                 n->skipIfNewValExists = false;
 5058 peter_e@gmx.net          6687                 :             12 :                 $$ = (Node *) n;
                               6688                 :                :             }
                               6689                 :                :          | ALTER TYPE_P any_name DROP VALUE_P Sconst
                               6690                 :                :             {
                               6691                 :                :                 /*
                               6692                 :                :                  * The following problems must be solved before this can be
                               6693                 :                :                  * implemented:
                               6694                 :                :                  *
                               6695                 :                :                  * - There must be no instance of the target value in
                               6696                 :                :                  *   any table.
                               6697                 :                :                  *
                               6698                 :                :                  * - The value must not appear in any catalog metadata,
                               6699                 :                :                  *   such as stored view expressions or column defaults.
                               6700                 :                :                  *
                               6701                 :                :                  * - The value must not appear in any non-leaf page of a
                               6702                 :                :                  *   btree (and similar issues with other index types).
                               6703                 :                :                  *   This is problematic because a value could persist
                               6704                 :                :                  *   there long after it's gone from user-visible data.
                               6705                 :                :                  *
                               6706                 :                :                  * - Concurrent sessions must not be able to insert the
                               6707                 :                :                  *   value while the preceding conditions are being checked.
                               6708                 :                :                  *
                               6709                 :                :                  * - Possibly more...
                               6710                 :                :                  */
  704 tgl@sss.pgh.pa.us        6711         [ #  # ]:UBC           0 :                 ereport(ERROR,
                               6712                 :                :                         (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               6713                 :                :                          errmsg("dropping an enum value is not implemented"),
                               6714                 :                :                          parser_errposition(@4)));
                               6715                 :                :             }
                               6716                 :                :          ;
                               6717                 :                : 
 4732 andrew@dunslane.net      6718                 :CBC           6 : opt_if_not_exists: IF_P NOT EXISTS              { $$ = true; }
 1755 peter@eisentraut.org     6719                 :            180 :         | /* EMPTY */                          { $$ = false; }
                               6720                 :                :         ;
                               6721                 :                : 
                               6722                 :                : 
                               6723                 :                : /*****************************************************************************
                               6724                 :                :  *
                               6725                 :                :  *      QUERIES :
                               6726                 :                :  *              CREATE OPERATOR CLASS ...
                               6727                 :                :  *              CREATE OPERATOR FAMILY ...
                               6728                 :                :  *              ALTER OPERATOR FAMILY ...
                               6729                 :                :  *              DROP OPERATOR CLASS ...
                               6730                 :                :  *              DROP OPERATOR FAMILY ...
                               6731                 :                :  *
                               6732                 :                :  *****************************************************************************/
                               6733                 :                : 
                               6734                 :                : CreateOpClassStmt:
                               6735                 :                :             CREATE OPERATOR CLASS any_name opt_default FOR TYPE_P Typename
                               6736                 :                :             USING name opt_opfamily AS opclass_item_list
                               6737                 :                :                 {
 8440 tgl@sss.pgh.pa.us        6738                 :            278 :                     CreateOpClassStmt *n = makeNode(CreateOpClassStmt);
                               6739                 :                : 
                               6740                 :            278 :                     n->opclassname = $4;
                               6741                 :            278 :                     n->isDefault = $5;
                               6742                 :            278 :                     n->datatype = $8;
                               6743                 :            278 :                     n->amname = $10;
 6801                          6744                 :            278 :                     n->opfamilyname = $11;
                               6745                 :            278 :                     n->items = $13;
 8440                          6746                 :            278 :                     $$ = (Node *) n;
                               6747                 :                :                 }
                               6748                 :                :         ;
                               6749                 :                : 
                               6750                 :                : opclass_item_list:
 7769 neilc@samurai.com        6751                 :            706 :             opclass_item                            { $$ = list_make1($1); }
 8440 tgl@sss.pgh.pa.us        6752                 :           2694 :             | opclass_item_list ',' opclass_item    { $$ = lappend($1, $3); }
                               6753                 :                :         ;
                               6754                 :                : 
                               6755                 :                : opclass_item:
                               6756                 :                :             OPERATOR Iconst any_operator opclass_purpose
                               6757                 :                :                 {
                               6758                 :            933 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
 3174 peter_e@gmx.net          6759                 :            933 :                     ObjectWithArgs *owa = makeNode(ObjectWithArgs);
                               6760                 :                : 
                               6761                 :            933 :                     owa->objname = $3;
                               6762                 :            933 :                     owa->objargs = NIL;
 8440 tgl@sss.pgh.pa.us        6763                 :            933 :                     n->itemtype = OPCLASS_ITEM_OPERATOR;
 3174 peter_e@gmx.net          6764                 :            933 :                     n->name = owa;
 8440 tgl@sss.pgh.pa.us        6765                 :            933 :                     n->number = $2;
 5400                          6766                 :            933 :                     n->order_family = $4;
 8440                          6767                 :            933 :                     $$ = (Node *) n;
                               6768                 :                :                 }
                               6769                 :                :             | OPERATOR Iconst operator_with_argtypes opclass_purpose
                               6770                 :                :                 {
                               6771                 :            785 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
                               6772                 :                : 
                               6773                 :            785 :                     n->itemtype = OPCLASS_ITEM_OPERATOR;
 3174 peter_e@gmx.net          6774                 :            785 :                     n->name = $3;
 8440 tgl@sss.pgh.pa.us        6775                 :            785 :                     n->number = $2;
 3174 peter_e@gmx.net          6776                 :            785 :                     n->order_family = $4;
 8440 tgl@sss.pgh.pa.us        6777                 :            785 :                     $$ = (Node *) n;
                               6778                 :                :                 }
                               6779                 :                :             | FUNCTION Iconst function_with_argtypes
                               6780                 :                :                 {
                               6781                 :           1207 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
                               6782                 :                : 
                               6783                 :           1207 :                     n->itemtype = OPCLASS_ITEM_FUNCTION;
 3174 peter_e@gmx.net          6784                 :           1207 :                     n->name = $3;
 8440 tgl@sss.pgh.pa.us        6785                 :           1207 :                     n->number = $2;
                               6786                 :           1207 :                     $$ = (Node *) n;
                               6787                 :                :                 }
                               6788                 :                :             | FUNCTION Iconst '(' type_list ')' function_with_argtypes
                               6789                 :                :                 {
 6801                          6790                 :            295 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
                               6791                 :                : 
                               6792                 :            295 :                     n->itemtype = OPCLASS_ITEM_FUNCTION;
 3174 peter_e@gmx.net          6793                 :            295 :                     n->name = $6;
 6801 tgl@sss.pgh.pa.us        6794                 :            295 :                     n->number = $2;
                               6795                 :            295 :                     n->class_args = $4;
                               6796                 :            295 :                     $$ = (Node *) n;
                               6797                 :                :                 }
                               6798                 :                :             | STORAGE Typename
                               6799                 :                :                 {
 8440                          6800                 :            180 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
                               6801                 :                : 
                               6802                 :            180 :                     n->itemtype = OPCLASS_ITEM_STORAGETYPE;
                               6803                 :            180 :                     n->storedtype = $2;
                               6804                 :            180 :                     $$ = (Node *) n;
                               6805                 :                :                 }
                               6806                 :                :         ;
                               6807                 :                : 
 2943 peter_e@gmx.net          6808                 :            226 : opt_default:    DEFAULT                     { $$ = true; }
                               6809                 :             84 :             | /*EMPTY*/                     { $$ = false; }
                               6810                 :                :         ;
                               6811                 :                : 
 6801 tgl@sss.pgh.pa.us        6812                 :             22 : opt_opfamily:   FAMILY any_name             { $$ = $2; }
                               6813                 :            256 :             | /*EMPTY*/                     { $$ = NIL; }
                               6814                 :                :         ;
                               6815                 :                : 
 5400 tgl@sss.pgh.pa.us        6816                 :UBC           0 : opclass_purpose: FOR SEARCH                 { $$ = NIL; }
 5400 tgl@sss.pgh.pa.us        6817                 :CBC          60 :             | FOR ORDER BY any_name         { $$ = $4; }
                               6818                 :           1658 :             | /*EMPTY*/                     { $$ = NIL; }
                               6819                 :                :         ;
                               6820                 :                : 
                               6821                 :                : 
                               6822                 :                : CreateOpFamilyStmt:
                               6823                 :                :             CREATE OPERATOR FAMILY any_name USING name
                               6824                 :                :                 {
 6801                          6825                 :             74 :                     CreateOpFamilyStmt *n = makeNode(CreateOpFamilyStmt);
                               6826                 :                : 
                               6827                 :             74 :                     n->opfamilyname = $4;
                               6828                 :             74 :                     n->amname = $6;
                               6829                 :             74 :                     $$ = (Node *) n;
                               6830                 :                :                 }
                               6831                 :                :         ;
                               6832                 :                : 
                               6833                 :                : AlterOpFamilyStmt:
                               6834                 :                :             ALTER OPERATOR FAMILY any_name USING name ADD_P opclass_item_list
                               6835                 :                :                 {
                               6836                 :            428 :                     AlterOpFamilyStmt *n = makeNode(AlterOpFamilyStmt);
                               6837                 :                : 
                               6838                 :            428 :                     n->opfamilyname = $4;
                               6839                 :            428 :                     n->amname = $6;
                               6840                 :            428 :                     n->isDrop = false;
                               6841                 :            428 :                     n->items = $8;
                               6842                 :            428 :                     $$ = (Node *) n;
                               6843                 :                :                 }
                               6844                 :                :             | ALTER OPERATOR FAMILY any_name USING name DROP opclass_drop_list
                               6845                 :                :                 {
                               6846                 :             32 :                     AlterOpFamilyStmt *n = makeNode(AlterOpFamilyStmt);
                               6847                 :                : 
                               6848                 :             32 :                     n->opfamilyname = $4;
                               6849                 :             32 :                     n->amname = $6;
                               6850                 :             32 :                     n->isDrop = true;
                               6851                 :             32 :                     n->items = $8;
                               6852                 :             32 :                     $$ = (Node *) n;
                               6853                 :                :                 }
                               6854                 :                :         ;
                               6855                 :                : 
                               6856                 :                : opclass_drop_list:
                               6857                 :             32 :             opclass_drop                            { $$ = list_make1($1); }
                               6858                 :             15 :             | opclass_drop_list ',' opclass_drop    { $$ = lappend($1, $3); }
                               6859                 :                :         ;
                               6860                 :                : 
                               6861                 :                : opclass_drop:
                               6862                 :                :             OPERATOR Iconst '(' type_list ')'
                               6863                 :                :                 {
                               6864                 :             28 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
                               6865                 :                : 
                               6866                 :             28 :                     n->itemtype = OPCLASS_ITEM_OPERATOR;
                               6867                 :             28 :                     n->number = $2;
 3174 peter_e@gmx.net          6868                 :             28 :                     n->class_args = $4;
 6801 tgl@sss.pgh.pa.us        6869                 :             28 :                     $$ = (Node *) n;
                               6870                 :                :                 }
                               6871                 :                :             | FUNCTION Iconst '(' type_list ')'
                               6872                 :                :                 {
                               6873                 :             19 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
                               6874                 :                : 
                               6875                 :             19 :                     n->itemtype = OPCLASS_ITEM_FUNCTION;
                               6876                 :             19 :                     n->number = $2;
 3174 peter_e@gmx.net          6877                 :             19 :                     n->class_args = $4;
 6801 tgl@sss.pgh.pa.us        6878                 :             19 :                     $$ = (Node *) n;
                               6879                 :                :                 }
                               6880                 :                :         ;
                               6881                 :                : 
                               6882                 :                : 
                               6883                 :                : DropOpClassStmt:
                               6884                 :                :             DROP OPERATOR CLASS any_name USING name opt_drop_behavior
                               6885                 :                :                 {
 5042 rhaas@postgresql.org     6886                 :             19 :                     DropStmt *n = makeNode(DropStmt);
                               6887                 :                : 
 3827 alvherre@alvh.no-ip.     6888                 :             19 :                     n->objects = list_make1(lcons(makeString($6), $4));
 5042 rhaas@postgresql.org     6889                 :             19 :                     n->removeType = OBJECT_OPCLASS;
 8440 tgl@sss.pgh.pa.us        6890                 :             19 :                     n->behavior = $7;
 7022 andrew@dunslane.net      6891                 :             19 :                     n->missing_ok = false;
 4901 simon@2ndQuadrant.co     6892                 :             19 :                     n->concurrent = false;
 7022 andrew@dunslane.net      6893                 :             19 :                     $$ = (Node *) n;
                               6894                 :                :                 }
                               6895                 :                :             | DROP OPERATOR CLASS IF_P EXISTS any_name USING name opt_drop_behavior
                               6896                 :                :                 {
 5042 rhaas@postgresql.org     6897                 :              9 :                     DropStmt *n = makeNode(DropStmt);
                               6898                 :                : 
 3827 alvherre@alvh.no-ip.     6899                 :              9 :                     n->objects = list_make1(lcons(makeString($8), $6));
 5042 rhaas@postgresql.org     6900                 :              9 :                     n->removeType = OBJECT_OPCLASS;
 7022 andrew@dunslane.net      6901                 :              9 :                     n->behavior = $9;
                               6902                 :              9 :                     n->missing_ok = true;
 4901 simon@2ndQuadrant.co     6903                 :              9 :                     n->concurrent = false;
 8440 tgl@sss.pgh.pa.us        6904                 :              9 :                     $$ = (Node *) n;
                               6905                 :                :                 }
                               6906                 :                :         ;
                               6907                 :                : 
                               6908                 :                : DropOpFamilyStmt:
                               6909                 :                :             DROP OPERATOR FAMILY any_name USING name opt_drop_behavior
                               6910                 :                :                 {
 5042 rhaas@postgresql.org     6911                 :             55 :                     DropStmt *n = makeNode(DropStmt);
                               6912                 :                : 
 3827 alvherre@alvh.no-ip.     6913                 :             55 :                     n->objects = list_make1(lcons(makeString($6), $4));
 5042 rhaas@postgresql.org     6914                 :             55 :                     n->removeType = OBJECT_OPFAMILY;
 6801 tgl@sss.pgh.pa.us        6915                 :             55 :                     n->behavior = $7;
                               6916                 :             55 :                     n->missing_ok = false;
 4901 simon@2ndQuadrant.co     6917                 :             55 :                     n->concurrent = false;
 6801 tgl@sss.pgh.pa.us        6918                 :             55 :                     $$ = (Node *) n;
                               6919                 :                :                 }
                               6920                 :                :             | DROP OPERATOR FAMILY IF_P EXISTS any_name USING name opt_drop_behavior
                               6921                 :                :                 {
 5042 rhaas@postgresql.org     6922                 :              9 :                     DropStmt *n = makeNode(DropStmt);
                               6923                 :                : 
 3827 alvherre@alvh.no-ip.     6924                 :              9 :                     n->objects = list_make1(lcons(makeString($8), $6));
 5042 rhaas@postgresql.org     6925                 :              9 :                     n->removeType = OBJECT_OPFAMILY;
 6801 tgl@sss.pgh.pa.us        6926                 :              9 :                     n->behavior = $9;
                               6927                 :              9 :                     n->missing_ok = true;
 4901 simon@2ndQuadrant.co     6928                 :              9 :                     n->concurrent = false;
 6801 tgl@sss.pgh.pa.us        6929                 :              9 :                     $$ = (Node *) n;
                               6930                 :                :                 }
                               6931                 :                :         ;
                               6932                 :                : 
                               6933                 :                : 
                               6934                 :                : /*****************************************************************************
                               6935                 :                :  *
                               6936                 :                :  *      QUERY:
                               6937                 :                :  *
                               6938                 :                :  *      DROP OWNED BY username [, username ...] [ RESTRICT | CASCADE ]
                               6939                 :                :  *      REASSIGN OWNED BY username [, username ...] TO username
                               6940                 :                :  *
                               6941                 :                :  *****************************************************************************/
                               6942                 :                : DropOwnedStmt:
                               6943                 :                :             DROP OWNED BY role_list opt_drop_behavior
                               6944                 :                :                 {
 7229 alvherre@alvh.no-ip.     6945                 :             77 :                     DropOwnedStmt *n = makeNode(DropOwnedStmt);
                               6946                 :                : 
                               6947                 :             77 :                     n->roles = $4;
                               6948                 :             77 :                     n->behavior = $5;
 1212 peter@eisentraut.org     6949                 :             77 :                     $$ = (Node *) n;
                               6950                 :                :                 }
                               6951                 :                :         ;
                               6952                 :                : 
                               6953                 :                : ReassignOwnedStmt:
                               6954                 :                :             REASSIGN OWNED BY role_list TO RoleSpec
                               6955                 :                :                 {
 7229 alvherre@alvh.no-ip.     6956                 :             26 :                     ReassignOwnedStmt *n = makeNode(ReassignOwnedStmt);
                               6957                 :                : 
                               6958                 :             26 :                     n->roles = $4;
                               6959                 :             26 :                     n->newrole = $6;
 1212 peter@eisentraut.org     6960                 :             26 :                     $$ = (Node *) n;
                               6961                 :                :                 }
                               6962                 :                :         ;
                               6963                 :                : 
                               6964                 :                : /*****************************************************************************
                               6965                 :                :  *
                               6966                 :                :  *      QUERY:
                               6967                 :                :  *
                               6968                 :                :  *      DROP itemtype [ IF EXISTS ] itemname [, itemname ...]
                               6969                 :                :  *           [ RESTRICT | CASCADE ]
                               6970                 :                :  *
                               6971                 :                :  *****************************************************************************/
                               6972                 :                : 
                               6973                 :                : DropStmt:   DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
                               6974                 :                :                 {
 9089 bruce@momjian.us         6975                 :            673 :                     DropStmt *n = makeNode(DropStmt);
                               6976                 :                : 
 9085 tgl@sss.pgh.pa.us        6977                 :            673 :                     n->removeType = $2;
 2943 peter_e@gmx.net          6978                 :            673 :                     n->missing_ok = true;
 7231 andrew@dunslane.net      6979                 :            673 :                     n->objects = $5;
                               6980                 :            673 :                     n->behavior = $6;
 4901 simon@2ndQuadrant.co     6981                 :            673 :                     n->concurrent = false;
 1212 peter@eisentraut.org     6982                 :            673 :                     $$ = (Node *) n;
                               6983                 :                :                 }
                               6984                 :                :             | DROP object_type_any_name any_name_list opt_drop_behavior
                               6985                 :                :                 {
 3220 peter_e@gmx.net          6986                 :           8049 :                     DropStmt *n = makeNode(DropStmt);
                               6987                 :                : 
                               6988                 :           8049 :                     n->removeType = $2;
 2943                          6989                 :           8049 :                     n->missing_ok = false;
 3220                          6990                 :           8049 :                     n->objects = $3;
                               6991                 :           8049 :                     n->behavior = $4;
                               6992                 :           8049 :                     n->concurrent = false;
 1212 peter@eisentraut.org     6993                 :           8049 :                     $$ = (Node *) n;
                               6994                 :                :                 }
                               6995                 :                :             | DROP drop_type_name IF_P EXISTS name_list opt_drop_behavior
                               6996                 :                :                 {
 3220 peter_e@gmx.net          6997                 :             39 :                     DropStmt *n = makeNode(DropStmt);
                               6998                 :                : 
                               6999                 :             39 :                     n->removeType = $2;
 2943                          7000                 :             39 :                     n->missing_ok = true;
 3220                          7001                 :             39 :                     n->objects = $5;
                               7002                 :             39 :                     n->behavior = $6;
                               7003                 :             39 :                     n->concurrent = false;
 1212 peter@eisentraut.org     7004                 :             39 :                     $$ = (Node *) n;
                               7005                 :                :                 }
                               7006                 :                :             | DROP drop_type_name name_list opt_drop_behavior
                               7007                 :                :                 {
 7231 andrew@dunslane.net      7008                 :            688 :                     DropStmt *n = makeNode(DropStmt);
                               7009                 :                : 
                               7010                 :            688 :                     n->removeType = $2;
 2943 peter_e@gmx.net          7011                 :            688 :                     n->missing_ok = false;
 8570 tgl@sss.pgh.pa.us        7012                 :            688 :                     n->objects = $3;
 8572 bruce@momjian.us         7013                 :            688 :                     n->behavior = $4;
 4901 simon@2ndQuadrant.co     7014                 :            688 :                     n->concurrent = false;
 1212 peter@eisentraut.org     7015                 :            688 :                     $$ = (Node *) n;
                               7016                 :                :                 }
                               7017                 :                :             | DROP object_type_name_on_any_name name ON any_name opt_drop_behavior
                               7018                 :                :                 {
 3119 peter_e@gmx.net          7019                 :            564 :                     DropStmt *n = makeNode(DropStmt);
                               7020                 :                : 
                               7021                 :            564 :                     n->removeType = $2;
                               7022                 :            564 :                     n->objects = list_make1(lappend($5, makeString($3)));
                               7023                 :            564 :                     n->behavior = $6;
                               7024                 :            564 :                     n->missing_ok = false;
                               7025                 :            564 :                     n->concurrent = false;
                               7026                 :            564 :                     $$ = (Node *) n;
                               7027                 :                :                 }
                               7028                 :                :             | DROP object_type_name_on_any_name IF_P EXISTS name ON any_name opt_drop_behavior
                               7029                 :                :                 {
                               7030                 :             24 :                     DropStmt *n = makeNode(DropStmt);
                               7031                 :                : 
                               7032                 :             24 :                     n->removeType = $2;
                               7033                 :             24 :                     n->objects = list_make1(lappend($7, makeString($5)));
                               7034                 :             24 :                     n->behavior = $8;
                               7035                 :             24 :                     n->missing_ok = true;
                               7036                 :             24 :                     n->concurrent = false;
                               7037                 :             24 :                     $$ = (Node *) n;
                               7038                 :                :                 }
                               7039                 :                :             | DROP TYPE_P type_name_list opt_drop_behavior
                               7040                 :                :                 {
 3903 alvherre@alvh.no-ip.     7041                 :            280 :                     DropStmt *n = makeNode(DropStmt);
                               7042                 :                : 
                               7043                 :            280 :                     n->removeType = OBJECT_TYPE;
 2943 peter_e@gmx.net          7044                 :            280 :                     n->missing_ok = false;
 3903 alvherre@alvh.no-ip.     7045                 :            280 :                     n->objects = $3;
                               7046                 :            280 :                     n->behavior = $4;
                               7047                 :            280 :                     n->concurrent = false;
                               7048                 :            280 :                     $$ = (Node *) n;
                               7049                 :                :                 }
                               7050                 :                :             | DROP TYPE_P IF_P EXISTS type_name_list opt_drop_behavior
                               7051                 :                :                 {
                               7052                 :             13 :                     DropStmt *n = makeNode(DropStmt);
                               7053                 :                : 
                               7054                 :             13 :                     n->removeType = OBJECT_TYPE;
 2943 peter_e@gmx.net          7055                 :             13 :                     n->missing_ok = true;
 3903 alvherre@alvh.no-ip.     7056                 :             13 :                     n->objects = $5;
                               7057                 :             13 :                     n->behavior = $6;
                               7058                 :             13 :                     n->concurrent = false;
                               7059                 :             13 :                     $$ = (Node *) n;
                               7060                 :                :                 }
                               7061                 :                :             | DROP DOMAIN_P type_name_list opt_drop_behavior
                               7062                 :                :                 {
                               7063                 :            232 :                     DropStmt *n = makeNode(DropStmt);
                               7064                 :                : 
                               7065                 :            232 :                     n->removeType = OBJECT_DOMAIN;
 2943 peter_e@gmx.net          7066                 :            232 :                     n->missing_ok = false;
 3903 alvherre@alvh.no-ip.     7067                 :            232 :                     n->objects = $3;
                               7068                 :            232 :                     n->behavior = $4;
                               7069                 :            232 :                     n->concurrent = false;
                               7070                 :            232 :                     $$ = (Node *) n;
                               7071                 :                :                 }
                               7072                 :                :             | DROP DOMAIN_P IF_P EXISTS type_name_list opt_drop_behavior
                               7073                 :                :                 {
                               7074                 :              9 :                     DropStmt *n = makeNode(DropStmt);
                               7075                 :                : 
                               7076                 :              9 :                     n->removeType = OBJECT_DOMAIN;
 2943 peter_e@gmx.net          7077                 :              9 :                     n->missing_ok = true;
 3903 alvherre@alvh.no-ip.     7078                 :              9 :                     n->objects = $5;
                               7079                 :              9 :                     n->behavior = $6;
                               7080                 :              9 :                     n->concurrent = false;
                               7081                 :              9 :                     $$ = (Node *) n;
                               7082                 :                :                 }
                               7083                 :                :             | DROP INDEX CONCURRENTLY any_name_list opt_drop_behavior
                               7084                 :                :                 {
 4901 simon@2ndQuadrant.co     7085                 :             69 :                     DropStmt *n = makeNode(DropStmt);
                               7086                 :                : 
                               7087                 :             69 :                     n->removeType = OBJECT_INDEX;
 2943 peter_e@gmx.net          7088                 :             69 :                     n->missing_ok = false;
 4901 simon@2ndQuadrant.co     7089                 :             69 :                     n->objects = $4;
                               7090                 :             69 :                     n->behavior = $5;
                               7091                 :             69 :                     n->concurrent = true;
 1212 peter@eisentraut.org     7092                 :             69 :                     $$ = (Node *) n;
                               7093                 :                :                 }
                               7094                 :                :             | DROP INDEX CONCURRENTLY IF_P EXISTS any_name_list opt_drop_behavior
                               7095                 :                :                 {
 4901 simon@2ndQuadrant.co     7096                 :              6 :                     DropStmt *n = makeNode(DropStmt);
                               7097                 :                : 
                               7098                 :              6 :                     n->removeType = OBJECT_INDEX;
 2943 peter_e@gmx.net          7099                 :              6 :                     n->missing_ok = true;
 4901 simon@2ndQuadrant.co     7100                 :              6 :                     n->objects = $6;
                               7101                 :              6 :                     n->behavior = $7;
                               7102                 :              6 :                     n->concurrent = true;
 1212 peter@eisentraut.org     7103                 :              6 :                     $$ = (Node *) n;
                               7104                 :                :                 }
                               7105                 :                :         ;
                               7106                 :                : 
                               7107                 :                : /* object types taking any_name/any_name_list */
                               7108                 :                : object_type_any_name:
 3220 peter_e@gmx.net          7109                 :           7520 :             TABLE                                   { $$ = OBJECT_TABLE; }
 8107                          7110                 :             96 :             | SEQUENCE                              { $$ = OBJECT_SEQUENCE; }
                               7111                 :            520 :             | VIEW                                  { $$ = OBJECT_VIEW; }
 4570 kgrittn@postgresql.o     7112                 :             65 :             | MATERIALIZED VIEW                     { $$ = OBJECT_MATVIEW; }
 8107 peter_e@gmx.net          7113                 :            389 :             | INDEX                                 { $$ = OBJECT_INDEX; }
 5362 rhaas@postgresql.org     7114                 :             93 :             | FOREIGN TABLE                         { $$ = OBJECT_FOREIGN_TABLE; }
 5320 peter_e@gmx.net          7115                 :             48 :             | COLLATION                             { $$ = OBJECT_COLLATION; }
 8107                          7116                 :             28 :             | CONVERSION_P                          { $$ = OBJECT_CONVERSION; }
 3088 alvherre@alvh.no-ip.     7117                 :            105 :             | STATISTICS                            { $$ = OBJECT_STATISTIC_EXT; }
 6591 tgl@sss.pgh.pa.us        7118                 :             10 :             | TEXT_P SEARCH PARSER                  { $$ = OBJECT_TSPARSER; }
                               7119                 :           1407 :             | TEXT_P SEARCH DICTIONARY              { $$ = OBJECT_TSDICTIONARY; }
                               7120                 :             58 :             | TEXT_P SEARCH TEMPLATE                { $$ = OBJECT_TSTEMPLATE; }
                               7121                 :           1409 :             | TEXT_P SEARCH CONFIGURATION           { $$ = OBJECT_TSCONFIGURATION; }
                               7122                 :                :         ;
                               7123                 :                : 
                               7124                 :                : /*
                               7125                 :                :  * object types taking name/name_list
                               7126                 :                :  *
                               7127                 :                :  * DROP handles some of them separately
                               7128                 :                :  */
                               7129                 :                : 
                               7130                 :                : object_type_name:
 1911 peter@eisentraut.org     7131                 :            120 :             drop_type_name                          { $$ = $1; }
                               7132                 :            119 :             | DATABASE                              { $$ = OBJECT_DATABASE; }
                               7133                 :             26 :             | ROLE                                  { $$ = OBJECT_ROLE; }
                               7134                 :              5 :             | SUBSCRIPTION                          { $$ = OBJECT_SUBSCRIPTION; }
 1911 peter@eisentraut.org     7135                 :UBC           0 :             | TABLESPACE                            { $$ = OBJECT_TABLESPACE; }
                               7136                 :                :         ;
                               7137                 :                : 
                               7138                 :                : drop_type_name:
 3220 peter_e@gmx.net          7139                 :CBC          23 :             ACCESS METHOD                           { $$ = OBJECT_ACCESS_METHOD; }
                               7140                 :             65 :             | EVENT TRIGGER                         { $$ = OBJECT_EVENT_TRIGGER; }
                               7141                 :             60 :             | EXTENSION                             { $$ = OBJECT_EXTENSION; }
 3119                          7142                 :             77 :             | FOREIGN DATA_P WRAPPER                { $$ = OBJECT_FDW; }
 1913 peter@eisentraut.org     7143                 :             77 :             | opt_procedural LANGUAGE               { $$ = OBJECT_LANGUAGE; }
 3152 peter_e@gmx.net          7144                 :            196 :             | PUBLICATION                           { $$ = OBJECT_PUBLICATION; }
 3220                          7145                 :            284 :             | SCHEMA                                { $$ = OBJECT_SCHEMA; }
 3119                          7146                 :             65 :             | SERVER                                { $$ = OBJECT_FOREIGN_SERVER; }
                               7147                 :                :         ;
                               7148                 :                : 
                               7149                 :                : /* object types attached to a table */
                               7150                 :                : object_type_name_on_any_name:
                               7151                 :             82 :             POLICY                                  { $$ = OBJECT_POLICY; }
                               7152                 :            134 :             | RULE                                  { $$ = OBJECT_RULE; }
                               7153                 :            398 :             | TRIGGER                               { $$ = OBJECT_TRIGGER; }
                               7154                 :                :         ;
                               7155                 :                : 
                               7156                 :                : any_name_list:
 7769 neilc@samurai.com        7157                 :          13138 :             any_name                                { $$ = list_make1($1); }
 8482 bruce@momjian.us         7158                 :           2093 :             | any_name_list ',' any_name            { $$ = lappend($1, $3); }
                               7159                 :                :         ;
                               7160                 :                : 
 7769 neilc@samurai.com        7161                 :          31762 : any_name:   ColId                       { $$ = list_make1(makeString($1)); }
 7759 tgl@sss.pgh.pa.us        7162                 :           4475 :             | ColId attrs               { $$ = lcons(makeString($1), $2); }
                               7163                 :                :         ;
                               7164                 :                : 
                               7165                 :                : attrs:      '.' attr_name
                               7166                 :          65177 :                     { $$ = list_make1(makeString($2)); }
                               7167                 :                :             | attrs '.' attr_name
 7607                          7168                 :             32 :                     { $$ = lappend($1, makeString($3)); }
                               7169                 :                :         ;
                               7170                 :                : 
                               7171                 :                : type_name_list:
 3220 peter_e@gmx.net          7172                 :            534 :             Typename                                { $$ = list_make1($1); }
                               7173                 :             48 :             | type_name_list ',' Typename           { $$ = lappend($1, $3); }
                               7174                 :                :         ;
                               7175                 :                : 
                               7176                 :                : /*****************************************************************************
                               7177                 :                :  *
                               7178                 :                :  *      QUERY:
                               7179                 :                :  *              truncate table relname1, relname2, ...
                               7180                 :                :  *
                               7181                 :                :  *****************************************************************************/
                               7182                 :                : 
                               7183                 :                : TruncateStmt:
                               7184                 :                :             TRUNCATE opt_table relation_expr_list opt_restart_seqs opt_drop_behavior
                               7185                 :                :                 {
 9480 bruce@momjian.us         7186                 :            849 :                     TruncateStmt *n = makeNode(TruncateStmt);
                               7187                 :                : 
 7527 tgl@sss.pgh.pa.us        7188                 :            849 :                     n->relations = $3;
 6322                          7189                 :            849 :                     n->restart_seqs = $4;
                               7190                 :            849 :                     n->behavior = $5;
 1212 peter@eisentraut.org     7191                 :            849 :                     $$ = (Node *) n;
                               7192                 :                :                 }
                               7193                 :                :         ;
                               7194                 :                : 
                               7195                 :                : opt_restart_seqs:
 6322 tgl@sss.pgh.pa.us        7196                 :             12 :             CONTINUE_P IDENTITY_P       { $$ = false; }
                               7197                 :             12 :             | RESTART IDENTITY_P        { $$ = true; }
                               7198                 :            825 :             | /* EMPTY */               { $$ = false; }
                               7199                 :                :         ;
                               7200                 :                : 
                               7201                 :                : /*****************************************************************************
                               7202                 :                :  *
                               7203                 :                :  * COMMENT ON <object> IS <text>
                               7204                 :                :  *
                               7205                 :                :  *****************************************************************************/
                               7206                 :                : 
                               7207                 :                : CommentStmt:
                               7208                 :                :             COMMENT ON object_type_any_name any_name IS comment_text
                               7209                 :                :                 {
 8482 bruce@momjian.us         7210                 :           2949 :                     CommentStmt *n = makeNode(CommentStmt);
                               7211                 :                : 
                               7212                 :           2949 :                     n->objtype = $3;
 3220 peter_e@gmx.net          7213                 :           2949 :                     n->object = (Node *) $4;
                               7214                 :           2949 :                     n->comment = $6;
                               7215                 :           2949 :                     $$ = (Node *) n;
                               7216                 :                :                 }
                               7217                 :                :             | COMMENT ON COLUMN any_name IS comment_text
                               7218                 :                :                 {
 1911 peter@eisentraut.org     7219                 :             57 :                     CommentStmt *n = makeNode(CommentStmt);
                               7220                 :                : 
                               7221                 :             57 :                     n->objtype = OBJECT_COLUMN;
                               7222                 :             57 :                     n->object = (Node *) $4;
                               7223                 :             57 :                     n->comment = $6;
                               7224                 :             57 :                     $$ = (Node *) n;
                               7225                 :                :                 }
                               7226                 :                :             | COMMENT ON object_type_name name IS comment_text
                               7227                 :                :                 {
 3220 peter_e@gmx.net          7228                 :            239 :                     CommentStmt *n = makeNode(CommentStmt);
                               7229                 :                : 
                               7230                 :            239 :                     n->objtype = $3;
                               7231                 :            239 :                     n->object = (Node *) makeString($4);
 8482 bruce@momjian.us         7232                 :            239 :                     n->comment = $6;
                               7233                 :            239 :                     $$ = (Node *) n;
                               7234                 :                :                 }
                               7235                 :                :             | COMMENT ON TYPE_P Typename IS comment_text
                               7236                 :                :                 {
 3903 alvherre@alvh.no-ip.     7237                 :             28 :                     CommentStmt *n = makeNode(CommentStmt);
                               7238                 :                : 
                               7239                 :             28 :                     n->objtype = OBJECT_TYPE;
 3220 peter_e@gmx.net          7240                 :             28 :                     n->object = (Node *) $4;
 3903 alvherre@alvh.no-ip.     7241                 :             28 :                     n->comment = $6;
                               7242                 :             28 :                     $$ = (Node *) n;
                               7243                 :                :                 }
                               7244                 :                :             | COMMENT ON DOMAIN_P Typename IS comment_text
                               7245                 :                :                 {
                               7246                 :              4 :                     CommentStmt *n = makeNode(CommentStmt);
                               7247                 :                : 
                               7248                 :              4 :                     n->objtype = OBJECT_DOMAIN;
 3220 peter_e@gmx.net          7249                 :              4 :                     n->object = (Node *) $4;
 3903 alvherre@alvh.no-ip.     7250                 :              4 :                     n->comment = $6;
                               7251                 :              4 :                     $$ = (Node *) n;
                               7252                 :                :                 }
                               7253                 :                :             | COMMENT ON AGGREGATE aggregate_with_argtypes IS comment_text
                               7254                 :                :                 {
 8482 bruce@momjian.us         7255                 :             20 :                     CommentStmt *n = makeNode(CommentStmt);
                               7256                 :                : 
 8107 peter_e@gmx.net          7257                 :             20 :                     n->objtype = OBJECT_AGGREGATE;
 3220                          7258                 :             20 :                     n->object = (Node *) $4;
 3278                          7259                 :             20 :                     n->comment = $6;
 8482 bruce@momjian.us         7260                 :             20 :                     $$ = (Node *) n;
                               7261                 :                :                 }
                               7262                 :                :             | COMMENT ON FUNCTION function_with_argtypes IS comment_text
                               7263                 :                :                 {
                               7264                 :             85 :                     CommentStmt *n = makeNode(CommentStmt);
                               7265                 :                : 
 8107 peter_e@gmx.net          7266                 :             85 :                     n->objtype = OBJECT_FUNCTION;
 3220                          7267                 :             85 :                     n->object = (Node *) $4;
 3278                          7268                 :             85 :                     n->comment = $6;
 8482 bruce@momjian.us         7269                 :             85 :                     $$ = (Node *) n;
                               7270                 :                :                 }
                               7271                 :                :             | COMMENT ON OPERATOR operator_with_argtypes IS comment_text
                               7272                 :                :                 {
                               7273                 :              9 :                     CommentStmt *n = makeNode(CommentStmt);
                               7274                 :                : 
 8107 peter_e@gmx.net          7275                 :              9 :                     n->objtype = OBJECT_OPERATOR;
 3220                          7276                 :              9 :                     n->object = (Node *) $4;
 3174                          7277                 :              9 :                     n->comment = $6;
 8482 bruce@momjian.us         7278                 :              9 :                     $$ = (Node *) n;
                               7279                 :                :                 }
                               7280                 :                :             | COMMENT ON CONSTRAINT name ON any_name IS comment_text
                               7281                 :                :                 {
                               7282                 :             75 :                     CommentStmt *n = makeNode(CommentStmt);
                               7283                 :                : 
 3910 alvherre@alvh.no-ip.     7284                 :             75 :                     n->objtype = OBJECT_TABCONSTRAINT;
 3220 peter_e@gmx.net          7285                 :             75 :                     n->object = (Node *) lappend($6, makeString($4));
 8482 bruce@momjian.us         7286                 :             75 :                     n->comment = $8;
                               7287                 :             75 :                     $$ = (Node *) n;
                               7288                 :                :                 }
                               7289                 :                :             | COMMENT ON CONSTRAINT name ON DOMAIN_P any_name IS comment_text
                               7290                 :                :                 {
 3910 alvherre@alvh.no-ip.     7291                 :             24 :                     CommentStmt *n = makeNode(CommentStmt);
                               7292                 :                : 
                               7293                 :             24 :                     n->objtype = OBJECT_DOMCONSTRAINT;
                               7294                 :                :                     /*
                               7295                 :                :                      * should use Typename not any_name in the production, but
                               7296                 :                :                      * there's a shift/reduce conflict if we do that, so fix it
                               7297                 :                :                      * up here.
                               7298                 :                :                      */
 3220 peter_e@gmx.net          7299                 :             24 :                     n->object = (Node *) list_make2(makeTypeNameFromNameList($7), makeString($4));
 3910 alvherre@alvh.no-ip.     7300                 :             24 :                     n->comment = $9;
                               7301                 :             24 :                     $$ = (Node *) n;
                               7302                 :                :                 }
                               7303                 :                :             | COMMENT ON object_type_name_on_any_name name ON any_name IS comment_text
                               7304                 :                :                 {
 3936 sfrost@snowman.net       7305                 :             20 :                     CommentStmt *n = makeNode(CommentStmt);
                               7306                 :                : 
 1911 peter@eisentraut.org     7307                 :             20 :                     n->objtype = $3;
 3220 peter_e@gmx.net          7308                 :             20 :                     n->object = (Node *) lappend($6, makeString($4));
 3936 sfrost@snowman.net       7309                 :             20 :                     n->comment = $8;
                               7310                 :             20 :                     $$ = (Node *) n;
                               7311                 :                :                 }
                               7312                 :                :             | COMMENT ON PROCEDURE function_with_argtypes IS comment_text
                               7313                 :                :                 {
 2837 peter_e@gmx.net          7314                 :UBC           0 :                     CommentStmt *n = makeNode(CommentStmt);
                               7315                 :                : 
                               7316                 :              0 :                     n->objtype = OBJECT_PROCEDURE;
                               7317                 :              0 :                     n->object = (Node *) $4;
                               7318                 :              0 :                     n->comment = $6;
                               7319                 :              0 :                     $$ = (Node *) n;
                               7320                 :                :                 }
                               7321                 :                :             | COMMENT ON ROUTINE function_with_argtypes IS comment_text
                               7322                 :                :                 {
                               7323                 :              0 :                     CommentStmt *n = makeNode(CommentStmt);
                               7324                 :                : 
                               7325                 :              0 :                     n->objtype = OBJECT_ROUTINE;
                               7326                 :              0 :                     n->object = (Node *) $4;
                               7327                 :              0 :                     n->comment = $6;
                               7328                 :              0 :                     $$ = (Node *) n;
                               7329                 :                :                 }
                               7330                 :                :             | COMMENT ON TRANSFORM FOR Typename LANGUAGE name IS comment_text
                               7331                 :                :                 {
 3786 peter_e@gmx.net          7332                 :CBC           7 :                     CommentStmt *n = makeNode(CommentStmt);
                               7333                 :                : 
                               7334                 :              7 :                     n->objtype = OBJECT_TRANSFORM;
 3220                          7335                 :              7 :                     n->object = (Node *) list_make2($5, makeString($7));
 3786                          7336                 :              7 :                     n->comment = $9;
                               7337                 :              7 :                     $$ = (Node *) n;
                               7338                 :                :                 }
                               7339                 :                :             | COMMENT ON OPERATOR CLASS any_name USING name IS comment_text
                               7340                 :                :                 {
 7960 tgl@sss.pgh.pa.us        7341                 :UBC           0 :                     CommentStmt *n = makeNode(CommentStmt);
                               7342                 :                : 
                               7343                 :              0 :                     n->objtype = OBJECT_OPCLASS;
 3220 peter_e@gmx.net          7344                 :              0 :                     n->object = (Node *) lcons(makeString($7), $5);
 7960 tgl@sss.pgh.pa.us        7345                 :              0 :                     n->comment = $9;
                               7346                 :              0 :                     $$ = (Node *) n;
                               7347                 :                :                 }
                               7348                 :                :             | COMMENT ON OPERATOR FAMILY any_name USING name IS comment_text
                               7349                 :                :                 {
 6801                          7350                 :              0 :                     CommentStmt *n = makeNode(CommentStmt);
                               7351                 :                : 
                               7352                 :              0 :                     n->objtype = OBJECT_OPFAMILY;
 3220 peter_e@gmx.net          7353                 :              0 :                     n->object = (Node *) lcons(makeString($7), $5);
 6801 tgl@sss.pgh.pa.us        7354                 :              0 :                     n->comment = $9;
                               7355                 :              0 :                     $$ = (Node *) n;
                               7356                 :                :                 }
                               7357                 :                :             | COMMENT ON LARGE_P OBJECT_P NumericOnly IS comment_text
                               7358                 :                :                 {
 7960 tgl@sss.pgh.pa.us        7359                 :CBC          12 :                     CommentStmt *n = makeNode(CommentStmt);
                               7360                 :                : 
                               7361                 :             12 :                     n->objtype = OBJECT_LARGEOBJECT;
 3220 peter_e@gmx.net          7362                 :             12 :                     n->object = (Node *) $5;
 7960 tgl@sss.pgh.pa.us        7363                 :             12 :                     n->comment = $7;
                               7364                 :             12 :                     $$ = (Node *) n;
                               7365                 :                :                 }
                               7366                 :                :             | COMMENT ON CAST '(' Typename AS Typename ')' IS comment_text
                               7367                 :                :                 {
 7960 tgl@sss.pgh.pa.us        7368                 :UBC           0 :                     CommentStmt *n = makeNode(CommentStmt);
                               7369                 :                : 
                               7370                 :              0 :                     n->objtype = OBJECT_CAST;
 3220 peter_e@gmx.net          7371                 :              0 :                     n->object = (Node *) list_make2($5, $7);
 7960 tgl@sss.pgh.pa.us        7372                 :              0 :                     n->comment = $10;
                               7373                 :              0 :                     $$ = (Node *) n;
                               7374                 :                :                 }
                               7375                 :                :         ;
                               7376                 :                : 
                               7377                 :                : comment_text:
 8455 tgl@sss.pgh.pa.us        7378                 :CBC        3477 :             Sconst                              { $$ = $1; }
                               7379                 :             52 :             | NULL_P                            { $$ = NULL; }
                               7380                 :                :         ;
                               7381                 :                : 
                               7382                 :                : 
                               7383                 :                : /*****************************************************************************
                               7384                 :                :  *
                               7385                 :                :  *  SECURITY LABEL [FOR <provider>] ON <object> IS <label>
                               7386                 :                :  *
                               7387                 :                :  *  As with COMMENT ON, <object> can refer to various types of database
                               7388                 :                :  *  objects (e.g. TABLE, COLUMN, etc.).
                               7389                 :                :  *
                               7390                 :                :  *****************************************************************************/
                               7391                 :                : 
                               7392                 :                : SecLabelStmt:
                               7393                 :                :             SECURITY LABEL opt_provider ON object_type_any_name any_name
                               7394                 :                :             IS security_label
                               7395                 :                :                 {
 5458 rhaas@postgresql.org     7396                 :             24 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7397                 :                : 
                               7398                 :             24 :                     n->provider = $3;
                               7399                 :             24 :                     n->objtype = $5;
 3220 peter_e@gmx.net          7400                 :             24 :                     n->object = (Node *) $6;
                               7401                 :             24 :                     n->label = $8;
                               7402                 :             24 :                     $$ = (Node *) n;
                               7403                 :                :                 }
                               7404                 :                :             | SECURITY LABEL opt_provider ON COLUMN any_name
                               7405                 :                :               IS security_label
                               7406                 :                :                 {
 1911 peter@eisentraut.org     7407                 :              2 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7408                 :                : 
                               7409                 :              2 :                     n->provider = $3;
                               7410                 :              2 :                     n->objtype = OBJECT_COLUMN;
                               7411                 :              2 :                     n->object = (Node *) $6;
                               7412                 :              2 :                     n->label = $8;
                               7413                 :              2 :                     $$ = (Node *) n;
                               7414                 :                :                 }
                               7415                 :                :             | SECURITY LABEL opt_provider ON object_type_name name
                               7416                 :                :               IS security_label
                               7417                 :                :                 {
 3220 peter_e@gmx.net          7418                 :             22 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7419                 :                : 
                               7420                 :             22 :                     n->provider = $3;
                               7421                 :             22 :                     n->objtype = $5;
                               7422                 :             22 :                     n->object = (Node *) makeString($6);
 5458 rhaas@postgresql.org     7423                 :             22 :                     n->label = $8;
                               7424                 :             22 :                     $$ = (Node *) n;
                               7425                 :                :                 }
                               7426                 :                :             | SECURITY LABEL opt_provider ON TYPE_P Typename
                               7427                 :                :               IS security_label
                               7428                 :                :                 {
 3903 alvherre@alvh.no-ip.     7429                 :UBC           0 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7430                 :                : 
                               7431                 :              0 :                     n->provider = $3;
                               7432                 :              0 :                     n->objtype = OBJECT_TYPE;
 3220 peter_e@gmx.net          7433                 :              0 :                     n->object = (Node *) $6;
 3903 alvherre@alvh.no-ip.     7434                 :              0 :                     n->label = $8;
                               7435                 :              0 :                     $$ = (Node *) n;
                               7436                 :                :                 }
                               7437                 :                :             | SECURITY LABEL opt_provider ON DOMAIN_P Typename
                               7438                 :                :               IS security_label
                               7439                 :                :                 {
 3903 alvherre@alvh.no-ip.     7440                 :CBC           1 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7441                 :                : 
                               7442                 :              1 :                     n->provider = $3;
 2957 peter_e@gmx.net          7443                 :              1 :                     n->objtype = OBJECT_DOMAIN;
 3220                          7444                 :              1 :                     n->object = (Node *) $6;
 3903 alvherre@alvh.no-ip.     7445                 :              1 :                     n->label = $8;
                               7446                 :              1 :                     $$ = (Node *) n;
                               7447                 :                :                 }
                               7448                 :                :             | SECURITY LABEL opt_provider ON AGGREGATE aggregate_with_argtypes
                               7449                 :                :               IS security_label
                               7450                 :                :                 {
 5458 rhaas@postgresql.org     7451                 :UBC           0 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7452                 :                : 
                               7453                 :              0 :                     n->provider = $3;
                               7454                 :              0 :                     n->objtype = OBJECT_AGGREGATE;
 3220 peter_e@gmx.net          7455                 :              0 :                     n->object = (Node *) $6;
 3278                          7456                 :              0 :                     n->label = $8;
 5458 rhaas@postgresql.org     7457                 :              0 :                     $$ = (Node *) n;
                               7458                 :                :                 }
                               7459                 :                :             | SECURITY LABEL opt_provider ON FUNCTION function_with_argtypes
                               7460                 :                :               IS security_label
                               7461                 :                :                 {
 5458 rhaas@postgresql.org     7462                 :CBC           1 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7463                 :                : 
                               7464                 :              1 :                     n->provider = $3;
                               7465                 :              1 :                     n->objtype = OBJECT_FUNCTION;
 3220 peter_e@gmx.net          7466                 :              1 :                     n->object = (Node *) $6;
 3278                          7467                 :              1 :                     n->label = $8;
 5458 rhaas@postgresql.org     7468                 :              1 :                     $$ = (Node *) n;
                               7469                 :                :                 }
                               7470                 :                :             | SECURITY LABEL opt_provider ON LARGE_P OBJECT_P NumericOnly
                               7471                 :                :               IS security_label
                               7472                 :                :                 {
 5458 rhaas@postgresql.org     7473                 :UBC           0 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7474                 :                : 
                               7475                 :              0 :                     n->provider = $3;
                               7476                 :              0 :                     n->objtype = OBJECT_LARGEOBJECT;
 3220 peter_e@gmx.net          7477                 :              0 :                     n->object = (Node *) $7;
 5458 rhaas@postgresql.org     7478                 :              0 :                     n->label = $9;
                               7479                 :              0 :                     $$ = (Node *) n;
                               7480                 :                :                 }
                               7481                 :                :             | SECURITY LABEL opt_provider ON PROCEDURE function_with_argtypes
                               7482                 :                :               IS security_label
                               7483                 :                :                 {
 2837 peter_e@gmx.net          7484                 :              0 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7485                 :                : 
                               7486                 :              0 :                     n->provider = $3;
                               7487                 :              0 :                     n->objtype = OBJECT_PROCEDURE;
                               7488                 :              0 :                     n->object = (Node *) $6;
                               7489                 :              0 :                     n->label = $8;
                               7490                 :              0 :                     $$ = (Node *) n;
                               7491                 :                :                 }
                               7492                 :                :             | SECURITY LABEL opt_provider ON ROUTINE function_with_argtypes
                               7493                 :                :               IS security_label
                               7494                 :                :                 {
                               7495                 :              0 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7496                 :                : 
                               7497                 :              0 :                     n->provider = $3;
                               7498                 :              0 :                     n->objtype = OBJECT_ROUTINE;
                               7499                 :              0 :                     n->object = (Node *) $6;
                               7500                 :              0 :                     n->label = $8;
                               7501                 :              0 :                     $$ = (Node *) n;
                               7502                 :                :                 }
                               7503                 :                :         ;
                               7504                 :                : 
 4479 tgl@sss.pgh.pa.us        7505                 :CBC          10 : opt_provider:   FOR NonReservedWord_or_Sconst   { $$ = $2; }
 1755 peter@eisentraut.org     7506                 :             40 :                 | /* EMPTY */                   { $$ = NULL; }
                               7507                 :                :         ;
                               7508                 :                : 
 5458 rhaas@postgresql.org     7509                 :             50 : security_label: Sconst              { $$ = $1; }
 5458 rhaas@postgresql.org     7510                 :UBC           0 :                 | NULL_P            { $$ = NULL; }
                               7511                 :                :         ;
                               7512                 :                : 
                               7513                 :                : /*****************************************************************************
                               7514                 :                :  *
                               7515                 :                :  *      QUERY:
                               7516                 :                :  *          fetch/move
                               7517                 :                :  *
                               7518                 :                :  *****************************************************************************/
                               7519                 :                : 
                               7520                 :                : FetchStmt:  FETCH fetch_args
                               7521                 :                :                 {
 8215 tgl@sss.pgh.pa.us        7522                 :CBC        3696 :                     FetchStmt *n = (FetchStmt *) $2;
                               7523                 :                : 
 2943 peter_e@gmx.net          7524                 :           3696 :                     n->ismove = false;
 1212 peter@eisentraut.org     7525                 :           3696 :                     $$ = (Node *) n;
                               7526                 :                :                 }
                               7527                 :                :             | MOVE fetch_args
                               7528                 :                :                 {
 8215 tgl@sss.pgh.pa.us        7529                 :             29 :                     FetchStmt *n = (FetchStmt *) $2;
                               7530                 :                : 
 2943 peter_e@gmx.net          7531                 :             29 :                     n->ismove = true;
 1212 peter@eisentraut.org     7532                 :             29 :                     $$ = (Node *) n;
                               7533                 :                :                 }
                               7534                 :                :         ;
                               7535                 :                : 
                               7536                 :                : fetch_args: cursor_name
                               7537                 :                :                 {
 9363 bruce@momjian.us         7538                 :             83 :                     FetchStmt *n = makeNode(FetchStmt);
                               7539                 :                : 
 5778 alvherre@alvh.no-ip.     7540                 :             83 :                     n->portalname = $1;
 8244 tgl@sss.pgh.pa.us        7541                 :             83 :                     n->direction = FETCH_FORWARD;
 9363 bruce@momjian.us         7542                 :             83 :                     n->howMany = 1;
   66 michael@paquier.xyz      7543                 :GNC          83 :                     n->location = -1;
                               7544                 :             83 :                     n->direction_keyword = FETCH_KEYWORD_NONE;
 1212 peter@eisentraut.org     7545                 :CBC          83 :                     $$ = (Node *) n;
                               7546                 :                :                 }
                               7547                 :                :             | from_in cursor_name
                               7548                 :                :                 {
 9363 bruce@momjian.us         7549                 :             78 :                     FetchStmt *n = makeNode(FetchStmt);
                               7550                 :                : 
 5778 alvherre@alvh.no-ip.     7551                 :             78 :                     n->portalname = $2;
 8244 tgl@sss.pgh.pa.us        7552                 :             78 :                     n->direction = FETCH_FORWARD;
 9363 bruce@momjian.us         7553                 :             78 :                     n->howMany = 1;
   66 michael@paquier.xyz      7554                 :GNC          78 :                     n->location = -1;
                               7555                 :             78 :                     n->direction_keyword = FETCH_KEYWORD_NONE;
                               7556                 :             78 :                     $$ = (Node *) n;
                               7557                 :                :                 }
                               7558                 :                :             | SignedIconst opt_from_in cursor_name
                               7559                 :                :                 {
                               7560                 :           2106 :                     FetchStmt *n = makeNode(FetchStmt);
                               7561                 :                : 
                               7562                 :           2106 :                     n->portalname = $3;
                               7563                 :           2106 :                     n->direction = FETCH_FORWARD;
                               7564                 :           2106 :                     n->howMany = $1;
                               7565                 :           2106 :                     n->location = @1;
                               7566                 :           2106 :                     n->direction_keyword = FETCH_KEYWORD_NONE;
 1212 peter@eisentraut.org     7567                 :CBC        2106 :                     $$ = (Node *) n;
                               7568                 :                :                 }
                               7569                 :                :             | NEXT opt_from_in cursor_name
                               7570                 :                :                 {
10204 vadim4o@yahoo.com        7571                 :           1002 :                     FetchStmt *n = makeNode(FetchStmt);
                               7572                 :                : 
 5778 alvherre@alvh.no-ip.     7573                 :           1002 :                     n->portalname = $3;
 8215 tgl@sss.pgh.pa.us        7574                 :           1002 :                     n->direction = FETCH_FORWARD;
                               7575                 :           1002 :                     n->howMany = 1;
   66 michael@paquier.xyz      7576                 :GNC        1002 :                     n->location = -1;
                               7577                 :           1002 :                     n->direction_keyword = FETCH_KEYWORD_NEXT;
 1212 peter@eisentraut.org     7578                 :CBC        1002 :                     $$ = (Node *) n;
                               7579                 :                :                 }
                               7580                 :                :             | PRIOR opt_from_in cursor_name
                               7581                 :                :                 {
 9363 bruce@momjian.us         7582                 :             16 :                     FetchStmt *n = makeNode(FetchStmt);
                               7583                 :                : 
 5778 alvherre@alvh.no-ip.     7584                 :             16 :                     n->portalname = $3;
 8215 tgl@sss.pgh.pa.us        7585                 :             16 :                     n->direction = FETCH_BACKWARD;
                               7586                 :             16 :                     n->howMany = 1;
   66 michael@paquier.xyz      7587                 :GNC          16 :                     n->location = -1;
                               7588                 :             16 :                     n->direction_keyword = FETCH_KEYWORD_PRIOR;
 1212 peter@eisentraut.org     7589                 :CBC          16 :                     $$ = (Node *) n;
                               7590                 :                :                 }
                               7591                 :                :             | FIRST_P opt_from_in cursor_name
                               7592                 :                :                 {
 9363 bruce@momjian.us         7593                 :             13 :                     FetchStmt *n = makeNode(FetchStmt);
                               7594                 :                : 
 5778 alvherre@alvh.no-ip.     7595                 :             13 :                     n->portalname = $3;
 8215 tgl@sss.pgh.pa.us        7596                 :             13 :                     n->direction = FETCH_ABSOLUTE;
 9363 bruce@momjian.us         7597                 :             13 :                     n->howMany = 1;
   66 michael@paquier.xyz      7598                 :GNC          13 :                     n->location = -1;
                               7599                 :             13 :                     n->direction_keyword = FETCH_KEYWORD_FIRST;
 1212 peter@eisentraut.org     7600                 :CBC          13 :                     $$ = (Node *) n;
                               7601                 :                :                 }
                               7602                 :                :             | LAST_P opt_from_in cursor_name
                               7603                 :                :                 {
 8215 tgl@sss.pgh.pa.us        7604                 :             10 :                     FetchStmt *n = makeNode(FetchStmt);
                               7605                 :                : 
 5778 alvherre@alvh.no-ip.     7606                 :             10 :                     n->portalname = $3;
 8215 tgl@sss.pgh.pa.us        7607                 :             10 :                     n->direction = FETCH_ABSOLUTE;
                               7608                 :             10 :                     n->howMany = -1;
   66 michael@paquier.xyz      7609                 :GNC          10 :                     n->location = -1;
                               7610                 :             10 :                     n->direction_keyword = FETCH_KEYWORD_LAST;
 1212 peter@eisentraut.org     7611                 :CBC          10 :                     $$ = (Node *) n;
                               7612                 :                :                 }
                               7613                 :                :             | ABSOLUTE_P SignedIconst opt_from_in cursor_name
                               7614                 :                :                 {
 8215 tgl@sss.pgh.pa.us        7615                 :             43 :                     FetchStmt *n = makeNode(FetchStmt);
                               7616                 :                : 
 5778 alvherre@alvh.no-ip.     7617                 :             43 :                     n->portalname = $4;
 8215 tgl@sss.pgh.pa.us        7618                 :             43 :                     n->direction = FETCH_ABSOLUTE;
                               7619                 :             43 :                     n->howMany = $2;
   66 michael@paquier.xyz      7620                 :GNC          43 :                     n->location = @2;
                               7621                 :             43 :                     n->direction_keyword = FETCH_KEYWORD_ABSOLUTE;
 1212 peter@eisentraut.org     7622                 :CBC          43 :                     $$ = (Node *) n;
                               7623                 :                :                 }
                               7624                 :                :             | RELATIVE_P SignedIconst opt_from_in cursor_name
                               7625                 :                :                 {
 8215 tgl@sss.pgh.pa.us        7626                 :             18 :                     FetchStmt *n = makeNode(FetchStmt);
                               7627                 :                : 
 5778 alvherre@alvh.no-ip.     7628                 :             18 :                     n->portalname = $4;
 8215 tgl@sss.pgh.pa.us        7629                 :             18 :                     n->direction = FETCH_RELATIVE;
                               7630                 :             18 :                     n->howMany = $2;
   66 michael@paquier.xyz      7631                 :GNC          18 :                     n->location = @2;
                               7632                 :             18 :                     n->direction_keyword = FETCH_KEYWORD_RELATIVE;
 1212 peter@eisentraut.org     7633                 :CBC          18 :                     $$ = (Node *) n;
                               7634                 :                :                 }
                               7635                 :                :             | ALL opt_from_in cursor_name
                               7636                 :                :                 {
 8215 tgl@sss.pgh.pa.us        7637                 :            134 :                     FetchStmt *n = makeNode(FetchStmt);
                               7638                 :                : 
 5778 alvherre@alvh.no-ip.     7639                 :            134 :                     n->portalname = $3;
 8215 tgl@sss.pgh.pa.us        7640                 :            134 :                     n->direction = FETCH_FORWARD;
                               7641                 :            134 :                     n->howMany = FETCH_ALL;
   66 michael@paquier.xyz      7642                 :GNC         134 :                     n->location = -1;
                               7643                 :            134 :                     n->direction_keyword = FETCH_KEYWORD_ALL;
 1212 peter@eisentraut.org     7644                 :CBC         134 :                     $$ = (Node *) n;
                               7645                 :                :                 }
                               7646                 :                :             | FORWARD opt_from_in cursor_name
                               7647                 :                :                 {
 9363 bruce@momjian.us         7648                 :             10 :                     FetchStmt *n = makeNode(FetchStmt);
                               7649                 :                : 
 5778 alvherre@alvh.no-ip.     7650                 :             10 :                     n->portalname = $3;
 8244 tgl@sss.pgh.pa.us        7651                 :             10 :                     n->direction = FETCH_FORWARD;
 9363 bruce@momjian.us         7652                 :             10 :                     n->howMany = 1;
   66 michael@paquier.xyz      7653                 :GNC          10 :                     n->location = -1;
                               7654                 :             10 :                     n->direction_keyword = FETCH_KEYWORD_FORWARD;
 1212 peter@eisentraut.org     7655                 :CBC          10 :                     $$ = (Node *) n;
                               7656                 :                :                 }
                               7657                 :                :             | FORWARD SignedIconst opt_from_in cursor_name
                               7658                 :                :                 {
 9363 bruce@momjian.us         7659                 :              6 :                     FetchStmt *n = makeNode(FetchStmt);
                               7660                 :                : 
 5778 alvherre@alvh.no-ip.     7661                 :              6 :                     n->portalname = $4;
 8244 tgl@sss.pgh.pa.us        7662                 :              6 :                     n->direction = FETCH_FORWARD;
 8215                          7663                 :              6 :                     n->howMany = $2;
   66 michael@paquier.xyz      7664                 :GNC           6 :                     n->location = @2;
                               7665                 :              6 :                     n->direction_keyword = FETCH_KEYWORD_FORWARD;
 1212 peter@eisentraut.org     7666                 :CBC           6 :                     $$ = (Node *) n;
                               7667                 :                :                 }
                               7668                 :                :             | FORWARD ALL opt_from_in cursor_name
                               7669                 :                :                 {
 8215 tgl@sss.pgh.pa.us        7670                 :              8 :                     FetchStmt *n = makeNode(FetchStmt);
                               7671                 :                : 
 5778 alvherre@alvh.no-ip.     7672                 :              8 :                     n->portalname = $4;
 8215 tgl@sss.pgh.pa.us        7673                 :              8 :                     n->direction = FETCH_FORWARD;
                               7674                 :              8 :                     n->howMany = FETCH_ALL;
   66 michael@paquier.xyz      7675                 :GNC           8 :                     n->location = -1;
                               7676                 :              8 :                     n->direction_keyword = FETCH_KEYWORD_FORWARD_ALL;
 1212 peter@eisentraut.org     7677                 :CBC           8 :                     $$ = (Node *) n;
                               7678                 :                :                 }
                               7679                 :                :             | BACKWARD opt_from_in cursor_name
                               7680                 :                :                 {
 8215 tgl@sss.pgh.pa.us        7681                 :             40 :                     FetchStmt *n = makeNode(FetchStmt);
                               7682                 :                : 
 5778 alvherre@alvh.no-ip.     7683                 :             40 :                     n->portalname = $3;
 8215 tgl@sss.pgh.pa.us        7684                 :             40 :                     n->direction = FETCH_BACKWARD;
 9363 bruce@momjian.us         7685                 :             40 :                     n->howMany = 1;
   66 michael@paquier.xyz      7686                 :GNC          40 :                     n->location = -1;
                               7687                 :             40 :                     n->direction_keyword = FETCH_KEYWORD_BACKWARD;
 1212 peter@eisentraut.org     7688                 :CBC          40 :                     $$ = (Node *) n;
                               7689                 :                :                 }
                               7690                 :                :             | BACKWARD SignedIconst opt_from_in cursor_name
                               7691                 :                :                 {
 8215 tgl@sss.pgh.pa.us        7692                 :            112 :                     FetchStmt *n = makeNode(FetchStmt);
                               7693                 :                : 
 5778 alvherre@alvh.no-ip.     7694                 :            112 :                     n->portalname = $4;
 8215 tgl@sss.pgh.pa.us        7695                 :            112 :                     n->direction = FETCH_BACKWARD;
                               7696                 :            112 :                     n->howMany = $2;
   66 michael@paquier.xyz      7697                 :GNC         112 :                     n->location = @2;
                               7698                 :            112 :                     n->direction_keyword = FETCH_KEYWORD_BACKWARD;
 1212 peter@eisentraut.org     7699                 :CBC         112 :                     $$ = (Node *) n;
                               7700                 :                :                 }
                               7701                 :                :             | BACKWARD ALL opt_from_in cursor_name
                               7702                 :                :                 {
 8215 tgl@sss.pgh.pa.us        7703                 :             46 :                     FetchStmt *n = makeNode(FetchStmt);
                               7704                 :                : 
 5778 alvherre@alvh.no-ip.     7705                 :             46 :                     n->portalname = $4;
 8215 tgl@sss.pgh.pa.us        7706                 :             46 :                     n->direction = FETCH_BACKWARD;
                               7707                 :             46 :                     n->howMany = FETCH_ALL;
   66 michael@paquier.xyz      7708                 :GNC          46 :                     n->location = -1;
                               7709                 :             46 :                     n->direction_keyword = FETCH_KEYWORD_BACKWARD_ALL;
 1212 peter@eisentraut.org     7710                 :CBC          46 :                     $$ = (Node *) n;
                               7711                 :                :                 }
                               7712                 :                :         ;
                               7713                 :                : 
                               7714                 :                : from_in:    FROM
                               7715                 :                :             | IN_P
                               7716                 :                :         ;
                               7717                 :                : 
                               7718                 :                : opt_from_in:    from_in
                               7719                 :                :             | /* EMPTY */
                               7720                 :                :         ;
                               7721                 :                : 
                               7722                 :                : 
                               7723                 :                : /*****************************************************************************
                               7724                 :                :  *
                               7725                 :                :  * GRANT and REVOKE statements
                               7726                 :                :  *
                               7727                 :                :  *****************************************************************************/
                               7728                 :                : 
                               7729                 :                : GrantStmt:  GRANT privileges ON privilege_target TO grantee_list
                               7730                 :                :             opt_grant_grant_option opt_granted_by
                               7731                 :                :                 {
 8855 peter_e@gmx.net          7732                 :           5869 :                     GrantStmt *n = makeNode(GrantStmt);
                               7733                 :                : 
                               7734                 :           5869 :                     n->is_grant = true;
                               7735                 :           5869 :                     n->privileges = $2;
 5808 tgl@sss.pgh.pa.us        7736                 :           5869 :                     n->targtype = ($4)->targtype;
 8601 peter_e@gmx.net          7737                 :           5869 :                     n->objtype = ($4)->objtype;
                               7738                 :           5869 :                     n->objects = ($4)->objs;
                               7739                 :           5869 :                     n->grantees = $6;
 8262                          7740                 :           5869 :                     n->grant_option = $7;
 1680 peter@eisentraut.org     7741                 :           5869 :                     n->grantor = $8;
 1212                          7742                 :           5869 :                     $$ = (Node *) n;
                               7743                 :                :                 }
                               7744                 :                :         ;
                               7745                 :                : 
                               7746                 :                : RevokeStmt:
                               7747                 :                :             REVOKE privileges ON privilege_target
                               7748                 :                :             FROM grantee_list opt_granted_by opt_drop_behavior
                               7749                 :                :                 {
 8601 peter_e@gmx.net          7750                 :           5212 :                     GrantStmt *n = makeNode(GrantStmt);
                               7751                 :                : 
                               7752                 :           5212 :                     n->is_grant = false;
 7375 tgl@sss.pgh.pa.us        7753                 :           5212 :                     n->grant_option = false;
                               7754                 :           5212 :                     n->privileges = $2;
 5808                          7755                 :           5212 :                     n->targtype = ($4)->targtype;
 7375                          7756                 :           5212 :                     n->objtype = ($4)->objtype;
                               7757                 :           5212 :                     n->objects = ($4)->objs;
                               7758                 :           5212 :                     n->grantees = $6;
 1680 peter@eisentraut.org     7759                 :           5212 :                     n->grantor = $7;
                               7760                 :           5212 :                     n->behavior = $8;
 1212                          7761                 :           5212 :                     $$ = (Node *) n;
                               7762                 :                :                 }
                               7763                 :                :             | REVOKE GRANT OPTION FOR privileges ON privilege_target
                               7764                 :                :             FROM grantee_list opt_granted_by opt_drop_behavior
                               7765                 :                :                 {
 7375 tgl@sss.pgh.pa.us        7766                 :              8 :                     GrantStmt *n = makeNode(GrantStmt);
                               7767                 :                : 
                               7768                 :              8 :                     n->is_grant = false;
                               7769                 :              8 :                     n->grant_option = true;
                               7770                 :              8 :                     n->privileges = $5;
 5808                          7771                 :              8 :                     n->targtype = ($7)->targtype;
 7375                          7772                 :              8 :                     n->objtype = ($7)->objtype;
                               7773                 :              8 :                     n->objects = ($7)->objs;
                               7774                 :              8 :                     n->grantees = $9;
 1680 peter@eisentraut.org     7775                 :              8 :                     n->grantor = $10;
                               7776                 :              8 :                     n->behavior = $11;
 1212                          7777                 :              8 :                     $$ = (Node *) n;
                               7778                 :                :                 }
                               7779                 :                :         ;
                               7780                 :                : 
                               7781                 :                : 
                               7782                 :                : /*
                               7783                 :                :  * Privilege names are represented as strings; the validity of the privilege
                               7784                 :                :  * names gets checked at execution.  This is a bit annoying but we have little
                               7785                 :                :  * choice because of the syntactic conflict with lists of role names in
                               7786                 :                :  * GRANT/REVOKE.  What's more, we have to call out in the "privilege"
                               7787                 :                :  * production any reserved keywords that need to be usable as privilege names.
                               7788                 :                :  */
                               7789                 :                : 
                               7790                 :                : /* either ALL [PRIVILEGES] or a list of individual privileges */
                               7791                 :                : privileges: privilege_list
 7375 tgl@sss.pgh.pa.us        7792                 :           9784 :                 { $$ = $1; }
                               7793                 :                :             | ALL
                               7794                 :           1345 :                 { $$ = NIL; }
                               7795                 :                :             | ALL PRIVILEGES
                               7796                 :             60 :                 { $$ = NIL; }
                               7797                 :                :             | ALL '(' columnList ')'
                               7798                 :                :                 {
 6071                          7799                 :              9 :                     AccessPriv *n = makeNode(AccessPriv);
                               7800                 :                : 
                               7801                 :              9 :                     n->priv_name = NULL;
                               7802                 :              9 :                     n->cols = $3;
                               7803                 :              9 :                     $$ = list_make1(n);
                               7804                 :                :                 }
                               7805                 :                :             | ALL PRIVILEGES '(' columnList ')'
                               7806                 :                :                 {
 6071 tgl@sss.pgh.pa.us        7807                 :UBC           0 :                     AccessPriv *n = makeNode(AccessPriv);
                               7808                 :                : 
                               7809                 :              0 :                     n->priv_name = NULL;
                               7810                 :              0 :                     n->cols = $4;
                               7811                 :              0 :                     $$ = list_make1(n);
                               7812                 :                :                 }
                               7813                 :                :         ;
                               7814                 :                : 
 6071 tgl@sss.pgh.pa.us        7815                 :CBC       10243 : privilege_list: privilege                           { $$ = list_make1($1); }
                               7816                 :            275 :             | privilege_list ',' privilege          { $$ = lappend($1, $3); }
                               7817                 :                :         ;
                               7818                 :                : 
                               7819                 :                : privilege:  SELECT opt_column_list
                               7820                 :                :             {
                               7821                 :           4758 :                 AccessPriv *n = makeNode(AccessPriv);
                               7822                 :                : 
                               7823                 :           4758 :                 n->priv_name = pstrdup($1);
                               7824                 :           4758 :                 n->cols = $2;
                               7825                 :           4758 :                 $$ = n;
                               7826                 :                :             }
                               7827                 :                :         | REFERENCES opt_column_list
                               7828                 :                :             {
                               7829                 :              7 :                 AccessPriv *n = makeNode(AccessPriv);
                               7830                 :                : 
                               7831                 :              7 :                 n->priv_name = pstrdup($1);
                               7832                 :              7 :                 n->cols = $2;
                               7833                 :              7 :                 $$ = n;
                               7834                 :                :             }
                               7835                 :                :         | CREATE opt_column_list
                               7836                 :                :             {
                               7837                 :            145 :                 AccessPriv *n = makeNode(AccessPriv);
                               7838                 :                : 
                               7839                 :            145 :                 n->priv_name = pstrdup($1);
                               7840                 :            145 :                 n->cols = $2;
                               7841                 :            145 :                 $$ = n;
                               7842                 :                :             }
                               7843                 :                :         | ALTER SYSTEM_P
                               7844                 :                :             {
 1249                          7845                 :             12 :                 AccessPriv *n = makeNode(AccessPriv);
                               7846                 :             12 :                 n->priv_name = pstrdup("alter system");
                               7847                 :             12 :                 n->cols = NIL;
                               7848                 :             12 :                 $$ = n;
                               7849                 :                :             }
                               7850                 :                :         | ColId opt_column_list
                               7851                 :                :             {
 6071                          7852                 :           5596 :                 AccessPriv *n = makeNode(AccessPriv);
                               7853                 :                : 
                               7854                 :           5596 :                 n->priv_name = $1;
                               7855                 :           5596 :                 n->cols = $2;
                               7856                 :           5596 :                 $$ = n;
                               7857                 :                :             }
                               7858                 :                :         ;
                               7859                 :                : 
                               7860                 :                : parameter_name_list:
                               7861                 :                :         parameter_name
                               7862                 :                :             {
 1249                          7863                 :             38 :                 $$ = list_make1(makeString($1));
                               7864                 :                :             }
                               7865                 :                :         | parameter_name_list ',' parameter_name
                               7866                 :                :             {
                               7867                 :             25 :                 $$ = lappend($1, makeString($3));
                               7868                 :                :             }
                               7869                 :                :         ;
                               7870                 :                : 
                               7871                 :                : parameter_name:
                               7872                 :                :         ColId
                               7873                 :                :             {
                               7874                 :             63 :                 $$ = $1;
                               7875                 :                :             }
                               7876                 :                :         | parameter_name '.' ColId
                               7877                 :                :             {
                               7878                 :             16 :                 $$ = psprintf("%s.%s", $1, $3);
                               7879                 :                :             }
                               7880                 :                :         ;
                               7881                 :                : 
                               7882                 :                : 
                               7883                 :                : /* Don't bother trying to fold the first two rules into one using
                               7884                 :                :  * opt_table.  You're going to get conflicts.
                               7885                 :                :  */
                               7886                 :                : privilege_target:
                               7887                 :                :             qualified_name_list
                               7888                 :                :                 {
 6071                          7889                 :           5791 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7890                 :                : 
 5808                          7891                 :           5791 :                     n->targtype = ACL_TARGET_OBJECT;
 2887 peter_e@gmx.net          7892                 :           5791 :                     n->objtype = OBJECT_TABLE;
 8601                          7893                 :           5791 :                     n->objs = $1;
                               7894                 :           5791 :                     $$ = n;
                               7895                 :                :                 }
                               7896                 :                :             | TABLE qualified_name_list
                               7897                 :                :                 {
 6071 tgl@sss.pgh.pa.us        7898                 :            181 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7899                 :                : 
 5808                          7900                 :            181 :                     n->targtype = ACL_TARGET_OBJECT;
 2887 peter_e@gmx.net          7901                 :            181 :                     n->objtype = OBJECT_TABLE;
 8601                          7902                 :            181 :                     n->objs = $2;
                               7903                 :            181 :                     $$ = n;
                               7904                 :                :                 }
                               7905                 :                :             | SEQUENCE qualified_name_list
                               7906                 :                :                 {
 6071 tgl@sss.pgh.pa.us        7907                 :             11 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7908                 :                : 
 5808                          7909                 :             11 :                     n->targtype = ACL_TARGET_OBJECT;
 2887 peter_e@gmx.net          7910                 :             11 :                     n->objtype = OBJECT_SEQUENCE;
 7168 bruce@momjian.us         7911                 :             11 :                     n->objs = $2;
                               7912                 :             11 :                     $$ = n;
                               7913                 :                :                 }
                               7914                 :                :             | FOREIGN DATA_P WRAPPER name_list
                               7915                 :                :                 {
 6071 tgl@sss.pgh.pa.us        7916                 :             46 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7917                 :                : 
 5808                          7918                 :             46 :                     n->targtype = ACL_TARGET_OBJECT;
 2887 peter_e@gmx.net          7919                 :             46 :                     n->objtype = OBJECT_FDW;
 6105                          7920                 :             46 :                     n->objs = $4;
                               7921                 :             46 :                     $$ = n;
                               7922                 :                :                 }
                               7923                 :                :             | FOREIGN SERVER name_list
                               7924                 :                :                 {
 6071 tgl@sss.pgh.pa.us        7925                 :             45 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7926                 :                : 
 5808                          7927                 :             45 :                     n->targtype = ACL_TARGET_OBJECT;
 2887 peter_e@gmx.net          7928                 :             45 :                     n->objtype = OBJECT_FOREIGN_SERVER;
 6105                          7929                 :             45 :                     n->objs = $3;
                               7930                 :             45 :                     $$ = n;
                               7931                 :                :                 }
                               7932                 :                :             | FUNCTION function_with_argtypes_list
                               7933                 :                :                 {
 6071 tgl@sss.pgh.pa.us        7934                 :           4464 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7935                 :                : 
 5808                          7936                 :           4464 :                     n->targtype = ACL_TARGET_OBJECT;
 2887 peter_e@gmx.net          7937                 :           4464 :                     n->objtype = OBJECT_FUNCTION;
 8539 tgl@sss.pgh.pa.us        7938                 :           4464 :                     n->objs = $2;
                               7939                 :           4464 :                     $$ = n;
                               7940                 :                :                 }
                               7941                 :                :             | PROCEDURE function_with_argtypes_list
                               7942                 :                :                 {
 2837 peter_e@gmx.net          7943                 :             21 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7944                 :                : 
                               7945                 :             21 :                     n->targtype = ACL_TARGET_OBJECT;
 2887                          7946                 :             21 :                     n->objtype = OBJECT_PROCEDURE;
 2837                          7947                 :             21 :                     n->objs = $2;
                               7948                 :             21 :                     $$ = n;
                               7949                 :                :                 }
                               7950                 :                :             | ROUTINE function_with_argtypes_list
                               7951                 :                :                 {
 2837 peter_e@gmx.net          7952                 :UBC           0 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7953                 :                : 
                               7954                 :              0 :                     n->targtype = ACL_TARGET_OBJECT;
 2887                          7955                 :              0 :                     n->objtype = OBJECT_ROUTINE;
 2837                          7956                 :              0 :                     n->objs = $2;
                               7957                 :              0 :                     $$ = n;
                               7958                 :                :                 }
                               7959                 :                :             | DATABASE name_list
                               7960                 :                :                 {
 6071 tgl@sss.pgh.pa.us        7961                 :CBC         169 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7962                 :                : 
 5808                          7963                 :            169 :                     n->targtype = ACL_TARGET_OBJECT;
 2887 peter_e@gmx.net          7964                 :            169 :                     n->objtype = OBJECT_DATABASE;
 8601                          7965                 :            169 :                     n->objs = $2;
                               7966                 :            169 :                     $$ = n;
                               7967                 :                :                 }
                               7968                 :                :             | DOMAIN_P any_name_list
                               7969                 :                :                 {
 5009                          7970                 :             13 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7971                 :                : 
                               7972                 :             13 :                     n->targtype = ACL_TARGET_OBJECT;
 2887                          7973                 :             13 :                     n->objtype = OBJECT_DOMAIN;
 5009                          7974                 :             13 :                     n->objs = $2;
                               7975                 :             13 :                     $$ = n;
                               7976                 :                :                 }
                               7977                 :                :             | LANGUAGE name_list
                               7978                 :                :                 {
 6071 tgl@sss.pgh.pa.us        7979                 :             21 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7980                 :                : 
 5808                          7981                 :             21 :                     n->targtype = ACL_TARGET_OBJECT;
 2887 peter_e@gmx.net          7982                 :             21 :                     n->objtype = OBJECT_LANGUAGE;
 8539 tgl@sss.pgh.pa.us        7983                 :             21 :                     n->objs = $2;
                               7984                 :             21 :                     $$ = n;
                               7985                 :                :                 }
                               7986                 :                :             | LARGE_P OBJECT_P NumericOnly_list
                               7987                 :                :                 {
 5748 itagaki.takahiro@gma     7988                 :             40 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7989                 :                : 
                               7990                 :             40 :                     n->targtype = ACL_TARGET_OBJECT;
 2887 peter_e@gmx.net          7991                 :             40 :                     n->objtype = OBJECT_LARGEOBJECT;
 5748 itagaki.takahiro@gma     7992                 :             40 :                     n->objs = $3;
                               7993                 :             40 :                     $$ = n;
                               7994                 :                :                 }
                               7995                 :                :             | PARAMETER parameter_name_list
                               7996                 :                :                 {
 1249 tgl@sss.pgh.pa.us        7997                 :             38 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               7998                 :             38 :                     n->targtype = ACL_TARGET_OBJECT;
                               7999                 :             38 :                     n->objtype = OBJECT_PARAMETER_ACL;
                               8000                 :             38 :                     n->objs = $2;
                               8001                 :             38 :                     $$ = n;
                               8002                 :                :                 }
                               8003                 :                :             | SCHEMA name_list
                               8004                 :                :                 {
 6071                          8005                 :            181 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               8006                 :                : 
 5808                          8007                 :            181 :                     n->targtype = ACL_TARGET_OBJECT;
 2887 peter_e@gmx.net          8008                 :            181 :                     n->objtype = OBJECT_SCHEMA;
 8601                          8009                 :            181 :                     n->objs = $2;
                               8010                 :            181 :                     $$ = n;
                               8011                 :                :                 }
                               8012                 :                :             | TABLESPACE name_list
                               8013                 :                :                 {
 6071 tgl@sss.pgh.pa.us        8014                 :              3 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               8015                 :                : 
 5808                          8016                 :              3 :                     n->targtype = ACL_TARGET_OBJECT;
 2887 peter_e@gmx.net          8017                 :              3 :                     n->objtype = OBJECT_TABLESPACE;
 7750 tgl@sss.pgh.pa.us        8018                 :              3 :                     n->objs = $2;
                               8019                 :              3 :                     $$ = n;
                               8020                 :                :                 }
                               8021                 :                :             | TYPE_P any_name_list
                               8022                 :                :                 {
 5009 peter_e@gmx.net          8023                 :             56 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               8024                 :                : 
                               8025                 :             56 :                     n->targtype = ACL_TARGET_OBJECT;
 2887                          8026                 :             56 :                     n->objtype = OBJECT_TYPE;
 5009                          8027                 :             56 :                     n->objs = $2;
                               8028                 :             56 :                     $$ = n;
                               8029                 :                :                 }
                               8030                 :                :             | ALL TABLES IN_P SCHEMA name_list
                               8031                 :                :                 {
 5808 tgl@sss.pgh.pa.us        8032                 :              6 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               8033                 :                : 
                               8034                 :              6 :                     n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
 2887 peter_e@gmx.net          8035                 :              6 :                     n->objtype = OBJECT_TABLE;
 5808 tgl@sss.pgh.pa.us        8036                 :              6 :                     n->objs = $5;
                               8037                 :              6 :                     $$ = n;
                               8038                 :                :                 }
                               8039                 :                :             | ALL SEQUENCES IN_P SCHEMA name_list
                               8040                 :                :                 {
 5808 tgl@sss.pgh.pa.us        8041                 :UBC           0 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               8042                 :                : 
                               8043                 :              0 :                     n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
 2887 peter_e@gmx.net          8044                 :              0 :                     n->objtype = OBJECT_SEQUENCE;
 5808 tgl@sss.pgh.pa.us        8045                 :              0 :                     n->objs = $5;
                               8046                 :              0 :                     $$ = n;
                               8047                 :                :                 }
                               8048                 :                :             | ALL FUNCTIONS IN_P SCHEMA name_list
                               8049                 :                :                 {
 5808 tgl@sss.pgh.pa.us        8050                 :CBC           3 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               8051                 :                : 
                               8052                 :              3 :                     n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
 2887 peter_e@gmx.net          8053                 :              3 :                     n->objtype = OBJECT_FUNCTION;
 5808 tgl@sss.pgh.pa.us        8054                 :              3 :                     n->objs = $5;
                               8055                 :              3 :                     $$ = n;
                               8056                 :                :                 }
                               8057                 :                :             | ALL PROCEDURES IN_P SCHEMA name_list
                               8058                 :                :                 {
 2837 peter_e@gmx.net          8059                 :              3 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               8060                 :                : 
                               8061                 :              3 :                     n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
 2887                          8062                 :              3 :                     n->objtype = OBJECT_PROCEDURE;
 2837                          8063                 :              3 :                     n->objs = $5;
                               8064                 :              3 :                     $$ = n;
                               8065                 :                :                 }
                               8066                 :                :             | ALL ROUTINES IN_P SCHEMA name_list
                               8067                 :                :                 {
                               8068                 :              3 :                     PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
                               8069                 :                : 
                               8070                 :              3 :                     n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
 2887                          8071                 :              3 :                     n->objtype = OBJECT_ROUTINE;
 2837                          8072                 :              3 :                     n->objs = $5;
                               8073                 :              3 :                     $$ = n;
                               8074                 :                :                 }
                               8075                 :                :         ;
                               8076                 :                : 
                               8077                 :                : 
                               8078                 :                : grantee_list:
 7769 neilc@samurai.com        8079                 :          11192 :             grantee                                 { $$ = list_make1($1); }
 8482 bruce@momjian.us         8080                 :             54 :             | grantee_list ',' grantee              { $$ = lappend($1, $3); }
                               8081                 :                :         ;
                               8082                 :                : 
                               8083                 :                : grantee:
 3834 alvherre@alvh.no-ip.     8084                 :          11234 :             RoleSpec                                { $$ = $1; }
                               8085                 :             12 :             | GROUP_P RoleSpec                      { $$ = $2; }
                               8086                 :                :         ;
                               8087                 :                : 
                               8088                 :                : 
                               8089                 :                : opt_grant_grant_option:
 2943 peter_e@gmx.net          8090                 :             51 :             WITH GRANT OPTION { $$ = true; }
                               8091                 :           5880 :             | /*EMPTY*/ { $$ = false; }
                               8092                 :                :         ;
                               8093                 :                : 
                               8094                 :                : /*****************************************************************************
                               8095                 :                :  *
                               8096                 :                :  * GRANT and REVOKE ROLE statements
                               8097                 :                :  *
                               8098                 :                :  *****************************************************************************/
                               8099                 :                : 
                               8100                 :                : GrantRoleStmt:
                               8101                 :                :             GRANT privilege_list TO role_list opt_granted_by
                               8102                 :                :                 {
 7375 tgl@sss.pgh.pa.us        8103                 :            292 :                     GrantRoleStmt *n = makeNode(GrantRoleStmt);
                               8104                 :                : 
                               8105                 :            292 :                     n->is_grant = true;
                               8106                 :            292 :                     n->granted_roles = $2;
                               8107                 :            292 :                     n->grantee_roles = $4;
 1108 rhaas@postgresql.org     8108                 :            292 :                     n->opt = NIL;
                               8109                 :            292 :                     n->grantor = $5;
                               8110                 :            292 :                     $$ = (Node *) n;
                               8111                 :                :                 }
                               8112                 :                :           | GRANT privilege_list TO role_list WITH grant_role_opt_list opt_granted_by
                               8113                 :                :                 {
                               8114                 :             89 :                     GrantRoleStmt *n = makeNode(GrantRoleStmt);
                               8115                 :                : 
                               8116                 :             89 :                     n->is_grant = true;
                               8117                 :             89 :                     n->granted_roles = $2;
                               8118                 :             89 :                     n->grantee_roles = $4;
                               8119                 :             89 :                     n->opt = $6;
                               8120                 :             89 :                     n->grantor = $7;
 1212 peter@eisentraut.org     8121                 :             89 :                     $$ = (Node *) n;
                               8122                 :                :                 }
                               8123                 :                :         ;
                               8124                 :                : 
                               8125                 :                : RevokeRoleStmt:
                               8126                 :                :             REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior
                               8127                 :                :                 {
 7375 tgl@sss.pgh.pa.us        8128                 :             45 :                     GrantRoleStmt *n = makeNode(GrantRoleStmt);
                               8129                 :                : 
                               8130                 :             45 :                     n->is_grant = false;
 1108 rhaas@postgresql.org     8131                 :             45 :                     n->opt = NIL;
 7375 tgl@sss.pgh.pa.us        8132                 :             45 :                     n->granted_roles = $2;
                               8133                 :             45 :                     n->grantee_roles = $4;
 1111 rhaas@postgresql.org     8134                 :             45 :                     n->grantor = $5;
 7375 tgl@sss.pgh.pa.us        8135                 :             45 :                     n->behavior = $6;
 1212 peter@eisentraut.org     8136                 :             45 :                     $$ = (Node *) n;
                               8137                 :                :                 }
                               8138                 :                :             | REVOKE ColId OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior
                               8139                 :                :                 {
 7375 tgl@sss.pgh.pa.us        8140                 :             33 :                     GrantRoleStmt *n = makeNode(GrantRoleStmt);
                               8141                 :                :                     DefElem *opt;
                               8142                 :                : 
 1108 rhaas@postgresql.org     8143                 :             33 :                     opt = makeDefElem(pstrdup($2),
                               8144                 :             33 :                                       (Node *) makeBoolean(false), @2);
 7375 tgl@sss.pgh.pa.us        8145                 :             33 :                     n->is_grant = false;
 1108 rhaas@postgresql.org     8146                 :             33 :                     n->opt = list_make1(opt);
 7375 tgl@sss.pgh.pa.us        8147                 :             33 :                     n->granted_roles = $5;
                               8148                 :             33 :                     n->grantee_roles = $7;
 1111 rhaas@postgresql.org     8149                 :             33 :                     n->grantor = $8;
 7375 tgl@sss.pgh.pa.us        8150                 :             33 :                     n->behavior = $9;
 1212 peter@eisentraut.org     8151                 :             33 :                     $$ = (Node *) n;
                               8152                 :                :                 }
                               8153                 :                :         ;
                               8154                 :                : 
                               8155                 :                : grant_role_opt_list:
 1108 rhaas@postgresql.org     8156                 :             60 :             grant_role_opt_list ',' grant_role_opt  { $$ = lappend($1, $3); }
                               8157                 :             89 :             | grant_role_opt                        { $$ = list_make1($1); }
                               8158                 :                :         ;
                               8159                 :                : 
                               8160                 :                : grant_role_opt:
                               8161                 :                :         ColLabel grant_role_opt_value
                               8162                 :                :             {
                               8163                 :            149 :                 $$ = makeDefElem(pstrdup($1), $2, @1);
                               8164                 :                :             }
                               8165                 :                :         ;
                               8166                 :                : 
                               8167                 :                : grant_role_opt_value:
                               8168                 :             36 :         OPTION          { $$ = (Node *) makeBoolean(true); }
                               8169                 :             56 :         | TRUE_P        { $$ = (Node *) makeBoolean(true); }
                               8170                 :             57 :         | FALSE_P       { $$ = (Node *) makeBoolean(false); }
                               8171                 :                :         ;
                               8172                 :                : 
 3834 alvherre@alvh.no-ip.     8173                 :             69 : opt_granted_by: GRANTED BY RoleSpec                     { $$ = $3; }
 7375 tgl@sss.pgh.pa.us        8174                 :          11479 :             | /*EMPTY*/                                 { $$ = NULL; }
                               8175                 :                :         ;
                               8176                 :                : 
                               8177                 :                : /*****************************************************************************
                               8178                 :                :  *
                               8179                 :                :  * ALTER DEFAULT PRIVILEGES statement
                               8180                 :                :  *
                               8181                 :                :  *****************************************************************************/
                               8182                 :                : 
                               8183                 :                : AlterDefaultPrivilegesStmt:
                               8184                 :                :             ALTER DEFAULT PRIVILEGES DefACLOptionList DefACLAction
                               8185                 :                :                 {
 5815                          8186                 :            103 :                     AlterDefaultPrivilegesStmt *n = makeNode(AlterDefaultPrivilegesStmt);
                               8187                 :                : 
                               8188                 :            103 :                     n->options = $4;
                               8189                 :            103 :                     n->action = (GrantStmt *) $5;
 1212 peter@eisentraut.org     8190                 :            103 :                     $$ = (Node *) n;
                               8191                 :                :                 }
                               8192                 :                :         ;
                               8193                 :                : 
                               8194                 :                : DefACLOptionList:
 5815 tgl@sss.pgh.pa.us        8195                 :             72 :             DefACLOptionList DefACLOption           { $$ = lappend($1, $2); }
                               8196                 :            103 :             | /* EMPTY */                           { $$ = NIL; }
                               8197                 :                :         ;
                               8198                 :                : 
                               8199                 :                : DefACLOption:
                               8200                 :                :             IN_P SCHEMA name_list
                               8201                 :                :                 {
 1212 peter@eisentraut.org     8202                 :             30 :                     $$ = makeDefElem("schemas", (Node *) $3, @1);
                               8203                 :                :                 }
                               8204                 :                :             | FOR ROLE role_list
                               8205                 :                :                 {
                               8206                 :             42 :                     $$ = makeDefElem("roles", (Node *) $3, @1);
                               8207                 :                :                 }
                               8208                 :                :             | FOR USER role_list
                               8209                 :                :                 {
 1212 peter@eisentraut.org     8210                 :UBC           0 :                     $$ = makeDefElem("roles", (Node *) $3, @1);
                               8211                 :                :                 }
                               8212                 :                :         ;
                               8213                 :                : 
                               8214                 :                : /*
                               8215                 :                :  * This should match GRANT/REVOKE, except that individual target objects
                               8216                 :                :  * are not mentioned and we only allow a subset of object types.
                               8217                 :                :  */
                               8218                 :                : DefACLAction:
                               8219                 :                :             GRANT privileges ON defacl_privilege_target TO grantee_list
                               8220                 :                :             opt_grant_grant_option
                               8221                 :                :                 {
 5815 tgl@sss.pgh.pa.us        8222                 :CBC          62 :                     GrantStmt *n = makeNode(GrantStmt);
                               8223                 :                : 
                               8224                 :             62 :                     n->is_grant = true;
                               8225                 :             62 :                     n->privileges = $2;
 5808                          8226                 :             62 :                     n->targtype = ACL_TARGET_DEFAULTS;
 5815                          8227                 :             62 :                     n->objtype = $4;
                               8228                 :             62 :                     n->objects = NIL;
                               8229                 :             62 :                     n->grantees = $6;
                               8230                 :             62 :                     n->grant_option = $7;
 1212 peter@eisentraut.org     8231                 :             62 :                     $$ = (Node *) n;
                               8232                 :                :                 }
                               8233                 :                :             | REVOKE privileges ON defacl_privilege_target
                               8234                 :                :             FROM grantee_list opt_drop_behavior
                               8235                 :                :                 {
 5815 tgl@sss.pgh.pa.us        8236                 :             41 :                     GrantStmt *n = makeNode(GrantStmt);
                               8237                 :                : 
                               8238                 :             41 :                     n->is_grant = false;
                               8239                 :             41 :                     n->grant_option = false;
                               8240                 :             41 :                     n->privileges = $2;
 5808                          8241                 :             41 :                     n->targtype = ACL_TARGET_DEFAULTS;
 5815                          8242                 :             41 :                     n->objtype = $4;
                               8243                 :             41 :                     n->objects = NIL;
                               8244                 :             41 :                     n->grantees = $6;
                               8245                 :             41 :                     n->behavior = $7;
 1212 peter@eisentraut.org     8246                 :             41 :                     $$ = (Node *) n;
                               8247                 :                :                 }
                               8248                 :                :             | REVOKE GRANT OPTION FOR privileges ON defacl_privilege_target
                               8249                 :                :             FROM grantee_list opt_drop_behavior
                               8250                 :                :                 {
 5815 tgl@sss.pgh.pa.us        8251                 :UBC           0 :                     GrantStmt *n = makeNode(GrantStmt);
                               8252                 :                : 
                               8253                 :              0 :                     n->is_grant = false;
                               8254                 :              0 :                     n->grant_option = true;
                               8255                 :              0 :                     n->privileges = $5;
 5808                          8256                 :              0 :                     n->targtype = ACL_TARGET_DEFAULTS;
 5815                          8257                 :              0 :                     n->objtype = $7;
                               8258                 :              0 :                     n->objects = NIL;
                               8259                 :              0 :                     n->grantees = $9;
                               8260                 :              0 :                     n->behavior = $10;
 1212 peter@eisentraut.org     8261                 :              0 :                     $$ = (Node *) n;
                               8262                 :                :                 }
                               8263                 :                :         ;
                               8264                 :                : 
                               8265                 :                : defacl_privilege_target:
 2887 peter_e@gmx.net          8266                 :CBC          39 :             TABLES          { $$ = OBJECT_TABLE; }
                               8267                 :              8 :             | FUNCTIONS     { $$ = OBJECT_FUNCTION; }
                               8268                 :              3 :             | ROUTINES      { $$ = OBJECT_FUNCTION; }
                               8269                 :              3 :             | SEQUENCES     { $$ = OBJECT_SEQUENCE; }
                               8270                 :             17 :             | TYPES_P       { $$ = OBJECT_TYPE; }
                               8271                 :             18 :             | SCHEMAS       { $$ = OBJECT_SCHEMA; }
  155 fujii@postgresql.org     8272                 :             15 :             | LARGE_P OBJECTS_P { $$ = OBJECT_LARGEOBJECT; }
                               8273                 :                :         ;
                               8274                 :                : 
                               8275                 :                : 
                               8276                 :                : /*****************************************************************************
                               8277                 :                :  *
                               8278                 :                :  *      QUERY: CREATE INDEX
                               8279                 :                :  *
                               8280                 :                :  * Note: we cannot put TABLESPACE clause after WHERE clause unless we are
                               8281                 :                :  * willing to make TABLESPACE a fully reserved word.
                               8282                 :                :  *****************************************************************************/
                               8283                 :                : 
                               8284                 :                : IndexStmt:  CREATE opt_unique INDEX opt_concurrently opt_single_name
                               8285                 :                :             ON relation_expr access_method_clause '(' index_params ')'
                               8286                 :                :             opt_include opt_unique_null_treatment opt_reloptions OptTableSpace where_clause
                               8287                 :                :                 {
 6952 tgl@sss.pgh.pa.us        8288                 :           3323 :                     IndexStmt *n = makeNode(IndexStmt);
                               8289                 :                : 
                               8290                 :           3323 :                     n->unique = $2;
 5736                          8291                 :           3323 :                     n->concurrent = $4;
 6952                          8292                 :           3323 :                     n->idxname = $5;
                               8293                 :           3323 :                     n->relation = $7;
                               8294                 :           3323 :                     n->accessMethod = $8;
                               8295                 :           3323 :                     n->indexParams = $10;
 2709 teodor@sigaev.ru         8296                 :           3323 :                     n->indexIncludingParams = $12;
 1311 peter@eisentraut.org     8297                 :           3323 :                     n->nulls_not_distinct = !$13;
                               8298                 :           3323 :                     n->options = $14;
                               8299                 :           3323 :                     n->tableSpace = $15;
                               8300                 :           3323 :                     n->whereClause = $16;
 4800 tgl@sss.pgh.pa.us        8301                 :           3323 :                     n->excludeOpNames = NIL;
                               8302                 :           3323 :                     n->idxcomment = NULL;
 5338                          8303                 :           3323 :                     n->indexOid = InvalidOid;
 1158 rhaas@postgresql.org     8304                 :           3323 :                     n->oldNumber = InvalidRelFileNumber;
 1981 noah@leadboat.com        8305                 :           3323 :                     n->oldCreateSubid = InvalidSubTransactionId;
 1158 rhaas@postgresql.org     8306                 :           3323 :                     n->oldFirstRelfilelocatorSubid = InvalidSubTransactionId;
 4800 tgl@sss.pgh.pa.us        8307                 :           3323 :                     n->primary = false;
                               8308                 :           3323 :                     n->isconstraint = false;
                               8309                 :           3323 :                     n->deferrable = false;
                               8310                 :           3323 :                     n->initdeferred = false;
 3849                          8311                 :           3323 :                     n->transformed = false;
 3957 fujii@postgresql.org     8312                 :           3323 :                     n->if_not_exists = false;
 2326 alvherre@alvh.no-ip.     8313                 :           3323 :                     n->reset_default_tblspc = false;
 1212 peter@eisentraut.org     8314                 :           3323 :                     $$ = (Node *) n;
                               8315                 :                :                 }
                               8316                 :                :             | CREATE opt_unique INDEX opt_concurrently IF_P NOT EXISTS name
                               8317                 :                :             ON relation_expr access_method_clause '(' index_params ')'
                               8318                 :                :             opt_include opt_unique_null_treatment opt_reloptions OptTableSpace where_clause
                               8319                 :                :                 {
 3957 fujii@postgresql.org     8320                 :              9 :                     IndexStmt *n = makeNode(IndexStmt);
                               8321                 :                : 
                               8322                 :              9 :                     n->unique = $2;
                               8323                 :              9 :                     n->concurrent = $4;
                               8324                 :              9 :                     n->idxname = $8;
                               8325                 :              9 :                     n->relation = $10;
                               8326                 :              9 :                     n->accessMethod = $11;
                               8327                 :              9 :                     n->indexParams = $13;
 2709 teodor@sigaev.ru         8328                 :              9 :                     n->indexIncludingParams = $15;
 1311 peter@eisentraut.org     8329                 :              9 :                     n->nulls_not_distinct = !$16;
                               8330                 :              9 :                     n->options = $17;
                               8331                 :              9 :                     n->tableSpace = $18;
                               8332                 :              9 :                     n->whereClause = $19;
 3957 fujii@postgresql.org     8333                 :              9 :                     n->excludeOpNames = NIL;
                               8334                 :              9 :                     n->idxcomment = NULL;
                               8335                 :              9 :                     n->indexOid = InvalidOid;
 1158 rhaas@postgresql.org     8336                 :              9 :                     n->oldNumber = InvalidRelFileNumber;
 1981 noah@leadboat.com        8337                 :              9 :                     n->oldCreateSubid = InvalidSubTransactionId;
 1158 rhaas@postgresql.org     8338                 :              9 :                     n->oldFirstRelfilelocatorSubid = InvalidSubTransactionId;
 3957 fujii@postgresql.org     8339                 :              9 :                     n->primary = false;
                               8340                 :              9 :                     n->isconstraint = false;
                               8341                 :              9 :                     n->deferrable = false;
                               8342                 :              9 :                     n->initdeferred = false;
 3849 tgl@sss.pgh.pa.us        8343                 :              9 :                     n->transformed = false;
 3957 fujii@postgresql.org     8344                 :              9 :                     n->if_not_exists = true;
 2326 alvherre@alvh.no-ip.     8345                 :              9 :                     n->reset_default_tblspc = false;
 1212 peter@eisentraut.org     8346                 :              9 :                     $$ = (Node *) n;
                               8347                 :                :                 }
                               8348                 :                :         ;
                               8349                 :                : 
                               8350                 :                : opt_unique:
 2943 peter_e@gmx.net          8351                 :            645 :             UNIQUE                                  { $$ = true; }
                               8352                 :           2690 :             | /*EMPTY*/                             { $$ = false; }
                               8353                 :                :         ;
                               8354                 :                : 
                               8355                 :                : access_method_clause:
 1914 peter@eisentraut.org     8356                 :           1505 :             USING name                              { $$ = $2; }
 8481 bruce@momjian.us         8357                 :           1944 :             | /*EMPTY*/                             { $$ = DEFAULT_INDEX_TYPE; }
                               8358                 :                :         ;
                               8359                 :                : 
 7769 neilc@samurai.com        8360                 :           4053 : index_params:   index_elem                          { $$ = list_make1($1); }
 8137 tgl@sss.pgh.pa.us        8361                 :           1079 :             | index_params ',' index_elem           { $$ = lappend($1, $3); }
                               8362                 :                :         ;
                               8363                 :                : 
                               8364                 :                : 
                               8365                 :                : index_elem_options:
                               8366                 :                :     opt_collate opt_qualified_name opt_asc_desc opt_nulls_order
                               8367                 :                :         {
 1986 akorotkov@postgresql     8368                 :           5423 :             $$ = makeNode(IndexElem);
                               8369                 :           5423 :             $$->name = NULL;
                               8370                 :           5423 :             $$->expr = NULL;
                               8371                 :           5423 :             $$->indexcolname = NULL;
                               8372                 :           5423 :             $$->collation = $1;
                               8373                 :           5423 :             $$->opclass = $2;
                               8374                 :           5423 :             $$->opclassopts = NIL;
                               8375                 :           5423 :             $$->ordering = $3;
                               8376                 :           5423 :             $$->nulls_ordering = $4;
                               8377                 :                :         }
                               8378                 :                :     | opt_collate any_name reloptions opt_asc_desc opt_nulls_order
                               8379                 :                :         {
                               8380                 :             71 :             $$ = makeNode(IndexElem);
                               8381                 :             71 :             $$->name = NULL;
                               8382                 :             71 :             $$->expr = NULL;
                               8383                 :             71 :             $$->indexcolname = NULL;
                               8384                 :             71 :             $$->collation = $1;
                               8385                 :             71 :             $$->opclass = $2;
                               8386                 :             71 :             $$->opclassopts = $3;
                               8387                 :             71 :             $$->ordering = $4;
                               8388                 :             71 :             $$->nulls_ordering = $5;
                               8389                 :                :         }
                               8390                 :                :     ;
                               8391                 :                : 
                               8392                 :                : /*
                               8393                 :                :  * Index attributes can be either simple column references, or arbitrary
                               8394                 :                :  * expressions in parens.  For backwards-compatibility reasons, we allow
                               8395                 :                :  * an expression that's just a function call to be written without parens.
                               8396                 :                :  */
                               8397                 :                : index_elem: ColId index_elem_options
                               8398                 :                :                 {
                               8399                 :           4933 :                     $$ = $2;
 8137 tgl@sss.pgh.pa.us        8400                 :           4933 :                     $$->name = $1;
                               8401                 :                :                 }
                               8402                 :                :             | func_expr_windowless index_elem_options
                               8403                 :                :                 {
 1986 akorotkov@postgresql     8404                 :            303 :                     $$ = $2;
 7647 tgl@sss.pgh.pa.us        8405                 :            303 :                     $$->expr = $1;
                               8406                 :                :                 }
                               8407                 :                :             | '(' a_expr ')' index_elem_options
                               8408                 :                :                 {
 1986 akorotkov@postgresql     8409                 :            258 :                     $$ = $4;
 8137 tgl@sss.pgh.pa.us        8410                 :            258 :                     $$->expr = $2;
                               8411                 :                :                 }
                               8412                 :                :         ;
                               8413                 :                : 
 2709 teodor@sigaev.ru         8414                 :            109 : opt_include:        INCLUDE '(' index_including_params ')'          { $$ = $3; }
                               8415                 :           3223 :              |      /* EMPTY */                     { $$ = NIL; }
                               8416                 :                :         ;
                               8417                 :                : 
                               8418                 :            109 : index_including_params: index_elem                      { $$ = list_make1($1); }
                               8419                 :             83 :             | index_including_params ',' index_elem     { $$ = lappend($1, $3); }
                               8420                 :                :         ;
                               8421                 :                : 
 5324 peter_e@gmx.net          8422                 :             96 : opt_collate: COLLATE any_name                       { $$ = $2; }
                               8423                 :           8143 :             | /*EMPTY*/                             { $$ = NIL; }
                               8424                 :                :         ;
                               8425                 :                : 
                               8426                 :                : 
 6815 tgl@sss.pgh.pa.us        8427                 :            909 : opt_asc_desc: ASC                           { $$ = SORTBY_ASC; }
 6214                          8428                 :           1782 :             | DESC                          { $$ = SORTBY_DESC; }
                               8429                 :          56613 :             | /*EMPTY*/                     { $$ = SORTBY_DEFAULT; }
                               8430                 :                :         ;
                               8431                 :                : 
 3847                          8432                 :            175 : opt_nulls_order: NULLS_LA FIRST_P           { $$ = SORTBY_NULLS_FIRST; }
                               8433                 :            859 :             | NULLS_LA LAST_P               { $$ = SORTBY_NULLS_LAST; }
 6815                          8434                 :          58380 :             | /*EMPTY*/                     { $$ = SORTBY_NULLS_DEFAULT; }
                               8435                 :                :         ;
                               8436                 :                : 
                               8437                 :                : 
                               8438                 :                : /*****************************************************************************
                               8439                 :                :  *
                               8440                 :                :  *      QUERY:
                               8441                 :                :  *              create [or replace] function <fname>
                               8442                 :                :  *                      [(<type-1> { , <type-n>})]
                               8443                 :                :  *                      returns <type-r>
                               8444                 :                :  *                      as <filename or code in language as appropriate>
                               8445                 :                :  *                      language <lang> [with parameters]
                               8446                 :                :  *
                               8447                 :                :  *****************************************************************************/
                               8448                 :                : 
                               8449                 :                : CreateFunctionStmt:
                               8450                 :                :             CREATE opt_or_replace FUNCTION func_name func_args_with_defaults
                               8451                 :                :             RETURNS func_return opt_createfunc_opt_list opt_routine_body
                               8452                 :                :                 {
 8513 peter_e@gmx.net          8453                 :          11841 :                     CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
                               8454                 :                : 
 2780 tgl@sss.pgh.pa.us        8455                 :          11841 :                     n->is_procedure = false;
 8740                          8456                 :          11841 :                     n->replace = $2;
 8551                          8457                 :          11841 :                     n->funcname = $4;
 7914                          8458                 :          11841 :                     n->parameters = $5;
 8562                          8459                 :          11841 :                     n->returnType = $7;
 8513 peter_e@gmx.net          8460                 :          11841 :                     n->options = $8;
 1613 peter@eisentraut.org     8461                 :          11841 :                     n->sql_body = $9;
 1212                          8462                 :          11841 :                     $$ = (Node *) n;
                               8463                 :                :                 }
                               8464                 :                :             | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults
                               8465                 :                :               RETURNS TABLE '(' table_func_column_list ')' opt_createfunc_opt_list opt_routine_body
                               8466                 :                :                 {
 6259 tgl@sss.pgh.pa.us        8467                 :             97 :                     CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
                               8468                 :                : 
 2780                          8469                 :             97 :                     n->is_procedure = false;
 6259                          8470                 :             97 :                     n->replace = $2;
                               8471                 :             97 :                     n->funcname = $4;
  310                          8472                 :             97 :                     n->parameters = mergeTableFuncParameters($5, $9, yyscanner);
 6259                          8473                 :             97 :                     n->returnType = TableFuncTypeName($9);
                               8474                 :             97 :                     n->returnType->location = @7;
                               8475                 :             97 :                     n->options = $11;
 1613 peter@eisentraut.org     8476                 :             97 :                     n->sql_body = $12;
 1212                          8477                 :             97 :                     $$ = (Node *) n;
                               8478                 :                :                 }
                               8479                 :                :             | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults
                               8480                 :                :               opt_createfunc_opt_list opt_routine_body
                               8481                 :                :                 {
 7464 tgl@sss.pgh.pa.us        8482                 :            242 :                     CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
                               8483                 :                : 
 2780                          8484                 :            242 :                     n->is_procedure = false;
 7464                          8485                 :            242 :                     n->replace = $2;
                               8486                 :            242 :                     n->funcname = $4;
                               8487                 :            242 :                     n->parameters = $5;
                               8488                 :            242 :                     n->returnType = NULL;
                               8489                 :            242 :                     n->options = $6;
 1613 peter@eisentraut.org     8490                 :            242 :                     n->sql_body = $7;
 1212                          8491                 :            242 :                     $$ = (Node *) n;
                               8492                 :                :                 }
                               8493                 :                :             | CREATE opt_or_replace PROCEDURE func_name func_args_with_defaults
                               8494                 :                :               opt_createfunc_opt_list opt_routine_body
                               8495                 :                :                 {
 2837 peter_e@gmx.net          8496                 :            182 :                     CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
                               8497                 :                : 
 2780 tgl@sss.pgh.pa.us        8498                 :            182 :                     n->is_procedure = true;
 2837 peter_e@gmx.net          8499                 :            182 :                     n->replace = $2;
                               8500                 :            182 :                     n->funcname = $4;
                               8501                 :            182 :                     n->parameters = $5;
                               8502                 :            182 :                     n->returnType = NULL;
                               8503                 :            182 :                     n->options = $6;
 1613 peter@eisentraut.org     8504                 :            182 :                     n->sql_body = $7;
 1212                          8505                 :            182 :                     $$ = (Node *) n;
                               8506                 :                :                 }
                               8507                 :                :         ;
                               8508                 :                : 
                               8509                 :                : opt_or_replace:
 2943 peter_e@gmx.net          8510                 :           4975 :             OR REPLACE                              { $$ = true; }
                               8511                 :          10114 :             | /*EMPTY*/                             { $$ = false; }
                               8512                 :                :         ;
                               8513                 :                : 
 8482 bruce@momjian.us         8514                 :           6041 : func_args:  '(' func_args_list ')'                  { $$ = $2; }
                               8515                 :           2946 :             | '(' ')'                               { $$ = NIL; }
                               8516                 :                :         ;
                               8517                 :                : 
                               8518                 :                : func_args_list:
 7769 neilc@samurai.com        8519                 :           6041 :             func_arg                                { $$ = list_make1($1); }
 8482 bruce@momjian.us         8520                 :           5633 :             | func_args_list ',' func_arg           { $$ = lappend($1, $3); }
                               8521                 :                :         ;
                               8522                 :                : 
                               8523                 :                : function_with_argtypes_list:
 3278 peter_e@gmx.net          8524                 :           6348 :             function_with_argtypes                  { $$ = list_make1($1); }
                               8525                 :                :             | function_with_argtypes_list ',' function_with_argtypes
                               8526                 :             42 :                                                     { $$ = lappend($1, $3); }
                               8527                 :                :         ;
                               8528                 :                : 
                               8529                 :                : function_with_argtypes:
                               8530                 :                :             func_name func_args
                               8531                 :                :                 {
 3174                          8532                 :           8987 :                     ObjectWithArgs *n = makeNode(ObjectWithArgs);
                               8533                 :                : 
                               8534                 :           8987 :                     n->objname = $1;
 1549 tgl@sss.pgh.pa.us        8535                 :           8987 :                     n->objargs = extractArgTypes($2);
                               8536                 :           8987 :                     n->objfuncargs = $2;
 3278 peter_e@gmx.net          8537                 :           8987 :                     $$ = n;
                               8538                 :                :                 }
                               8539                 :                :             /*
                               8540                 :                :              * Because of reduce/reduce conflicts, we can't use func_name
                               8541                 :                :              * below, but we can write it out the long way, which actually
                               8542                 :                :              * allows more cases.
                               8543                 :                :              */
                               8544                 :                :             | type_func_name_keyword
                               8545                 :                :                 {
 3103 peter_e@gmx.net          8546                 :UBC           0 :                     ObjectWithArgs *n = makeNode(ObjectWithArgs);
                               8547                 :                : 
                               8548                 :              0 :                     n->objname = list_make1(makeString(pstrdup($1)));
                               8549                 :              0 :                     n->args_unspecified = true;
                               8550                 :              0 :                     $$ = n;
                               8551                 :                :                 }
                               8552                 :                :             | ColId
                               8553                 :                :                 {
 3103 peter_e@gmx.net          8554                 :CBC         185 :                     ObjectWithArgs *n = makeNode(ObjectWithArgs);
                               8555                 :                : 
                               8556                 :            185 :                     n->objname = list_make1(makeString($1));
                               8557                 :            185 :                     n->args_unspecified = true;
                               8558                 :            185 :                     $$ = n;
                               8559                 :                :                 }
                               8560                 :                :             | ColId indirection
                               8561                 :                :                 {
                               8562                 :             14 :                     ObjectWithArgs *n = makeNode(ObjectWithArgs);
                               8563                 :                : 
                               8564                 :             14 :                     n->objname = check_func_name(lcons(makeString($1), $2),
                               8565                 :                :                                                   yyscanner);
                               8566                 :             14 :                     n->args_unspecified = true;
                               8567                 :             14 :                     $$ = n;
                               8568                 :                :                 }
                               8569                 :                :         ;
                               8570                 :                : 
                               8571                 :                : /*
                               8572                 :                :  * func_args_with_defaults is separate because we only want to accept
                               8573                 :                :  * defaults in CREATE FUNCTION, not in ALTER etc.
                               8574                 :                :  */
                               8575                 :                : func_args_with_defaults:
 6120                          8576                 :          10139 :         '(' func_args_with_defaults_list ')'        { $$ = $2; }
 6106 tgl@sss.pgh.pa.us        8577                 :           2223 :         | '(' ')'                                   { $$ = NIL; }
                               8578                 :                :         ;
                               8579                 :                : 
                               8580                 :                : func_args_with_defaults_list:
                               8581                 :          10139 :         func_arg_with_default                       { $$ = list_make1($1); }
                               8582                 :                :         | func_args_with_defaults_list ',' func_arg_with_default
                               8583                 :          17652 :                                                     { $$ = lappend($1, $3); }
                               8584                 :                :         ;
                               8585                 :                : 
                               8586                 :                : /*
                               8587                 :                :  * The style with arg_class first is SQL99 standard, but Oracle puts
                               8588                 :                :  * param_name first; accept both since it's likely people will try both
                               8589                 :                :  * anyway.  Don't bother trying to save productions by letting arg_class
                               8590                 :                :  * have an empty alternative ... you'll get shift/reduce conflicts.
                               8591                 :                :  *
                               8592                 :                :  * We can catch over-specified arguments here if we want to,
                               8593                 :                :  * but for now better to silently swallow typmod, etc.
                               8594                 :                :  * - thomas 2000-03-22
                               8595                 :                :  */
                               8596                 :                : func_arg:
                               8597                 :                :             arg_class param_name func_type
                               8598                 :                :                 {
 7914                          8599                 :           7903 :                     FunctionParameter *n = makeNode(FunctionParameter);
                               8600                 :                : 
                               8601                 :           7903 :                     n->name = $2;
                               8602                 :           7903 :                     n->argType = $3;
 7466                          8603                 :           7903 :                     n->mode = $1;
 6120 peter_e@gmx.net          8604                 :           7903 :                     n->defexpr = NULL;
  310 tgl@sss.pgh.pa.us        8605                 :           7903 :                     n->location = @1;
 7914                          8606                 :           7903 :                     $$ = n;
                               8607                 :                :                 }
                               8608                 :                :             | param_name arg_class func_type
                               8609                 :                :                 {
                               8610                 :            210 :                     FunctionParameter *n = makeNode(FunctionParameter);
                               8611                 :                : 
 7466                          8612                 :            210 :                     n->name = $1;
                               8613                 :            210 :                     n->argType = $3;
                               8614                 :            210 :                     n->mode = $2;
 6120 peter_e@gmx.net          8615                 :            210 :                     n->defexpr = NULL;
  310 tgl@sss.pgh.pa.us        8616                 :            210 :                     n->location = @1;
 7466                          8617                 :            210 :                     $$ = n;
                               8618                 :                :                 }
                               8619                 :                :             | param_name func_type
                               8620                 :                :                 {
                               8621                 :           7844 :                     FunctionParameter *n = makeNode(FunctionParameter);
                               8622                 :                : 
                               8623                 :           7844 :                     n->name = $1;
 7914                          8624                 :           7844 :                     n->argType = $2;
 1549                          8625                 :           7844 :                     n->mode = FUNC_PARAM_DEFAULT;
 6120 peter_e@gmx.net          8626                 :           7844 :                     n->defexpr = NULL;
  310 tgl@sss.pgh.pa.us        8627                 :           7844 :                     n->location = @1;
 7914                          8628                 :           7844 :                     $$ = n;
                               8629                 :                :                 }
                               8630                 :                :             | arg_class func_type
                               8631                 :                :                 {
 7466                          8632                 :            164 :                     FunctionParameter *n = makeNode(FunctionParameter);
                               8633                 :                : 
                               8634                 :            164 :                     n->name = NULL;
                               8635                 :            164 :                     n->argType = $2;
                               8636                 :            164 :                     n->mode = $1;
 6120 peter_e@gmx.net          8637                 :            164 :                     n->defexpr = NULL;
  310 tgl@sss.pgh.pa.us        8638                 :            164 :                     n->location = @1;
 7466                          8639                 :            164 :                     $$ = n;
                               8640                 :                :                 }
                               8641                 :                :             | func_type
                               8642                 :                :                 {
                               8643                 :          23794 :                     FunctionParameter *n = makeNode(FunctionParameter);
                               8644                 :                : 
                               8645                 :          23794 :                     n->name = NULL;
                               8646                 :          23794 :                     n->argType = $1;
 1549                          8647                 :          23794 :                     n->mode = FUNC_PARAM_DEFAULT;
 6120 peter_e@gmx.net          8648                 :          23794 :                     n->defexpr = NULL;
  310 tgl@sss.pgh.pa.us        8649                 :          23794 :                     n->location = @1;
 7466                          8650                 :          23794 :                     $$ = n;
                               8651                 :                :                 }
                               8652                 :                :         ;
                               8653                 :                : 
                               8654                 :                : /* INOUT is SQL99 standard, IN OUT is for Oracle compatibility */
 6261                          8655                 :           1698 : arg_class:  IN_P                                { $$ = FUNC_PARAM_IN; }
                               8656                 :           6197 :             | OUT_P                             { $$ = FUNC_PARAM_OUT; }
                               8657                 :             99 :             | INOUT                             { $$ = FUNC_PARAM_INOUT; }
 6261 tgl@sss.pgh.pa.us        8658                 :UBC           0 :             | IN_P OUT_P                        { $$ = FUNC_PARAM_INOUT; }
 6261 tgl@sss.pgh.pa.us        8659                 :CBC         283 :             | VARIADIC                          { $$ = FUNC_PARAM_VARIADIC; }
                               8660                 :                :         ;
                               8661                 :                : 
                               8662                 :                : /*
                               8663                 :                :  * Ideally param_name should be ColId, but that causes too many conflicts.
                               8664                 :                :  */
                               8665                 :                : param_name: type_function_name
                               8666                 :                :         ;
                               8667                 :                : 
                               8668                 :                : func_return:
                               8669                 :                :             func_type
                               8670                 :                :                 {
                               8671                 :                :                     /* We can catch over-specified results here if we want to,
                               8672                 :                :                      * but for now better to silently swallow typmod, etc.
                               8673                 :                :                      * - thomas 2000-03-22
                               8674                 :                :                      */
 9294 lockhart@fourpalms.o     8675                 :          11841 :                     $$ = $1;
                               8676                 :                :                 }
                               8677                 :                :         ;
                               8678                 :                : 
                               8679                 :                : /*
                               8680                 :                :  * We would like to make the %TYPE productions here be ColId attrs etc,
                               8681                 :                :  * but that causes reduce/reduce conflicts.  type_function_name
                               8682                 :                :  * is next best choice.
                               8683                 :                :  */
 8482 bruce@momjian.us         8684                 :          62336 : func_type:  Typename                                { $$ = $1; }
                               8685                 :                :             | type_function_name attrs '%' TYPE_P
                               8686                 :                :                 {
 6825 tgl@sss.pgh.pa.us        8687                 :              9 :                     $$ = makeTypeNameFromNameList(lcons(makeString($1), $2));
 8562                          8688                 :              9 :                     $$->pct_type = true;
 7116                          8689                 :              9 :                     $$->location = @1;
                               8690                 :                :                 }
                               8691                 :                :             | SETOF type_function_name attrs '%' TYPE_P
                               8692                 :                :                 {
 6825                          8693                 :              3 :                     $$ = makeTypeNameFromNameList(lcons(makeString($2), $3));
 7158                          8694                 :              3 :                     $$->pct_type = true;
 2943 peter_e@gmx.net          8695                 :              3 :                     $$->setof = true;
 7116 tgl@sss.pgh.pa.us        8696                 :              3 :                     $$->location = @2;
                               8697                 :                :                 }
                               8698                 :                :         ;
                               8699                 :                : 
                               8700                 :                : func_arg_with_default:
                               8701                 :                :         func_arg
                               8702                 :                :                 {
 5058 peter_e@gmx.net          8703                 :          24619 :                     $$ = $1;
                               8704                 :                :                 }
                               8705                 :                :         | func_arg DEFAULT a_expr
                               8706                 :                :                 {
                               8707                 :           3074 :                     $$ = $1;
                               8708                 :           3074 :                     $$->defexpr = $3;
                               8709                 :                :                 }
                               8710                 :                :         | func_arg '=' a_expr
                               8711                 :                :                 {
                               8712                 :             98 :                     $$ = $1;
                               8713                 :             98 :                     $$->defexpr = $3;
                               8714                 :                :                 }
                               8715                 :                :         ;
                               8716                 :                : 
                               8717                 :                : /* Aggregate args can be most things that function args can be */
                               8718                 :                : aggr_arg:   func_arg
                               8719                 :                :                 {
 1549 tgl@sss.pgh.pa.us        8720         [ +  + ]:            450 :                     if (!($1->mode == FUNC_PARAM_DEFAULT ||
                               8721         [ +  - ]:             30 :                           $1->mode == FUNC_PARAM_IN ||
 4386                          8722         [ -  + ]:             30 :                           $1->mode == FUNC_PARAM_VARIADIC))
 4386 tgl@sss.pgh.pa.us        8723         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               8724                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               8725                 :                :                                  errmsg("aggregates cannot have output arguments"),
                               8726                 :                :                                  parser_errposition(@1)));
 4386 tgl@sss.pgh.pa.us        8727                 :CBC         450 :                     $$ = $1;
                               8728                 :                :                 }
                               8729                 :                :         ;
                               8730                 :                : 
                               8731                 :                : /*
                               8732                 :                :  * The SQL standard offers no guidance on how to declare aggregate argument
                               8733                 :                :  * lists, since it doesn't have CREATE AGGREGATE etc.  We accept these cases:
                               8734                 :                :  *
                               8735                 :                :  * (*)                                  - normal agg with no args
                               8736                 :                :  * (aggr_arg,...)                       - normal agg with args
                               8737                 :                :  * (ORDER BY aggr_arg,...)              - ordered-set agg with no direct args
                               8738                 :                :  * (aggr_arg,... ORDER BY aggr_arg,...) - ordered-set agg with direct args
                               8739                 :                :  *
                               8740                 :                :  * The zero-argument case is spelled with '*' for consistency with COUNT(*).
                               8741                 :                :  *
                               8742                 :                :  * An additional restriction is that if the direct-args list ends in a
                               8743                 :                :  * VARIADIC item, the ordered-args list must contain exactly one item that
                               8744                 :                :  * is also VARIADIC with the same type.  This allows us to collapse the two
                               8745                 :                :  * VARIADIC items into one, which is necessary to represent the aggregate in
                               8746                 :                :  * pg_proc.  We check this at the grammar stage so that we can return a list
                               8747                 :                :  * in which the second VARIADIC item is already discarded, avoiding extra work
                               8748                 :                :  * in cases such as DROP AGGREGATE.
                               8749                 :                :  *
                               8750                 :                :  * The return value of this production is a two-element list, in which the
                               8751                 :                :  * first item is a sublist of FunctionParameter nodes (with any duplicate
                               8752                 :                :  * VARIADIC item already dropped, as per above) and the second is an Integer
                               8753                 :                :  * node, containing -1 if there was no ORDER BY and otherwise the number
                               8754                 :                :  * of argument declarations before the ORDER BY.  (If this number is equal
                               8755                 :                :  * to the first sublist's length, then we dropped a duplicate VARIADIC item.)
                               8756                 :                :  * This representation is passed as-is to CREATE AGGREGATE; for operations
                               8757                 :                :  * on existing aggregates, we can just apply extractArgTypes to the first
                               8758                 :                :  * sublist.
                               8759                 :                :  */
                               8760                 :                : aggr_args:  '(' '*' ')'
                               8761                 :                :                 {
 4275                          8762                 :             68 :                     $$ = list_make2(NIL, makeInteger(-1));
                               8763                 :                :                 }
                               8764                 :                :             | '(' aggr_args_list ')'
                               8765                 :                :                 {
                               8766                 :            366 :                     $$ = list_make2($2, makeInteger(-1));
                               8767                 :                :                 }
                               8768                 :                :             | '(' ORDER BY aggr_args_list ')'
                               8769                 :                :                 {
                               8770                 :              3 :                     $$ = list_make2($4, makeInteger(0));
                               8771                 :                :                 }
                               8772                 :                :             | '(' aggr_args_list ORDER BY aggr_args_list ')'
                               8773                 :                :                 {
                               8774                 :                :                     /* this is the only case requiring consistency checking */
                               8775                 :             16 :                     $$ = makeOrderedSetArgs($2, $5, yyscanner);
                               8776                 :                :                 }
                               8777                 :                :         ;
                               8778                 :                : 
                               8779                 :                : aggr_args_list:
 4386                          8780                 :            401 :             aggr_arg                                { $$ = list_make1($1); }
                               8781                 :             49 :             | aggr_args_list ',' aggr_arg           { $$ = lappend($1, $3); }
                               8782                 :                :         ;
                               8783                 :                : 
                               8784                 :                : aggregate_with_argtypes:
                               8785                 :                :             func_name aggr_args
                               8786                 :                :                 {
 3174 peter_e@gmx.net          8787                 :            181 :                     ObjectWithArgs *n = makeNode(ObjectWithArgs);
                               8788                 :                : 
                               8789                 :            181 :                     n->objname = $1;
                               8790                 :            181 :                     n->objargs = extractAggrArgTypes($2);
 1549 tgl@sss.pgh.pa.us        8791                 :            181 :                     n->objfuncargs = (List *) linitial($2);
 3278 peter_e@gmx.net          8792                 :            181 :                     $$ = n;
                               8793                 :                :                 }
                               8794                 :                :         ;
                               8795                 :                : 
                               8796                 :                : aggregate_with_argtypes_list:
 3174                          8797                 :             52 :             aggregate_with_argtypes                 { $$ = list_make1($1); }
                               8798                 :                :             | aggregate_with_argtypes_list ',' aggregate_with_argtypes
 3174 peter_e@gmx.net          8799                 :UBC           0 :                                                     { $$ = lappend($1, $3); }
                               8800                 :                :         ;
                               8801                 :                : 
                               8802                 :                : opt_createfunc_opt_list:
                               8803                 :                :             createfunc_opt_list
 1613 peter@eisentraut.org     8804                 :CBC          27 :             | /*EMPTY*/ { $$ = NIL; }
                               8805                 :                :     ;
                               8806                 :                : 
                               8807                 :                : createfunc_opt_list:
                               8808                 :                :             /* Must be at least one to prevent conflict */
 5058 peter_e@gmx.net          8809                 :          12335 :             createfunc_opt_item                     { $$ = list_make1($1); }
 8481 bruce@momjian.us         8810                 :          32883 :             | createfunc_opt_list createfunc_opt_item { $$ = lappend($1, $2); }
                               8811                 :                :     ;
                               8812                 :                : 
                               8813                 :                : /*
                               8814                 :                :  * Options common to both CREATE FUNCTION and ALTER FUNCTION
                               8815                 :                :  */
                               8816                 :                : common_func_opt_item:
                               8817                 :                :             CALLED ON NULL_P INPUT_P
                               8818                 :                :                 {
 1212 peter@eisentraut.org     8819                 :            159 :                     $$ = makeDefElem("strict", (Node *) makeBoolean(false), @1);
                               8820                 :                :                 }
                               8821                 :                :             | RETURNS NULL_P ON NULL_P INPUT_P
                               8822                 :                :                 {
                               8823                 :            441 :                     $$ = makeDefElem("strict", (Node *) makeBoolean(true), @1);
                               8824                 :                :                 }
                               8825                 :                :             | STRICT_P
                               8826                 :                :                 {
                               8827                 :           6681 :                     $$ = makeDefElem("strict", (Node *) makeBoolean(true), @1);
                               8828                 :                :                 }
                               8829                 :                :             | IMMUTABLE
                               8830                 :                :                 {
                               8831                 :           5099 :                     $$ = makeDefElem("volatility", (Node *) makeString("immutable"), @1);
                               8832                 :                :                 }
                               8833                 :                :             | STABLE
                               8834                 :                :                 {
                               8835                 :           1262 :                     $$ = makeDefElem("volatility", (Node *) makeString("stable"), @1);
                               8836                 :                :                 }
                               8837                 :                :             | VOLATILE
                               8838                 :                :                 {
                               8839                 :            837 :                     $$ = makeDefElem("volatility", (Node *) makeString("volatile"), @1);
                               8840                 :                :                 }
                               8841                 :                :             | EXTERNAL SECURITY DEFINER
                               8842                 :                :                 {
 1212 peter@eisentraut.org     8843                 :UBC           0 :                     $$ = makeDefElem("security", (Node *) makeBoolean(true), @1);
                               8844                 :                :                 }
                               8845                 :                :             | EXTERNAL SECURITY INVOKER
                               8846                 :                :                 {
                               8847                 :              0 :                     $$ = makeDefElem("security", (Node *) makeBoolean(false), @1);
                               8848                 :                :                 }
                               8849                 :                :             | SECURITY DEFINER
                               8850                 :                :                 {
 1212 peter@eisentraut.org     8851                 :CBC          31 :                     $$ = makeDefElem("security", (Node *) makeBoolean(true), @1);
                               8852                 :                :                 }
                               8853                 :                :             | SECURITY INVOKER
                               8854                 :                :                 {
                               8855                 :              9 :                     $$ = makeDefElem("security", (Node *) makeBoolean(false), @1);
                               8856                 :                :                 }
                               8857                 :                :             | LEAKPROOF
                               8858                 :                :                 {
                               8859                 :             23 :                     $$ = makeDefElem("leakproof", (Node *) makeBoolean(true), @1);
                               8860                 :                :                 }
                               8861                 :                :             | NOT LEAKPROOF
                               8862                 :                :                 {
                               8863                 :              6 :                     $$ = makeDefElem("leakproof", (Node *) makeBoolean(false), @1);
                               8864                 :                :                 }
                               8865                 :                :             | COST NumericOnly
                               8866                 :                :                 {
                               8867                 :           2180 :                     $$ = makeDefElem("cost", (Node *) $2, @1);
                               8868                 :                :                 }
                               8869                 :                :             | ROWS NumericOnly
                               8870                 :                :                 {
                               8871                 :            300 :                     $$ = makeDefElem("rows", (Node *) $2, @1);
                               8872                 :                :                 }
                               8873                 :                :             | SUPPORT any_name
                               8874                 :                :                 {
                               8875                 :             57 :                     $$ = makeDefElem("support", (Node *) $2, @1);
                               8876                 :                :                 }
                               8877                 :                :             | FunctionSetResetClause
                               8878                 :                :                 {
                               8879                 :                :                     /* we abuse the normal content of a DefElem here */
                               8880                 :             63 :                     $$ = makeDefElem("set", (Node *) $1, @1);
                               8881                 :                :                 }
                               8882                 :                :             | PARALLEL ColId
                               8883                 :                :                 {
                               8884                 :           6848 :                     $$ = makeDefElem("parallel", (Node *) makeString($2), @1);
                               8885                 :                :                 }
                               8886                 :                :         ;
                               8887                 :                : 
                               8888                 :                : createfunc_opt_item:
                               8889                 :                :             AS func_as
                               8890                 :                :                 {
                               8891                 :           9525 :                     $$ = makeDefElem("as", (Node *) $2, @1);
                               8892                 :                :                 }
                               8893                 :                :             | LANGUAGE NonReservedWord_or_Sconst
                               8894                 :                :                 {
                               8895                 :          12325 :                     $$ = makeDefElem("language", (Node *) makeString($2), @1);
                               8896                 :                :                 }
                               8897                 :                :             | TRANSFORM transform_type_list
                               8898                 :                :                 {
                               8899                 :             59 :                     $$ = makeDefElem("transform", (Node *) $2, @1);
                               8900                 :                :                 }
                               8901                 :                :             | WINDOW
                               8902                 :                :                 {
                               8903                 :             10 :                     $$ = makeDefElem("window", (Node *) makeBoolean(true), @1);
                               8904                 :                :                 }
                               8905                 :                :             | common_func_opt_item
                               8906                 :                :                 {
 7481 neilc@samurai.com        8907                 :          23299 :                     $$ = $1;
                               8908                 :                :                 }
                               8909                 :                :         ;
                               8910                 :                : 
 7769                          8911                 :           8192 : func_as:    Sconst                      { $$ = list_make1(makeString($1)); }
                               8912                 :                :             | Sconst ',' Sconst
                               8913                 :                :                 {
                               8914                 :           1333 :                     $$ = list_make2(makeString($1), makeString($3));
                               8915                 :                :                 }
                               8916                 :                :         ;
                               8917                 :                : 
                               8918                 :                : ReturnStmt: RETURN a_expr
                               8919                 :                :                 {
 1613 peter@eisentraut.org     8920                 :           2439 :                     ReturnStmt *r = makeNode(ReturnStmt);
                               8921                 :                : 
                               8922                 :           2439 :                     r->returnval = (Node *) $2;
                               8923                 :           2439 :                     $$ = (Node *) r;
                               8924                 :                :                 }
                               8925                 :                :         ;
                               8926                 :                : 
                               8927                 :                : opt_routine_body:
                               8928                 :                :             ReturnStmt
                               8929                 :                :                 {
                               8930                 :           2436 :                     $$ = $1;
                               8931                 :                :                 }
                               8932                 :                :             | BEGIN_P ATOMIC routine_body_stmt_list END_P
                               8933                 :                :                 {
                               8934                 :                :                     /*
                               8935                 :                :                      * A compound statement is stored as a single-item list
                               8936                 :                :                      * containing the list of statements as its member.  That
                               8937                 :                :                      * way, the parse analysis code can tell apart an empty
                               8938                 :                :                      * body from no body at all.
                               8939                 :                :                      */
                               8940                 :            404 :                     $$ = (Node *) list_make1($3);
                               8941                 :                :                 }
                               8942                 :                :             | /*EMPTY*/
                               8943                 :                :                 {
                               8944                 :           9522 :                     $$ = NULL;
                               8945                 :                :                 }
                               8946                 :                :         ;
                               8947                 :                : 
                               8948                 :                : routine_body_stmt_list:
                               8949                 :                :             routine_body_stmt_list routine_body_stmt ';'
                               8950                 :                :                 {
                               8951                 :                :                     /* As in stmtmulti, discard empty statements */
 1551 tgl@sss.pgh.pa.us        8952         [ +  + ]:            412 :                     if ($2 != NULL)
                               8953                 :            403 :                         $$ = lappend($1, $2);
                               8954                 :                :                     else
                               8955                 :              9 :                         $$ = $1;
                               8956                 :                :                 }
                               8957                 :                :             | /*EMPTY*/
                               8958                 :                :                 {
 1613 peter@eisentraut.org     8959                 :            404 :                     $$ = NIL;
                               8960                 :                :                 }
                               8961                 :                :         ;
                               8962                 :                : 
                               8963                 :                : routine_body_stmt:
                               8964                 :                :             stmt
                               8965                 :                :             | ReturnStmt
                               8966                 :                :         ;
                               8967                 :                : 
                               8968                 :                : transform_type_list:
 3786 peter_e@gmx.net          8969                 :             59 :             FOR TYPE_P Typename { $$ = list_make1($3); }
                               8970                 :              2 :             | transform_type_list ',' FOR TYPE_P Typename { $$ = lappend($1, $5); }
                               8971                 :                :         ;
                               8972                 :                : 
                               8973                 :                : opt_definition:
 8482 bruce@momjian.us         8974                 :            326 :             WITH definition                         { $$ = $2; }
                               8975                 :           5086 :             | /*EMPTY*/                             { $$ = NIL; }
                               8976                 :                :         ;
                               8977                 :                : 
                               8978                 :                : table_func_column:  param_name func_type
                               8979                 :                :                 {
 6259 tgl@sss.pgh.pa.us        8980                 :            227 :                     FunctionParameter *n = makeNode(FunctionParameter);
                               8981                 :                : 
                               8982                 :            227 :                     n->name = $1;
                               8983                 :            227 :                     n->argType = $2;
                               8984                 :            227 :                     n->mode = FUNC_PARAM_TABLE;
 6106                          8985                 :            227 :                     n->defexpr = NULL;
  310                          8986                 :            227 :                     n->location = @1;
 6259                          8987                 :            227 :                     $$ = n;
                               8988                 :                :                 }
                               8989                 :                :         ;
                               8990                 :                : 
                               8991                 :                : table_func_column_list:
                               8992                 :                :             table_func_column
                               8993                 :                :                 {
                               8994                 :             97 :                     $$ = list_make1($1);
                               8995                 :                :                 }
                               8996                 :                :             | table_func_column_list ',' table_func_column
                               8997                 :                :                 {
                               8998                 :            130 :                     $$ = lappend($1, $3);
                               8999                 :                :                 }
                               9000                 :                :         ;
                               9001                 :                : 
                               9002                 :                : /*****************************************************************************
                               9003                 :                :  * ALTER FUNCTION / ALTER PROCEDURE / ALTER ROUTINE
                               9004                 :                :  *
                               9005                 :                :  * RENAME and OWNER subcommands are already provided by the generic
                               9006                 :                :  * ALTER infrastructure, here we just specify alterations that can
                               9007                 :                :  * only be applied to functions.
                               9008                 :                :  *
                               9009                 :                :  *****************************************************************************/
                               9010                 :                : AlterFunctionStmt:
                               9011                 :                :             ALTER FUNCTION function_with_argtypes alterfunc_opt_list opt_restrict
                               9012                 :                :                 {
 7481 neilc@samurai.com        9013                 :            686 :                     AlterFunctionStmt *n = makeNode(AlterFunctionStmt);
                               9014                 :                : 
 2837 peter_e@gmx.net          9015                 :            686 :                     n->objtype = OBJECT_FUNCTION;
                               9016                 :            686 :                     n->func = $3;
                               9017                 :            686 :                     n->actions = $4;
                               9018                 :            686 :                     $$ = (Node *) n;
                               9019                 :                :                 }
                               9020                 :                :             | ALTER PROCEDURE function_with_argtypes alterfunc_opt_list opt_restrict
                               9021                 :                :                 {
                               9022                 :              9 :                     AlterFunctionStmt *n = makeNode(AlterFunctionStmt);
                               9023                 :                : 
                               9024                 :              9 :                     n->objtype = OBJECT_PROCEDURE;
                               9025                 :              9 :                     n->func = $3;
                               9026                 :              9 :                     n->actions = $4;
                               9027                 :              9 :                     $$ = (Node *) n;
                               9028                 :                :                 }
                               9029                 :                :             | ALTER ROUTINE function_with_argtypes alterfunc_opt_list opt_restrict
                               9030                 :                :                 {
 2837 peter_e@gmx.net          9031                 :UBC           0 :                     AlterFunctionStmt *n = makeNode(AlterFunctionStmt);
                               9032                 :                : 
                               9033                 :              0 :                     n->objtype = OBJECT_ROUTINE;
 7466 tgl@sss.pgh.pa.us        9034                 :              0 :                     n->func = $3;
 7481 neilc@samurai.com        9035                 :              0 :                     n->actions = $4;
                               9036                 :              0 :                     $$ = (Node *) n;
                               9037                 :                :                 }
                               9038                 :                :         ;
                               9039                 :                : 
                               9040                 :                : alterfunc_opt_list:
                               9041                 :                :             /* At least one option must be specified */
 7481 neilc@samurai.com        9042                 :CBC         695 :             common_func_opt_item                    { $$ = list_make1($1); }
                               9043                 :              2 :             | alterfunc_opt_list common_func_opt_item { $$ = lappend($1, $2); }
                               9044                 :                :         ;
                               9045                 :                : 
                               9046                 :                : /* Ignored, merely for SQL compliance */
                               9047                 :                : opt_restrict:
                               9048                 :                :             RESTRICT
                               9049                 :                :             | /* EMPTY */
                               9050                 :                :         ;
                               9051                 :                : 
                               9052                 :                : 
                               9053                 :                : /*****************************************************************************
                               9054                 :                :  *
                               9055                 :                :  *      QUERY:
                               9056                 :                :  *
                               9057                 :                :  *      DROP FUNCTION funcname (arg1, arg2, ...) [ RESTRICT | CASCADE ]
                               9058                 :                :  *      DROP PROCEDURE procname (arg1, arg2, ...) [ RESTRICT | CASCADE ]
                               9059                 :                :  *      DROP ROUTINE routname (arg1, arg2, ...) [ RESTRICT | CASCADE ]
                               9060                 :                :  *      DROP AGGREGATE aggname (arg1, ...) [ RESTRICT | CASCADE ]
                               9061                 :                :  *      DROP OPERATOR opname (leftoperand_typ, rightoperand_typ) [ RESTRICT | CASCADE ]
                               9062                 :                :  *
                               9063                 :                :  *****************************************************************************/
                               9064                 :                : 
                               9065                 :                : RemoveFuncStmt:
                               9066                 :                :             DROP FUNCTION function_with_argtypes_list opt_drop_behavior
                               9067                 :                :                 {
 5042 rhaas@postgresql.org     9068                 :           1651 :                     DropStmt *n = makeNode(DropStmt);
                               9069                 :                : 
                               9070                 :           1651 :                     n->removeType = OBJECT_FUNCTION;
 3174 peter_e@gmx.net          9071                 :           1651 :                     n->objects = $3;
 3278                          9072                 :           1651 :                     n->behavior = $4;
 7022 andrew@dunslane.net      9073                 :           1651 :                     n->missing_ok = false;
 4901 simon@2ndQuadrant.co     9074                 :           1651 :                     n->concurrent = false;
 1212 peter@eisentraut.org     9075                 :           1651 :                     $$ = (Node *) n;
                               9076                 :                :                 }
                               9077                 :                :             | DROP FUNCTION IF_P EXISTS function_with_argtypes_list opt_drop_behavior
                               9078                 :                :                 {
 5042 rhaas@postgresql.org     9079                 :            130 :                     DropStmt *n = makeNode(DropStmt);
                               9080                 :                : 
                               9081                 :            130 :                     n->removeType = OBJECT_FUNCTION;
 3174 peter_e@gmx.net          9082                 :            130 :                     n->objects = $5;
 3278                          9083                 :            130 :                     n->behavior = $6;
 7022 andrew@dunslane.net      9084                 :            130 :                     n->missing_ok = true;
 4901 simon@2ndQuadrant.co     9085                 :            130 :                     n->concurrent = false;
 1212 peter@eisentraut.org     9086                 :            130 :                     $$ = (Node *) n;
                               9087                 :                :                 }
                               9088                 :                :             | DROP PROCEDURE function_with_argtypes_list opt_drop_behavior
                               9089                 :                :                 {
 2837 peter_e@gmx.net          9090                 :             70 :                     DropStmt *n = makeNode(DropStmt);
                               9091                 :                : 
                               9092                 :             70 :                     n->removeType = OBJECT_PROCEDURE;
                               9093                 :             70 :                     n->objects = $3;
                               9094                 :             70 :                     n->behavior = $4;
                               9095                 :             70 :                     n->missing_ok = false;
                               9096                 :             70 :                     n->concurrent = false;
 1212 peter@eisentraut.org     9097                 :             70 :                     $$ = (Node *) n;
                               9098                 :                :                 }
                               9099                 :                :             | DROP PROCEDURE IF_P EXISTS function_with_argtypes_list opt_drop_behavior
                               9100                 :                :                 {
 2837 peter_e@gmx.net          9101                 :              3 :                     DropStmt *n = makeNode(DropStmt);
                               9102                 :                : 
                               9103                 :              3 :                     n->removeType = OBJECT_PROCEDURE;
                               9104                 :              3 :                     n->objects = $5;
                               9105                 :              3 :                     n->behavior = $6;
                               9106                 :              3 :                     n->missing_ok = true;
                               9107                 :              3 :                     n->concurrent = false;
 1212 peter@eisentraut.org     9108                 :              3 :                     $$ = (Node *) n;
                               9109                 :                :                 }
                               9110                 :                :             | DROP ROUTINE function_with_argtypes_list opt_drop_behavior
                               9111                 :                :                 {
 2837 peter_e@gmx.net          9112                 :              6 :                     DropStmt *n = makeNode(DropStmt);
                               9113                 :                : 
                               9114                 :              6 :                     n->removeType = OBJECT_ROUTINE;
                               9115                 :              6 :                     n->objects = $3;
                               9116                 :              6 :                     n->behavior = $4;
                               9117                 :              6 :                     n->missing_ok = false;
                               9118                 :              6 :                     n->concurrent = false;
 1212 peter@eisentraut.org     9119                 :              6 :                     $$ = (Node *) n;
                               9120                 :                :                 }
                               9121                 :                :             | DROP ROUTINE IF_P EXISTS function_with_argtypes_list opt_drop_behavior
                               9122                 :                :                 {
 2837 peter_e@gmx.net          9123                 :              3 :                     DropStmt *n = makeNode(DropStmt);
                               9124                 :                : 
                               9125                 :              3 :                     n->removeType = OBJECT_ROUTINE;
                               9126                 :              3 :                     n->objects = $5;
                               9127                 :              3 :                     n->behavior = $6;
                               9128                 :              3 :                     n->missing_ok = true;
                               9129                 :              3 :                     n->concurrent = false;
 1212 peter@eisentraut.org     9130                 :              3 :                     $$ = (Node *) n;
                               9131                 :                :                 }
                               9132                 :                :         ;
                               9133                 :                : 
                               9134                 :                : RemoveAggrStmt:
                               9135                 :                :             DROP AGGREGATE aggregate_with_argtypes_list opt_drop_behavior
                               9136                 :                :                 {
 5042 rhaas@postgresql.org     9137                 :             37 :                     DropStmt *n = makeNode(DropStmt);
                               9138                 :                : 
                               9139                 :             37 :                     n->removeType = OBJECT_AGGREGATE;
 3174 peter_e@gmx.net          9140                 :             37 :                     n->objects = $3;
 3278                          9141                 :             37 :                     n->behavior = $4;
 7022 andrew@dunslane.net      9142                 :             37 :                     n->missing_ok = false;
 4901 simon@2ndQuadrant.co     9143                 :             37 :                     n->concurrent = false;
 1212 peter@eisentraut.org     9144                 :             37 :                     $$ = (Node *) n;
                               9145                 :                :                 }
                               9146                 :                :             | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes_list opt_drop_behavior
                               9147                 :                :                 {
 5042 rhaas@postgresql.org     9148                 :             15 :                     DropStmt *n = makeNode(DropStmt);
                               9149                 :                : 
                               9150                 :             15 :                     n->removeType = OBJECT_AGGREGATE;
 3174 peter_e@gmx.net          9151                 :             15 :                     n->objects = $5;
 3278                          9152                 :             15 :                     n->behavior = $6;
 7022 andrew@dunslane.net      9153                 :             15 :                     n->missing_ok = true;
 4901 simon@2ndQuadrant.co     9154                 :             15 :                     n->concurrent = false;
 1212 peter@eisentraut.org     9155                 :             15 :                     $$ = (Node *) n;
                               9156                 :                :                 }
                               9157                 :                :         ;
                               9158                 :                : 
                               9159                 :                : RemoveOperStmt:
                               9160                 :                :             DROP OPERATOR operator_with_argtypes_list opt_drop_behavior
                               9161                 :                :                 {
 5042 rhaas@postgresql.org     9162                 :            100 :                     DropStmt *n = makeNode(DropStmt);
                               9163                 :                : 
                               9164                 :            100 :                     n->removeType = OBJECT_OPERATOR;
 3174 peter_e@gmx.net          9165                 :            100 :                     n->objects = $3;
                               9166                 :            100 :                     n->behavior = $4;
 7022 andrew@dunslane.net      9167                 :            100 :                     n->missing_ok = false;
 4901 simon@2ndQuadrant.co     9168                 :            100 :                     n->concurrent = false;
 1212 peter@eisentraut.org     9169                 :            100 :                     $$ = (Node *) n;
                               9170                 :                :                 }
                               9171                 :                :             | DROP OPERATOR IF_P EXISTS operator_with_argtypes_list opt_drop_behavior
                               9172                 :                :                 {
 5042 rhaas@postgresql.org     9173                 :             15 :                     DropStmt *n = makeNode(DropStmt);
                               9174                 :                : 
                               9175                 :             15 :                     n->removeType = OBJECT_OPERATOR;
 3174 peter_e@gmx.net          9176                 :             15 :                     n->objects = $5;
                               9177                 :             15 :                     n->behavior = $6;
 7022 andrew@dunslane.net      9178                 :             15 :                     n->missing_ok = true;
 4901 simon@2ndQuadrant.co     9179                 :             15 :                     n->concurrent = false;
 1212 peter@eisentraut.org     9180                 :             15 :                     $$ = (Node *) n;
                               9181                 :                :                 }
                               9182                 :                :         ;
                               9183                 :                : 
                               9184                 :                : oper_argtypes:
                               9185                 :                :             '(' Typename ')'
                               9186                 :                :                 {
 8085 tgl@sss.pgh.pa.us        9187         [ +  - ]:              6 :                    ereport(ERROR,
                               9188                 :                :                            (errcode(ERRCODE_SYNTAX_ERROR),
                               9189                 :                :                             errmsg("missing argument"),
                               9190                 :                :                             errhint("Use NONE to denote the missing argument of a unary operator."),
                               9191                 :                :                             parser_errposition(@3)));
                               9192                 :                :                 }
                               9193                 :                :             | '(' Typename ',' Typename ')'
 6214                          9194                 :           1232 :                     { $$ = list_make2($2, $4); }
                               9195                 :                :             | '(' NONE ',' Typename ')'                 /* left unary */
                               9196                 :             16 :                     { $$ = list_make2(NULL, $4); }
                               9197                 :                :             | '(' Typename ',' NONE ')'                 /* right unary */
                               9198                 :              6 :                     { $$ = list_make2($2, NULL); }
                               9199                 :                :         ;
                               9200                 :                : 
                               9201                 :                : any_operator:
                               9202                 :                :             all_Op
 7769 neilc@samurai.com        9203                 :          11069 :                     { $$ = list_make1(makeString($1)); }
                               9204                 :                :             | ColId '.' any_operator
 8481 bruce@momjian.us         9205                 :           7944 :                     { $$ = lcons(makeString($1), $3); }
                               9206                 :                :         ;
                               9207                 :                : 
                               9208                 :                : operator_with_argtypes_list:
 3174 peter_e@gmx.net          9209                 :            115 :             operator_with_argtypes                  { $$ = list_make1($1); }
                               9210                 :                :             | operator_with_argtypes_list ',' operator_with_argtypes
 3174 peter_e@gmx.net          9211                 :UBC           0 :                                                     { $$ = lappend($1, $3); }
                               9212                 :                :         ;
                               9213                 :                : 
                               9214                 :                : operator_with_argtypes:
                               9215                 :                :             any_operator oper_argtypes
                               9216                 :                :                 {
 3174 peter_e@gmx.net          9217                 :CBC        1254 :                     ObjectWithArgs *n = makeNode(ObjectWithArgs);
                               9218                 :                : 
                               9219                 :           1254 :                     n->objname = $1;
                               9220                 :           1254 :                     n->objargs = $2;
                               9221                 :           1254 :                     $$ = n;
                               9222                 :                :                 }
                               9223                 :                :         ;
                               9224                 :                : 
                               9225                 :                : /*****************************************************************************
                               9226                 :                :  *
                               9227                 :                :  *      DO <anonymous code block> [ LANGUAGE language ]
                               9228                 :                :  *
                               9229                 :                :  * We use a DefElem list for future extensibility, and to allow flexibility
                               9230                 :                :  * in the clause order.
                               9231                 :                :  *
                               9232                 :                :  *****************************************************************************/
                               9233                 :                : 
                               9234                 :                : DoStmt: DO dostmt_opt_list
                               9235                 :                :                 {
 5828 tgl@sss.pgh.pa.us        9236                 :            569 :                     DoStmt *n = makeNode(DoStmt);
                               9237                 :                : 
                               9238                 :            569 :                     n->args = $2;
 1212 peter@eisentraut.org     9239                 :            569 :                     $$ = (Node *) n;
                               9240                 :                :                 }
                               9241                 :                :         ;
                               9242                 :                : 
                               9243                 :                : dostmt_opt_list:
 5828 tgl@sss.pgh.pa.us        9244                 :            569 :             dostmt_opt_item                     { $$ = list_make1($1); }
                               9245                 :             99 :             | dostmt_opt_list dostmt_opt_item   { $$ = lappend($1, $2); }
                               9246                 :                :         ;
                               9247                 :                : 
                               9248                 :                : dostmt_opt_item:
                               9249                 :                :             Sconst
                               9250                 :                :                 {
 1212 peter@eisentraut.org     9251                 :            569 :                     $$ = makeDefElem("as", (Node *) makeString($1), @1);
                               9252                 :                :                 }
                               9253                 :                :             | LANGUAGE NonReservedWord_or_Sconst
                               9254                 :                :                 {
                               9255                 :             99 :                     $$ = makeDefElem("language", (Node *) makeString($2), @1);
                               9256                 :                :                 }
                               9257                 :                :         ;
                               9258                 :                : 
                               9259                 :                : /*****************************************************************************
                               9260                 :                :  *
                               9261                 :                :  *      CREATE CAST / DROP CAST
                               9262                 :                :  *
                               9263                 :                :  *****************************************************************************/
                               9264                 :                : 
                               9265                 :                : CreateCastStmt: CREATE CAST '(' Typename AS Typename ')'
                               9266                 :                :                     WITH FUNCTION function_with_argtypes cast_context
                               9267                 :                :                 {
 8451 peter_e@gmx.net          9268                 :             54 :                     CreateCastStmt *n = makeNode(CreateCastStmt);
                               9269                 :                : 
                               9270                 :             54 :                     n->sourcetype = $4;
                               9271                 :             54 :                     n->targettype = $6;
 7466 tgl@sss.pgh.pa.us        9272                 :             54 :                     n->func = $10;
 8389                          9273                 :             54 :                     n->context = (CoercionContext) $11;
 6154 heikki.linnakangas@i     9274                 :             54 :                     n->inout = false;
 1212 peter@eisentraut.org     9275                 :             54 :                     $$ = (Node *) n;
                               9276                 :                :                 }
                               9277                 :                :             | CREATE CAST '(' Typename AS Typename ')'
                               9278                 :                :                     WITHOUT FUNCTION cast_context
                               9279                 :                :                 {
 8451 peter_e@gmx.net          9280                 :             81 :                     CreateCastStmt *n = makeNode(CreateCastStmt);
                               9281                 :                : 
                               9282                 :             81 :                     n->sourcetype = $4;
                               9283                 :             81 :                     n->targettype = $6;
                               9284                 :             81 :                     n->func = NULL;
 8389 tgl@sss.pgh.pa.us        9285                 :             81 :                     n->context = (CoercionContext) $10;
 6154 heikki.linnakangas@i     9286                 :             81 :                     n->inout = false;
 1212 peter@eisentraut.org     9287                 :             81 :                     $$ = (Node *) n;
                               9288                 :                :                 }
                               9289                 :                :             | CREATE CAST '(' Typename AS Typename ')'
                               9290                 :                :                     WITH INOUT cast_context
                               9291                 :                :                 {
 6154 heikki.linnakangas@i     9292                 :              4 :                     CreateCastStmt *n = makeNode(CreateCastStmt);
                               9293                 :                : 
                               9294                 :              4 :                     n->sourcetype = $4;
                               9295                 :              4 :                     n->targettype = $6;
                               9296                 :              4 :                     n->func = NULL;
                               9297                 :              4 :                     n->context = (CoercionContext) $10;
                               9298                 :              4 :                     n->inout = true;
 1212 peter@eisentraut.org     9299                 :              4 :                     $$ = (Node *) n;
                               9300                 :                :                 }
                               9301                 :                :         ;
                               9302                 :                : 
 8389 tgl@sss.pgh.pa.us        9303                 :             18 : cast_context:  AS IMPLICIT_P                    { $$ = COERCION_IMPLICIT; }
                               9304                 :             29 :         | AS ASSIGNMENT                         { $$ = COERCION_ASSIGNMENT; }
                               9305                 :             92 :         | /*EMPTY*/                             { $$ = COERCION_EXPLICIT; }
                               9306                 :                :         ;
                               9307                 :                : 
                               9308                 :                : 
                               9309                 :                : DropCastStmt: DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_behavior
                               9310                 :                :                 {
 5042 rhaas@postgresql.org     9311                 :             30 :                     DropStmt *n = makeNode(DropStmt);
                               9312                 :                : 
                               9313                 :             30 :                     n->removeType = OBJECT_CAST;
 3220 peter_e@gmx.net          9314                 :             30 :                     n->objects = list_make1(list_make2($5, $7));
 7022 andrew@dunslane.net      9315                 :             30 :                     n->behavior = $9;
      tgl@sss.pgh.pa.us        9316                 :             30 :                     n->missing_ok = $3;
 4901 simon@2ndQuadrant.co     9317                 :             30 :                     n->concurrent = false;
 1212 peter@eisentraut.org     9318                 :             30 :                     $$ = (Node *) n;
                               9319                 :                :                 }
                               9320                 :                :         ;
                               9321                 :                : 
 2943 peter_e@gmx.net          9322                 :             18 : opt_if_exists: IF_P EXISTS                      { $$ = true; }
                               9323                 :             19 :         | /*EMPTY*/                             { $$ = false; }
                               9324                 :                :         ;
                               9325                 :                : 
                               9326                 :                : 
                               9327                 :                : /*****************************************************************************
                               9328                 :                :  *
                               9329                 :                :  *      CREATE TRANSFORM / DROP TRANSFORM
                               9330                 :                :  *
                               9331                 :                :  *****************************************************************************/
                               9332                 :                : 
                               9333                 :                : CreateTransformStmt: CREATE opt_or_replace TRANSFORM FOR Typename LANGUAGE name '(' transform_element_list ')'
                               9334                 :                :                 {
 3786                          9335                 :             25 :                     CreateTransformStmt *n = makeNode(CreateTransformStmt);
                               9336                 :                : 
                               9337                 :             25 :                     n->replace = $2;
                               9338                 :             25 :                     n->type_name = $5;
                               9339                 :             25 :                     n->lang = $7;
                               9340                 :             25 :                     n->fromsql = linitial($9);
                               9341                 :             25 :                     n->tosql = lsecond($9);
 1212 peter@eisentraut.org     9342                 :             25 :                     $$ = (Node *) n;
                               9343                 :                :                 }
                               9344                 :                :         ;
                               9345                 :                : 
                               9346                 :                : transform_element_list: FROM SQL_P WITH FUNCTION function_with_argtypes ',' TO SQL_P WITH FUNCTION function_with_argtypes
                               9347                 :                :                 {
 3786 peter_e@gmx.net          9348                 :             22 :                     $$ = list_make2($5, $11);
                               9349                 :                :                 }
                               9350                 :                :                 | TO SQL_P WITH FUNCTION function_with_argtypes ',' FROM SQL_P WITH FUNCTION function_with_argtypes
                               9351                 :                :                 {
 3786 peter_e@gmx.net          9352                 :UBC           0 :                     $$ = list_make2($11, $5);
                               9353                 :                :                 }
                               9354                 :                :                 | FROM SQL_P WITH FUNCTION function_with_argtypes
                               9355                 :                :                 {
 3786 peter_e@gmx.net          9356                 :CBC           2 :                     $$ = list_make2($5, NULL);
                               9357                 :                :                 }
                               9358                 :                :                 | TO SQL_P WITH FUNCTION function_with_argtypes
                               9359                 :                :                 {
                               9360                 :              1 :                     $$ = list_make2(NULL, $5);
                               9361                 :                :                 }
                               9362                 :                :         ;
                               9363                 :                : 
                               9364                 :                : 
                               9365                 :                : DropTransformStmt: DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_drop_behavior
                               9366                 :                :                 {
                               9367                 :              7 :                     DropStmt *n = makeNode(DropStmt);
                               9368                 :                : 
                               9369                 :              7 :                     n->removeType = OBJECT_TRANSFORM;
 3220                          9370                 :              7 :                     n->objects = list_make1(list_make2($5, makeString($7)));
 3786                          9371                 :              7 :                     n->behavior = $8;
                               9372                 :              7 :                     n->missing_ok = $3;
 1212 peter@eisentraut.org     9373                 :              7 :                     $$ = (Node *) n;
                               9374                 :                :                 }
                               9375                 :                :         ;
                               9376                 :                : 
                               9377                 :                : 
                               9378                 :                : /*****************************************************************************
                               9379                 :                :  *
                               9380                 :                :  *      QUERY:
                               9381                 :                :  *
                               9382                 :                :  *      REINDEX [ (options) ] {INDEX | TABLE | SCHEMA} [CONCURRENTLY] <name>
                               9383                 :                :  *      REINDEX [ (options) ] {DATABASE | SYSTEM} [CONCURRENTLY] [<name>]
                               9384                 :                :  *****************************************************************************/
                               9385                 :                : 
                               9386                 :                : ReindexStmt:
                               9387                 :                :             REINDEX opt_utility_option_list reindex_target_relation opt_concurrently qualified_name
                               9388                 :                :                 {
 9332 inoue@tpf.co.jp          9389                 :            452 :                     ReindexStmt *n = makeNode(ReindexStmt);
                               9390                 :                : 
 1142 alvherre@alvh.no-ip.     9391                 :            452 :                     n->kind = $3;
                               9392                 :            452 :                     n->relation = $5;
 8570 tgl@sss.pgh.pa.us        9393                 :            452 :                     n->name = NULL;
 1142 alvherre@alvh.no-ip.     9394                 :            452 :                     n->params = $2;
                               9395         [ +  + ]:            452 :                     if ($4)
 1738 michael@paquier.xyz      9396                 :            257 :                         n->params = lappend(n->params,
 1142 alvherre@alvh.no-ip.     9397                 :            257 :                                             makeDefElem("concurrently", NULL, @4));
 1212 peter@eisentraut.org     9398                 :            452 :                     $$ = (Node *) n;
                               9399                 :                :                 }
                               9400                 :                :             | REINDEX opt_utility_option_list SCHEMA opt_concurrently name
                               9401                 :                :                 {
 3924 simon@2ndQuadrant.co     9402                 :             58 :                     ReindexStmt *n = makeNode(ReindexStmt);
                               9403                 :                : 
 1142 alvherre@alvh.no-ip.     9404                 :             58 :                     n->kind = REINDEX_OBJECT_SCHEMA;
 3924 simon@2ndQuadrant.co     9405                 :             58 :                     n->relation = NULL;
 1138 michael@paquier.xyz      9406                 :             58 :                     n->name = $5;
 1142 alvherre@alvh.no-ip.     9407                 :             58 :                     n->params = $2;
                               9408         [ +  + ]:             58 :                     if ($4)
 1738 michael@paquier.xyz      9409                 :             20 :                         n->params = lappend(n->params,
 1142 alvherre@alvh.no-ip.     9410                 :             20 :                                             makeDefElem("concurrently", NULL, @4));
 1212 peter@eisentraut.org     9411                 :             58 :                     $$ = (Node *) n;
                               9412                 :                :                 }
                               9413                 :                :             | REINDEX opt_utility_option_list reindex_target_all opt_concurrently opt_single_name
                               9414                 :                :                 {
 8570 tgl@sss.pgh.pa.us        9415                 :             34 :                     ReindexStmt *n = makeNode(ReindexStmt);
                               9416                 :                : 
 1138 michael@paquier.xyz      9417                 :             34 :                     n->kind = $3;
 8570 tgl@sss.pgh.pa.us        9418                 :             34 :                     n->relation = NULL;
 1138 michael@paquier.xyz      9419                 :             34 :                     n->name = $5;
 1142 alvherre@alvh.no-ip.     9420                 :             34 :                     n->params = $2;
 1138 michael@paquier.xyz      9421         [ +  + ]:             34 :                     if ($4)
                               9422                 :              5 :                         n->params = lappend(n->params,
                               9423                 :              5 :                                             makeDefElem("concurrently", NULL, @4));
 1212 peter@eisentraut.org     9424                 :             34 :                     $$ = (Node *) n;
                               9425                 :                :                 }
                               9426                 :                :         ;
                               9427                 :                : reindex_target_relation:
 3767 fujii@postgresql.org     9428                 :            195 :             INDEX                   { $$ = REINDEX_OBJECT_INDEX; }
                               9429                 :            257 :             | TABLE                 { $$ = REINDEX_OBJECT_TABLE; }
                               9430                 :                :         ;
                               9431                 :                : reindex_target_all:
 1138 michael@paquier.xyz      9432                 :             17 :             SYSTEM_P                { $$ = REINDEX_OBJECT_SYSTEM; }
                               9433                 :             17 :             | DATABASE              { $$ = REINDEX_OBJECT_DATABASE; }
                               9434                 :                :         ;
                               9435                 :                : 
                               9436                 :                : /*****************************************************************************
                               9437                 :                :  *
                               9438                 :                :  * ALTER TABLESPACE
                               9439                 :                :  *
                               9440                 :                :  *****************************************************************************/
                               9441                 :                : 
                               9442                 :                : AlterTblSpcStmt:
                               9443                 :                :             ALTER TABLESPACE name SET reloptions
                               9444                 :                :                 {
                               9445                 :                :                     AlterTableSpaceOptionsStmt *n =
 4164 sfrost@snowman.net       9446                 :              6 :                         makeNode(AlterTableSpaceOptionsStmt);
                               9447                 :                : 
                               9448                 :              6 :                     n->tablespacename = $3;
                               9449                 :              6 :                     n->options = $5;
 2943 peter_e@gmx.net          9450                 :              6 :                     n->isReset = false;
 1212 peter@eisentraut.org     9451                 :              6 :                     $$ = (Node *) n;
                               9452                 :                :                 }
                               9453                 :                :             | ALTER TABLESPACE name RESET reloptions
                               9454                 :                :                 {
                               9455                 :                :                     AlterTableSpaceOptionsStmt *n =
 4164 sfrost@snowman.net       9456                 :              6 :                         makeNode(AlterTableSpaceOptionsStmt);
                               9457                 :                : 
                               9458                 :              6 :                     n->tablespacename = $3;
                               9459                 :              6 :                     n->options = $5;
 2943 peter_e@gmx.net          9460                 :              6 :                     n->isReset = true;
 1212 peter@eisentraut.org     9461                 :              6 :                     $$ = (Node *) n;
                               9462                 :                :                 }
                               9463                 :                :         ;
                               9464                 :                : 
                               9465                 :                : /*****************************************************************************
                               9466                 :                :  *
                               9467                 :                :  * ALTER THING name RENAME TO newname
                               9468                 :                :  *
                               9469                 :                :  *****************************************************************************/
                               9470                 :                : 
                               9471                 :                : RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
                               9472                 :                :                 {
 8107 peter_e@gmx.net          9473                 :             21 :                     RenameStmt *n = makeNode(RenameStmt);
                               9474                 :                : 
                               9475                 :             21 :                     n->renameType = OBJECT_AGGREGATE;
 3220                          9476                 :             21 :                     n->object = (Node *) $3;
 3278                          9477                 :             21 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9478                 :             21 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9479                 :             21 :                     $$ = (Node *) n;
                               9480                 :                :                 }
                               9481                 :                :             | ALTER COLLATION any_name RENAME TO name
                               9482                 :                :                 {
 5320 peter_e@gmx.net          9483                 :              9 :                     RenameStmt *n = makeNode(RenameStmt);
                               9484                 :                : 
                               9485                 :              9 :                     n->renameType = OBJECT_COLLATION;
 3220                          9486                 :              9 :                     n->object = (Node *) $3;
 5320                          9487                 :              9 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9488                 :              9 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9489                 :              9 :                     $$ = (Node *) n;
                               9490                 :                :                 }
                               9491                 :                :             | ALTER CONVERSION_P any_name RENAME TO name
                               9492                 :                :                 {
 8107 peter_e@gmx.net          9493                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                               9494                 :                : 
                               9495                 :             12 :                     n->renameType = OBJECT_CONVERSION;
 3220                          9496                 :             12 :                     n->object = (Node *) $3;
 8107                          9497                 :             12 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9498                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9499                 :             12 :                     $$ = (Node *) n;
                               9500                 :                :                 }
                               9501                 :                :             | ALTER DATABASE name RENAME TO name
                               9502                 :                :                 {
 8107 peter_e@gmx.net          9503                 :              3 :                     RenameStmt *n = makeNode(RenameStmt);
                               9504                 :                : 
                               9505                 :              3 :                     n->renameType = OBJECT_DATABASE;
                               9506                 :              3 :                     n->subname = $3;
                               9507                 :              3 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9508                 :              3 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9509                 :              3 :                     $$ = (Node *) n;
                               9510                 :                :                 }
                               9511                 :                :             | ALTER DOMAIN_P any_name RENAME TO name
                               9512                 :                :                 {
 5007 peter_e@gmx.net          9513                 :              3 :                     RenameStmt *n = makeNode(RenameStmt);
                               9514                 :                : 
                               9515                 :              3 :                     n->renameType = OBJECT_DOMAIN;
 3220                          9516                 :              3 :                     n->object = (Node *) $3;
 5007                          9517                 :              3 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9518                 :              3 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9519                 :              3 :                     $$ = (Node *) n;
                               9520                 :                :                 }
                               9521                 :                :             | ALTER DOMAIN_P any_name RENAME CONSTRAINT name TO name
                               9522                 :                :                 {
 4904 peter_e@gmx.net          9523                 :              3 :                     RenameStmt *n = makeNode(RenameStmt);
                               9524                 :                : 
 3910 alvherre@alvh.no-ip.     9525                 :              3 :                     n->renameType = OBJECT_DOMCONSTRAINT;
 3220 peter_e@gmx.net          9526                 :              3 :                     n->object = (Node *) $3;
 4904                          9527                 :              3 :                     n->subname = $6;
                               9528                 :              3 :                     n->newname = $8;
 1212 peter@eisentraut.org     9529                 :              3 :                     $$ = (Node *) n;
                               9530                 :                :                 }
                               9531                 :                :             | ALTER FOREIGN DATA_P WRAPPER name RENAME TO name
                               9532                 :                :                 {
 5020 peter_e@gmx.net          9533                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                               9534                 :                : 
                               9535                 :             12 :                     n->renameType = OBJECT_FDW;
 3220                          9536                 :             12 :                     n->object = (Node *) makeString($5);
 5020                          9537                 :             12 :                     n->newname = $8;
 4975 simon@2ndQuadrant.co     9538                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9539                 :             12 :                     $$ = (Node *) n;
                               9540                 :                :                 }
                               9541                 :                :             | ALTER FUNCTION function_with_argtypes RENAME TO name
                               9542                 :                :                 {
 8107 peter_e@gmx.net          9543                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                               9544                 :                : 
                               9545                 :             12 :                     n->renameType = OBJECT_FUNCTION;
 3220                          9546                 :             12 :                     n->object = (Node *) $3;
 6578 tgl@sss.pgh.pa.us        9547                 :             12 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9548                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9549                 :             12 :                     $$ = (Node *) n;
                               9550                 :                :                 }
                               9551                 :                :             | ALTER GROUP_P RoleId RENAME TO RoleId
                               9552                 :                :                 {
 8107 peter_e@gmx.net          9553                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9554                 :                : 
 7375 tgl@sss.pgh.pa.us        9555                 :              0 :                     n->renameType = OBJECT_ROLE;
 8107 peter_e@gmx.net          9556                 :              0 :                     n->subname = $3;
                               9557                 :              0 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9558                 :              0 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9559                 :              0 :                     $$ = (Node *) n;
                               9560                 :                :                 }
                               9561                 :                :             | ALTER opt_procedural LANGUAGE name RENAME TO name
                               9562                 :                :                 {
 8107 peter_e@gmx.net          9563                 :CBC           9 :                     RenameStmt *n = makeNode(RenameStmt);
                               9564                 :                : 
                               9565                 :              9 :                     n->renameType = OBJECT_LANGUAGE;
 3220                          9566                 :              9 :                     n->object = (Node *) makeString($4);
 6739 tgl@sss.pgh.pa.us        9567                 :              9 :                     n->newname = $7;
 4975 simon@2ndQuadrant.co     9568                 :              9 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9569                 :              9 :                     $$ = (Node *) n;
                               9570                 :                :                 }
                               9571                 :                :             | ALTER OPERATOR CLASS any_name USING name RENAME TO name
                               9572                 :                :                 {
 8107 peter_e@gmx.net          9573                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                               9574                 :                : 
                               9575                 :             12 :                     n->renameType = OBJECT_OPCLASS;
 3220                          9576                 :             12 :                     n->object = (Node *) lcons(makeString($6), $4);
 8107                          9577                 :             12 :                     n->newname = $9;
 4975 simon@2ndQuadrant.co     9578                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9579                 :             12 :                     $$ = (Node *) n;
                               9580                 :                :                 }
                               9581                 :                :             | ALTER OPERATOR FAMILY any_name USING name RENAME TO name
                               9582                 :                :                 {
 6801 tgl@sss.pgh.pa.us        9583                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                               9584                 :                : 
                               9585                 :             12 :                     n->renameType = OBJECT_OPFAMILY;
 3220 peter_e@gmx.net          9586                 :             12 :                     n->object = (Node *) lcons(makeString($6), $4);
 6801 tgl@sss.pgh.pa.us        9587                 :             12 :                     n->newname = $9;
 4975 simon@2ndQuadrant.co     9588                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9589                 :             12 :                     $$ = (Node *) n;
                               9590                 :                :                 }
                               9591                 :                :             | ALTER POLICY name ON qualified_name RENAME TO name
                               9592                 :                :                 {
 4005 sfrost@snowman.net       9593                 :              9 :                     RenameStmt *n = makeNode(RenameStmt);
                               9594                 :                : 
                               9595                 :              9 :                     n->renameType = OBJECT_POLICY;
                               9596                 :              9 :                     n->relation = $5;
                               9597                 :              9 :                     n->subname = $3;
                               9598                 :              9 :                     n->newname = $8;
                               9599                 :              9 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9600                 :              9 :                     $$ = (Node *) n;
                               9601                 :                :                 }
                               9602                 :                :             | ALTER POLICY IF_P EXISTS name ON qualified_name RENAME TO name
                               9603                 :                :                 {
 4005 sfrost@snowman.net       9604                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9605                 :                : 
                               9606                 :              0 :                     n->renameType = OBJECT_POLICY;
                               9607                 :              0 :                     n->relation = $7;
                               9608                 :              0 :                     n->subname = $5;
                               9609                 :              0 :                     n->newname = $10;
                               9610                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     9611                 :              0 :                     $$ = (Node *) n;
                               9612                 :                :                 }
                               9613                 :                :             | ALTER PROCEDURE function_with_argtypes RENAME TO name
                               9614                 :                :                 {
 2837 peter_e@gmx.net          9615                 :              0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9616                 :                : 
                               9617                 :              0 :                     n->renameType = OBJECT_PROCEDURE;
                               9618                 :              0 :                     n->object = (Node *) $3;
                               9619                 :              0 :                     n->newname = $6;
                               9620                 :              0 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9621                 :              0 :                     $$ = (Node *) n;
                               9622                 :                :                 }
                               9623                 :                :             | ALTER PUBLICATION name RENAME TO name
                               9624                 :                :                 {
 3109 peter_e@gmx.net          9625                 :CBC          21 :                     RenameStmt *n = makeNode(RenameStmt);
                               9626                 :                : 
                               9627                 :             21 :                     n->renameType = OBJECT_PUBLICATION;
 3220                          9628                 :             21 :                     n->object = (Node *) makeString($3);
 3109                          9629                 :             21 :                     n->newname = $6;
                               9630                 :             21 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9631                 :             21 :                     $$ = (Node *) n;
                               9632                 :                :                 }
                               9633                 :                :             | ALTER ROUTINE function_with_argtypes RENAME TO name
                               9634                 :                :                 {
 2837 peter_e@gmx.net          9635                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                               9636                 :                : 
                               9637                 :             12 :                     n->renameType = OBJECT_ROUTINE;
                               9638                 :             12 :                     n->object = (Node *) $3;
                               9639                 :             12 :                     n->newname = $6;
                               9640                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9641                 :             12 :                     $$ = (Node *) n;
                               9642                 :                :                 }
                               9643                 :                :             | ALTER SCHEMA name RENAME TO name
                               9644                 :                :                 {
 8107 peter_e@gmx.net          9645                 :             10 :                     RenameStmt *n = makeNode(RenameStmt);
                               9646                 :                : 
                               9647                 :             10 :                     n->renameType = OBJECT_SCHEMA;
                               9648                 :             10 :                     n->subname = $3;
                               9649                 :             10 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9650                 :             10 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9651                 :             10 :                     $$ = (Node *) n;
                               9652                 :                :                 }
                               9653                 :                :             | ALTER SERVER name RENAME TO name
                               9654                 :                :                 {
 5020 peter_e@gmx.net          9655                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                               9656                 :                : 
                               9657                 :             12 :                     n->renameType = OBJECT_FOREIGN_SERVER;
 3220                          9658                 :             12 :                     n->object = (Node *) makeString($3);
 5020                          9659                 :             12 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9660                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9661                 :             12 :                     $$ = (Node *) n;
                               9662                 :                :                 }
                               9663                 :                :             | ALTER SUBSCRIPTION name RENAME TO name
                               9664                 :                :                 {
 3109 peter_e@gmx.net          9665                 :             19 :                     RenameStmt *n = makeNode(RenameStmt);
                               9666                 :                : 
                               9667                 :             19 :                     n->renameType = OBJECT_SUBSCRIPTION;
 3220                          9668                 :             19 :                     n->object = (Node *) makeString($3);
 3109                          9669                 :             19 :                     n->newname = $6;
                               9670                 :             19 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9671                 :             19 :                     $$ = (Node *) n;
                               9672                 :                :                 }
                               9673                 :                :             | ALTER TABLE relation_expr RENAME TO name
                               9674                 :                :                 {
10225 bruce@momjian.us         9675                 :            144 :                     RenameStmt *n = makeNode(RenameStmt);
                               9676                 :                : 
 7794 tgl@sss.pgh.pa.us        9677                 :            144 :                     n->renameType = OBJECT_TABLE;
                               9678                 :            144 :                     n->relation = $3;
                               9679                 :            144 :                     n->subname = NULL;
                               9680                 :            144 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9681                 :            144 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9682                 :            144 :                     $$ = (Node *) n;
                               9683                 :                :                 }
                               9684                 :                :             | ALTER TABLE IF_P EXISTS relation_expr RENAME TO name
                               9685                 :                :                 {
 4975 simon@2ndQuadrant.co     9686                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9687                 :                : 
                               9688                 :              0 :                     n->renameType = OBJECT_TABLE;
                               9689                 :              0 :                     n->relation = $5;
                               9690                 :              0 :                     n->subname = NULL;
                               9691                 :              0 :                     n->newname = $8;
                               9692                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     9693                 :              0 :                     $$ = (Node *) n;
                               9694                 :                :                 }
                               9695                 :                :             | ALTER SEQUENCE qualified_name RENAME TO name
                               9696                 :                :                 {
 6640 neilc@samurai.com        9697                 :CBC           1 :                     RenameStmt *n = makeNode(RenameStmt);
                               9698                 :                : 
                               9699                 :              1 :                     n->renameType = OBJECT_SEQUENCE;
                               9700                 :              1 :                     n->relation = $3;
                               9701                 :              1 :                     n->subname = NULL;
                               9702                 :              1 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9703                 :              1 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9704                 :              1 :                     $$ = (Node *) n;
                               9705                 :                :                 }
                               9706                 :                :             | ALTER SEQUENCE IF_P EXISTS qualified_name RENAME TO name
                               9707                 :                :                 {
 4975 simon@2ndQuadrant.co     9708                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9709                 :                : 
                               9710                 :              0 :                     n->renameType = OBJECT_SEQUENCE;
                               9711                 :              0 :                     n->relation = $5;
                               9712                 :              0 :                     n->subname = NULL;
                               9713                 :              0 :                     n->newname = $8;
                               9714                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     9715                 :              0 :                     $$ = (Node *) n;
                               9716                 :                :                 }
                               9717                 :                :             | ALTER VIEW qualified_name RENAME TO name
                               9718                 :                :                 {
 6640 neilc@samurai.com        9719                 :CBC           3 :                     RenameStmt *n = makeNode(RenameStmt);
                               9720                 :                : 
                               9721                 :              3 :                     n->renameType = OBJECT_VIEW;
                               9722                 :              3 :                     n->relation = $3;
                               9723                 :              3 :                     n->subname = NULL;
                               9724                 :              3 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9725                 :              3 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9726                 :              3 :                     $$ = (Node *) n;
                               9727                 :                :                 }
                               9728                 :                :             | ALTER VIEW IF_P EXISTS qualified_name RENAME TO name
                               9729                 :                :                 {
 4975 simon@2ndQuadrant.co     9730                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9731                 :                : 
                               9732                 :              0 :                     n->renameType = OBJECT_VIEW;
                               9733                 :              0 :                     n->relation = $5;
                               9734                 :              0 :                     n->subname = NULL;
                               9735                 :              0 :                     n->newname = $8;
                               9736                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     9737                 :              0 :                     $$ = (Node *) n;
                               9738                 :                :                 }
                               9739                 :                :             | ALTER MATERIALIZED VIEW qualified_name RENAME TO name
                               9740                 :                :                 {
 4570 kgrittn@postgresql.o     9741                 :              0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9742                 :                : 
                               9743                 :              0 :                     n->renameType = OBJECT_MATVIEW;
                               9744                 :              0 :                     n->relation = $4;
                               9745                 :              0 :                     n->subname = NULL;
                               9746                 :              0 :                     n->newname = $7;
                               9747                 :              0 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9748                 :              0 :                     $$ = (Node *) n;
                               9749                 :                :                 }
                               9750                 :                :             | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME TO name
                               9751                 :                :                 {
 4570 kgrittn@postgresql.o     9752                 :              0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9753                 :                : 
                               9754                 :              0 :                     n->renameType = OBJECT_MATVIEW;
                               9755                 :              0 :                     n->relation = $6;
                               9756                 :              0 :                     n->subname = NULL;
                               9757                 :              0 :                     n->newname = $9;
                               9758                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     9759                 :              0 :                     $$ = (Node *) n;
                               9760                 :                :                 }
                               9761                 :                :             | ALTER INDEX qualified_name RENAME TO name
                               9762                 :                :                 {
 7687 bruce@momjian.us         9763                 :CBC          96 :                     RenameStmt *n = makeNode(RenameStmt);
                               9764                 :                : 
                               9765                 :             96 :                     n->renameType = OBJECT_INDEX;
                               9766                 :             96 :                     n->relation = $3;
                               9767                 :             96 :                     n->subname = NULL;
                               9768                 :             96 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9769                 :             96 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9770                 :             96 :                     $$ = (Node *) n;
                               9771                 :                :                 }
                               9772                 :                :             | ALTER INDEX IF_P EXISTS qualified_name RENAME TO name
                               9773                 :                :                 {
 4975 simon@2ndQuadrant.co     9774                 :              6 :                     RenameStmt *n = makeNode(RenameStmt);
                               9775                 :                : 
                               9776                 :              6 :                     n->renameType = OBJECT_INDEX;
                               9777                 :              6 :                     n->relation = $5;
                               9778                 :              6 :                     n->subname = NULL;
                               9779                 :              6 :                     n->newname = $8;
                               9780                 :              6 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     9781                 :              6 :                     $$ = (Node *) n;
                               9782                 :                :                 }
                               9783                 :                :             | ALTER FOREIGN TABLE relation_expr RENAME TO name
                               9784                 :                :                 {
 5362 rhaas@postgresql.org     9785                 :              3 :                     RenameStmt *n = makeNode(RenameStmt);
                               9786                 :                : 
                               9787                 :              3 :                     n->renameType = OBJECT_FOREIGN_TABLE;
                               9788                 :              3 :                     n->relation = $4;
                               9789                 :              3 :                     n->subname = NULL;
                               9790                 :              3 :                     n->newname = $7;
 4975 simon@2ndQuadrant.co     9791                 :              3 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9792                 :              3 :                     $$ = (Node *) n;
                               9793                 :                :                 }
                               9794                 :                :             | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME TO name
                               9795                 :                :                 {
 4975 simon@2ndQuadrant.co     9796                 :              3 :                     RenameStmt *n = makeNode(RenameStmt);
                               9797                 :                : 
                               9798                 :              3 :                     n->renameType = OBJECT_FOREIGN_TABLE;
                               9799                 :              3 :                     n->relation = $6;
                               9800                 :              3 :                     n->subname = NULL;
                               9801                 :              3 :                     n->newname = $9;
                               9802                 :              3 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     9803                 :              3 :                     $$ = (Node *) n;
                               9804                 :                :                 }
                               9805                 :                :             | ALTER TABLE relation_expr RENAME opt_column name TO name
                               9806                 :                :                 {
 7794 tgl@sss.pgh.pa.us        9807                 :            119 :                     RenameStmt *n = makeNode(RenameStmt);
                               9808                 :                : 
                               9809                 :            119 :                     n->renameType = OBJECT_COLUMN;
 5362 rhaas@postgresql.org     9810                 :            119 :                     n->relationType = OBJECT_TABLE;
 8570 tgl@sss.pgh.pa.us        9811                 :            119 :                     n->relation = $3;
 8107 peter_e@gmx.net          9812                 :            119 :                     n->subname = $6;
 8888 tgl@sss.pgh.pa.us        9813                 :            119 :                     n->newname = $8;
 4975 simon@2ndQuadrant.co     9814                 :            119 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9815                 :            119 :                     $$ = (Node *) n;
                               9816                 :                :                 }
                               9817                 :                :             | ALTER TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
                               9818                 :                :                 {
 4975 simon@2ndQuadrant.co     9819                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                               9820                 :                : 
                               9821                 :             12 :                     n->renameType = OBJECT_COLUMN;
                               9822                 :             12 :                     n->relationType = OBJECT_TABLE;
                               9823                 :             12 :                     n->relation = $5;
                               9824                 :             12 :                     n->subname = $8;
                               9825                 :             12 :                     n->newname = $10;
                               9826                 :             12 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     9827                 :             12 :                     $$ = (Node *) n;
                               9828                 :                :                 }
                               9829                 :                :             | ALTER VIEW qualified_name RENAME opt_column name TO name
                               9830                 :                :                 {
 2116 fujii@postgresql.org     9831                 :              9 :                     RenameStmt *n = makeNode(RenameStmt);
                               9832                 :                : 
                               9833                 :              9 :                     n->renameType = OBJECT_COLUMN;
                               9834                 :              9 :                     n->relationType = OBJECT_VIEW;
                               9835                 :              9 :                     n->relation = $3;
                               9836                 :              9 :                     n->subname = $6;
                               9837                 :              9 :                     n->newname = $8;
                               9838                 :              9 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9839                 :              9 :                     $$ = (Node *) n;
                               9840                 :                :                 }
                               9841                 :                :             | ALTER VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name
                               9842                 :                :                 {
 2116 fujii@postgresql.org     9843                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9844                 :                : 
                               9845                 :              0 :                     n->renameType = OBJECT_COLUMN;
                               9846                 :              0 :                     n->relationType = OBJECT_VIEW;
                               9847                 :              0 :                     n->relation = $5;
                               9848                 :              0 :                     n->subname = $8;
                               9849                 :              0 :                     n->newname = $10;
                               9850                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     9851                 :              0 :                     $$ = (Node *) n;
                               9852                 :                :                 }
                               9853                 :                :             | ALTER MATERIALIZED VIEW qualified_name RENAME opt_column name TO name
                               9854                 :                :                 {
 4570 kgrittn@postgresql.o     9855                 :              0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9856                 :                : 
                               9857                 :              0 :                     n->renameType = OBJECT_COLUMN;
                               9858                 :              0 :                     n->relationType = OBJECT_MATVIEW;
                               9859                 :              0 :                     n->relation = $4;
                               9860                 :              0 :                     n->subname = $7;
                               9861                 :              0 :                     n->newname = $9;
                               9862                 :              0 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9863                 :              0 :                     $$ = (Node *) n;
                               9864                 :                :                 }
                               9865                 :                :             | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name
                               9866                 :                :                 {
 4570 kgrittn@postgresql.o     9867                 :              0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9868                 :                : 
                               9869                 :              0 :                     n->renameType = OBJECT_COLUMN;
                               9870                 :              0 :                     n->relationType = OBJECT_MATVIEW;
                               9871                 :              0 :                     n->relation = $6;
                               9872                 :              0 :                     n->subname = $9;
                               9873                 :              0 :                     n->newname = $11;
                               9874                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     9875                 :              0 :                     $$ = (Node *) n;
                               9876                 :                :                 }
                               9877                 :                :             | ALTER TABLE relation_expr RENAME CONSTRAINT name TO name
                               9878                 :                :                 {
 4928 peter_e@gmx.net          9879                 :CBC          36 :                     RenameStmt *n = makeNode(RenameStmt);
                               9880                 :                : 
 3910 alvherre@alvh.no-ip.     9881                 :             36 :                     n->renameType = OBJECT_TABCONSTRAINT;
 4928 peter_e@gmx.net          9882                 :             36 :                     n->relation = $3;
                               9883                 :             36 :                     n->subname = $6;
                               9884                 :             36 :                     n->newname = $8;
 3819 bruce@momjian.us         9885                 :             36 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9886                 :             36 :                     $$ = (Node *) n;
                               9887                 :                :                 }
                               9888                 :                :             | ALTER TABLE IF_P EXISTS relation_expr RENAME CONSTRAINT name TO name
                               9889                 :                :                 {
 3819 bruce@momjian.us         9890                 :              3 :                     RenameStmt *n = makeNode(RenameStmt);
                               9891                 :                : 
                               9892                 :              3 :                     n->renameType = OBJECT_TABCONSTRAINT;
                               9893                 :              3 :                     n->relation = $5;
                               9894                 :              3 :                     n->subname = $8;
                               9895                 :              3 :                     n->newname = $10;
                               9896                 :              3 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     9897                 :              3 :                     $$ = (Node *) n;
                               9898                 :                :                 }
                               9899                 :                :             | ALTER FOREIGN TABLE relation_expr RENAME opt_column name TO name
                               9900                 :                :                 {
 5362 rhaas@postgresql.org     9901                 :              3 :                     RenameStmt *n = makeNode(RenameStmt);
                               9902                 :                : 
                               9903                 :              3 :                     n->renameType = OBJECT_COLUMN;
                               9904                 :              3 :                     n->relationType = OBJECT_FOREIGN_TABLE;
                               9905                 :              3 :                     n->relation = $4;
                               9906                 :              3 :                     n->subname = $7;
                               9907                 :              3 :                     n->newname = $9;
 4975 simon@2ndQuadrant.co     9908                 :              3 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9909                 :              3 :                     $$ = (Node *) n;
                               9910                 :                :                 }
                               9911                 :                :             | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
                               9912                 :                :                 {
 4975 simon@2ndQuadrant.co     9913                 :              3 :                     RenameStmt *n = makeNode(RenameStmt);
                               9914                 :                : 
                               9915                 :              3 :                     n->renameType = OBJECT_COLUMN;
                               9916                 :              3 :                     n->relationType = OBJECT_FOREIGN_TABLE;
                               9917                 :              3 :                     n->relation = $6;
                               9918                 :              3 :                     n->subname = $9;
                               9919                 :              3 :                     n->newname = $11;
                               9920                 :              3 :                     n->missing_ok = true;
 1212 peter@eisentraut.org     9921                 :              3 :                     $$ = (Node *) n;
                               9922                 :                :                 }
                               9923                 :                :             | ALTER RULE name ON qualified_name RENAME TO name
                               9924                 :                :                 {
 4593 tgl@sss.pgh.pa.us        9925                 :             17 :                     RenameStmt *n = makeNode(RenameStmt);
                               9926                 :                : 
                               9927                 :             17 :                     n->renameType = OBJECT_RULE;
                               9928                 :             17 :                     n->relation = $5;
                               9929                 :             17 :                     n->subname = $3;
                               9930                 :             17 :                     n->newname = $8;
                               9931                 :             17 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9932                 :             17 :                     $$ = (Node *) n;
                               9933                 :                :                 }
                               9934                 :                :             | ALTER TRIGGER name ON qualified_name RENAME TO name
                               9935                 :                :                 {
 8536 bruce@momjian.us         9936                 :             20 :                     RenameStmt *n = makeNode(RenameStmt);
                               9937                 :                : 
 7341 tgl@sss.pgh.pa.us        9938                 :             20 :                     n->renameType = OBJECT_TRIGGER;
 8536 bruce@momjian.us         9939                 :             20 :                     n->relation = $5;
 8107 peter_e@gmx.net          9940                 :             20 :                     n->subname = $3;
 8536 bruce@momjian.us         9941                 :             20 :                     n->newname = $8;
 4975 simon@2ndQuadrant.co     9942                 :             20 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9943                 :             20 :                     $$ = (Node *) n;
                               9944                 :                :                 }
                               9945                 :                :             | ALTER EVENT TRIGGER name RENAME TO name
                               9946                 :                :                 {
 4798 rhaas@postgresql.org     9947                 :              6 :                     RenameStmt *n = makeNode(RenameStmt);
                               9948                 :                : 
                               9949                 :              6 :                     n->renameType = OBJECT_EVENT_TRIGGER;
 3220 peter_e@gmx.net          9950                 :              6 :                     n->object = (Node *) makeString($4);
 4798 rhaas@postgresql.org     9951                 :              6 :                     n->newname = $7;
 1212 peter@eisentraut.org     9952                 :              6 :                     $$ = (Node *) n;
                               9953                 :                :                 }
                               9954                 :                :             | ALTER ROLE RoleId RENAME TO RoleId
                               9955                 :                :                 {
 8107 peter_e@gmx.net          9956                 :             16 :                     RenameStmt *n = makeNode(RenameStmt);
                               9957                 :                : 
 7375 tgl@sss.pgh.pa.us        9958                 :             16 :                     n->renameType = OBJECT_ROLE;
                               9959                 :             16 :                     n->subname = $3;
                               9960                 :             16 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9961                 :             16 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9962                 :             16 :                     $$ = (Node *) n;
                               9963                 :                :                 }
                               9964                 :                :             | ALTER USER RoleId RENAME TO RoleId
                               9965                 :                :                 {
 7375 tgl@sss.pgh.pa.us        9966                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9967                 :                : 
                               9968                 :              0 :                     n->renameType = OBJECT_ROLE;
 8107 peter_e@gmx.net          9969                 :              0 :                     n->subname = $3;
                               9970                 :              0 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9971                 :              0 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9972                 :              0 :                     $$ = (Node *) n;
                               9973                 :                :                 }
                               9974                 :                :             | ALTER TABLESPACE name RENAME TO name
                               9975                 :                :                 {
 7743 tgl@sss.pgh.pa.us        9976                 :CBC           3 :                     RenameStmt *n = makeNode(RenameStmt);
                               9977                 :                : 
                               9978                 :              3 :                     n->renameType = OBJECT_TABLESPACE;
                               9979                 :              3 :                     n->subname = $3;
                               9980                 :              3 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co     9981                 :              3 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9982                 :              3 :                     $$ = (Node *) n;
                               9983                 :                :                 }
                               9984                 :                :             | ALTER STATISTICS any_name RENAME TO name
                               9985                 :                :                 {
 3088 alvherre@alvh.no-ip.     9986                 :             15 :                     RenameStmt *n = makeNode(RenameStmt);
                               9987                 :                : 
                               9988                 :             15 :                     n->renameType = OBJECT_STATISTIC_EXT;
                               9989                 :             15 :                     n->object = (Node *) $3;
                               9990                 :             15 :                     n->newname = $6;
                               9991                 :             15 :                     n->missing_ok = false;
 1212 peter@eisentraut.org     9992                 :             15 :                     $$ = (Node *) n;
                               9993                 :                :                 }
                               9994                 :                :             | ALTER TEXT_P SEARCH PARSER any_name RENAME TO name
                               9995                 :                :                 {
 6591 tgl@sss.pgh.pa.us        9996                 :              6 :                     RenameStmt *n = makeNode(RenameStmt);
                               9997                 :                : 
                               9998                 :              6 :                     n->renameType = OBJECT_TSPARSER;
 3220 peter_e@gmx.net          9999                 :              6 :                     n->object = (Node *) $5;
 6591 tgl@sss.pgh.pa.us       10000                 :              6 :                     n->newname = $8;
 4975 simon@2ndQuadrant.co    10001                 :              6 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10002                 :              6 :                     $$ = (Node *) n;
                              10003                 :                :                 }
                              10004                 :                :             | ALTER TEXT_P SEARCH DICTIONARY any_name RENAME TO name
                              10005                 :                :                 {
 6591 tgl@sss.pgh.pa.us       10006                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                              10007                 :                : 
                              10008                 :             12 :                     n->renameType = OBJECT_TSDICTIONARY;
 3220 peter_e@gmx.net         10009                 :             12 :                     n->object = (Node *) $5;
 6591 tgl@sss.pgh.pa.us       10010                 :             12 :                     n->newname = $8;
 4975 simon@2ndQuadrant.co    10011                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10012                 :             12 :                     $$ = (Node *) n;
                              10013                 :                :                 }
                              10014                 :                :             | ALTER TEXT_P SEARCH TEMPLATE any_name RENAME TO name
                              10015                 :                :                 {
 6591 tgl@sss.pgh.pa.us       10016                 :              6 :                     RenameStmt *n = makeNode(RenameStmt);
                              10017                 :                : 
                              10018                 :              6 :                     n->renameType = OBJECT_TSTEMPLATE;
 3220 peter_e@gmx.net         10019                 :              6 :                     n->object = (Node *) $5;
 6591 tgl@sss.pgh.pa.us       10020                 :              6 :                     n->newname = $8;
 4975 simon@2ndQuadrant.co    10021                 :              6 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10022                 :              6 :                     $$ = (Node *) n;
                              10023                 :                :                 }
                              10024                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name
                              10025                 :                :                 {
 6591 tgl@sss.pgh.pa.us       10026                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                              10027                 :                : 
                              10028                 :             12 :                     n->renameType = OBJECT_TSCONFIGURATION;
 3220 peter_e@gmx.net         10029                 :             12 :                     n->object = (Node *) $5;
 6591 tgl@sss.pgh.pa.us       10030                 :             12 :                     n->newname = $8;
 4975 simon@2ndQuadrant.co    10031                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10032                 :             12 :                     $$ = (Node *) n;
                              10033                 :                :                 }
                              10034                 :                :             | ALTER TYPE_P any_name RENAME TO name
                              10035                 :                :                 {
 6380 tgl@sss.pgh.pa.us       10036                 :             13 :                     RenameStmt *n = makeNode(RenameStmt);
                              10037                 :                : 
                              10038                 :             13 :                     n->renameType = OBJECT_TYPE;
 3220 peter_e@gmx.net         10039                 :             13 :                     n->object = (Node *) $3;
 6380 tgl@sss.pgh.pa.us       10040                 :             13 :                     n->newname = $6;
 4975 simon@2ndQuadrant.co    10041                 :             13 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10042                 :             13 :                     $$ = (Node *) n;
                              10043                 :                :                 }
                              10044                 :                :             | ALTER TYPE_P any_name RENAME ATTRIBUTE name TO name opt_drop_behavior
                              10045                 :                :                 {
 5459 peter_e@gmx.net         10046                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                              10047                 :                : 
                              10048                 :             12 :                     n->renameType = OBJECT_ATTRIBUTE;
 5362 rhaas@postgresql.org    10049                 :             12 :                     n->relationType = OBJECT_TYPE;
 5459 peter_e@gmx.net         10050                 :             12 :                     n->relation = makeRangeVarFromAnyName($3, @3, yyscanner);
                              10051                 :             12 :                     n->subname = $6;
                              10052                 :             12 :                     n->newname = $8;
 5401                         10053                 :             12 :                     n->behavior = $9;
 4975 simon@2ndQuadrant.co    10054                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10055                 :             12 :                     $$ = (Node *) n;
                              10056                 :                :                 }
                              10057                 :                :         ;
                              10058                 :                : 
                              10059                 :                : opt_column: COLUMN
                              10060                 :                :             | /*EMPTY*/
                              10061                 :                :         ;
                              10062                 :                : 
 5295 tgl@sss.pgh.pa.us       10063                 :             91 : opt_set_data: SET DATA_P                            { $$ = 1; }
 6164 peter_e@gmx.net         10064                 :            456 :             | /*EMPTY*/                             { $$ = 0; }
                              10065                 :                :         ;
                              10066                 :                : 
                              10067                 :                : /*****************************************************************************
                              10068                 :                :  *
                              10069                 :                :  * ALTER THING name DEPENDS ON EXTENSION name
                              10070                 :                :  *
                              10071                 :                :  *****************************************************************************/
                              10072                 :                : 
                              10073                 :                : AlterObjectDependsStmt:
                              10074                 :                :             ALTER FUNCTION function_with_argtypes opt_no DEPENDS ON EXTENSION name
                              10075                 :                :                 {
 3441 alvherre@alvh.no-ip.    10076                 :              6 :                     AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
                              10077                 :                : 
                              10078                 :              6 :                     n->objectType = OBJECT_FUNCTION;
 3220 peter_e@gmx.net         10079                 :              6 :                     n->object = (Node *) $3;
 1965 alvherre@alvh.no-ip.    10080                 :              6 :                     n->extname = makeString($8);
                              10081                 :              6 :                     n->remove = $4;
 1212 peter@eisentraut.org    10082                 :              6 :                     $$ = (Node *) n;
                              10083                 :                :                 }
                              10084                 :                :             | ALTER PROCEDURE function_with_argtypes opt_no DEPENDS ON EXTENSION name
                              10085                 :                :                 {
 2837 peter_e@gmx.net         10086                 :UBC           0 :                     AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
                              10087                 :                : 
                              10088                 :              0 :                     n->objectType = OBJECT_PROCEDURE;
                              10089                 :              0 :                     n->object = (Node *) $3;
 1965 alvherre@alvh.no-ip.    10090                 :              0 :                     n->extname = makeString($8);
                              10091                 :              0 :                     n->remove = $4;
 1212 peter@eisentraut.org    10092                 :              0 :                     $$ = (Node *) n;
                              10093                 :                :                 }
                              10094                 :                :             | ALTER ROUTINE function_with_argtypes opt_no DEPENDS ON EXTENSION name
                              10095                 :                :                 {
 2837 peter_e@gmx.net         10096                 :              0 :                     AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
                              10097                 :                : 
                              10098                 :              0 :                     n->objectType = OBJECT_ROUTINE;
                              10099                 :              0 :                     n->object = (Node *) $3;
 1965 alvherre@alvh.no-ip.    10100                 :              0 :                     n->extname = makeString($8);
                              10101                 :              0 :                     n->remove = $4;
 1212 peter@eisentraut.org    10102                 :              0 :                     $$ = (Node *) n;
                              10103                 :                :                 }
                              10104                 :                :             | ALTER TRIGGER name ON qualified_name opt_no DEPENDS ON EXTENSION name
                              10105                 :                :                 {
 3441 alvherre@alvh.no-ip.    10106                 :CBC           5 :                     AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
                              10107                 :                : 
                              10108                 :              5 :                     n->objectType = OBJECT_TRIGGER;
                              10109                 :              5 :                     n->relation = $5;
 3220 peter_e@gmx.net         10110                 :              5 :                     n->object = (Node *) list_make1(makeString($3));
 1965 alvherre@alvh.no-ip.    10111                 :              5 :                     n->extname = makeString($10);
                              10112                 :              5 :                     n->remove = $6;
 1212 peter@eisentraut.org    10113                 :              5 :                     $$ = (Node *) n;
                              10114                 :                :                 }
                              10115                 :                :             | ALTER MATERIALIZED VIEW qualified_name opt_no DEPENDS ON EXTENSION name
                              10116                 :                :                 {
 3441 alvherre@alvh.no-ip.    10117                 :              5 :                     AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
                              10118                 :                : 
                              10119                 :              5 :                     n->objectType = OBJECT_MATVIEW;
                              10120                 :              5 :                     n->relation = $4;
 1965                         10121                 :              5 :                     n->extname = makeString($9);
                              10122                 :              5 :                     n->remove = $5;
 1212 peter@eisentraut.org    10123                 :              5 :                     $$ = (Node *) n;
                              10124                 :                :                 }
                              10125                 :                :             | ALTER INDEX qualified_name opt_no DEPENDS ON EXTENSION name
                              10126                 :                :                 {
 3441 alvherre@alvh.no-ip.    10127                 :              7 :                     AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
                              10128                 :                : 
                              10129                 :              7 :                     n->objectType = OBJECT_INDEX;
                              10130                 :              7 :                     n->relation = $3;
 1965                         10131                 :              7 :                     n->extname = makeString($8);
                              10132                 :              7 :                     n->remove = $4;
 1212 peter@eisentraut.org    10133                 :              7 :                     $$ = (Node *) n;
                              10134                 :                :                 }
                              10135                 :                :         ;
                              10136                 :                : 
 1965 alvherre@alvh.no-ip.    10137                 :              4 : opt_no:     NO              { $$ = true; }
                              10138                 :             19 :             | /* EMPTY */   { $$ = false;   }
                              10139                 :                :         ;
                              10140                 :                : 
                              10141                 :                : /*****************************************************************************
                              10142                 :                :  *
                              10143                 :                :  * ALTER THING name SET SCHEMA name
                              10144                 :                :  *
                              10145                 :                :  *****************************************************************************/
                              10146                 :                : 
                              10147                 :                : AlterObjectSchemaStmt:
                              10148                 :                :             ALTER AGGREGATE aggregate_with_argtypes SET SCHEMA name
                              10149                 :                :                 {
 7341 tgl@sss.pgh.pa.us       10150                 :             12 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10151                 :                : 
                              10152                 :             12 :                     n->objectType = OBJECT_AGGREGATE;
 3220 peter_e@gmx.net         10153                 :             12 :                     n->object = (Node *) $3;
 3278                         10154                 :             12 :                     n->newschema = $6;
 4975 simon@2ndQuadrant.co    10155                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10156                 :             12 :                     $$ = (Node *) n;
                              10157                 :                :                 }
                              10158                 :                :             | ALTER COLLATION any_name SET SCHEMA name
                              10159                 :                :                 {
 5320 peter_e@gmx.net         10160                 :              3 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10161                 :                : 
                              10162                 :              3 :                     n->objectType = OBJECT_COLLATION;
 3220                         10163                 :              3 :                     n->object = (Node *) $3;
 5320                         10164                 :              3 :                     n->newschema = $6;
 4975 simon@2ndQuadrant.co    10165                 :              3 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10166                 :              3 :                     $$ = (Node *) n;
                              10167                 :                :                 }
                              10168                 :                :             | ALTER CONVERSION_P any_name SET SCHEMA name
                              10169                 :                :                 {
 5398 rhaas@postgresql.org    10170                 :             12 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10171                 :                : 
                              10172                 :             12 :                     n->objectType = OBJECT_CONVERSION;
 3220 peter_e@gmx.net         10173                 :             12 :                     n->object = (Node *) $3;
 5398 rhaas@postgresql.org    10174                 :             12 :                     n->newschema = $6;
 4975 simon@2ndQuadrant.co    10175                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10176                 :             12 :                     $$ = (Node *) n;
                              10177                 :                :                 }
                              10178                 :                :             | ALTER DOMAIN_P any_name SET SCHEMA name
                              10179                 :                :                 {
 7341 tgl@sss.pgh.pa.us       10180                 :              3 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10181                 :                : 
                              10182                 :              3 :                     n->objectType = OBJECT_DOMAIN;
 3220 peter_e@gmx.net         10183                 :              3 :                     n->object = (Node *) $3;
 7341 tgl@sss.pgh.pa.us       10184                 :              3 :                     n->newschema = $6;
 4975 simon@2ndQuadrant.co    10185                 :              3 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10186                 :              3 :                     $$ = (Node *) n;
                              10187                 :                :                 }
                              10188                 :                :             | ALTER EXTENSION name SET SCHEMA name
                              10189                 :                :                 {
 5324 tgl@sss.pgh.pa.us       10190                 :              6 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10191                 :                : 
                              10192                 :              6 :                     n->objectType = OBJECT_EXTENSION;
 3220 peter_e@gmx.net         10193                 :              6 :                     n->object = (Node *) makeString($3);
 5324 tgl@sss.pgh.pa.us       10194                 :              6 :                     n->newschema = $6;
 4975 simon@2ndQuadrant.co    10195                 :              6 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10196                 :              6 :                     $$ = (Node *) n;
                              10197                 :                :                 }
                              10198                 :                :             | ALTER FUNCTION function_with_argtypes SET SCHEMA name
                              10199                 :                :                 {
 7341 tgl@sss.pgh.pa.us       10200                 :             21 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10201                 :                : 
                              10202                 :             21 :                     n->objectType = OBJECT_FUNCTION;
 3220 peter_e@gmx.net         10203                 :             21 :                     n->object = (Node *) $3;
 6578 tgl@sss.pgh.pa.us       10204                 :             21 :                     n->newschema = $6;
 4975 simon@2ndQuadrant.co    10205                 :             21 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10206                 :             21 :                     $$ = (Node *) n;
                              10207                 :                :                 }
                              10208                 :                :             | ALTER OPERATOR operator_with_argtypes SET SCHEMA name
                              10209                 :                :                 {
 5398 rhaas@postgresql.org    10210                 :              9 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10211                 :                : 
                              10212                 :              9 :                     n->objectType = OBJECT_OPERATOR;
 3220 peter_e@gmx.net         10213                 :              9 :                     n->object = (Node *) $3;
 3174                         10214                 :              9 :                     n->newschema = $6;
 4975 simon@2ndQuadrant.co    10215                 :              9 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10216                 :              9 :                     $$ = (Node *) n;
                              10217                 :                :                 }
                              10218                 :                :             | ALTER OPERATOR CLASS any_name USING name SET SCHEMA name
                              10219                 :                :                 {
 5398 rhaas@postgresql.org    10220                 :             12 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10221                 :                : 
                              10222                 :             12 :                     n->objectType = OBJECT_OPCLASS;
 3220 peter_e@gmx.net         10223                 :             12 :                     n->object = (Node *) lcons(makeString($6), $4);
 5398 rhaas@postgresql.org    10224                 :             12 :                     n->newschema = $9;
 4975 simon@2ndQuadrant.co    10225                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10226                 :             12 :                     $$ = (Node *) n;
                              10227                 :                :                 }
                              10228                 :                :             | ALTER OPERATOR FAMILY any_name USING name SET SCHEMA name
                              10229                 :                :                 {
 5398 rhaas@postgresql.org    10230                 :             12 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10231                 :                : 
                              10232                 :             12 :                     n->objectType = OBJECT_OPFAMILY;
 3220 peter_e@gmx.net         10233                 :             12 :                     n->object = (Node *) lcons(makeString($6), $4);
 5398 rhaas@postgresql.org    10234                 :             12 :                     n->newschema = $9;
 4975 simon@2ndQuadrant.co    10235                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10236                 :             12 :                     $$ = (Node *) n;
                              10237                 :                :                 }
                              10238                 :                :             | ALTER PROCEDURE function_with_argtypes SET SCHEMA name
                              10239                 :                :                 {
 2837 peter_e@gmx.net         10240                 :UBC           0 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10241                 :                : 
                              10242                 :              0 :                     n->objectType = OBJECT_PROCEDURE;
                              10243                 :              0 :                     n->object = (Node *) $3;
                              10244                 :              0 :                     n->newschema = $6;
                              10245                 :              0 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10246                 :              0 :                     $$ = (Node *) n;
                              10247                 :                :                 }
                              10248                 :                :             | ALTER ROUTINE function_with_argtypes SET SCHEMA name
                              10249                 :                :                 {
 2837 peter_e@gmx.net         10250                 :              0 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10251                 :                : 
                              10252                 :              0 :                     n->objectType = OBJECT_ROUTINE;
                              10253                 :              0 :                     n->object = (Node *) $3;
                              10254                 :              0 :                     n->newschema = $6;
                              10255                 :              0 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10256                 :              0 :                     $$ = (Node *) n;
                              10257                 :                :                 }
                              10258                 :                :             | ALTER TABLE relation_expr SET SCHEMA name
                              10259                 :                :                 {
 6292 tgl@sss.pgh.pa.us       10260                 :CBC          33 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10261                 :                : 
                              10262                 :             33 :                     n->objectType = OBJECT_TABLE;
                              10263                 :             33 :                     n->relation = $3;
                              10264                 :             33 :                     n->newschema = $6;
 4975 simon@2ndQuadrant.co    10265                 :             33 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10266                 :             33 :                     $$ = (Node *) n;
                              10267                 :                :                 }
                              10268                 :                :             | ALTER TABLE IF_P EXISTS relation_expr SET SCHEMA name
                              10269                 :                :                 {
 4975 simon@2ndQuadrant.co    10270                 :              6 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10271                 :                : 
                              10272                 :              6 :                     n->objectType = OBJECT_TABLE;
                              10273                 :              6 :                     n->relation = $5;
                              10274                 :              6 :                     n->newschema = $8;
                              10275                 :              6 :                     n->missing_ok = true;
 1212 peter@eisentraut.org    10276                 :              6 :                     $$ = (Node *) n;
                              10277                 :                :                 }
                              10278                 :                :             | ALTER STATISTICS any_name SET SCHEMA name
                              10279                 :                :                 {
 3088 alvherre@alvh.no-ip.    10280                 :              9 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10281                 :                : 
                              10282                 :              9 :                     n->objectType = OBJECT_STATISTIC_EXT;
                              10283                 :              9 :                     n->object = (Node *) $3;
                              10284                 :              9 :                     n->newschema = $6;
                              10285                 :              9 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10286                 :              9 :                     $$ = (Node *) n;
                              10287                 :                :                 }
                              10288                 :                :             | ALTER TEXT_P SEARCH PARSER any_name SET SCHEMA name
                              10289                 :                :                 {
 5398 rhaas@postgresql.org    10290                 :              9 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10291                 :                : 
                              10292                 :              9 :                     n->objectType = OBJECT_TSPARSER;
 3220 peter_e@gmx.net         10293                 :              9 :                     n->object = (Node *) $5;
 5398 rhaas@postgresql.org    10294                 :              9 :                     n->newschema = $8;
 4975 simon@2ndQuadrant.co    10295                 :              9 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10296                 :              9 :                     $$ = (Node *) n;
                              10297                 :                :                 }
                              10298                 :                :             | ALTER TEXT_P SEARCH DICTIONARY any_name SET SCHEMA name
                              10299                 :                :                 {
 5398 rhaas@postgresql.org    10300                 :             12 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10301                 :                : 
                              10302                 :             12 :                     n->objectType = OBJECT_TSDICTIONARY;
 3220 peter_e@gmx.net         10303                 :             12 :                     n->object = (Node *) $5;
 5398 rhaas@postgresql.org    10304                 :             12 :                     n->newschema = $8;
 4975 simon@2ndQuadrant.co    10305                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10306                 :             12 :                     $$ = (Node *) n;
                              10307                 :                :                 }
                              10308                 :                :             | ALTER TEXT_P SEARCH TEMPLATE any_name SET SCHEMA name
                              10309                 :                :                 {
 5398 rhaas@postgresql.org    10310                 :              9 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10311                 :                : 
                              10312                 :              9 :                     n->objectType = OBJECT_TSTEMPLATE;
 3220 peter_e@gmx.net         10313                 :              9 :                     n->object = (Node *) $5;
 5398 rhaas@postgresql.org    10314                 :              9 :                     n->newschema = $8;
 4975 simon@2ndQuadrant.co    10315                 :              9 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10316                 :              9 :                     $$ = (Node *) n;
                              10317                 :                :                 }
                              10318                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name SET SCHEMA name
                              10319                 :                :                 {
 5398 rhaas@postgresql.org    10320                 :             12 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10321                 :                : 
                              10322                 :             12 :                     n->objectType = OBJECT_TSCONFIGURATION;
 3220 peter_e@gmx.net         10323                 :             12 :                     n->object = (Node *) $5;
 5398 rhaas@postgresql.org    10324                 :             12 :                     n->newschema = $8;
 4975 simon@2ndQuadrant.co    10325                 :             12 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10326                 :             12 :                     $$ = (Node *) n;
                              10327                 :                :                 }
                              10328                 :                :             | ALTER SEQUENCE qualified_name SET SCHEMA name
                              10329                 :                :                 {
 7341 tgl@sss.pgh.pa.us       10330                 :              4 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10331                 :                : 
                              10332                 :              4 :                     n->objectType = OBJECT_SEQUENCE;
                              10333                 :              4 :                     n->relation = $3;
                              10334                 :              4 :                     n->newschema = $6;
 4975 simon@2ndQuadrant.co    10335                 :              4 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10336                 :              4 :                     $$ = (Node *) n;
                              10337                 :                :                 }
                              10338                 :                :             | ALTER SEQUENCE IF_P EXISTS qualified_name SET SCHEMA name
                              10339                 :                :                 {
 4975 simon@2ndQuadrant.co    10340                 :UBC           0 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10341                 :                : 
                              10342                 :              0 :                     n->objectType = OBJECT_SEQUENCE;
                              10343                 :              0 :                     n->relation = $5;
                              10344                 :              0 :                     n->newschema = $8;
                              10345                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org    10346                 :              0 :                     $$ = (Node *) n;
                              10347                 :                :                 }
                              10348                 :                :             | ALTER VIEW qualified_name SET SCHEMA name
                              10349                 :                :                 {
 7341 tgl@sss.pgh.pa.us       10350                 :              0 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10351                 :                : 
 6292                         10352                 :              0 :                     n->objectType = OBJECT_VIEW;
 7341                         10353                 :              0 :                     n->relation = $3;
                              10354                 :              0 :                     n->newschema = $6;
 4975 simon@2ndQuadrant.co    10355                 :              0 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10356                 :              0 :                     $$ = (Node *) n;
                              10357                 :                :                 }
                              10358                 :                :             | ALTER VIEW IF_P EXISTS qualified_name SET SCHEMA name
                              10359                 :                :                 {
 4975 simon@2ndQuadrant.co    10360                 :              0 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10361                 :                : 
                              10362                 :              0 :                     n->objectType = OBJECT_VIEW;
                              10363                 :              0 :                     n->relation = $5;
                              10364                 :              0 :                     n->newschema = $8;
                              10365                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org    10366                 :              0 :                     $$ = (Node *) n;
                              10367                 :                :                 }
                              10368                 :                :             | ALTER MATERIALIZED VIEW qualified_name SET SCHEMA name
                              10369                 :                :                 {
 4570 kgrittn@postgresql.o    10370                 :CBC           3 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10371                 :                : 
                              10372                 :              3 :                     n->objectType = OBJECT_MATVIEW;
                              10373                 :              3 :                     n->relation = $4;
                              10374                 :              3 :                     n->newschema = $7;
                              10375                 :              3 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10376                 :              3 :                     $$ = (Node *) n;
                              10377                 :                :                 }
                              10378                 :                :             | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name SET SCHEMA name
                              10379                 :                :                 {
 4570 kgrittn@postgresql.o    10380                 :UBC           0 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10381                 :                : 
                              10382                 :              0 :                     n->objectType = OBJECT_MATVIEW;
                              10383                 :              0 :                     n->relation = $6;
                              10384                 :              0 :                     n->newschema = $9;
                              10385                 :              0 :                     n->missing_ok = true;
 1212 peter@eisentraut.org    10386                 :              0 :                     $$ = (Node *) n;
                              10387                 :                :                 }
                              10388                 :                :             | ALTER FOREIGN TABLE relation_expr SET SCHEMA name
                              10389                 :                :                 {
 5362 rhaas@postgresql.org    10390                 :CBC           3 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10391                 :                : 
                              10392                 :              3 :                     n->objectType = OBJECT_FOREIGN_TABLE;
                              10393                 :              3 :                     n->relation = $4;
                              10394                 :              3 :                     n->newschema = $7;
 4975 simon@2ndQuadrant.co    10395                 :              3 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10396                 :              3 :                     $$ = (Node *) n;
                              10397                 :                :                 }
                              10398                 :                :             | ALTER FOREIGN TABLE IF_P EXISTS relation_expr SET SCHEMA name
                              10399                 :                :                 {
 4975 simon@2ndQuadrant.co    10400                 :              3 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10401                 :                : 
                              10402                 :              3 :                     n->objectType = OBJECT_FOREIGN_TABLE;
                              10403                 :              3 :                     n->relation = $6;
                              10404                 :              3 :                     n->newschema = $9;
                              10405                 :              3 :                     n->missing_ok = true;
 1212 peter@eisentraut.org    10406                 :              3 :                     $$ = (Node *) n;
                              10407                 :                :                 }
                              10408                 :                :             | ALTER TYPE_P any_name SET SCHEMA name
                              10409                 :                :                 {
 7341 tgl@sss.pgh.pa.us       10410                 :              6 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10411                 :                : 
                              10412                 :              6 :                     n->objectType = OBJECT_TYPE;
 3220 peter_e@gmx.net         10413                 :              6 :                     n->object = (Node *) $3;
 7341 tgl@sss.pgh.pa.us       10414                 :              6 :                     n->newschema = $6;
 4975 simon@2ndQuadrant.co    10415                 :              6 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    10416                 :              6 :                     $$ = (Node *) n;
                              10417                 :                :                 }
                              10418                 :                :         ;
                              10419                 :                : 
                              10420                 :                : /*****************************************************************************
                              10421                 :                :  *
                              10422                 :                :  * ALTER OPERATOR name SET define
                              10423                 :                :  *
                              10424                 :                :  *****************************************************************************/
                              10425                 :                : 
                              10426                 :                : AlterOperatorStmt:
                              10427                 :                :             ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')'
                              10428                 :                :                 {
 3707 heikki.linnakangas@i    10429                 :            304 :                     AlterOperatorStmt *n = makeNode(AlterOperatorStmt);
                              10430                 :                : 
 3174 peter_e@gmx.net         10431                 :            304 :                     n->opername = $3;
                              10432                 :            304 :                     n->options = $6;
 1212 peter@eisentraut.org    10433                 :            304 :                     $$ = (Node *) n;
                              10434                 :                :                 }
                              10435                 :                :         ;
                              10436                 :                : 
 3707 heikki.linnakangas@i    10437                 :            334 : operator_def_list:  operator_def_elem                               { $$ = list_make1($1); }
                              10438                 :            253 :             | operator_def_list ',' operator_def_elem               { $$ = lappend($1, $3); }
                              10439                 :                :         ;
                              10440                 :                : 
                              10441                 :                : operator_def_elem: ColLabel '=' NONE
 3287 peter_e@gmx.net         10442                 :             15 :                         { $$ = makeDefElem($1, NULL, @1); }
                              10443                 :                :                    | ColLabel '=' operator_def_arg
 3042                         10444                 :            555 :                         { $$ = makeDefElem($1, (Node *) $3, @1); }
                              10445                 :                :                    | ColLabel
  687 tgl@sss.pgh.pa.us       10446                 :             17 :                         { $$ = makeDefElem($1, NULL, @1); }
                              10447                 :                :         ;
                              10448                 :                : 
                              10449                 :                : /* must be similar enough to def_arg to avoid reduce/reduce conflicts */
                              10450                 :                : operator_def_arg:
 1212 peter@eisentraut.org    10451                 :            516 :             func_type                       { $$ = (Node *) $1; }
                              10452                 :             12 :             | reserved_keyword              { $$ = (Node *) makeString(pstrdup($1)); }
                              10453                 :             27 :             | qual_all_Op                   { $$ = (Node *) $1; }
 1212 peter@eisentraut.org    10454                 :UBC           0 :             | NumericOnly                   { $$ = (Node *) $1; }
                              10455                 :              0 :             | Sconst                        { $$ = (Node *) makeString($1); }
                              10456                 :                :         ;
                              10457                 :                : 
                              10458                 :                : /*****************************************************************************
                              10459                 :                :  *
                              10460                 :                :  * ALTER TYPE name SET define
                              10461                 :                :  *
                              10462                 :                :  * We repurpose ALTER OPERATOR's version of "definition" here
                              10463                 :                :  *
                              10464                 :                :  *****************************************************************************/
                              10465                 :                : 
                              10466                 :                : AlterTypeStmt:
                              10467                 :                :             ALTER TYPE_P any_name SET '(' operator_def_list ')'
                              10468                 :                :                 {
 2010 tgl@sss.pgh.pa.us       10469                 :CBC          30 :                     AlterTypeStmt *n = makeNode(AlterTypeStmt);
                              10470                 :                : 
                              10471                 :             30 :                     n->typeName = $3;
                              10472                 :             30 :                     n->options = $6;
 1212 peter@eisentraut.org    10473                 :             30 :                     $$ = (Node *) n;
                              10474                 :                :                 }
                              10475                 :                :         ;
                              10476                 :                : 
                              10477                 :                : /*****************************************************************************
                              10478                 :                :  *
                              10479                 :                :  * ALTER THING name OWNER TO newname
                              10480                 :                :  *
                              10481                 :                :  *****************************************************************************/
                              10482                 :                : 
                              10483                 :                : AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
                              10484                 :                :                 {
 7743 tgl@sss.pgh.pa.us       10485                 :             71 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10486                 :                : 
                              10487                 :             71 :                     n->objectType = OBJECT_AGGREGATE;
 3220 peter_e@gmx.net         10488                 :             71 :                     n->object = (Node *) $3;
 3278                         10489                 :             71 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10490                 :             71 :                     $$ = (Node *) n;
                              10491                 :                :                 }
                              10492                 :                :             | ALTER COLLATION any_name OWNER TO RoleSpec
                              10493                 :                :                 {
 5320 peter_e@gmx.net         10494                 :              9 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10495                 :                : 
                              10496                 :              9 :                     n->objectType = OBJECT_COLLATION;
 3220                         10497                 :              9 :                     n->object = (Node *) $3;
 5320                         10498                 :              9 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10499                 :              9 :                     $$ = (Node *) n;
                              10500                 :                :                 }
                              10501                 :                :             | ALTER CONVERSION_P any_name OWNER TO RoleSpec
                              10502                 :                :                 {
 7743 tgl@sss.pgh.pa.us       10503                 :             12 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10504                 :                : 
                              10505                 :             12 :                     n->objectType = OBJECT_CONVERSION;
 3220 peter_e@gmx.net         10506                 :             12 :                     n->object = (Node *) $3;
 7743 tgl@sss.pgh.pa.us       10507                 :             12 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10508                 :             12 :                     $$ = (Node *) n;
                              10509                 :                :                 }
                              10510                 :                :             | ALTER DATABASE name OWNER TO RoleSpec
                              10511                 :                :                 {
 7743 tgl@sss.pgh.pa.us       10512                 :             43 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10513                 :                : 
                              10514                 :             43 :                     n->objectType = OBJECT_DATABASE;
 3220 peter_e@gmx.net         10515                 :             43 :                     n->object = (Node *) makeString($3);
 7743 tgl@sss.pgh.pa.us       10516                 :             43 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10517                 :             43 :                     $$ = (Node *) n;
                              10518                 :                :                 }
                              10519                 :                :             | ALTER DOMAIN_P any_name OWNER TO RoleSpec
                              10520                 :                :                 {
 7743 tgl@sss.pgh.pa.us       10521                 :             24 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10522                 :                : 
                              10523                 :             24 :                     n->objectType = OBJECT_DOMAIN;
 3220 peter_e@gmx.net         10524                 :             24 :                     n->object = (Node *) $3;
 7743 tgl@sss.pgh.pa.us       10525                 :             24 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10526                 :             24 :                     $$ = (Node *) n;
                              10527                 :                :                 }
                              10528                 :                :             | ALTER FUNCTION function_with_argtypes OWNER TO RoleSpec
                              10529                 :                :                 {
 7743 tgl@sss.pgh.pa.us       10530                 :            293 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10531                 :                : 
                              10532                 :            293 :                     n->objectType = OBJECT_FUNCTION;
 3220 peter_e@gmx.net         10533                 :            293 :                     n->object = (Node *) $3;
 6578 tgl@sss.pgh.pa.us       10534                 :            293 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10535                 :            293 :                     $$ = (Node *) n;
                              10536                 :                :                 }
                              10537                 :                :             | ALTER opt_procedural LANGUAGE name OWNER TO RoleSpec
                              10538                 :                :                 {
 6739 tgl@sss.pgh.pa.us       10539                 :             71 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10540                 :                : 
                              10541                 :             71 :                     n->objectType = OBJECT_LANGUAGE;
 3220 peter_e@gmx.net         10542                 :             71 :                     n->object = (Node *) makeString($4);
 6739 tgl@sss.pgh.pa.us       10543                 :             71 :                     n->newowner = $7;
 1212 peter@eisentraut.org    10544                 :             71 :                     $$ = (Node *) n;
                              10545                 :                :                 }
                              10546                 :                :             | ALTER LARGE_P OBJECT_P NumericOnly OWNER TO RoleSpec
                              10547                 :                :                 {
 5748 itagaki.takahiro@gma    10548                 :              3 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10549                 :                : 
                              10550                 :              3 :                     n->objectType = OBJECT_LARGEOBJECT;
 3220 peter_e@gmx.net         10551                 :              3 :                     n->object = (Node *) $4;
 5748 itagaki.takahiro@gma    10552                 :              3 :                     n->newowner = $7;
 1212 peter@eisentraut.org    10553                 :              3 :                     $$ = (Node *) n;
                              10554                 :                :                 }
                              10555                 :                :             | ALTER OPERATOR operator_with_argtypes OWNER TO RoleSpec
                              10556                 :                :                 {
 7743 tgl@sss.pgh.pa.us       10557                 :             23 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10558                 :                : 
                              10559                 :             23 :                     n->objectType = OBJECT_OPERATOR;
 3220 peter_e@gmx.net         10560                 :             23 :                     n->object = (Node *) $3;
 3174                         10561                 :             23 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10562                 :             23 :                     $$ = (Node *) n;
                              10563                 :                :                 }
                              10564                 :                :             | ALTER OPERATOR CLASS any_name USING name OWNER TO RoleSpec
                              10565                 :                :                 {
 7743 tgl@sss.pgh.pa.us       10566                 :             27 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10567                 :                : 
                              10568                 :             27 :                     n->objectType = OBJECT_OPCLASS;
 3220 peter_e@gmx.net         10569                 :             27 :                     n->object = (Node *) lcons(makeString($6), $4);
 7743 tgl@sss.pgh.pa.us       10570                 :             27 :                     n->newowner = $9;
 1212 peter@eisentraut.org    10571                 :             27 :                     $$ = (Node *) n;
                              10572                 :                :                 }
                              10573                 :                :             | ALTER OPERATOR FAMILY any_name USING name OWNER TO RoleSpec
                              10574                 :                :                 {
 6801 tgl@sss.pgh.pa.us       10575                 :             31 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10576                 :                : 
                              10577                 :             31 :                     n->objectType = OBJECT_OPFAMILY;
 3220 peter_e@gmx.net         10578                 :             31 :                     n->object = (Node *) lcons(makeString($6), $4);
 6801 tgl@sss.pgh.pa.us       10579                 :             31 :                     n->newowner = $9;
 1212 peter@eisentraut.org    10580                 :             31 :                     $$ = (Node *) n;
                              10581                 :                :                 }
                              10582                 :                :             | ALTER PROCEDURE function_with_argtypes OWNER TO RoleSpec
                              10583                 :                :                 {
 2837 peter_e@gmx.net         10584                 :             12 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10585                 :                : 
                              10586                 :             12 :                     n->objectType = OBJECT_PROCEDURE;
                              10587                 :             12 :                     n->object = (Node *) $3;
                              10588                 :             12 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10589                 :             12 :                     $$ = (Node *) n;
                              10590                 :                :                 }
                              10591                 :                :             | ALTER ROUTINE function_with_argtypes OWNER TO RoleSpec
                              10592                 :                :                 {
 2837 peter_e@gmx.net         10593                 :UBC           0 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10594                 :                : 
                              10595                 :              0 :                     n->objectType = OBJECT_ROUTINE;
                              10596                 :              0 :                     n->object = (Node *) $3;
                              10597                 :              0 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10598                 :              0 :                     $$ = (Node *) n;
                              10599                 :                :                 }
                              10600                 :                :             | ALTER SCHEMA name OWNER TO RoleSpec
                              10601                 :                :                 {
 7743 tgl@sss.pgh.pa.us       10602                 :CBC          32 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10603                 :                : 
                              10604                 :             32 :                     n->objectType = OBJECT_SCHEMA;
 3220 peter_e@gmx.net         10605                 :             32 :                     n->object = (Node *) makeString($3);
 7743 tgl@sss.pgh.pa.us       10606                 :             32 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10607                 :             32 :                     $$ = (Node *) n;
                              10608                 :                :                 }
                              10609                 :                :             | ALTER TYPE_P any_name OWNER TO RoleSpec
                              10610                 :                :                 {
 7743 tgl@sss.pgh.pa.us       10611                 :             42 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10612                 :                : 
                              10613                 :             42 :                     n->objectType = OBJECT_TYPE;
 3220 peter_e@gmx.net         10614                 :             42 :                     n->object = (Node *) $3;
 7743 tgl@sss.pgh.pa.us       10615                 :             42 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10616                 :             42 :                     $$ = (Node *) n;
                              10617                 :                :                 }
                              10618                 :                :             | ALTER TABLESPACE name OWNER TO RoleSpec
                              10619                 :                :                 {
 7743 tgl@sss.pgh.pa.us       10620                 :              3 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10621                 :                : 
                              10622                 :              3 :                     n->objectType = OBJECT_TABLESPACE;
 3220 peter_e@gmx.net         10623                 :              3 :                     n->object = (Node *) makeString($3);
 7743 tgl@sss.pgh.pa.us       10624                 :              3 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10625                 :              3 :                     $$ = (Node *) n;
                              10626                 :                :                 }
                              10627                 :                :             | ALTER STATISTICS any_name OWNER TO RoleSpec
                              10628                 :                :                 {
 3088 alvherre@alvh.no-ip.    10629                 :             16 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10630                 :                : 
                              10631                 :             16 :                     n->objectType = OBJECT_STATISTIC_EXT;
                              10632                 :             16 :                     n->object = (Node *) $3;
                              10633                 :             16 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10634                 :             16 :                     $$ = (Node *) n;
                              10635                 :                :                 }
                              10636                 :                :             | ALTER TEXT_P SEARCH DICTIONARY any_name OWNER TO RoleSpec
                              10637                 :                :                 {
 6591 tgl@sss.pgh.pa.us       10638                 :             21 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10639                 :                : 
                              10640                 :             21 :                     n->objectType = OBJECT_TSDICTIONARY;
 3220 peter_e@gmx.net         10641                 :             21 :                     n->object = (Node *) $5;
 6591 tgl@sss.pgh.pa.us       10642                 :             21 :                     n->newowner = $8;
 1212 peter@eisentraut.org    10643                 :             21 :                     $$ = (Node *) n;
                              10644                 :                :                 }
                              10645                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name OWNER TO RoleSpec
                              10646                 :                :                 {
 6591 tgl@sss.pgh.pa.us       10647                 :             16 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10648                 :                : 
                              10649                 :             16 :                     n->objectType = OBJECT_TSCONFIGURATION;
 3220 peter_e@gmx.net         10650                 :             16 :                     n->object = (Node *) $5;
 6591 tgl@sss.pgh.pa.us       10651                 :             16 :                     n->newowner = $8;
 1212 peter@eisentraut.org    10652                 :             16 :                     $$ = (Node *) n;
                              10653                 :                :                 }
                              10654                 :                :             | ALTER FOREIGN DATA_P WRAPPER name OWNER TO RoleSpec
                              10655                 :                :                 {
 6105 peter_e@gmx.net         10656                 :             10 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10657                 :                : 
                              10658                 :             10 :                     n->objectType = OBJECT_FDW;
 3220                         10659                 :             10 :                     n->object = (Node *) makeString($5);
 6105                         10660                 :             10 :                     n->newowner = $8;
 1212 peter@eisentraut.org    10661                 :             10 :                     $$ = (Node *) n;
                              10662                 :                :                 }
                              10663                 :                :             | ALTER SERVER name OWNER TO RoleSpec
                              10664                 :                :                 {
 6105 peter_e@gmx.net         10665                 :             34 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10666                 :                : 
                              10667                 :             34 :                     n->objectType = OBJECT_FOREIGN_SERVER;
 3220                         10668                 :             34 :                     n->object = (Node *) makeString($3);
 6105                         10669                 :             34 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10670                 :             34 :                     $$ = (Node *) n;
                              10671                 :                :                 }
                              10672                 :                :             | ALTER EVENT TRIGGER name OWNER TO RoleSpec
                              10673                 :                :                 {
 4798 rhaas@postgresql.org    10674                 :              7 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10675                 :                : 
                              10676                 :              7 :                     n->objectType = OBJECT_EVENT_TRIGGER;
 3220 peter_e@gmx.net         10677                 :              7 :                     n->object = (Node *) makeString($4);
 4798 rhaas@postgresql.org    10678                 :              7 :                     n->newowner = $7;
 1212 peter@eisentraut.org    10679                 :              7 :                     $$ = (Node *) n;
                              10680                 :                :                 }
                              10681                 :                :             | ALTER PUBLICATION name OWNER TO RoleSpec
                              10682                 :                :                 {
 3152 peter_e@gmx.net         10683                 :             18 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10684                 :                : 
                              10685                 :             18 :                     n->objectType = OBJECT_PUBLICATION;
 3220                         10686                 :             18 :                     n->object = (Node *) makeString($3);
 3152                         10687                 :             18 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10688                 :             18 :                     $$ = (Node *) n;
                              10689                 :                :                 }
                              10690                 :                :             | ALTER SUBSCRIPTION name OWNER TO RoleSpec
                              10691                 :                :                 {
 3152 peter_e@gmx.net         10692                 :              9 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10693                 :                : 
                              10694                 :              9 :                     n->objectType = OBJECT_SUBSCRIPTION;
 3220                         10695                 :              9 :                     n->object = (Node *) makeString($3);
 3152                         10696                 :              9 :                     n->newowner = $6;
 1212 peter@eisentraut.org    10697                 :              9 :                     $$ = (Node *) n;
                              10698                 :                :                 }
                              10699                 :                :         ;
                              10700                 :                : 
                              10701                 :                : 
                              10702                 :                : /*****************************************************************************
                              10703                 :                :  *
                              10704                 :                :  * CREATE PUBLICATION name [WITH options]
                              10705                 :                :  *
                              10706                 :                :  * CREATE PUBLICATION FOR ALL TABLES [WITH options]
                              10707                 :                :  *
                              10708                 :                :  * CREATE PUBLICATION FOR pub_obj [, ...] [WITH options]
                              10709                 :                :  *
                              10710                 :                :  * pub_obj is one of:
                              10711                 :                :  *
                              10712                 :                :  *      TABLE table [, ...]
                              10713                 :                :  *      TABLES IN SCHEMA schema [, ...]
                              10714                 :                :  *
                              10715                 :                :  *****************************************************************************/
                              10716                 :                : 
                              10717                 :                : CreatePublicationStmt:
                              10718                 :                :             CREATE PUBLICATION name opt_definition
                              10719                 :                :                 {
 3152 peter_e@gmx.net         10720                 :             73 :                     CreatePublicationStmt *n = makeNode(CreatePublicationStmt);
                              10721                 :                : 
                              10722                 :             73 :                     n->pubname = $3;
 1410 akapila@postgresql.o    10723                 :             73 :                     n->options = $4;
 1212 peter@eisentraut.org    10724                 :             73 :                     $$ = (Node *) n;
                              10725                 :                :                 }
                              10726                 :                :             | CREATE PUBLICATION name FOR ALL TABLES opt_definition
                              10727                 :                :                 {
 1410 akapila@postgresql.o    10728                 :             50 :                     CreatePublicationStmt *n = makeNode(CreatePublicationStmt);
                              10729                 :                : 
                              10730                 :             50 :                     n->pubname = $3;
                              10731                 :             50 :                     n->options = $7;
 1248 tomas.vondra@postgre    10732                 :             50 :                     n->for_all_tables = true;
 1212 peter@eisentraut.org    10733                 :             50 :                     $$ = (Node *) n;
                              10734                 :                :                 }
                              10735                 :                :             | CREATE PUBLICATION name FOR pub_obj_list opt_definition
                              10736                 :                :                 {
 1410 akapila@postgresql.o    10737                 :            329 :                     CreatePublicationStmt *n = makeNode(CreatePublicationStmt);
                              10738                 :                : 
                              10739                 :            329 :                     n->pubname = $3;
                              10740                 :            329 :                     n->options = $6;
 1212 peter@eisentraut.org    10741                 :            329 :                     n->pubobjects = (List *) $5;
 1410 akapila@postgresql.o    10742                 :            329 :                     preprocess_pubobj_list(n->pubobjects, yyscanner);
 1212 peter@eisentraut.org    10743                 :            314 :                     $$ = (Node *) n;
                              10744                 :                :                 }
                              10745                 :                :         ;
                              10746                 :                : 
                              10747                 :                : /*
                              10748                 :                :  * FOR TABLE and FOR TABLES IN SCHEMA specifications
                              10749                 :                :  *
                              10750                 :                :  * This rule parses publication objects with and without keyword prefixes.
                              10751                 :                :  *
                              10752                 :                :  * The actual type of the object without keyword prefix depends on the previous
                              10753                 :                :  * one with keyword prefix. It will be preprocessed in preprocess_pubobj_list().
                              10754                 :                :  *
                              10755                 :                :  * For the object without keyword prefix, we cannot just use relation_expr here,
                              10756                 :                :  * because some extended expressions in relation_expr cannot be used as a
                              10757                 :                :  * schemaname and we cannot differentiate it. So, we extract the rules from
                              10758                 :                :  * relation_expr here.
                              10759                 :                :  */
                              10760                 :                : PublicationObjSpec:
                              10761                 :                :             TABLE relation_expr opt_column_list OptWhereClause
                              10762                 :                :                 {
 1410 akapila@postgresql.o    10763                 :            661 :                     $$ = makeNode(PublicationObjSpec);
                              10764                 :            661 :                     $$->pubobjtype = PUBLICATIONOBJ_TABLE;
                              10765                 :            661 :                     $$->pubtable = makeNode(PublicationTable);
                              10766                 :            661 :                     $$->pubtable->relation = $2;
 1260 tomas.vondra@postgre    10767                 :            661 :                     $$->pubtable->columns = $3;
                              10768                 :            661 :                     $$->pubtable->whereClause = $4;
                              10769                 :                :                 }
                              10770                 :                :             | TABLES IN_P SCHEMA ColId
                              10771                 :                :                 {
 1410 akapila@postgresql.o    10772                 :            186 :                     $$ = makeNode(PublicationObjSpec);
 1346 alvherre@alvh.no-ip.    10773                 :            186 :                     $$->pubobjtype = PUBLICATIONOBJ_TABLES_IN_SCHEMA;
 1080                         10774                 :            186 :                     $$->name = $4;
                              10775                 :            186 :                     $$->location = @4;
                              10776                 :                :                 }
                              10777                 :                :             | TABLES IN_P SCHEMA CURRENT_SCHEMA
                              10778                 :                :                 {
 1410 akapila@postgresql.o    10779                 :              9 :                     $$ = makeNode(PublicationObjSpec);
 1346 alvherre@alvh.no-ip.    10780                 :              9 :                     $$->pubobjtype = PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA;
 1080                         10781                 :              9 :                     $$->location = @4;
                              10782                 :                :                 }
                              10783                 :                :             | ColId opt_column_list OptWhereClause
                              10784                 :                :                 {
 1410 akapila@postgresql.o    10785                 :             65 :                     $$ = makeNode(PublicationObjSpec);
                              10786                 :             65 :                     $$->pubobjtype = PUBLICATIONOBJ_CONTINUATION;
                              10787                 :                :                     /*
                              10788                 :                :                      * If either a row filter or column list is specified, create
                              10789                 :                :                      * a PublicationTable object.
                              10790                 :                :                      */
 1260 tomas.vondra@postgre    10791   [ +  +  +  + ]:             65 :                     if ($2 || $3)
                              10792                 :                :                     {
                              10793                 :                :                         /*
                              10794                 :                :                          * The OptWhereClause must be stored here but it is
                              10795                 :                :                          * valid only for tables. For non-table objects, an
                              10796                 :                :                          * error will be thrown later via
                              10797                 :                :                          * preprocess_pubobj_list().
                              10798                 :                :                          */
 1292 akapila@postgresql.o    10799                 :             21 :                         $$->pubtable = makeNode(PublicationTable);
                              10800                 :             21 :                         $$->pubtable->relation = makeRangeVar(NULL, $1, @1);
 1260 tomas.vondra@postgre    10801                 :             21 :                         $$->pubtable->columns = $2;
                              10802                 :             21 :                         $$->pubtable->whereClause = $3;
                              10803                 :                :                     }
                              10804                 :                :                     else
                              10805                 :                :                     {
 1292 akapila@postgresql.o    10806                 :             44 :                         $$->name = $1;
                              10807                 :                :                     }
 1410                         10808                 :             65 :                     $$->location = @1;
                              10809                 :                :                 }
                              10810                 :                :             | ColId indirection opt_column_list OptWhereClause
                              10811                 :                :                 {
                              10812                 :             16 :                     $$ = makeNode(PublicationObjSpec);
                              10813                 :             16 :                     $$->pubobjtype = PUBLICATIONOBJ_CONTINUATION;
                              10814                 :             16 :                     $$->pubtable = makeNode(PublicationTable);
                              10815                 :             16 :                     $$->pubtable->relation = makeRangeVarFromQualifiedName($1, $2, @1, yyscanner);
 1260 tomas.vondra@postgre    10816                 :             16 :                     $$->pubtable->columns = $3;
                              10817                 :             16 :                     $$->pubtable->whereClause = $4;
 1410 akapila@postgresql.o    10818                 :             16 :                     $$->location = @1;
                              10819                 :                :                 }
                              10820                 :                :             /* grammar like tablename * , ONLY tablename, ONLY ( tablename ) */
                              10821                 :                :             | extended_relation_expr opt_column_list OptWhereClause
                              10822                 :                :                 {
                              10823                 :              3 :                     $$ = makeNode(PublicationObjSpec);
                              10824                 :              3 :                     $$->pubobjtype = PUBLICATIONOBJ_CONTINUATION;
                              10825                 :              3 :                     $$->pubtable = makeNode(PublicationTable);
                              10826                 :              3 :                     $$->pubtable->relation = $1;
 1260 tomas.vondra@postgre    10827                 :              3 :                     $$->pubtable->columns = $2;
                              10828                 :              3 :                     $$->pubtable->whereClause = $3;
                              10829                 :                :                 }
                              10830                 :                :             | CURRENT_SCHEMA
                              10831                 :                :                 {
 1410 akapila@postgresql.o    10832                 :              9 :                     $$ = makeNode(PublicationObjSpec);
                              10833                 :              9 :                     $$->pubobjtype = PUBLICATIONOBJ_CONTINUATION;
                              10834                 :              9 :                     $$->location = @1;
                              10835                 :                :                 }
                              10836                 :                :                 ;
                              10837                 :                : 
                              10838                 :                : pub_obj_list:   PublicationObjSpec
 1461 alvherre@alvh.no-ip.    10839                 :            822 :                     { $$ = list_make1($1); }
                              10840                 :                :             | pub_obj_list ',' PublicationObjSpec
 1410 akapila@postgresql.o    10841                 :            127 :                     { $$ = lappend($1, $3); }
                              10842                 :                :     ;
                              10843                 :                : 
                              10844                 :                : /*****************************************************************************
                              10845                 :                :  *
                              10846                 :                :  * ALTER PUBLICATION name SET ( options )
                              10847                 :                :  *
                              10848                 :                :  * ALTER PUBLICATION name ADD pub_obj [, ...]
                              10849                 :                :  *
                              10850                 :                :  * ALTER PUBLICATION name DROP pub_obj [, ...]
                              10851                 :                :  *
                              10852                 :                :  * ALTER PUBLICATION name SET pub_obj [, ...]
                              10853                 :                :  *
                              10854                 :                :  * pub_obj is one of:
                              10855                 :                :  *
                              10856                 :                :  *      TABLE table_name [, ...]
                              10857                 :                :  *      TABLES IN SCHEMA schema_name [, ...]
                              10858                 :                :  *
                              10859                 :                :  *****************************************************************************/
                              10860                 :                : 
                              10861                 :                : AlterPublicationStmt:
                              10862                 :                :             ALTER PUBLICATION name SET definition
                              10863                 :                :                 {
 3152 peter_e@gmx.net         10864                 :             58 :                     AlterPublicationStmt *n = makeNode(AlterPublicationStmt);
                              10865                 :                : 
                              10866                 :             58 :                     n->pubname = $3;
                              10867                 :             58 :                     n->options = $5;
 1212 peter@eisentraut.org    10868                 :             58 :                     $$ = (Node *) n;
                              10869                 :                :                 }
                              10870                 :                :             | ALTER PUBLICATION name ADD_P pub_obj_list
                              10871                 :                :                 {
 3152 peter_e@gmx.net         10872                 :            184 :                     AlterPublicationStmt *n = makeNode(AlterPublicationStmt);
                              10873                 :                : 
                              10874                 :            184 :                     n->pubname = $3;
 1410 akapila@postgresql.o    10875                 :            184 :                     n->pubobjects = $5;
                              10876                 :            184 :                     preprocess_pubobj_list(n->pubobjects, yyscanner);
 1342 alvherre@alvh.no-ip.    10877                 :            181 :                     n->action = AP_AddObjects;
 1212 peter@eisentraut.org    10878                 :            181 :                     $$ = (Node *) n;
                              10879                 :                :                 }
                              10880                 :                :             | ALTER PUBLICATION name SET pub_obj_list
                              10881                 :                :                 {
 3152 peter_e@gmx.net         10882                 :            232 :                     AlterPublicationStmt *n = makeNode(AlterPublicationStmt);
                              10883                 :                : 
                              10884                 :            232 :                     n->pubname = $3;
 1410 akapila@postgresql.o    10885                 :            232 :                     n->pubobjects = $5;
                              10886                 :            232 :                     preprocess_pubobj_list(n->pubobjects, yyscanner);
 1342 alvherre@alvh.no-ip.    10887                 :            232 :                     n->action = AP_SetObjects;
 1212 peter@eisentraut.org    10888                 :            232 :                     $$ = (Node *) n;
                              10889                 :                :                 }
                              10890                 :                :             | ALTER PUBLICATION name DROP pub_obj_list
                              10891                 :                :                 {
 3152 peter_e@gmx.net         10892                 :             77 :                     AlterPublicationStmt *n = makeNode(AlterPublicationStmt);
                              10893                 :                : 
                              10894                 :             77 :                     n->pubname = $3;
 1410 akapila@postgresql.o    10895                 :             77 :                     n->pubobjects = $5;
                              10896                 :             77 :                     preprocess_pubobj_list(n->pubobjects, yyscanner);
 1342 alvherre@alvh.no-ip.    10897                 :             77 :                     n->action = AP_DropObjects;
 1212 peter@eisentraut.org    10898                 :             77 :                     $$ = (Node *) n;
                              10899                 :                :                 }
                              10900                 :                :         ;
                              10901                 :                : 
                              10902                 :                : /*****************************************************************************
                              10903                 :                :  *
                              10904                 :                :  * CREATE SUBSCRIPTION name ...
                              10905                 :                :  *
                              10906                 :                :  *****************************************************************************/
                              10907                 :                : 
                              10908                 :                : CreateSubscriptionStmt:
                              10909                 :                :             CREATE SUBSCRIPTION name CONNECTION Sconst PUBLICATION name_list opt_definition
                              10910                 :                :                 {
                              10911                 :                :                     CreateSubscriptionStmt *n =
 3152 peter_e@gmx.net         10912                 :            239 :                         makeNode(CreateSubscriptionStmt);
                              10913                 :            239 :                     n->subname = $3;
                              10914                 :            239 :                     n->conninfo = $5;
                              10915                 :            239 :                     n->publication = $7;
                              10916                 :            239 :                     n->options = $8;
 1212 peter@eisentraut.org    10917                 :            239 :                     $$ = (Node *) n;
                              10918                 :                :                 }
                              10919                 :                :         ;
                              10920                 :                : 
                              10921                 :                : /*****************************************************************************
                              10922                 :                :  *
                              10923                 :                :  * ALTER SUBSCRIPTION name ...
                              10924                 :                :  *
                              10925                 :                :  *****************************************************************************/
                              10926                 :                : 
                              10927                 :                : AlterSubscriptionStmt:
                              10928                 :                :             ALTER SUBSCRIPTION name SET definition
                              10929                 :                :                 {
                              10930                 :                :                     AlterSubscriptionStmt *n =
 3152 peter_e@gmx.net         10931                 :            108 :                         makeNode(AlterSubscriptionStmt);
                              10932                 :                : 
 3089                         10933                 :            108 :                     n->kind = ALTER_SUBSCRIPTION_OPTIONS;
 3152                         10934                 :            108 :                     n->subname = $3;
                              10935                 :            108 :                     n->options = $5;
 1212 peter@eisentraut.org    10936                 :            108 :                     $$ = (Node *) n;
                              10937                 :                :                 }
                              10938                 :                :             | ALTER SUBSCRIPTION name CONNECTION Sconst
                              10939                 :                :                 {
                              10940                 :                :                     AlterSubscriptionStmt *n =
 3152 peter_e@gmx.net         10941                 :             13 :                         makeNode(AlterSubscriptionStmt);
                              10942                 :                : 
 3089                         10943                 :             13 :                     n->kind = ALTER_SUBSCRIPTION_CONNECTION;
 3152                         10944                 :             13 :                     n->subname = $3;
 3089                         10945                 :             13 :                     n->conninfo = $5;
 1212 peter@eisentraut.org    10946                 :             13 :                     $$ = (Node *) n;
                              10947                 :                :                 }
                              10948                 :                :             | ALTER SUBSCRIPTION name REFRESH PUBLICATION opt_definition
                              10949                 :                :                 {
                              10950                 :                :                     AlterSubscriptionStmt *n =
 3089 peter_e@gmx.net         10951                 :             29 :                         makeNode(AlterSubscriptionStmt);
                              10952                 :                : 
                              10953                 :             29 :                     n->kind = ALTER_SUBSCRIPTION_REFRESH;
                              10954                 :             29 :                     n->subname = $3;
                              10955                 :             29 :                     n->options = $6;
 1212 peter@eisentraut.org    10956                 :             29 :                     $$ = (Node *) n;
                              10957                 :                :                 }
                              10958                 :                :             | ALTER SUBSCRIPTION name ADD_P PUBLICATION name_list opt_definition
                              10959                 :                :                 {
                              10960                 :                :                     AlterSubscriptionStmt *n =
 1614                         10961                 :             14 :                         makeNode(AlterSubscriptionStmt);
                              10962                 :                : 
                              10963                 :             14 :                     n->kind = ALTER_SUBSCRIPTION_ADD_PUBLICATION;
                              10964                 :             14 :                     n->subname = $3;
                              10965                 :             14 :                     n->publication = $6;
                              10966                 :             14 :                     n->options = $7;
 1212                         10967                 :             14 :                     $$ = (Node *) n;
                              10968                 :                :                 }
                              10969                 :                :             | ALTER SUBSCRIPTION name DROP PUBLICATION name_list opt_definition
                              10970                 :                :                 {
                              10971                 :                :                     AlterSubscriptionStmt *n =
 1614                         10972                 :             13 :                         makeNode(AlterSubscriptionStmt);
                              10973                 :                : 
                              10974                 :             13 :                     n->kind = ALTER_SUBSCRIPTION_DROP_PUBLICATION;
                              10975                 :             13 :                     n->subname = $3;
                              10976                 :             13 :                     n->publication = $6;
                              10977                 :             13 :                     n->options = $7;
 1212                         10978                 :             13 :                     $$ = (Node *) n;
                              10979                 :                :                 }
                              10980                 :                :             | ALTER SUBSCRIPTION name SET PUBLICATION name_list opt_definition
                              10981                 :                :                 {
                              10982                 :                :                     AlterSubscriptionStmt *n =
 3152 peter_e@gmx.net         10983                 :             22 :                         makeNode(AlterSubscriptionStmt);
                              10984                 :                : 
 1614 peter@eisentraut.org    10985                 :             22 :                     n->kind = ALTER_SUBSCRIPTION_SET_PUBLICATION;
 3152 peter_e@gmx.net         10986                 :             22 :                     n->subname = $3;
 3089                         10987                 :             22 :                     n->publication = $6;
 3015                         10988                 :             22 :                     n->options = $7;
 1212 peter@eisentraut.org    10989                 :             22 :                     $$ = (Node *) n;
                              10990                 :                :                 }
                              10991                 :                :             | ALTER SUBSCRIPTION name ENABLE_P
                              10992                 :                :                 {
                              10993                 :                :                     AlterSubscriptionStmt *n =
 3152 peter_e@gmx.net         10994                 :             29 :                         makeNode(AlterSubscriptionStmt);
                              10995                 :                : 
 3089                         10996                 :             29 :                     n->kind = ALTER_SUBSCRIPTION_ENABLED;
 3152                         10997                 :             29 :                     n->subname = $3;
                              10998                 :             29 :                     n->options = list_make1(makeDefElem("enabled",
                              10999                 :                :                                             (Node *) makeBoolean(true), @1));
 1212 peter@eisentraut.org    11000                 :             29 :                     $$ = (Node *) n;
                              11001                 :                :                 }
                              11002                 :                :             | ALTER SUBSCRIPTION name DISABLE_P
                              11003                 :                :                 {
                              11004                 :                :                     AlterSubscriptionStmt *n =
 3152 peter_e@gmx.net         11005                 :             21 :                         makeNode(AlterSubscriptionStmt);
                              11006                 :                : 
 3089                         11007                 :             21 :                     n->kind = ALTER_SUBSCRIPTION_ENABLED;
 3152                         11008                 :             21 :                     n->subname = $3;
                              11009                 :             21 :                     n->options = list_make1(makeDefElem("enabled",
                              11010                 :                :                                             (Node *) makeBoolean(false), @1));
 1212 peter@eisentraut.org    11011                 :             21 :                     $$ = (Node *) n;
                              11012                 :                :                 }
                              11013                 :                :             | ALTER SUBSCRIPTION name SKIP definition
                              11014                 :                :                 {
                              11015                 :                :                     AlterSubscriptionStmt *n =
 1264 akapila@postgresql.o    11016                 :             12 :                         makeNode(AlterSubscriptionStmt);
                              11017                 :                : 
                              11018                 :             12 :                     n->kind = ALTER_SUBSCRIPTION_SKIP;
                              11019                 :             12 :                     n->subname = $3;
                              11020                 :             12 :                     n->options = $5;
 1212 peter@eisentraut.org    11021                 :             12 :                     $$ = (Node *) n;
                              11022                 :                :                 }
                              11023                 :                :         ;
                              11024                 :                : 
                              11025                 :                : /*****************************************************************************
                              11026                 :                :  *
                              11027                 :                :  * DROP SUBSCRIPTION [ IF EXISTS ] name
                              11028                 :                :  *
                              11029                 :                :  *****************************************************************************/
                              11030                 :                : 
                              11031                 :                : DropSubscriptionStmt: DROP SUBSCRIPTION name opt_drop_behavior
                              11032                 :                :                 {
 3152 peter_e@gmx.net         11033                 :            120 :                     DropSubscriptionStmt *n = makeNode(DropSubscriptionStmt);
                              11034                 :                : 
                              11035                 :            120 :                     n->subname = $3;
                              11036                 :            120 :                     n->missing_ok = false;
 3042                         11037                 :            120 :                     n->behavior = $4;
 3152                         11038                 :            120 :                     $$ = (Node *) n;
                              11039                 :                :                 }
                              11040                 :                :                 |  DROP SUBSCRIPTION IF_P EXISTS name opt_drop_behavior
                              11041                 :                :                 {
                              11042                 :              3 :                     DropSubscriptionStmt *n = makeNode(DropSubscriptionStmt);
                              11043                 :                : 
                              11044                 :              3 :                     n->subname = $5;
                              11045                 :              3 :                     n->missing_ok = true;
 3042                         11046                 :              3 :                     n->behavior = $6;
 3152                         11047                 :              3 :                     $$ = (Node *) n;
                              11048                 :                :                 }
                              11049                 :                :         ;
                              11050                 :                : 
                              11051                 :                : /*****************************************************************************
                              11052                 :                :  *
                              11053                 :                :  *      QUERY:  Define Rewrite Rule
                              11054                 :                :  *
                              11055                 :                :  *****************************************************************************/
                              11056                 :                : 
                              11057                 :                : RuleStmt:   CREATE opt_or_replace RULE name AS
                              11058                 :                :             ON event TO qualified_name where_clause
                              11059                 :                :             DO opt_instead RuleActionList
                              11060                 :                :                 {
 1212 peter@eisentraut.org    11061                 :            546 :                     RuleStmt   *n = makeNode(RuleStmt);
                              11062                 :                : 
 8405 tgl@sss.pgh.pa.us       11063                 :            546 :                     n->replace = $2;
 5784                         11064                 :            546 :                     n->relation = $9;
 8405                         11065                 :            546 :                     n->rulename = $4;
 5784                         11066                 :            546 :                     n->whereClause = $10;
                              11067                 :            546 :                     n->event = $7;
                              11068                 :            546 :                     n->instead = $12;
                              11069                 :            546 :                     n->actions = $13;
 1212 peter@eisentraut.org    11070                 :            546 :                     $$ = (Node *) n;
                              11071                 :                :                 }
                              11072                 :                :         ;
                              11073                 :                : 
                              11074                 :                : RuleActionList:
 8482 bruce@momjian.us        11075                 :             81 :             NOTHING                                 { $$ = NIL; }
 7769 neilc@samurai.com       11076                 :            442 :             | RuleActionStmt                        { $$ = list_make1($1); }
 8482 bruce@momjian.us        11077                 :             23 :             | '(' RuleActionMulti ')'               { $$ = $2; }
                              11078                 :                :         ;
                              11079                 :                : 
                              11080                 :                : /* the thrashing around here is to discard "empty" statements... */
                              11081                 :                : RuleActionMulti:
                              11082                 :                :             RuleActionMulti ';' RuleActionStmtOrEmpty
 7913 neilc@samurai.com       11083         [ +  + ]:             31 :                 { if ($3 != NULL)
 9079 bruce@momjian.us        11084                 :             23 :                     $$ = lappend($1, $3);
                              11085                 :                :                   else
 9466 tgl@sss.pgh.pa.us       11086                 :              8 :                     $$ = $1;
                              11087                 :                :                 }
                              11088                 :                :             | RuleActionStmtOrEmpty
 7913 neilc@samurai.com       11089         [ +  - ]:             23 :                 { if ($1 != NULL)
 7769                         11090                 :             23 :                     $$ = list_make1($1);
                              11091                 :                :                   else
 9466 tgl@sss.pgh.pa.us       11092                 :UBC           0 :                     $$ = NIL;
                              11093                 :                :                 }
                              11094                 :                :         ;
                              11095                 :                : 
                              11096                 :                : RuleActionStmt:
                              11097                 :                :             SelectStmt
                              11098                 :                :             | InsertStmt
                              11099                 :                :             | UpdateStmt
                              11100                 :                :             | DeleteStmt
                              11101                 :                :             | NotifyStmt
                              11102                 :                :         ;
                              11103                 :                : 
                              11104                 :                : RuleActionStmtOrEmpty:
 8482 bruce@momjian.us        11105                 :CBC          46 :             RuleActionStmt                          { $$ = $1; }
 7913 neilc@samurai.com       11106                 :              8 :             |   /*EMPTY*/                           { $$ = NULL; }
                              11107                 :                :         ;
                              11108                 :                : 
 8482 bruce@momjian.us        11109                 :              9 : event:      SELECT                                  { $$ = CMD_SELECT; }
                              11110                 :            216 :             | UPDATE                                { $$ = CMD_UPDATE; }
                              11111                 :             82 :             | DELETE_P                              { $$ = CMD_DELETE; }
                              11112                 :            239 :             | INSERT                                { $$ = CMD_INSERT; }
                              11113                 :                :          ;
                              11114                 :                : 
                              11115                 :                : opt_instead:
 2943 peter_e@gmx.net         11116                 :            376 :             INSTEAD                                 { $$ = true; }
                              11117                 :             78 :             | ALSO                                  { $$ = false; }
                              11118                 :             92 :             | /*EMPTY*/                             { $$ = false; }
                              11119                 :                :         ;
                              11120                 :                : 
                              11121                 :                : 
                              11122                 :                : /*****************************************************************************
                              11123                 :                :  *
                              11124                 :                :  *      QUERY:
                              11125                 :                :  *              NOTIFY <identifier> can appear both in rule bodies and
                              11126                 :                :  *              as a query-level command
                              11127                 :                :  *
                              11128                 :                :  *****************************************************************************/
                              11129                 :                : 
                              11130                 :                : NotifyStmt: NOTIFY ColId notify_payload
                              11131                 :                :                 {
10225 bruce@momjian.us        11132                 :             64 :                     NotifyStmt *n = makeNode(NotifyStmt);
                              11133                 :                : 
 6214 tgl@sss.pgh.pa.us       11134                 :             64 :                     n->conditionname = $2;
 5681                         11135                 :             64 :                     n->payload = $3;
 1212 peter@eisentraut.org    11136                 :             64 :                     $$ = (Node *) n;
                              11137                 :                :                 }
                              11138                 :                :         ;
                              11139                 :                : 
                              11140                 :                : notify_payload:
 5681 tgl@sss.pgh.pa.us       11141                 :             31 :             ',' Sconst                          { $$ = $2; }
                              11142                 :             33 :             | /*EMPTY*/                         { $$ = NULL; }
                              11143                 :                :         ;
                              11144                 :                : 
                              11145                 :                : ListenStmt: LISTEN ColId
                              11146                 :                :                 {
10225 bruce@momjian.us        11147                 :             37 :                     ListenStmt *n = makeNode(ListenStmt);
                              11148                 :                : 
 6214 tgl@sss.pgh.pa.us       11149                 :             37 :                     n->conditionname = $2;
 1212 peter@eisentraut.org    11150                 :             37 :                     $$ = (Node *) n;
                              11151                 :                :                 }
                              11152                 :                :         ;
                              11153                 :                : 
                              11154                 :                : UnlistenStmt:
                              11155                 :                :             UNLISTEN ColId
                              11156                 :                :                 {
 9874 scrappy@hub.org         11157                 :              3 :                     UnlistenStmt *n = makeNode(UnlistenStmt);
                              11158                 :                : 
 6214 tgl@sss.pgh.pa.us       11159                 :              3 :                     n->conditionname = $2;
 1212 peter@eisentraut.org    11160                 :              3 :                     $$ = (Node *) n;
                              11161                 :                :                 }
                              11162                 :                :             | UNLISTEN '*'
                              11163                 :                :                 {
 9829 lockhart@fourpalms.o    11164                 :             16 :                     UnlistenStmt *n = makeNode(UnlistenStmt);
                              11165                 :                : 
 6214 tgl@sss.pgh.pa.us       11166                 :             16 :                     n->conditionname = NULL;
 1212 peter@eisentraut.org    11167                 :             16 :                     $$ = (Node *) n;
                              11168                 :                :                 }
                              11169                 :                :         ;
                              11170                 :                : 
                              11171                 :                : 
                              11172                 :                : /*****************************************************************************
                              11173                 :                :  *
                              11174                 :                :  *      Transactions:
                              11175                 :                :  *
                              11176                 :                :  *      BEGIN / COMMIT / ROLLBACK
                              11177                 :                :  *      (also older versions END / ABORT)
                              11178                 :                :  *
                              11179                 :                :  *****************************************************************************/
                              11180                 :                : 
                              11181                 :                : TransactionStmt:
                              11182                 :                :             ABORT_P opt_transaction opt_transaction_chain
                              11183                 :                :                 {
10225 bruce@momjian.us        11184                 :            116 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11185                 :                : 
 8244 tgl@sss.pgh.pa.us       11186                 :            116 :                     n->kind = TRANS_STMT_ROLLBACK;
 8434 bruce@momjian.us        11187                 :            116 :                     n->options = NIL;
 2358 peter@eisentraut.org    11188                 :            116 :                     n->chain = $3;
  772 michael@paquier.xyz     11189                 :            116 :                     n->location = -1;
 1212 peter@eisentraut.org    11190                 :            116 :                     $$ = (Node *) n;
                              11191                 :                :                 }
                              11192                 :                :             | START TRANSACTION transaction_mode_list_or_empty
                              11193                 :                :                 {
10225 bruce@momjian.us        11194                 :            821 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11195                 :                : 
 8244 tgl@sss.pgh.pa.us       11196                 :            821 :                     n->kind = TRANS_STMT_START;
 8434 bruce@momjian.us        11197                 :            821 :                     n->options = $3;
  772 michael@paquier.xyz     11198                 :            821 :                     n->location = -1;
 1212 peter@eisentraut.org    11199                 :            821 :                     $$ = (Node *) n;
                              11200                 :                :                 }
                              11201                 :                :             | COMMIT opt_transaction opt_transaction_chain
                              11202                 :                :                 {
 9162 lockhart@fourpalms.o    11203                 :           5890 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11204                 :                : 
 8244 tgl@sss.pgh.pa.us       11205                 :           5890 :                     n->kind = TRANS_STMT_COMMIT;
 8434 bruce@momjian.us        11206                 :           5890 :                     n->options = NIL;
 2358 peter@eisentraut.org    11207                 :           5890 :                     n->chain = $3;
  772 michael@paquier.xyz     11208                 :           5890 :                     n->location = -1;
 1212 peter@eisentraut.org    11209                 :           5890 :                     $$ = (Node *) n;
                              11210                 :                :                 }
                              11211                 :                :             | ROLLBACK opt_transaction opt_transaction_chain
                              11212                 :                :                 {
10225 bruce@momjian.us        11213                 :           1323 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11214                 :                : 
 8244 tgl@sss.pgh.pa.us       11215                 :           1323 :                     n->kind = TRANS_STMT_ROLLBACK;
 8434 bruce@momjian.us        11216                 :           1323 :                     n->options = NIL;
 2358 peter@eisentraut.org    11217                 :           1323 :                     n->chain = $3;
  772 michael@paquier.xyz     11218                 :           1323 :                     n->location = -1;
 1212 peter@eisentraut.org    11219                 :           1323 :                     $$ = (Node *) n;
                              11220                 :                :                 }
                              11221                 :                :             | SAVEPOINT ColId
                              11222                 :                :                 {
 7711 tgl@sss.pgh.pa.us       11223                 :            999 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11224                 :                : 
                              11225                 :            999 :                     n->kind = TRANS_STMT_SAVEPOINT;
 2759 peter_e@gmx.net         11226                 :            999 :                     n->savepoint_name = $2;
  772 michael@paquier.xyz     11227                 :            999 :                     n->location = @2;
 1212 peter@eisentraut.org    11228                 :            999 :                     $$ = (Node *) n;
                              11229                 :                :                 }
                              11230                 :                :             | RELEASE SAVEPOINT ColId
                              11231                 :                :                 {
 7695 tgl@sss.pgh.pa.us       11232                 :            104 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11233                 :                : 
                              11234                 :            104 :                     n->kind = TRANS_STMT_RELEASE;
 2759 peter_e@gmx.net         11235                 :            104 :                     n->savepoint_name = $3;
  772 michael@paquier.xyz     11236                 :            104 :                     n->location = @3;
 1212 peter@eisentraut.org    11237                 :            104 :                     $$ = (Node *) n;
                              11238                 :                :                 }
                              11239                 :                :             | RELEASE ColId
                              11240                 :                :                 {
 7711 tgl@sss.pgh.pa.us       11241                 :             47 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11242                 :                : 
                              11243                 :             47 :                     n->kind = TRANS_STMT_RELEASE;
 2759 peter_e@gmx.net         11244                 :             47 :                     n->savepoint_name = $2;
  772 michael@paquier.xyz     11245                 :             47 :                     n->location = @2;
 1212 peter@eisentraut.org    11246                 :             47 :                     $$ = (Node *) n;
                              11247                 :                :                 }
                              11248                 :                :             | ROLLBACK opt_transaction TO SAVEPOINT ColId
                              11249                 :                :                 {
 7711 tgl@sss.pgh.pa.us       11250                 :            115 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11251                 :                : 
                              11252                 :            115 :                     n->kind = TRANS_STMT_ROLLBACK_TO;
 2759 peter_e@gmx.net         11253                 :            115 :                     n->savepoint_name = $5;
  772 michael@paquier.xyz     11254                 :            115 :                     n->location = @5;
 1212 peter@eisentraut.org    11255                 :            115 :                     $$ = (Node *) n;
                              11256                 :                :                 }
                              11257                 :                :             | ROLLBACK opt_transaction TO ColId
                              11258                 :                :                 {
 7695 tgl@sss.pgh.pa.us       11259                 :            256 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11260                 :                : 
                              11261                 :            256 :                     n->kind = TRANS_STMT_ROLLBACK_TO;
 2759 peter_e@gmx.net         11262                 :            256 :                     n->savepoint_name = $4;
  772 michael@paquier.xyz     11263                 :            256 :                     n->location = @4;
 1212 peter@eisentraut.org    11264                 :            256 :                     $$ = (Node *) n;
                              11265                 :                :                 }
                              11266                 :                :             | PREPARE TRANSACTION Sconst
                              11267                 :                :                 {
 7386 tgl@sss.pgh.pa.us       11268                 :            328 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11269                 :                : 
                              11270                 :            328 :                     n->kind = TRANS_STMT_PREPARE;
                              11271                 :            328 :                     n->gid = $3;
  756 michael@paquier.xyz     11272                 :            328 :                     n->location = @3;
 1212 peter@eisentraut.org    11273                 :            328 :                     $$ = (Node *) n;
                              11274                 :                :                 }
                              11275                 :                :             | COMMIT PREPARED Sconst
                              11276                 :                :                 {
 7386 tgl@sss.pgh.pa.us       11277                 :            243 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11278                 :                : 
                              11279                 :            243 :                     n->kind = TRANS_STMT_COMMIT_PREPARED;
                              11280                 :            243 :                     n->gid = $3;
  756 michael@paquier.xyz     11281                 :            243 :                     n->location = @3;
 1212 peter@eisentraut.org    11282                 :            243 :                     $$ = (Node *) n;
                              11283                 :                :                 }
                              11284                 :                :             | ROLLBACK PREPARED Sconst
                              11285                 :                :                 {
 7386 tgl@sss.pgh.pa.us       11286                 :             39 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11287                 :                : 
                              11288                 :             39 :                     n->kind = TRANS_STMT_ROLLBACK_PREPARED;
                              11289                 :             39 :                     n->gid = $3;
  756 michael@paquier.xyz     11290                 :             39 :                     n->location = @3;
 1212 peter@eisentraut.org    11291                 :             39 :                     $$ = (Node *) n;
                              11292                 :                :                 }
                              11293                 :                :         ;
                              11294                 :                : 
                              11295                 :                : TransactionStmtLegacy:
                              11296                 :                :             BEGIN_P opt_transaction transaction_mode_list_or_empty
                              11297                 :                :                 {
 1613                         11298                 :           7173 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11299                 :                : 
                              11300                 :           7173 :                     n->kind = TRANS_STMT_BEGIN;
                              11301                 :           7173 :                     n->options = $3;
  772 michael@paquier.xyz     11302                 :           7173 :                     n->location = -1;
 1212 peter@eisentraut.org    11303                 :           7173 :                     $$ = (Node *) n;
                              11304                 :                :                 }
                              11305                 :                :             | END_P opt_transaction opt_transaction_chain
                              11306                 :                :                 {
 1613                         11307                 :            180 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11308                 :                : 
                              11309                 :            180 :                     n->kind = TRANS_STMT_COMMIT;
                              11310                 :            180 :                     n->options = NIL;
                              11311                 :            180 :                     n->chain = $3;
  772 michael@paquier.xyz     11312                 :            180 :                     n->location = -1;
 1212 peter@eisentraut.org    11313                 :            180 :                     $$ = (Node *) n;
                              11314                 :                :                 }
                              11315                 :                :         ;
                              11316                 :                : 
                              11317                 :                : opt_transaction:    WORK
                              11318                 :                :             | TRANSACTION
                              11319                 :                :             | /*EMPTY*/
                              11320                 :                :         ;
                              11321                 :                : 
                              11322                 :                : transaction_mode_item:
                              11323                 :                :             ISOLATION LEVEL iso_level
 7695 tgl@sss.pgh.pa.us       11324                 :           3372 :                     { $$ = makeDefElem("transaction_isolation",
 3287 peter_e@gmx.net         11325                 :           3372 :                                        makeStringConst($3, @3), @1); }
                              11326                 :                :             | READ ONLY
 7695 tgl@sss.pgh.pa.us       11327                 :            709 :                     { $$ = makeDefElem("transaction_read_only",
 2943 peter_e@gmx.net         11328                 :            709 :                                        makeIntConst(true, @1), @1); }
                              11329                 :                :             | READ WRITE
 7695 tgl@sss.pgh.pa.us       11330                 :             45 :                     { $$ = makeDefElem("transaction_read_only",
 2943 peter_e@gmx.net         11331                 :             45 :                                        makeIntConst(false, @1), @1); }
                              11332                 :                :             | DEFERRABLE
 5325 heikki.linnakangas@i    11333                 :             22 :                     { $$ = makeDefElem("transaction_deferrable",
                              11334                 :                :                                        makeIntConst(true, @1), @1); }
                              11335                 :                :             | NOT DEFERRABLE
                              11336                 :              5 :                     { $$ = makeDefElem("transaction_deferrable",
 2943 peter_e@gmx.net         11337                 :              5 :                                        makeIntConst(false, @1), @1); }
                              11338                 :                :         ;
                              11339                 :                : 
                              11340                 :                : /* Syntax with commas is SQL-spec, without commas is Postgres historical */
                              11341                 :                : transaction_mode_list:
                              11342                 :                :             transaction_mode_item
 7695 tgl@sss.pgh.pa.us       11343                 :           3480 :                     { $$ = list_make1($1); }
                              11344                 :                :             | transaction_mode_list ',' transaction_mode_item
                              11345                 :            474 :                     { $$ = lappend($1, $3); }
                              11346                 :                :             | transaction_mode_list transaction_mode_item
                              11347                 :            199 :                     { $$ = lappend($1, $2); }
                              11348                 :                :         ;
                              11349                 :                : 
                              11350                 :                : transaction_mode_list_or_empty:
                              11351                 :                :             transaction_mode_list
                              11352                 :                :             | /* EMPTY */
 8275 peter_e@gmx.net         11353                 :           4817 :                     { $$ = NIL; }
                              11354                 :                :         ;
                              11355                 :                : 
                              11356                 :                : opt_transaction_chain:
 2358 peter@eisentraut.org    11357                 :             60 :             AND CHAIN       { $$ = true; }
                              11358                 :              1 :             | AND NO CHAIN  { $$ = false; }
                              11359                 :           7448 :             | /* EMPTY */   { $$ = false; }
                              11360                 :                :         ;
                              11361                 :                : 
                              11362                 :                : 
                              11363                 :                : /*****************************************************************************
                              11364                 :                :  *
                              11365                 :                :  *  QUERY:
                              11366                 :                :  *      CREATE [ OR REPLACE ] [ TEMP ] VIEW <viewname> '('target-list ')'
                              11367                 :                :  *          AS <query> [ WITH [ CASCADED | LOCAL ] CHECK OPTION ]
                              11368                 :                :  *
                              11369                 :                :  *****************************************************************************/
                              11370                 :                : 
                              11371                 :                : ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions
                              11372                 :                :                 AS SelectStmt opt_check_option
                              11373                 :                :                 {
 1212                         11374                 :           8350 :                     ViewStmt   *n = makeNode(ViewStmt);
                              11375                 :                : 
 8405 tgl@sss.pgh.pa.us       11376                 :           8350 :                     n->view = $4;
 5381 rhaas@postgresql.org    11377                 :           8350 :                     n->view->relpersistence = $2;
 8405 tgl@sss.pgh.pa.us       11378                 :           8350 :                     n->aliases = $5;
 5007 rhaas@postgresql.org    11379                 :           8350 :                     n->query = $8;
 6752 tgl@sss.pgh.pa.us       11380                 :           8350 :                     n->replace = false;
 5007 rhaas@postgresql.org    11381                 :           8350 :                     n->options = $6;
 4433 sfrost@snowman.net      11382                 :           8350 :                     n->withCheckOption = $9;
 7521 neilc@samurai.com       11383                 :           8350 :                     $$ = (Node *) n;
                              11384                 :                :                 }
                              11385                 :                :         | CREATE OR REPLACE OptTemp VIEW qualified_name opt_column_list opt_reloptions
                              11386                 :                :                 AS SelectStmt opt_check_option
                              11387                 :                :                 {
 1212 peter@eisentraut.org    11388                 :            122 :                     ViewStmt   *n = makeNode(ViewStmt);
                              11389                 :                : 
 7521 neilc@samurai.com       11390                 :            122 :                     n->view = $6;
 5381 rhaas@postgresql.org    11391                 :            122 :                     n->view->relpersistence = $4;
 7521 neilc@samurai.com       11392                 :            122 :                     n->aliases = $7;
 5007 rhaas@postgresql.org    11393                 :            122 :                     n->query = $10;
 6752 tgl@sss.pgh.pa.us       11394                 :            122 :                     n->replace = true;
 5007 rhaas@postgresql.org    11395                 :            122 :                     n->options = $8;
 4433 sfrost@snowman.net      11396                 :            122 :                     n->withCheckOption = $11;
 7521 neilc@samurai.com       11397                 :            122 :                     $$ = (Node *) n;
                              11398                 :                :                 }
                              11399                 :                :         | CREATE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions
                              11400                 :                :                 AS SelectStmt opt_check_option
                              11401                 :                :                 {
 1212 peter@eisentraut.org    11402                 :              4 :                     ViewStmt   *n = makeNode(ViewStmt);
                              11403                 :                : 
 4601 peter_e@gmx.net         11404                 :              4 :                     n->view = $5;
                              11405                 :              4 :                     n->view->relpersistence = $2;
                              11406                 :              4 :                     n->aliases = $7;
                              11407                 :              4 :                     n->query = makeRecursiveViewSelect(n->view->relname, n->aliases, $11);
                              11408                 :              4 :                     n->replace = false;
                              11409                 :              4 :                     n->options = $9;
 4433 sfrost@snowman.net      11410                 :              4 :                     n->withCheckOption = $12;
                              11411         [ -  + ]:              4 :                     if (n->withCheckOption != NO_CHECK_OPTION)
 4433 sfrost@snowman.net      11412         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              11413                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              11414                 :                :                                  errmsg("WITH CHECK OPTION not supported on recursive views"),
                              11415                 :                :                                  parser_errposition(@12)));
 4601 peter_e@gmx.net         11416                 :CBC           4 :                     $$ = (Node *) n;
                              11417                 :                :                 }
                              11418                 :                :         | CREATE OR REPLACE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions
                              11419                 :                :                 AS SelectStmt opt_check_option
                              11420                 :                :                 {
 1212 peter@eisentraut.org    11421                 :              3 :                     ViewStmt   *n = makeNode(ViewStmt);
                              11422                 :                : 
 4601 peter_e@gmx.net         11423                 :              3 :                     n->view = $7;
                              11424                 :              3 :                     n->view->relpersistence = $4;
                              11425                 :              3 :                     n->aliases = $9;
                              11426                 :              3 :                     n->query = makeRecursiveViewSelect(n->view->relname, n->aliases, $13);
                              11427                 :              3 :                     n->replace = true;
                              11428                 :              3 :                     n->options = $11;
 4433 sfrost@snowman.net      11429                 :              3 :                     n->withCheckOption = $14;
                              11430         [ -  + ]:              3 :                     if (n->withCheckOption != NO_CHECK_OPTION)
 4433 sfrost@snowman.net      11431         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              11432                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              11433                 :                :                                  errmsg("WITH CHECK OPTION not supported on recursive views"),
                              11434                 :                :                                  parser_errposition(@14)));
 4601 peter_e@gmx.net         11435                 :CBC           3 :                     $$ = (Node *) n;
                              11436                 :                :                 }
                              11437                 :                :         ;
                              11438                 :                : 
                              11439                 :                : opt_check_option:
 4433 sfrost@snowman.net      11440                 :             48 :         WITH CHECK OPTION               { $$ = CASCADED_CHECK_OPTION; }
                              11441                 :              3 :         | WITH CASCADED CHECK OPTION    { $$ = CASCADED_CHECK_OPTION; }
                              11442                 :             12 :         | WITH LOCAL CHECK OPTION       { $$ = LOCAL_CHECK_OPTION; }
                              11443                 :           8416 :         | /* EMPTY */                   { $$ = NO_CHECK_OPTION; }
                              11444                 :                :         ;
                              11445                 :                : 
                              11446                 :                : /*****************************************************************************
                              11447                 :                :  *
                              11448                 :                :  *      QUERY:
                              11449                 :                :  *              LOAD "filename"
                              11450                 :                :  *
                              11451                 :                :  *****************************************************************************/
                              11452                 :                : 
                              11453                 :                : LoadStmt:   LOAD file_name
                              11454                 :                :                 {
 1212 peter@eisentraut.org    11455                 :             27 :                     LoadStmt   *n = makeNode(LoadStmt);
                              11456                 :                : 
10225 bruce@momjian.us        11457                 :             27 :                     n->filename = $2;
 1212 peter@eisentraut.org    11458                 :             27 :                     $$ = (Node *) n;
                              11459                 :                :                 }
                              11460                 :                :         ;
                              11461                 :                : 
                              11462                 :                : 
                              11463                 :                : /*****************************************************************************
                              11464                 :                :  *
                              11465                 :                :  *      CREATE DATABASE
                              11466                 :                :  *
                              11467                 :                :  *****************************************************************************/
                              11468                 :                : 
                              11469                 :                : CreatedbStmt:
                              11470                 :                :             CREATE DATABASE name opt_with createdb_opt_list
                              11471                 :                :                 {
 9082 tgl@sss.pgh.pa.us       11472                 :            395 :                     CreatedbStmt *n = makeNode(CreatedbStmt);
                              11473                 :                : 
10225 bruce@momjian.us        11474                 :            395 :                     n->dbname = $3;
 8481                         11475                 :            395 :                     n->options = $5;
 1212 peter@eisentraut.org    11476                 :            395 :                     $$ = (Node *) n;
                              11477                 :                :                 }
                              11478                 :                :         ;
                              11479                 :                : 
                              11480                 :                : createdb_opt_list:
 4085 tgl@sss.pgh.pa.us       11481                 :            321 :             createdb_opt_items                      { $$ = $1; }
 8481 bruce@momjian.us        11482                 :            104 :             | /* EMPTY */                           { $$ = NIL; }
                              11483                 :                :         ;
                              11484                 :                : 
                              11485                 :                : createdb_opt_items:
 4085 tgl@sss.pgh.pa.us       11486                 :            321 :             createdb_opt_item                       { $$ = list_make1($1); }
                              11487                 :            477 :             | createdb_opt_items createdb_opt_item  { $$ = lappend($1, $2); }
                              11488                 :                :         ;
                              11489                 :                : 
                              11490                 :                : createdb_opt_item:
                              11491                 :                :             createdb_opt_name opt_equal NumericOnly
                              11492                 :                :                 {
 1037                         11493                 :            133 :                     $$ = makeDefElem($1, $3, @1);
                              11494                 :                :                 }
                              11495                 :                :             | createdb_opt_name opt_equal opt_boolean_or_string
                              11496                 :                :                 {
 1212 peter@eisentraut.org    11497                 :            665 :                     $$ = makeDefElem($1, (Node *) makeString($3), @1);
                              11498                 :                :                 }
                              11499                 :                :             | createdb_opt_name opt_equal DEFAULT
                              11500                 :                :                 {
 3287 peter_e@gmx.net         11501                 :UBC           0 :                     $$ = makeDefElem($1, NULL, @1);
                              11502                 :                :                 }
                              11503                 :                :         ;
                              11504                 :                : 
                              11505                 :                : /*
                              11506                 :                :  * Ideally we'd use ColId here, but that causes shift/reduce conflicts against
                              11507                 :                :  * the ALTER DATABASE SET/RESET syntaxes.  Instead call out specific keywords
                              11508                 :                :  * we need, and allow IDENT so that database option names don't have to be
                              11509                 :                :  * parser keywords unless they are already keywords for other reasons.
                              11510                 :                :  *
                              11511                 :                :  * XXX this coding technique is fragile since if someone makes a formerly
                              11512                 :                :  * non-keyword option name into a keyword and forgets to add it here, the
                              11513                 :                :  * option will silently break.  Best defense is to provide a regression test
                              11514                 :                :  * exercising every such option, at least at the syntax level.
                              11515                 :                :  */
                              11516                 :                : createdb_opt_name:
 4085 tgl@sss.pgh.pa.us       11517                 :CBC         554 :             IDENT                           { $$ = $1; }
                              11518                 :              1 :             | CONNECTION LIMIT              { $$ = pstrdup("connection_limit"); }
                              11519                 :             52 :             | ENCODING                      { $$ = pstrdup($1); }
 4085 tgl@sss.pgh.pa.us       11520                 :UBC           0 :             | LOCATION                      { $$ = pstrdup($1); }
 4085 tgl@sss.pgh.pa.us       11521                 :CBC           1 :             | OWNER                         { $$ = pstrdup($1); }
                              11522                 :             17 :             | TABLESPACE                    { $$ = pstrdup($1); }
                              11523                 :            173 :             | TEMPLATE                      { $$ = pstrdup($1); }
                              11524                 :                :         ;
                              11525                 :                : 
                              11526                 :                : /*
                              11527                 :                :  *  Though the equals sign doesn't match other WITH options, pg_dump uses
                              11528                 :                :  *  equals for backward compatibility, and it doesn't seem worth removing it.
                              11529                 :                :  */
                              11530                 :                : opt_equal:  '='
                              11531                 :                :             | /*EMPTY*/
                              11532                 :                :         ;
                              11533                 :                : 
                              11534                 :                : 
                              11535                 :                : /*****************************************************************************
                              11536                 :                :  *
                              11537                 :                :  *      ALTER DATABASE
                              11538                 :                :  *
                              11539                 :                :  *****************************************************************************/
                              11540                 :                : 
                              11541                 :                : AlterDatabaseStmt:
                              11542                 :                :             ALTER DATABASE name WITH createdb_opt_list
                              11543                 :                :                  {
 7342 tgl@sss.pgh.pa.us       11544                 :UBC           0 :                     AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt);
                              11545                 :                : 
                              11546                 :              0 :                     n->dbname = $3;
                              11547                 :              0 :                     n->options = $5;
 1212 peter@eisentraut.org    11548                 :              0 :                     $$ = (Node *) n;
                              11549                 :                :                  }
                              11550                 :                :             | ALTER DATABASE name createdb_opt_list
                              11551                 :                :                  {
 4085 tgl@sss.pgh.pa.us       11552                 :CBC          30 :                     AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt);
                              11553                 :                : 
                              11554                 :             30 :                     n->dbname = $3;
                              11555                 :             30 :                     n->options = $4;
 1212 peter@eisentraut.org    11556                 :             30 :                     $$ = (Node *) n;
                              11557                 :                :                  }
                              11558                 :                :             | ALTER DATABASE name SET TABLESPACE name
                              11559                 :                :                  {
 6147 tgl@sss.pgh.pa.us       11560                 :              8 :                     AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt);
                              11561                 :                : 
                              11562                 :              8 :                     n->dbname = $3;
                              11563                 :              8 :                     n->options = list_make1(makeDefElem("tablespace",
                              11564                 :                :                                                         (Node *) makeString($6), @6));
 1212 peter@eisentraut.org    11565                 :              8 :                     $$ = (Node *) n;
                              11566                 :                :                  }
                              11567                 :                :             | ALTER DATABASE name REFRESH COLLATION VERSION_P
                              11568                 :                :                  {
 1300                         11569                 :              3 :                     AlterDatabaseRefreshCollStmt *n = makeNode(AlterDatabaseRefreshCollStmt);
                              11570                 :                : 
                              11571                 :              3 :                     n->dbname = $3;
 1212                         11572                 :              3 :                     $$ = (Node *) n;
                              11573                 :                :                  }
                              11574                 :                :         ;
                              11575                 :                : 
                              11576                 :                : AlterDatabaseSetStmt:
                              11577                 :                :             ALTER DATABASE name SetResetClause
                              11578                 :                :                 {
 8590 peter_e@gmx.net         11579                 :            565 :                     AlterDatabaseSetStmt *n = makeNode(AlterDatabaseSetStmt);
                              11580                 :                : 
                              11581                 :            565 :                     n->dbname = $3;
 6578 tgl@sss.pgh.pa.us       11582                 :            565 :                     n->setstmt = $4;
 1212 peter@eisentraut.org    11583                 :            565 :                     $$ = (Node *) n;
                              11584                 :                :                 }
                              11585                 :                :         ;
                              11586                 :                : 
                              11587                 :                : 
                              11588                 :                : /*****************************************************************************
                              11589                 :                :  *
                              11590                 :                :  *      DROP DATABASE [ IF EXISTS ] dbname [ [ WITH ] ( options ) ]
                              11591                 :                :  *
                              11592                 :                :  * This is implicitly CASCADE, no need for drop behavior
                              11593                 :                :  *****************************************************************************/
                              11594                 :                : 
                              11595                 :                : DropdbStmt: DROP DATABASE name
                              11596                 :                :                 {
 8570 tgl@sss.pgh.pa.us       11597                 :             50 :                     DropdbStmt *n = makeNode(DropdbStmt);
                              11598                 :                : 
                              11599                 :             50 :                     n->dbname = $3;
 2943 peter_e@gmx.net         11600                 :             50 :                     n->missing_ok = false;
 2125 akapila@postgresql.o    11601                 :             50 :                     n->options = NULL;
 1212 peter@eisentraut.org    11602                 :             50 :                     $$ = (Node *) n;
                              11603                 :                :                 }
                              11604                 :                :             | DROP DATABASE IF_P EXISTS name
                              11605                 :                :                 {
 7228 andrew@dunslane.net     11606                 :              2 :                     DropdbStmt *n = makeNode(DropdbStmt);
                              11607                 :                : 
                              11608                 :              2 :                     n->dbname = $5;
 2943 peter_e@gmx.net         11609                 :              2 :                     n->missing_ok = true;
 2125 akapila@postgresql.o    11610                 :              2 :                     n->options = NULL;
 1212 peter@eisentraut.org    11611                 :              2 :                     $$ = (Node *) n;
                              11612                 :                :                 }
                              11613                 :                :             | DROP DATABASE name opt_with '(' drop_option_list ')'
                              11614                 :                :                 {
 2125 akapila@postgresql.o    11615                 :              7 :                     DropdbStmt *n = makeNode(DropdbStmt);
                              11616                 :                : 
                              11617                 :              7 :                     n->dbname = $3;
                              11618                 :              7 :                     n->missing_ok = false;
                              11619                 :              7 :                     n->options = $6;
 1212 peter@eisentraut.org    11620                 :              7 :                     $$ = (Node *) n;
                              11621                 :                :                 }
                              11622                 :                :             | DROP DATABASE IF_P EXISTS name opt_with '(' drop_option_list ')'
                              11623                 :                :                 {
 2125 akapila@postgresql.o    11624                 :              6 :                     DropdbStmt *n = makeNode(DropdbStmt);
                              11625                 :                : 
                              11626                 :              6 :                     n->dbname = $5;
                              11627                 :              6 :                     n->missing_ok = true;
                              11628                 :              6 :                     n->options = $8;
 1212 peter@eisentraut.org    11629                 :              6 :                     $$ = (Node *) n;
                              11630                 :                :                 }
                              11631                 :                :         ;
                              11632                 :                : 
                              11633                 :                : drop_option_list:
                              11634                 :                :             drop_option
                              11635                 :                :                 {
 2125 akapila@postgresql.o    11636                 :             13 :                     $$ = list_make1((Node *) $1);
                              11637                 :                :                 }
                              11638                 :                :             | drop_option_list ',' drop_option
                              11639                 :                :                 {
 2125 akapila@postgresql.o    11640                 :UBC           0 :                     $$ = lappend($1, (Node *) $3);
                              11641                 :                :                 }
                              11642                 :                :         ;
                              11643                 :                : 
                              11644                 :                : /*
                              11645                 :                :  * Currently only the FORCE option is supported, but the syntax is designed
                              11646                 :                :  * to be extensible so that we can add more options in the future if required.
                              11647                 :                :  */
                              11648                 :                : drop_option:
                              11649                 :                :             FORCE
                              11650                 :                :                 {
 2125 akapila@postgresql.o    11651                 :CBC          13 :                     $$ = makeDefElem("force", NULL, @1);
                              11652                 :                :                 }
                              11653                 :                :         ;
                              11654                 :                : 
                              11655                 :                : /*****************************************************************************
                              11656                 :                :  *
                              11657                 :                :  *      ALTER COLLATION
                              11658                 :                :  *
                              11659                 :                :  *****************************************************************************/
                              11660                 :                : 
                              11661                 :                : AlterCollationStmt: ALTER COLLATION any_name REFRESH VERSION_P
                              11662                 :                :                 {
 1583 tmunro@postgresql.or    11663                 :              3 :                     AlterCollationStmt *n = makeNode(AlterCollationStmt);
                              11664                 :                : 
                              11665                 :              3 :                     n->collname = $3;
 1212 peter@eisentraut.org    11666                 :              3 :                     $$ = (Node *) n;
                              11667                 :                :                 }
                              11668                 :                :         ;
                              11669                 :                : 
                              11670                 :                : 
                              11671                 :                : /*****************************************************************************
                              11672                 :                :  *
                              11673                 :                :  *      ALTER SYSTEM
                              11674                 :                :  *
                              11675                 :                :  * This is used to change configuration parameters persistently.
                              11676                 :                :  *****************************************************************************/
                              11677                 :                : 
                              11678                 :                : AlterSystemStmt:
                              11679                 :                :             ALTER SYSTEM_P SET generic_set
                              11680                 :                :                 {
 4280 ishii@postgresql.org    11681                 :             73 :                     AlterSystemStmt *n = makeNode(AlterSystemStmt);
                              11682                 :                : 
                              11683                 :             73 :                     n->setstmt = $4;
 1212 peter@eisentraut.org    11684                 :             73 :                     $$ = (Node *) n;
                              11685                 :                :                 }
                              11686                 :                :             | ALTER SYSTEM_P RESET generic_reset
                              11687                 :                :                 {
 4022 fujii@postgresql.org    11688                 :             31 :                     AlterSystemStmt *n = makeNode(AlterSystemStmt);
                              11689                 :                : 
                              11690                 :             31 :                     n->setstmt = $4;
 1212 peter@eisentraut.org    11691                 :             31 :                     $$ = (Node *) n;
                              11692                 :                :                 }
                              11693                 :                :         ;
                              11694                 :                : 
                              11695                 :                : 
                              11696                 :                : /*****************************************************************************
                              11697                 :                :  *
                              11698                 :                :  * Manipulate a domain
                              11699                 :                :  *
                              11700                 :                :  *****************************************************************************/
                              11701                 :                : 
                              11702                 :                : CreateDomainStmt:
                              11703                 :                :             CREATE DOMAIN_P any_name opt_as Typename ColQualList
                              11704                 :                :                 {
 8572 bruce@momjian.us        11705                 :            726 :                     CreateDomainStmt *n = makeNode(CreateDomainStmt);
                              11706                 :                : 
                              11707                 :            726 :                     n->domainname = $3;
 5896 peter_e@gmx.net         11708                 :            726 :                     n->typeName = $5;
 5295 tgl@sss.pgh.pa.us       11709                 :            726 :                     SplitColQualList($6, &n->constraints, &n->collClause,
                              11710                 :                :                                      yyscanner);
 1212 peter@eisentraut.org    11711                 :            726 :                     $$ = (Node *) n;
                              11712                 :                :                 }
                              11713                 :                :         ;
                              11714                 :                : 
                              11715                 :                : AlterDomainStmt:
                              11716                 :                :             /* ALTER DOMAIN <domain> {SET DEFAULT <expr>|DROP DEFAULT} */
                              11717                 :                :             ALTER DOMAIN_P any_name alter_column_default
                              11718                 :                :                 {
 8310 bruce@momjian.us        11719                 :              7 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11720                 :                : 
   65 michael@paquier.xyz     11721                 :GNC           7 :                     n->subtype = AD_AlterDefault;
 5896 peter_e@gmx.net         11722                 :CBC           7 :                     n->typeName = $3;
 8310 bruce@momjian.us        11723                 :              7 :                     n->def = $4;
 1212 peter@eisentraut.org    11724                 :              7 :                     $$ = (Node *) n;
                              11725                 :                :                 }
                              11726                 :                :             /* ALTER DOMAIN <domain> DROP NOT NULL */
                              11727                 :                :             | ALTER DOMAIN_P any_name DROP NOT NULL_P
                              11728                 :                :                 {
 8310 bruce@momjian.us        11729                 :              6 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11730                 :                : 
   65 michael@paquier.xyz     11731                 :GNC           6 :                     n->subtype = AD_DropNotNull;
 5896 peter_e@gmx.net         11732                 :CBC           6 :                     n->typeName = $3;
 1212 peter@eisentraut.org    11733                 :              6 :                     $$ = (Node *) n;
                              11734                 :                :                 }
                              11735                 :                :             /* ALTER DOMAIN <domain> SET NOT NULL */
                              11736                 :                :             | ALTER DOMAIN_P any_name SET NOT NULL_P
                              11737                 :                :                 {
 8310 bruce@momjian.us        11738                 :             12 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11739                 :                : 
   65 michael@paquier.xyz     11740                 :GNC          12 :                     n->subtype = AD_SetNotNull;
 5896 peter_e@gmx.net         11741                 :CBC          12 :                     n->typeName = $3;
 1212 peter@eisentraut.org    11742                 :             12 :                     $$ = (Node *) n;
                              11743                 :                :                 }
                              11744                 :                :             /* ALTER DOMAIN <domain> ADD CONSTRAINT ... */
                              11745                 :                :             | ALTER DOMAIN_P any_name ADD_P DomainConstraint
                              11746                 :                :                 {
 8310 bruce@momjian.us        11747                 :             91 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11748                 :                : 
   65 michael@paquier.xyz     11749                 :GNC          91 :                     n->subtype = AD_AddConstraint;
 5896 peter_e@gmx.net         11750                 :CBC          91 :                     n->typeName = $3;
 8310 bruce@momjian.us        11751                 :             91 :                     n->def = $5;
 1212 peter@eisentraut.org    11752                 :             91 :                     $$ = (Node *) n;
                              11753                 :                :                 }
                              11754                 :                :             /* ALTER DOMAIN <domain> DROP CONSTRAINT <name> [RESTRICT|CASCADE] */
                              11755                 :                :             | ALTER DOMAIN_P any_name DROP CONSTRAINT name opt_drop_behavior
                              11756                 :                :                 {
 8310 bruce@momjian.us        11757                 :             27 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11758                 :                : 
   65 michael@paquier.xyz     11759                 :GNC          27 :                     n->subtype = AD_DropConstraint;
 5896 peter_e@gmx.net         11760                 :CBC          27 :                     n->typeName = $3;
 8310 bruce@momjian.us        11761                 :             27 :                     n->name = $6;
                              11762                 :             27 :                     n->behavior = $7;
 4993 peter_e@gmx.net         11763                 :             27 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    11764                 :             27 :                     $$ = (Node *) n;
                              11765                 :                :                 }
                              11766                 :                :             /* ALTER DOMAIN <domain> DROP CONSTRAINT IF EXISTS <name> [RESTRICT|CASCADE] */
                              11767                 :                :             | ALTER DOMAIN_P any_name DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
                              11768                 :                :                 {
 4993 peter_e@gmx.net         11769                 :              3 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11770                 :                : 
   65 michael@paquier.xyz     11771                 :GNC           3 :                     n->subtype = AD_DropConstraint;
 4993 peter_e@gmx.net         11772                 :CBC           3 :                     n->typeName = $3;
                              11773                 :              3 :                     n->name = $8;
                              11774                 :              3 :                     n->behavior = $9;
                              11775                 :              3 :                     n->missing_ok = true;
 1212 peter@eisentraut.org    11776                 :              3 :                     $$ = (Node *) n;
                              11777                 :                :                 }
                              11778                 :                :             /* ALTER DOMAIN <domain> VALIDATE CONSTRAINT <name> */
                              11779                 :                :             | ALTER DOMAIN_P any_name VALIDATE CONSTRAINT name
                              11780                 :                :                 {
 5211 alvherre@alvh.no-ip.    11781                 :              6 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11782                 :                : 
   65 michael@paquier.xyz     11783                 :GNC           6 :                     n->subtype = AD_ValidateConstraint;
 5211 alvherre@alvh.no-ip.    11784                 :CBC           6 :                     n->typeName = $3;
                              11785                 :              6 :                     n->name = $6;
 1212 peter@eisentraut.org    11786                 :              6 :                     $$ = (Node *) n;
                              11787                 :                :                 }
                              11788                 :                :             ;
                              11789                 :                : 
                              11790                 :                : opt_as:     AS
                              11791                 :                :             | /* EMPTY */
                              11792                 :                :         ;
                              11793                 :                : 
                              11794                 :                : 
                              11795                 :                : /*****************************************************************************
                              11796                 :                :  *
                              11797                 :                :  * Manipulate a text search dictionary or configuration
                              11798                 :                :  *
                              11799                 :                :  *****************************************************************************/
                              11800                 :                : 
                              11801                 :                : AlterTSDictionaryStmt:
                              11802                 :                :             ALTER TEXT_P SEARCH DICTIONARY any_name definition
                              11803                 :                :                 {
 6591 tgl@sss.pgh.pa.us       11804                 :             20 :                     AlterTSDictionaryStmt *n = makeNode(AlterTSDictionaryStmt);
                              11805                 :                : 
                              11806                 :             20 :                     n->dictname = $5;
                              11807                 :             20 :                     n->options = $6;
 1212 peter@eisentraut.org    11808                 :             20 :                     $$ = (Node *) n;
                              11809                 :                :                 }
                              11810                 :                :         ;
                              11811                 :                : 
                              11812                 :                : AlterTSConfigurationStmt:
                              11813                 :                :             ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with any_name_list
                              11814                 :                :                 {
 6591 tgl@sss.pgh.pa.us       11815                 :           4259 :                     AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
                              11816                 :                : 
 3771 alvherre@alvh.no-ip.    11817                 :           4259 :                     n->kind = ALTER_TSCONFIG_ADD_MAPPING;
 6591 tgl@sss.pgh.pa.us       11818                 :           4259 :                     n->cfgname = $5;
                              11819                 :           4259 :                     n->tokentype = $9;
                              11820                 :           4259 :                     n->dicts = $11;
                              11821                 :           4259 :                     n->override = false;
                              11822                 :           4259 :                     n->replace = false;
 1212 peter@eisentraut.org    11823                 :           4259 :                     $$ = (Node *) n;
                              11824                 :                :                 }
                              11825                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with any_name_list
                              11826                 :                :                 {
 6591 tgl@sss.pgh.pa.us       11827                 :             13 :                     AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
                              11828                 :                : 
 3771 alvherre@alvh.no-ip.    11829                 :             13 :                     n->kind = ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN;
 6591 tgl@sss.pgh.pa.us       11830                 :             13 :                     n->cfgname = $5;
                              11831                 :             13 :                     n->tokentype = $9;
                              11832                 :             13 :                     n->dicts = $11;
                              11833                 :             13 :                     n->override = true;
                              11834                 :             13 :                     n->replace = false;
 1212 peter@eisentraut.org    11835                 :             13 :                     $$ = (Node *) n;
                              11836                 :                :                 }
                              11837                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING REPLACE any_name any_with any_name
                              11838                 :                :                 {
 6591 tgl@sss.pgh.pa.us       11839                 :              9 :                     AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
                              11840                 :                : 
 3771 alvherre@alvh.no-ip.    11841                 :              9 :                     n->kind = ALTER_TSCONFIG_REPLACE_DICT;
 6591 tgl@sss.pgh.pa.us       11842                 :              9 :                     n->cfgname = $5;
                              11843                 :              9 :                     n->tokentype = NIL;
                              11844                 :              9 :                     n->dicts = list_make2($9,$11);
                              11845                 :              9 :                     n->override = false;
                              11846                 :              9 :                     n->replace = true;
 1212 peter@eisentraut.org    11847                 :              9 :                     $$ = (Node *) n;
                              11848                 :                :                 }
                              11849                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list REPLACE any_name any_with any_name
                              11850                 :                :                 {
 6591 tgl@sss.pgh.pa.us       11851                 :UBC           0 :                     AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
                              11852                 :                : 
 3771 alvherre@alvh.no-ip.    11853                 :              0 :                     n->kind = ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN;
 6591 tgl@sss.pgh.pa.us       11854                 :              0 :                     n->cfgname = $5;
                              11855                 :              0 :                     n->tokentype = $9;
                              11856                 :              0 :                     n->dicts = list_make2($11,$13);
                              11857                 :              0 :                     n->override = false;
                              11858                 :              0 :                     n->replace = true;
 1212 peter@eisentraut.org    11859                 :              0 :                     $$ = (Node *) n;
                              11860                 :                :                 }
                              11861                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING FOR name_list
                              11862                 :                :                 {
 6591 tgl@sss.pgh.pa.us       11863                 :CBC           9 :                     AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
                              11864                 :                : 
 3771 alvherre@alvh.no-ip.    11865                 :              9 :                     n->kind = ALTER_TSCONFIG_DROP_MAPPING;
 6591 tgl@sss.pgh.pa.us       11866                 :              9 :                     n->cfgname = $5;
                              11867                 :              9 :                     n->tokentype = $9;
                              11868                 :              9 :                     n->missing_ok = false;
 1212 peter@eisentraut.org    11869                 :              9 :                     $$ = (Node *) n;
                              11870                 :                :                 }
                              11871                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING IF_P EXISTS FOR name_list
                              11872                 :                :                 {
 6591 tgl@sss.pgh.pa.us       11873                 :              6 :                     AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
                              11874                 :                : 
 3771 alvherre@alvh.no-ip.    11875                 :              6 :                     n->kind = ALTER_TSCONFIG_DROP_MAPPING;
 6591 tgl@sss.pgh.pa.us       11876                 :              6 :                     n->cfgname = $5;
                              11877                 :              6 :                     n->tokentype = $11;
                              11878                 :              6 :                     n->missing_ok = true;
 1212 peter@eisentraut.org    11879                 :              6 :                     $$ = (Node *) n;
                              11880                 :                :                 }
                              11881                 :                :         ;
                              11882                 :                : 
                              11883                 :                : /* Use this if TIME or ORDINALITY after WITH should be taken as an identifier */
                              11884                 :                : any_with:   WITH
                              11885                 :                :             | WITH_LA
                              11886                 :                :         ;
                              11887                 :                : 
                              11888                 :                : 
                              11889                 :                : /*****************************************************************************
                              11890                 :                :  *
                              11891                 :                :  * Manipulate a conversion
                              11892                 :                :  *
                              11893                 :                :  *      CREATE [DEFAULT] CONVERSION <conversion_name>
                              11894                 :                :  *      FOR <encoding_name> TO <encoding_name> FROM <func_name>
                              11895                 :                :  *
                              11896                 :                :  *****************************************************************************/
                              11897                 :                : 
                              11898                 :                : CreateConversionStmt:
                              11899                 :                :             CREATE opt_default CONVERSION_P any_name FOR Sconst
                              11900                 :                :             TO Sconst FROM any_name
                              11901                 :                :             {
 5058 peter_e@gmx.net         11902                 :             32 :                 CreateConversionStmt *n = makeNode(CreateConversionStmt);
                              11903                 :                : 
                              11904                 :             32 :                 n->conversion_name = $4;
                              11905                 :             32 :                 n->for_encoding_name = $6;
                              11906                 :             32 :                 n->to_encoding_name = $8;
                              11907                 :             32 :                 n->func_name = $10;
                              11908                 :             32 :                 n->def = $2;
 1212 peter@eisentraut.org    11909                 :             32 :                 $$ = (Node *) n;
                              11910                 :                :             }
                              11911                 :                :         ;
                              11912                 :                : 
                              11913                 :                : /*****************************************************************************
                              11914                 :                :  *
                              11915                 :                :  *      QUERY:
                              11916                 :                :  *              CLUSTER (options) [ <qualified_name> [ USING <index_name> ] ]
                              11917                 :                :  *              CLUSTER [VERBOSE] [ <qualified_name> [ USING <index_name> ] ]
                              11918                 :                :  *              CLUSTER [VERBOSE] <index_name> ON <qualified_name> (for pre-8.3)
                              11919                 :                :  *
                              11920                 :                :  *****************************************************************************/
                              11921                 :                : 
                              11922                 :                : ClusterStmt:
                              11923                 :                :             CLUSTER '(' utility_option_list ')' qualified_name cluster_index_specification
                              11924                 :                :                 {
 5058 peter_e@gmx.net         11925                 :UBC           0 :                     ClusterStmt *n = makeNode(ClusterStmt);
                              11926                 :                : 
  780 nathan@postgresql.or    11927                 :              0 :                     n->relation = $5;
                              11928                 :              0 :                     n->indexname = $6;
                              11929                 :              0 :                     n->params = $3;
 1212 peter@eisentraut.org    11930                 :              0 :                     $$ = (Node *) n;
                              11931                 :                :                 }
                              11932                 :                :             | CLUSTER opt_utility_option_list
                              11933                 :                :                 {
  780 nathan@postgresql.or    11934                 :GBC           8 :                     ClusterStmt *n = makeNode(ClusterStmt);
                              11935                 :                : 
                              11936                 :              8 :                     n->relation = NULL;
                              11937                 :              8 :                     n->indexname = NULL;
   43 alvherre@kurilemu.de    11938                 :GNC           8 :                     n->params = $2;
  780 nathan@postgresql.or    11939                 :GBC           8 :                     $$ = (Node *) n;
                              11940                 :                :                 }
                              11941                 :                :             /* unparenthesized VERBOSE kept for pre-14 compatibility */
                              11942                 :                :             | CLUSTER opt_verbose qualified_name cluster_index_specification
                              11943                 :                :                 {
 1738 michael@paquier.xyz     11944                 :CBC          98 :                     ClusterStmt *n = makeNode(ClusterStmt);
                              11945                 :                : 
  780 nathan@postgresql.or    11946                 :             98 :                     n->relation = $3;
                              11947                 :             98 :                     n->indexname = $4;
                              11948         [ -  + ]:             98 :                     if ($2)
   43 alvherre@kurilemu.de    11949                 :UNC           0 :                         n->params = list_make1(makeDefElem("verbose", NULL, @2));
 1212 peter@eisentraut.org    11950                 :CBC          98 :                     $$ = (Node *) n;
                              11951                 :                :                 }
                              11952                 :                :             /* unparenthesized VERBOSE kept for pre-17 compatibility */
                              11953                 :                :             | CLUSTER VERBOSE
                              11954                 :                :                 {
 5058 peter_e@gmx.net         11955                 :              8 :                     ClusterStmt *n = makeNode(ClusterStmt);
                              11956                 :                : 
                              11957                 :              8 :                     n->relation = NULL;
                              11958                 :              8 :                     n->indexname = NULL;
   43 alvherre@kurilemu.de    11959                 :GNC           8 :                     n->params = list_make1(makeDefElem("verbose", NULL, @2));
 1212 peter@eisentraut.org    11960                 :CBC           8 :                     $$ = (Node *) n;
                              11961                 :                :                 }
                              11962                 :                :             /* kept for pre-8.3 compatibility */
                              11963                 :                :             | CLUSTER opt_verbose name ON qualified_name
                              11964                 :                :                 {
 5058 peter_e@gmx.net         11965                 :             10 :                     ClusterStmt *n = makeNode(ClusterStmt);
                              11966                 :                : 
                              11967                 :             10 :                     n->relation = $5;
                              11968                 :             10 :                     n->indexname = $3;
 2601 michael@paquier.xyz     11969         [ -  + ]:             10 :                     if ($2)
   43 alvherre@kurilemu.de    11970                 :UNC           0 :                         n->params = list_make1(makeDefElem("verbose", NULL, @2));
 1212 peter@eisentraut.org    11971                 :CBC          10 :                     $$ = (Node *) n;
                              11972                 :                :                 }
                              11973                 :                :         ;
                              11974                 :                : 
                              11975                 :                : cluster_index_specification:
 1914                         11976                 :             78 :             USING name              { $$ = $2; }
 6726 bruce@momjian.us        11977                 :             20 :             | /*EMPTY*/             { $$ = NULL; }
                              11978                 :                :         ;
                              11979                 :                : 
                              11980                 :                : 
                              11981                 :                : /*****************************************************************************
                              11982                 :                :  *
                              11983                 :                :  *      QUERY:
                              11984                 :                :  *              VACUUM
                              11985                 :                :  *              ANALYZE
                              11986                 :                :  *
                              11987                 :                :  *****************************************************************************/
                              11988                 :                : 
                              11989                 :                : VacuumStmt: VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relation_list
                              11990                 :                :                 {
10225                         11991                 :            591 :                     VacuumStmt *n = makeNode(VacuumStmt);
                              11992                 :                : 
 2364 rhaas@postgresql.org    11993                 :            591 :                     n->options = NIL;
 5773 tgl@sss.pgh.pa.us       11994         [ +  + ]:            591 :                     if ($2)
 2364 rhaas@postgresql.org    11995                 :             65 :                         n->options = lappend(n->options,
                              11996                 :             65 :                                              makeDefElem("full", NULL, @2));
 3825 alvherre@alvh.no-ip.    11997         [ +  + ]:            591 :                     if ($3)
 2364 rhaas@postgresql.org    11998                 :             81 :                         n->options = lappend(n->options,
                              11999                 :             81 :                                              makeDefElem("freeze", NULL, @3));
 5773 tgl@sss.pgh.pa.us       12000         [ +  + ]:            591 :                     if ($4)
 2364 rhaas@postgresql.org    12001                 :              5 :                         n->options = lappend(n->options,
                              12002                 :              5 :                                              makeDefElem("verbose", NULL, @4));
 2797                         12003         [ +  + ]:            591 :                     if ($5)
 2364                         12004                 :            146 :                         n->options = lappend(n->options,
                              12005                 :            146 :                                              makeDefElem("analyze", NULL, @5));
 2797                         12006                 :            591 :                     n->rels = $6;
 2364                         12007                 :            591 :                     n->is_vacuumcmd = true;
 1212 peter@eisentraut.org    12008                 :            591 :                     $$ = (Node *) n;
                              12009                 :                :                 }
                              12010                 :                :             | VACUUM '(' utility_option_list ')' opt_vacuum_relation_list
                              12011                 :                :                 {
 5773 tgl@sss.pgh.pa.us       12012                 :           3889 :                     VacuumStmt *n = makeNode(VacuumStmt);
                              12013                 :                : 
 2364 rhaas@postgresql.org    12014                 :           3889 :                     n->options = $3;
 2895 tgl@sss.pgh.pa.us       12015                 :           3889 :                     n->rels = $5;
 2364 rhaas@postgresql.org    12016                 :           3889 :                     n->is_vacuumcmd = true;
 5773 tgl@sss.pgh.pa.us       12017                 :           3889 :                     $$ = (Node *) n;
                              12018                 :                :                 }
                              12019                 :                :         ;
                              12020                 :                : 
                              12021                 :                : AnalyzeStmt: analyze_keyword opt_utility_option_list opt_vacuum_relation_list
                              12022                 :                :                 {
 8888                         12023                 :           2435 :                     VacuumStmt *n = makeNode(VacuumStmt);
                              12024                 :                : 
   43 alvherre@kurilemu.de    12025                 :GNC        2435 :                     n->options = $2;
 2895 tgl@sss.pgh.pa.us       12026                 :CBC        2435 :                     n->rels = $3;
 2364 rhaas@postgresql.org    12027                 :           2435 :                     n->is_vacuumcmd = false;
 1212 peter@eisentraut.org    12028                 :           2435 :                     $$ = (Node *) n;
                              12029                 :                :                 }
                              12030                 :                :             | analyze_keyword VERBOSE opt_vacuum_relation_list
                              12031                 :                :                 {
 2742 andres@anarazel.de      12032                 :LBC        (93) :                     VacuumStmt *n = makeNode(VacuumStmt);
                              12033                 :                : 
   43 alvherre@kurilemu.de    12034                 :UNC           0 :                     n->options = list_make1(makeDefElem("verbose", NULL, @2));
                              12035                 :              0 :                     n->rels = $3;
 2364 rhaas@postgresql.org    12036                 :LBC        (93) :                     n->is_vacuumcmd = false;
 2742 andres@anarazel.de      12037                 :           (93) :                     $$ = (Node *) n;
                              12038                 :                :                 }
                              12039                 :                :         ;
                              12040                 :                : 
                              12041                 :                : analyze_keyword:
                              12042                 :                :             ANALYZE
                              12043                 :                :             | ANALYSE /* British */
                              12044                 :                :         ;
                              12045                 :                : 
                              12046                 :                : opt_analyze:
 2797 rhaas@postgresql.org    12047                 :CBC         146 :             analyze_keyword                         { $$ = true; }
                              12048                 :            445 :             | /*EMPTY*/                             { $$ = false; }
                              12049                 :                :         ;
                              12050                 :                : 
                              12051                 :                : opt_verbose:
 2943 peter_e@gmx.net         12052                 :              5 :             VERBOSE                                 { $$ = true; }
                              12053                 :           1846 :             | /*EMPTY*/                             { $$ = false; }
                              12054                 :                :         ;
                              12055                 :                : 
                              12056                 :             65 : opt_full:   FULL                                    { $$ = true; }
                              12057                 :            526 :             | /*EMPTY*/                             { $$ = false; }
                              12058                 :                :         ;
                              12059                 :                : 
                              12060                 :             81 : opt_freeze: FREEZE                                  { $$ = true; }
                              12061                 :            510 :             | /*EMPTY*/                             { $$ = false; }
                              12062                 :                :         ;
                              12063                 :                : 
                              12064                 :                : opt_name_list:
 8482 bruce@momjian.us        12065                 :           1443 :             '(' name_list ')'                       { $$ = $2; }
                              12066                 :           8045 :             | /*EMPTY*/                             { $$ = NIL; }
                              12067                 :                :         ;
                              12068                 :                : 
                              12069                 :                : vacuum_relation:
                              12070                 :                :             relation_expr opt_name_list
                              12071                 :                :                 {
 2895 tgl@sss.pgh.pa.us       12072                 :           6802 :                     $$ = (Node *) makeVacuumRelation($1, InvalidOid, $2);
                              12073                 :                :                 }
                              12074                 :                :         ;
                              12075                 :                : 
                              12076                 :                : vacuum_relation_list:
                              12077                 :                :             vacuum_relation
                              12078                 :           6721 :                     { $$ = list_make1($1); }
                              12079                 :                :             | vacuum_relation_list ',' vacuum_relation
                              12080                 :             81 :                     { $$ = lappend($1, $3); }
                              12081                 :                :         ;
                              12082                 :                : 
                              12083                 :                : opt_vacuum_relation_list:
                              12084                 :           6721 :             vacuum_relation_list                    { $$ = $1; }
                              12085                 :            194 :             | /*EMPTY*/                             { $$ = NIL; }
                              12086                 :                :         ;
                              12087                 :                : 
                              12088                 :                : 
                              12089                 :                : /*****************************************************************************
                              12090                 :                :  *
                              12091                 :                :  *      QUERY:
                              12092                 :                :  *              EXPLAIN [ANALYZE] [VERBOSE] query
                              12093                 :                :  *              EXPLAIN ( options ) query
                              12094                 :                :  *
                              12095                 :                :  *****************************************************************************/
                              12096                 :                : 
                              12097                 :                : ExplainStmt:
                              12098                 :                :         EXPLAIN ExplainableStmt
                              12099                 :                :                 {
 5886                         12100                 :           3859 :                     ExplainStmt *n = makeNode(ExplainStmt);
                              12101                 :                : 
                              12102                 :           3859 :                     n->query = $2;
                              12103                 :           3859 :                     n->options = NIL;
                              12104                 :           3859 :                     $$ = (Node *) n;
                              12105                 :                :                 }
                              12106                 :                :         | EXPLAIN analyze_keyword opt_verbose ExplainableStmt
                              12107                 :                :                 {
 8754                         12108                 :           1152 :                     ExplainStmt *n = makeNode(ExplainStmt);
                              12109                 :                : 
 6752                         12110                 :           1152 :                     n->query = $4;
 3287 peter_e@gmx.net         12111                 :           1152 :                     n->options = list_make1(makeDefElem("analyze", NULL, @2));
 5886 tgl@sss.pgh.pa.us       12112         [ -  + ]:           1152 :                     if ($3)
 5886 tgl@sss.pgh.pa.us       12113                 :UBC           0 :                         n->options = lappend(n->options,
 3287 peter_e@gmx.net         12114                 :              0 :                                              makeDefElem("verbose", NULL, @3));
 5886 tgl@sss.pgh.pa.us       12115                 :CBC        1152 :                     $$ = (Node *) n;
                              12116                 :                :                 }
                              12117                 :                :         | EXPLAIN VERBOSE ExplainableStmt
                              12118                 :                :                 {
                              12119                 :              6 :                     ExplainStmt *n = makeNode(ExplainStmt);
                              12120                 :                : 
                              12121                 :              6 :                     n->query = $3;
 3287 peter_e@gmx.net         12122                 :              6 :                     n->options = list_make1(makeDefElem("verbose", NULL, @2));
 5886 tgl@sss.pgh.pa.us       12123                 :              6 :                     $$ = (Node *) n;
                              12124                 :                :                 }
                              12125                 :                :         | EXPLAIN '(' utility_option_list ')' ExplainableStmt
                              12126                 :                :                 {
                              12127                 :           7027 :                     ExplainStmt *n = makeNode(ExplainStmt);
                              12128                 :                : 
                              12129                 :           7027 :                     n->query = $5;
                              12130                 :           7027 :                     n->options = $3;
                              12131                 :           7027 :                     $$ = (Node *) n;
                              12132                 :                :                 }
                              12133                 :                :         ;
                              12134                 :                : 
                              12135                 :                : ExplainableStmt:
                              12136                 :                :             SelectStmt
                              12137                 :                :             | InsertStmt
                              12138                 :                :             | UpdateStmt
                              12139                 :                :             | DeleteStmt
                              12140                 :                :             | MergeStmt
                              12141                 :                :             | DeclareCursorStmt
                              12142                 :                :             | CreateAsStmt
                              12143                 :                :             | CreateMatViewStmt
                              12144                 :                :             | RefreshMatViewStmt
                              12145                 :                :             | ExecuteStmt                   /* by default all are $$=$1 */
                              12146                 :                :         ;
                              12147                 :                : 
                              12148                 :                : /*****************************************************************************
                              12149                 :                :  *
                              12150                 :                :  *      QUERY:
                              12151                 :                :  *              PREPARE <plan_name> [(args, ...)] AS <query>
                              12152                 :                :  *
                              12153                 :                :  *****************************************************************************/
                              12154                 :                : 
                              12155                 :                : PrepareStmt: PREPARE name prep_type_clause AS PreparableStmt
                              12156                 :                :                 {
 8411                         12157                 :           1011 :                     PrepareStmt *n = makeNode(PrepareStmt);
                              12158                 :                : 
                              12159                 :           1011 :                     n->name = $2;
                              12160                 :           1011 :                     n->argtypes = $3;
 6752                         12161                 :           1011 :                     n->query = $5;
 8411                         12162                 :           1011 :                     $$ = (Node *) n;
                              12163                 :                :                 }
                              12164                 :                :         ;
                              12165                 :                : 
 6801                         12166                 :            855 : prep_type_clause: '(' type_list ')'         { $$ = $2; }
 8411                         12167                 :            165 :                 | /* EMPTY */               { $$ = NIL; }
                              12168                 :                :         ;
                              12169                 :                : 
                              12170                 :                : PreparableStmt:
                              12171                 :                :             SelectStmt
                              12172                 :                :             | InsertStmt
                              12173                 :                :             | UpdateStmt
                              12174                 :                :             | DeleteStmt
                              12175                 :                :             | MergeStmt                     /* by default all are $$=$1 */
                              12176                 :                :         ;
                              12177                 :                : 
                              12178                 :                : /*****************************************************************************
                              12179                 :                :  *
                              12180                 :                :  * EXECUTE <plan_name> [(params, ...)]
                              12181                 :                :  * CREATE TABLE <name> AS EXECUTE <plan_name> [(params, ...)]
                              12182                 :                :  *
                              12183                 :                :  *****************************************************************************/
                              12184                 :                : 
                              12185                 :                : ExecuteStmt: EXECUTE name execute_param_clause
                              12186                 :                :                 {
                              12187                 :           8248 :                     ExecuteStmt *n = makeNode(ExecuteStmt);
                              12188                 :                : 
                              12189                 :           8248 :                     n->name = $2;
                              12190                 :           8248 :                     n->params = $3;
 8103 peter_e@gmx.net         12191                 :           8248 :                     $$ = (Node *) n;
                              12192                 :                :                 }
                              12193                 :                :             | CREATE OptTemp TABLE create_as_target AS
                              12194                 :                :                 EXECUTE name execute_param_clause opt_with_data
                              12195                 :                :                 {
 4919 tgl@sss.pgh.pa.us       12196                 :             38 :                     CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
 8103 peter_e@gmx.net         12197                 :             38 :                     ExecuteStmt *n = makeNode(ExecuteStmt);
                              12198                 :                : 
 6773 tgl@sss.pgh.pa.us       12199                 :             38 :                     n->name = $7;
                              12200                 :             38 :                     n->params = $8;
 4919                         12201                 :             38 :                     ctas->query = (Node *) n;
                              12202                 :             38 :                     ctas->into = $4;
 1883 michael@paquier.xyz     12203                 :             38 :                     ctas->objtype = OBJECT_TABLE;
 4919 tgl@sss.pgh.pa.us       12204                 :             38 :                     ctas->is_select_into = false;
 2395 michael@paquier.xyz     12205                 :             38 :                     ctas->if_not_exists = false;
                              12206                 :                :                     /* cram additional flags into the IntoClause */
 5035 tgl@sss.pgh.pa.us       12207                 :             38 :                     $4->rel->relpersistence = $2;
                              12208                 :             38 :                     $4->skipData = !($9);
 4919                         12209                 :             38 :                     $$ = (Node *) ctas;
                              12210                 :                :                 }
                              12211                 :                :             | CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS
                              12212                 :                :                 EXECUTE name execute_param_clause opt_with_data
                              12213                 :                :                 {
 2395 michael@paquier.xyz     12214                 :              6 :                     CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
                              12215                 :              6 :                     ExecuteStmt *n = makeNode(ExecuteStmt);
                              12216                 :                : 
                              12217                 :              6 :                     n->name = $10;
                              12218                 :              6 :                     n->params = $11;
                              12219                 :              6 :                     ctas->query = (Node *) n;
                              12220                 :              6 :                     ctas->into = $7;
 1883                         12221                 :              6 :                     ctas->objtype = OBJECT_TABLE;
 2395                         12222                 :              6 :                     ctas->is_select_into = false;
                              12223                 :              6 :                     ctas->if_not_exists = true;
                              12224                 :                :                     /* cram additional flags into the IntoClause */
                              12225                 :              6 :                     $7->rel->relpersistence = $2;
                              12226                 :              6 :                     $7->skipData = !($12);
                              12227                 :              6 :                     $$ = (Node *) ctas;
                              12228                 :                :                 }
                              12229                 :                :         ;
                              12230                 :                : 
 8344 tgl@sss.pgh.pa.us       12231                 :           7721 : execute_param_clause: '(' expr_list ')'             { $$ = $2; }
 8411                         12232                 :            571 :                     | /* EMPTY */                   { $$ = NIL; }
                              12233                 :                :                     ;
                              12234                 :                : 
                              12235                 :                : /*****************************************************************************
                              12236                 :                :  *
                              12237                 :                :  *      QUERY:
                              12238                 :                :  *              DEALLOCATE [PREPARE] <plan_name>
                              12239                 :                :  *
                              12240                 :                :  *****************************************************************************/
                              12241                 :                : 
                              12242                 :                : DeallocateStmt: DEALLOCATE name
                              12243                 :                :                     {
                              12244                 :           1140 :                         DeallocateStmt *n = makeNode(DeallocateStmt);
                              12245                 :                : 
                              12246                 :           1140 :                         n->name = $2;
  741 michael@paquier.xyz     12247                 :           1140 :                         n->isall = false;
                              12248                 :           1140 :                         n->location = @2;
 8411 tgl@sss.pgh.pa.us       12249                 :           1140 :                         $$ = (Node *) n;
                              12250                 :                :                     }
                              12251                 :                :                 | DEALLOCATE PREPARE name
                              12252                 :                :                     {
                              12253                 :             10 :                         DeallocateStmt *n = makeNode(DeallocateStmt);
                              12254                 :                : 
                              12255                 :             10 :                         n->name = $3;
  741 michael@paquier.xyz     12256                 :             10 :                         n->isall = false;
                              12257                 :             10 :                         n->location = @3;
 8411 tgl@sss.pgh.pa.us       12258                 :             10 :                         $$ = (Node *) n;
                              12259                 :                :                     }
                              12260                 :                :                 | DEALLOCATE ALL
                              12261                 :                :                     {
 6722 neilc@samurai.com       12262                 :             35 :                         DeallocateStmt *n = makeNode(DeallocateStmt);
                              12263                 :                : 
                              12264                 :             35 :                         n->name = NULL;
  741 michael@paquier.xyz     12265                 :             35 :                         n->isall = true;
                              12266                 :             35 :                         n->location = -1;
 6722 neilc@samurai.com       12267                 :             35 :                         $$ = (Node *) n;
                              12268                 :                :                     }
                              12269                 :                :                 | DEALLOCATE PREPARE ALL
                              12270                 :                :                     {
                              12271                 :              1 :                         DeallocateStmt *n = makeNode(DeallocateStmt);
                              12272                 :                : 
                              12273                 :              1 :                         n->name = NULL;
  741 michael@paquier.xyz     12274                 :              1 :                         n->isall = true;
                              12275                 :              1 :                         n->location = -1;
 6722 neilc@samurai.com       12276                 :              1 :                         $$ = (Node *) n;
                              12277                 :                :                     }
                              12278                 :                :         ;
                              12279                 :                : 
                              12280                 :                : /*****************************************************************************
                              12281                 :                :  *
                              12282                 :                :  *      QUERY:
                              12283                 :                :  *              INSERT STATEMENTS
                              12284                 :                :  *
                              12285                 :                :  *****************************************************************************/
                              12286                 :                : 
                              12287                 :                : InsertStmt:
                              12288                 :                :             opt_with_clause INSERT INTO insert_target insert_rest
                              12289                 :                :             opt_on_conflict returning_clause
                              12290                 :                :                 {
 5440 tgl@sss.pgh.pa.us       12291                 :          35866 :                     $5->relation = $4;
 3774 andres@anarazel.de      12292                 :          35866 :                     $5->onConflictClause = $6;
  233 dean.a.rasheed@gmail    12293                 :          35866 :                     $5->returningClause = $7;
 5440 tgl@sss.pgh.pa.us       12294                 :          35866 :                     $5->withClause = $1;
                              12295                 :          35866 :                     $$ = (Node *) $5;
                              12296                 :                :                 }
                              12297                 :                :         ;
                              12298                 :                : 
                              12299                 :                : /*
                              12300                 :                :  * Can't easily make AS optional here, because VALUES in insert_rest would
                              12301                 :                :  * have a shift/reduce conflict with VALUES as an optional alias.  We could
                              12302                 :                :  * easily allow unreserved_keywords as optional aliases, but that'd be an odd
                              12303                 :                :  * divergence from other places.  So just require AS for now.
                              12304                 :                :  */
                              12305                 :                : insert_target:
                              12306                 :                :             qualified_name
                              12307                 :                :                 {
 3774 andres@anarazel.de      12308                 :          35803 :                     $$ = $1;
                              12309                 :                :                 }
                              12310                 :                :             | qualified_name AS ColId
                              12311                 :                :                 {
                              12312                 :             66 :                     $1->alias = makeAlias($3, NIL);
                              12313                 :             66 :                     $$ = $1;
                              12314                 :                :                 }
                              12315                 :                :         ;
                              12316                 :                : 
                              12317                 :                : insert_rest:
                              12318                 :                :             SelectStmt
                              12319                 :                :                 {
10102 bruce@momjian.us        12320                 :          23736 :                     $$ = makeNode(InsertStmt);
 9545 tgl@sss.pgh.pa.us       12321                 :          23736 :                     $$->cols = NIL;
 9102                         12322                 :          23736 :                     $$->selectStmt = $1;
                              12323                 :                :                 }
                              12324                 :                :             | OVERRIDING override_kind VALUE_P SelectStmt
                              12325                 :                :                 {
 3075 peter_e@gmx.net         12326                 :             48 :                     $$ = makeNode(InsertStmt);
                              12327                 :             48 :                     $$->cols = NIL;
                              12328                 :             48 :                     $$->override = $2;
                              12329                 :             48 :                     $$->selectStmt = $4;
                              12330                 :                :                 }
                              12331                 :                :             | '(' insert_column_list ')' SelectStmt
                              12332                 :                :                 {
 9728 bruce@momjian.us        12333                 :           6684 :                     $$ = makeNode(InsertStmt);
                              12334                 :           6684 :                     $$->cols = $2;
 6975 mail@joeconway.com      12335                 :           6684 :                     $$->selectStmt = $4;
                              12336                 :                :                 }
                              12337                 :                :             | '(' insert_column_list ')' OVERRIDING override_kind VALUE_P SelectStmt
                              12338                 :                :                 {
 3075 peter_e@gmx.net         12339                 :UBC           0 :                     $$ = makeNode(InsertStmt);
                              12340                 :              0 :                     $$->cols = $2;
                              12341                 :              0 :                     $$->override = $5;
                              12342                 :              0 :                     $$->selectStmt = $7;
                              12343                 :                :                 }
                              12344                 :                :             | DEFAULT VALUES
                              12345                 :                :                 {
 9728 bruce@momjian.us        12346                 :CBC        5401 :                     $$ = makeNode(InsertStmt);
 6975 mail@joeconway.com      12347                 :           5401 :                     $$->cols = NIL;
                              12348                 :           5401 :                     $$->selectStmt = NULL;
                              12349                 :                :                 }
                              12350                 :                :         ;
                              12351                 :                : 
                              12352                 :                : override_kind:
 3075 peter_e@gmx.net         12353                 :             33 :             USER        { $$ = OVERRIDING_USER_VALUE; }
                              12354                 :             30 :             | SYSTEM_P  { $$ = OVERRIDING_SYSTEM_VALUE; }
                              12355                 :                :         ;
                              12356                 :                : 
                              12357                 :                : insert_column_list:
                              12358                 :                :             insert_column_item
 7759 tgl@sss.pgh.pa.us       12359                 :           6851 :                     { $$ = list_make1($1); }
                              12360                 :                :             | insert_column_list ',' insert_column_item
 8481 bruce@momjian.us        12361                 :           7533 :                     { $$ = lappend($1, $3); }
                              12362                 :                :         ;
                              12363                 :                : 
                              12364                 :                : insert_column_item:
                              12365                 :                :             ColId opt_indirection
                              12366                 :                :                 {
 7759 tgl@sss.pgh.pa.us       12367                 :          14384 :                     $$ = makeNode(ResTarget);
                              12368                 :          14384 :                     $$->name = $1;
 5899                         12369                 :          14384 :                     $$->indirection = check_indirection($2, yyscanner);
 7759                         12370                 :          14384 :                     $$->val = NULL;
 7107                         12371                 :          14384 :                     $$->location = @1;
                              12372                 :                :                 }
                              12373                 :                :         ;
                              12374                 :                : 
                              12375                 :                : opt_on_conflict:
                              12376                 :                :             ON CONFLICT opt_conf_expr DO UPDATE SET set_clause_list where_clause
                              12377                 :                :                 {
 3774 andres@anarazel.de      12378                 :            659 :                     $$ = makeNode(OnConflictClause);
                              12379                 :            659 :                     $$->action = ONCONFLICT_UPDATE;
                              12380                 :            659 :                     $$->infer = $3;
                              12381                 :            659 :                     $$->targetList = $7;
                              12382                 :            659 :                     $$->whereClause = $8;
                              12383                 :            659 :                     $$->location = @1;
                              12384                 :                :                 }
                              12385                 :                :             |
                              12386                 :                :             ON CONFLICT opt_conf_expr DO NOTHING
                              12387                 :                :                 {
                              12388                 :            281 :                     $$ = makeNode(OnConflictClause);
                              12389                 :            281 :                     $$->action = ONCONFLICT_NOTHING;
                              12390                 :            281 :                     $$->infer = $3;
                              12391                 :            281 :                     $$->targetList = NIL;
                              12392                 :            281 :                     $$->whereClause = NULL;
                              12393                 :            281 :                     $$->location = @1;
                              12394                 :                :                 }
                              12395                 :                :             | /*EMPTY*/
                              12396                 :                :                 {
                              12397                 :          34929 :                     $$ = NULL;
                              12398                 :                :                 }
                              12399                 :                :         ;
                              12400                 :                : 
                              12401                 :                : opt_conf_expr:
                              12402                 :                :             '(' index_params ')' where_clause
                              12403                 :                :                 {
                              12404                 :            721 :                     $$ = makeNode(InferClause);
                              12405                 :            721 :                     $$->indexElems = $2;
                              12406                 :            721 :                     $$->whereClause = $4;
                              12407                 :            721 :                     $$->conname = NULL;
                              12408                 :            721 :                     $$->location = @1;
                              12409                 :                :                 }
                              12410                 :                :             |
                              12411                 :                :             ON CONSTRAINT name
                              12412                 :                :                 {
                              12413                 :             96 :                     $$ = makeNode(InferClause);
                              12414                 :             96 :                     $$->indexElems = NIL;
                              12415                 :             96 :                     $$->whereClause = NULL;
                              12416                 :             96 :                     $$->conname = $3;
                              12417                 :             96 :                     $$->location = @1;
                              12418                 :                :                 }
                              12419                 :                :             | /*EMPTY*/
                              12420                 :                :                 {
                              12421                 :            123 :                     $$ = NULL;
                              12422                 :                :                 }
                              12423                 :                :         ;
                              12424                 :                : 
                              12425                 :                : returning_clause:
                              12426                 :                :             RETURNING returning_with_clause target_list
                              12427                 :                :                 {
  233 dean.a.rasheed@gmail    12428                 :           1582 :                     ReturningClause *n = makeNode(ReturningClause);
                              12429                 :                : 
                              12430                 :           1582 :                     n->options = $2;
                              12431                 :           1582 :                     n->exprs = $3;
                              12432                 :           1582 :                     $$ = n;
                              12433                 :                :                 }
                              12434                 :                :             | /* EMPTY */
                              12435                 :                :                 {
                              12436                 :          44739 :                     $$ = NULL;
                              12437                 :                :                 }
                              12438                 :                :         ;
                              12439                 :                : 
                              12440                 :                : returning_with_clause:
                              12441                 :             36 :             WITH '(' returning_options ')'      { $$ = $3; }
                              12442                 :           1546 :             | /* EMPTY */                       { $$ = NIL; }
                              12443                 :                :         ;
                              12444                 :                : 
                              12445                 :                : returning_options:
                              12446                 :             36 :             returning_option                            { $$ = list_make1($1); }
                              12447                 :             27 :             | returning_options ',' returning_option    { $$ = lappend($1, $3); }
                              12448                 :                :         ;
                              12449                 :                : 
                              12450                 :                : returning_option:
                              12451                 :                :             returning_option_kind AS ColId
                              12452                 :                :                 {
                              12453                 :             63 :                     ReturningOption *n = makeNode(ReturningOption);
                              12454                 :                : 
                              12455                 :             63 :                     n->option = $1;
                              12456                 :             63 :                     n->value = $3;
                              12457                 :             63 :                     n->location = @1;
                              12458                 :             63 :                     $$ = (Node *) n;
                              12459                 :                :                 }
                              12460                 :                :         ;
                              12461                 :                : 
                              12462                 :                : returning_option_kind:
                              12463                 :             27 :             OLD         { $$ = RETURNING_OPTION_OLD; }
                              12464                 :             36 :             | NEW       { $$ = RETURNING_OPTION_NEW; }
                              12465                 :                :         ;
                              12466                 :                : 
                              12467                 :                : 
                              12468                 :                : /*****************************************************************************
                              12469                 :                :  *
                              12470                 :                :  *      QUERY:
                              12471                 :                :  *              DELETE STATEMENTS
                              12472                 :                :  *
                              12473                 :                :  *****************************************************************************/
                              12474                 :                : 
                              12475                 :                : DeleteStmt: opt_with_clause DELETE_P FROM relation_expr_opt_alias
                              12476                 :                :             using_clause where_or_current_clause returning_clause
                              12477                 :                :                 {
10225 bruce@momjian.us        12478                 :           2323 :                     DeleteStmt *n = makeNode(DeleteStmt);
                              12479                 :                : 
 5440 tgl@sss.pgh.pa.us       12480                 :           2323 :                     n->relation = $4;
                              12481                 :           2323 :                     n->usingClause = $5;
                              12482                 :           2323 :                     n->whereClause = $6;
  233 dean.a.rasheed@gmail    12483                 :           2323 :                     n->returningClause = $7;
 5440 tgl@sss.pgh.pa.us       12484                 :           2323 :                     n->withClause = $1;
 1212 peter@eisentraut.org    12485                 :           2323 :                     $$ = (Node *) n;
                              12486                 :                :                 }
                              12487                 :                :         ;
                              12488                 :                : 
                              12489                 :                : using_clause:
 5058 peter_e@gmx.net         12490                 :             54 :                 USING from_list                     { $$ = $2; }
 7457 neilc@samurai.com       12491                 :           2269 :             | /*EMPTY*/                             { $$ = NIL; }
                              12492                 :                :         ;
                              12493                 :                : 
                              12494                 :                : 
                              12495                 :                : /*****************************************************************************
                              12496                 :                :  *
                              12497                 :                :  *      QUERY:
                              12498                 :                :  *              LOCK TABLE
                              12499                 :                :  *
                              12500                 :                :  *****************************************************************************/
                              12501                 :                : 
                              12502                 :                : LockStmt:   LOCK_P opt_table relation_expr_list opt_lock opt_nowait
                              12503                 :                :                 {
 1212 peter@eisentraut.org    12504                 :            636 :                     LockStmt   *n = makeNode(LockStmt);
                              12505                 :                : 
 8570 tgl@sss.pgh.pa.us       12506                 :            636 :                     n->relations = $3;
 9609 bruce@momjian.us        12507                 :            636 :                     n->mode = $4;
 7849 ishii@postgresql.org    12508                 :            636 :                     n->nowait = $5;
 1212 peter@eisentraut.org    12509                 :            636 :                     $$ = (Node *) n;
                              12510                 :                :                 }
                              12511                 :                :         ;
                              12512                 :                : 
 5058 peter_e@gmx.net         12513                 :            581 : opt_lock:   IN_P lock_type MODE             { $$ = $2; }
 8481 bruce@momjian.us        12514                 :             55 :             | /*EMPTY*/                     { $$ = AccessExclusiveLock; }
                              12515                 :                :         ;
                              12516                 :                : 
                              12517                 :            336 : lock_type:  ACCESS SHARE                    { $$ = AccessShareLock; }
                              12518                 :              7 :             | ROW SHARE                     { $$ = RowShareLock; }
                              12519                 :             44 :             | ROW EXCLUSIVE                 { $$ = RowExclusiveLock; }
                              12520                 :             33 :             | SHARE UPDATE EXCLUSIVE        { $$ = ShareUpdateExclusiveLock; }
                              12521                 :             40 :             | SHARE                         { $$ = ShareLock; }
                              12522                 :              7 :             | SHARE ROW EXCLUSIVE           { $$ = ShareRowExclusiveLock; }
                              12523                 :             51 :             | EXCLUSIVE                     { $$ = ExclusiveLock; }
                              12524                 :             63 :             | ACCESS EXCLUSIVE              { $$ = AccessExclusiveLock; }
                              12525                 :                :         ;
                              12526                 :                : 
 2943 peter_e@gmx.net         12527                 :            205 : opt_nowait: NOWAIT                          { $$ = true; }
                              12528                 :            446 :             | /*EMPTY*/                     { $$ = false; }
                              12529                 :                :         ;
                              12530                 :                : 
                              12531                 :                : opt_nowait_or_skip:
 3987 alvherre@alvh.no-ip.    12532                 :             25 :             NOWAIT                          { $$ = LockWaitError; }
                              12533                 :             95 :             | SKIP LOCKED                   { $$ = LockWaitSkip; }
                              12534                 :           2495 :             | /*EMPTY*/                     { $$ = LockWaitBlock; }
                              12535                 :                :         ;
                              12536                 :                : 
                              12537                 :                : 
                              12538                 :                : /*****************************************************************************
                              12539                 :                :  *
                              12540                 :                :  *      QUERY:
                              12541                 :                :  *              UpdateStmt (UPDATE)
                              12542                 :                :  *
                              12543                 :                :  *****************************************************************************/
                              12544                 :                : 
                              12545                 :                : UpdateStmt: opt_with_clause UPDATE relation_expr_opt_alias
                              12546                 :                :             SET set_clause_list
                              12547                 :                :             from_clause
                              12548                 :                :             where_or_current_clause
                              12549                 :                :             returning_clause
                              12550                 :                :                 {
 6944 bruce@momjian.us        12551                 :           7073 :                     UpdateStmt *n = makeNode(UpdateStmt);
                              12552                 :                : 
 5440 tgl@sss.pgh.pa.us       12553                 :           7073 :                     n->relation = $3;
                              12554                 :           7073 :                     n->targetList = $5;
                              12555                 :           7073 :                     n->fromClause = $6;
                              12556                 :           7073 :                     n->whereClause = $7;
  233 dean.a.rasheed@gmail    12557                 :           7073 :                     n->returningClause = $8;
 5440 tgl@sss.pgh.pa.us       12558                 :           7073 :                     n->withClause = $1;
 1212 peter@eisentraut.org    12559                 :           7073 :                     $$ = (Node *) n;
                              12560                 :                :                 }
                              12561                 :                :         ;
                              12562                 :                : 
                              12563                 :                : set_clause_list:
 6943 tgl@sss.pgh.pa.us       12564                 :           8531 :             set_clause                          { $$ = $1; }
                              12565                 :           2106 :             | set_clause_list ',' set_clause    { $$ = list_concat($1,$3); }
                              12566                 :                :         ;
                              12567                 :                : 
                              12568                 :                : set_clause:
                              12569                 :                :             set_target '=' a_expr
                              12570                 :                :                 {
 3210                         12571                 :          10546 :                     $1->val = (Node *) $3;
                              12572                 :          10546 :                     $$ = list_make1($1);
                              12573                 :                :                 }
                              12574                 :                :             | '(' set_target_list ')' '=' a_expr
                              12575                 :                :                 {
 1212 peter@eisentraut.org    12576                 :             91 :                     int         ncolumns = list_length($2);
                              12577                 :             91 :                     int         i = 1;
                              12578                 :                :                     ListCell   *col_cell;
                              12579                 :                : 
                              12580                 :                :                     /* Create a MultiAssignRef source for each target */
 4098 tgl@sss.pgh.pa.us       12581   [ +  -  +  +  :            281 :                     foreach(col_cell, $2)
                                              +  + ]
                              12582                 :                :                     {
 1212 peter@eisentraut.org    12583                 :            190 :                         ResTarget  *res_col = (ResTarget *) lfirst(col_cell);
 4098 tgl@sss.pgh.pa.us       12584                 :            190 :                         MultiAssignRef *r = makeNode(MultiAssignRef);
                              12585                 :                : 
 3210                         12586                 :            190 :                         r->source = (Node *) $5;
 4098                         12587                 :            190 :                         r->colno = i;
                              12588                 :            190 :                         r->ncolumns = ncolumns;
                              12589                 :            190 :                         res_col->val = (Node *) r;
                              12590                 :            190 :                         i++;
                              12591                 :                :                     }
                              12592                 :                : 
 6943                         12593                 :             91 :                     $$ = $2;
                              12594                 :                :                 }
                              12595                 :                :         ;
                              12596                 :                : 
                              12597                 :                : set_target:
                              12598                 :                :             ColId opt_indirection
                              12599                 :                :                 {
                              12600                 :          10739 :                     $$ = makeNode(ResTarget);
                              12601                 :          10739 :                     $$->name = $1;
 5899                         12602                 :          10739 :                     $$->indirection = check_indirection($2, yyscanner);
 6943                         12603                 :          10739 :                     $$->val = NULL;  /* upper production sets this */
                              12604                 :          10739 :                     $$->location = @1;
                              12605                 :                :                 }
                              12606                 :                :         ;
                              12607                 :                : 
                              12608                 :                : set_target_list:
                              12609                 :             94 :             set_target                              { $$ = list_make1($1); }
                              12610                 :             99 :             | set_target_list ',' set_target        { $$ = lappend($1,$3); }
                              12611                 :                :         ;
                              12612                 :                : 
                              12613                 :                : 
                              12614                 :                : /*****************************************************************************
                              12615                 :                :  *
                              12616                 :                :  *      QUERY:
                              12617                 :                :  *              MERGE
                              12618                 :                :  *
                              12619                 :                :  *****************************************************************************/
                              12620                 :                : 
                              12621                 :                : MergeStmt:
                              12622                 :                :             opt_with_clause MERGE INTO relation_expr_opt_alias
                              12623                 :                :             USING table_ref
                              12624                 :                :             ON a_expr
                              12625                 :                :             merge_when_list
                              12626                 :                :             returning_clause
                              12627                 :                :                 {
 1212 peter@eisentraut.org    12628                 :           1059 :                     MergeStmt  *m = makeNode(MergeStmt);
                              12629                 :                : 
 1258 alvherre@alvh.no-ip.    12630                 :           1059 :                     m->withClause = $1;
                              12631                 :           1059 :                     m->relation = $4;
                              12632                 :           1059 :                     m->sourceRelation = $6;
                              12633                 :           1059 :                     m->joinCondition = $8;
                              12634                 :           1059 :                     m->mergeWhenClauses = $9;
  233 dean.a.rasheed@gmail    12635                 :           1059 :                     m->returningClause = $10;
                              12636                 :                : 
 1212 peter@eisentraut.org    12637                 :           1059 :                     $$ = (Node *) m;
                              12638                 :                :                 }
                              12639                 :                :         ;
                              12640                 :                : 
                              12641                 :                : merge_when_list:
 1258 alvherre@alvh.no-ip.    12642                 :           1059 :             merge_when_clause                       { $$ = list_make1($1); }
                              12643                 :            600 :             | merge_when_list merge_when_clause     { $$ = lappend($1,$2); }
                              12644                 :                :         ;
                              12645                 :                : 
                              12646                 :                : /*
                              12647                 :                :  * A WHEN clause may be WHEN MATCHED, WHEN NOT MATCHED BY SOURCE, or WHEN NOT
                              12648                 :                :  * MATCHED [BY TARGET]. The first two cases match target tuples, and support
                              12649                 :                :  * UPDATE/DELETE/DO NOTHING actions. The third case does not match target
                              12650                 :                :  * tuples, and only supports INSERT/DO NOTHING actions.
                              12651                 :                :  */
                              12652                 :                : merge_when_clause:
                              12653                 :                :             merge_when_tgt_matched opt_merge_when_condition THEN merge_update
                              12654                 :                :                 {
  525 dean.a.rasheed@gmail    12655                 :            799 :                     $4->matchKind = $1;
                              12656                 :            799 :                     $4->condition = $2;
                              12657                 :                : 
                              12658                 :            799 :                     $$ = (Node *) $4;
                              12659                 :                :                 }
                              12660                 :                :             | merge_when_tgt_matched opt_merge_when_condition THEN merge_delete
                              12661                 :                :                 {
                              12662                 :            265 :                     $4->matchKind = $1;
                              12663                 :            265 :                     $4->condition = $2;
                              12664                 :                : 
                              12665                 :            265 :                     $$ = (Node *) $4;
                              12666                 :                :                 }
                              12667                 :                :             | merge_when_tgt_not_matched opt_merge_when_condition THEN merge_insert
                              12668                 :                :                 {
                              12669                 :            550 :                     $4->matchKind = $1;
                              12670                 :            550 :                     $4->condition = $2;
                              12671                 :                : 
                              12672                 :            550 :                     $$ = (Node *) $4;
                              12673                 :                :                 }
                              12674                 :                :             | merge_when_tgt_matched opt_merge_when_condition THEN DO NOTHING
                              12675                 :                :                 {
 1258 alvherre@alvh.no-ip.    12676                 :             35 :                     MergeWhenClause *m = makeNode(MergeWhenClause);
                              12677                 :                : 
  525 dean.a.rasheed@gmail    12678                 :             35 :                     m->matchKind = $1;
 1258 alvherre@alvh.no-ip.    12679                 :             35 :                     m->commandType = CMD_NOTHING;
  525 dean.a.rasheed@gmail    12680                 :             35 :                     m->condition = $2;
                              12681                 :                : 
 1212 peter@eisentraut.org    12682                 :             35 :                     $$ = (Node *) m;
                              12683                 :                :                 }
                              12684                 :                :             | merge_when_tgt_not_matched opt_merge_when_condition THEN DO NOTHING
                              12685                 :                :                 {
 1258 alvherre@alvh.no-ip.    12686                 :             10 :                     MergeWhenClause *m = makeNode(MergeWhenClause);
                              12687                 :                : 
  525 dean.a.rasheed@gmail    12688                 :             10 :                     m->matchKind = $1;
 1258 alvherre@alvh.no-ip.    12689                 :             10 :                     m->commandType = CMD_NOTHING;
  525 dean.a.rasheed@gmail    12690                 :             10 :                     m->condition = $2;
                              12691                 :                : 
 1212 peter@eisentraut.org    12692                 :             10 :                     $$ = (Node *) m;
                              12693                 :                :                 }
                              12694                 :                :         ;
                              12695                 :                : 
                              12696                 :                : merge_when_tgt_matched:
  525 dean.a.rasheed@gmail    12697                 :           1018 :             WHEN MATCHED                    { $$ = MERGE_WHEN_MATCHED; }
                              12698                 :             90 :             | WHEN NOT MATCHED BY SOURCE    { $$ = MERGE_WHEN_NOT_MATCHED_BY_SOURCE; }
                              12699                 :                :         ;
                              12700                 :                : 
                              12701                 :                : merge_when_tgt_not_matched:
                              12702                 :            563 :             WHEN NOT MATCHED                { $$ = MERGE_WHEN_NOT_MATCHED_BY_TARGET; }
                              12703                 :              9 :             | WHEN NOT MATCHED BY TARGET    { $$ = MERGE_WHEN_NOT_MATCHED_BY_TARGET; }
                              12704                 :                :         ;
                              12705                 :                : 
                              12706                 :                : opt_merge_when_condition:
 1258 alvherre@alvh.no-ip.    12707                 :            425 :             AND a_expr              { $$ = $2; }
                              12708                 :           1255 :             |                       { $$ = NULL; }
                              12709                 :                :         ;
                              12710                 :                : 
                              12711                 :                : merge_update:
                              12712                 :                :             UPDATE SET set_clause_list
                              12713                 :                :                 {
                              12714                 :            799 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12715                 :            799 :                     n->commandType = CMD_UPDATE;
                              12716                 :            799 :                     n->override = OVERRIDING_NOT_SET;
                              12717                 :            799 :                     n->targetList = $3;
                              12718                 :            799 :                     n->values = NIL;
                              12719                 :                : 
                              12720                 :            799 :                     $$ = n;
                              12721                 :                :                 }
                              12722                 :                :         ;
                              12723                 :                : 
                              12724                 :                : merge_delete:
                              12725                 :                :             DELETE_P
                              12726                 :                :                 {
                              12727                 :            265 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12728                 :            265 :                     n->commandType = CMD_DELETE;
                              12729                 :            265 :                     n->override = OVERRIDING_NOT_SET;
                              12730                 :            265 :                     n->targetList = NIL;
                              12731                 :            265 :                     n->values = NIL;
                              12732                 :                : 
                              12733                 :            265 :                     $$ = n;
                              12734                 :                :                 }
                              12735                 :                :         ;
                              12736                 :                : 
                              12737                 :                : merge_insert:
                              12738                 :                :             INSERT merge_values_clause
                              12739                 :                :                 {
                              12740                 :            365 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12741                 :            365 :                     n->commandType = CMD_INSERT;
                              12742                 :            365 :                     n->override = OVERRIDING_NOT_SET;
                              12743                 :            365 :                     n->targetList = NIL;
                              12744                 :            365 :                     n->values = $2;
                              12745                 :            365 :                     $$ = n;
                              12746                 :                :                 }
                              12747                 :                :             | INSERT OVERRIDING override_kind VALUE_P merge_values_clause
                              12748                 :                :                 {
 1258 alvherre@alvh.no-ip.    12749                 :UBC           0 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12750                 :              0 :                     n->commandType = CMD_INSERT;
                              12751                 :              0 :                     n->override = $3;
                              12752                 :              0 :                     n->targetList = NIL;
                              12753                 :              0 :                     n->values = $5;
                              12754                 :              0 :                     $$ = n;
                              12755                 :                :                 }
                              12756                 :                :             | INSERT '(' insert_column_list ')' merge_values_clause
                              12757                 :                :                 {
 1258 alvherre@alvh.no-ip.    12758                 :CBC         152 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12759                 :            152 :                     n->commandType = CMD_INSERT;
                              12760                 :            152 :                     n->override = OVERRIDING_NOT_SET;
                              12761                 :            152 :                     n->targetList = $3;
                              12762                 :            152 :                     n->values = $5;
                              12763                 :            152 :                     $$ = n;
                              12764                 :                :                 }
                              12765                 :                :             | INSERT '(' insert_column_list ')' OVERRIDING override_kind VALUE_P merge_values_clause
                              12766                 :                :                 {
                              12767                 :             15 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12768                 :             15 :                     n->commandType = CMD_INSERT;
                              12769                 :             15 :                     n->override = $6;
                              12770                 :             15 :                     n->targetList = $3;
                              12771                 :             15 :                     n->values = $8;
                              12772                 :             15 :                     $$ = n;
                              12773                 :                :                 }
                              12774                 :                :             | INSERT DEFAULT VALUES
                              12775                 :                :                 {
                              12776                 :             18 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12777                 :             18 :                     n->commandType = CMD_INSERT;
                              12778                 :             18 :                     n->override = OVERRIDING_NOT_SET;
                              12779                 :             18 :                     n->targetList = NIL;
                              12780                 :             18 :                     n->values = NIL;
                              12781                 :             18 :                     $$ = n;
                              12782                 :                :                 }
                              12783                 :                :         ;
                              12784                 :                : 
                              12785                 :                : merge_values_clause:
                              12786                 :                :             VALUES '(' expr_list ')'
                              12787                 :                :                 {
                              12788                 :            532 :                     $$ = $3;
                              12789                 :                :                 }
                              12790                 :                :         ;
                              12791                 :                : 
                              12792                 :                : /*****************************************************************************
                              12793                 :                :  *
                              12794                 :                :  *      QUERY:
                              12795                 :                :  *              CURSOR STATEMENTS
                              12796                 :                :  *
                              12797                 :                :  *****************************************************************************/
                              12798                 :                : DeclareCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR SelectStmt
                              12799                 :                :                 {
 8216 tgl@sss.pgh.pa.us       12800                 :           2266 :                     DeclareCursorStmt *n = makeNode(DeclareCursorStmt);
                              12801                 :                : 
10225 bruce@momjian.us        12802                 :           2266 :                     n->portalname = $2;
                              12803                 :                :                     /* currently we always set FAST_PLAN option */
 6718 tgl@sss.pgh.pa.us       12804                 :           2266 :                     n->options = $3 | $5 | CURSOR_OPT_FAST_PLAN;
 8199 bruce@momjian.us        12805                 :           2266 :                     n->query = $7;
 1212 peter@eisentraut.org    12806                 :           2266 :                     $$ = (Node *) n;
                              12807                 :                :                 }
                              12808                 :                :         ;
                              12809                 :                : 
 5778 alvherre@alvh.no-ip.    12810                 :           7203 : cursor_name:    name                        { $$ = $1; }
                              12811                 :                :         ;
                              12812                 :                : 
 8216 tgl@sss.pgh.pa.us       12813                 :           2266 : cursor_options: /*EMPTY*/                   { $$ = 0; }
 8199 bruce@momjian.us        12814                 :             14 :             | cursor_options NO SCROLL      { $$ = $1 | CURSOR_OPT_NO_SCROLL; }
 8216 tgl@sss.pgh.pa.us       12815                 :            120 :             | cursor_options SCROLL         { $$ = $1 | CURSOR_OPT_SCROLL; }
 8199 bruce@momjian.us        12816                 :              5 :             | cursor_options BINARY         { $$ = $1 | CURSOR_OPT_BINARY; }
 1613 peter@eisentraut.org    12817                 :UBC           0 :             | cursor_options ASENSITIVE     { $$ = $1 | CURSOR_OPT_ASENSITIVE; }
 8216 tgl@sss.pgh.pa.us       12818                 :CBC           3 :             | cursor_options INSENSITIVE    { $$ = $1 | CURSOR_OPT_INSENSITIVE; }
                              12819                 :                :         ;
                              12820                 :                : 
 6718                         12821                 :           2217 : opt_hold: /* EMPTY */                       { $$ = 0; }
                              12822                 :             46 :             | WITH HOLD                     { $$ = CURSOR_OPT_HOLD; }
                              12823                 :              3 :             | WITHOUT HOLD                  { $$ = 0; }
                              12824                 :                :         ;
                              12825                 :                : 
                              12826                 :                : /*****************************************************************************
                              12827                 :                :  *
                              12828                 :                :  *      QUERY:
                              12829                 :                :  *              SELECT STATEMENTS
                              12830                 :                :  *
                              12831                 :                :  *****************************************************************************/
                              12832                 :                : 
                              12833                 :                : /* A complete SELECT statement looks like this.
                              12834                 :                :  *
                              12835                 :                :  * The rule returns either a single SelectStmt node or a tree of them,
                              12836                 :                :  * representing a set-operation tree.
                              12837                 :                :  *
                              12838                 :                :  * There is an ambiguity when a sub-SELECT is within an a_expr and there
                              12839                 :                :  * are excess parentheses: do the parentheses belong to the sub-SELECT or
                              12840                 :                :  * to the surrounding a_expr?  We don't really care, but bison wants to know.
                              12841                 :                :  * To resolve the ambiguity, we are careful to define the grammar so that
                              12842                 :                :  * the decision is staved off as long as possible: as long as we can keep
                              12843                 :                :  * absorbing parentheses into the sub-SELECT, we will do so, and only when
                              12844                 :                :  * it's no longer possible to do that will we decide that parens belong to
                              12845                 :                :  * the expression.  For example, in "SELECT (((SELECT 2)) + 3)" the extra
                              12846                 :                :  * parentheses are treated as part of the sub-select.  The necessity of doing
                              12847                 :                :  * it that way is shown by "SELECT (((SELECT 2)) UNION SELECT 2)".    Had we
                              12848                 :                :  * parsed "((SELECT 2))" as an a_expr, it'd be too late to go back to the
                              12849                 :                :  * SELECT viewpoint when we see the UNION.
                              12850                 :                :  *
                              12851                 :                :  * This approach is implemented by defining a nonterminal select_with_parens,
                              12852                 :                :  * which represents a SELECT with at least one outer layer of parentheses,
                              12853                 :                :  * and being careful to use select_with_parens, never '(' SelectStmt ')',
                              12854                 :                :  * in the expression grammar.  We will then have shift-reduce conflicts
                              12855                 :                :  * which we can resolve in favor of always treating '(' <select> ')' as
                              12856                 :                :  * a select_with_parens.  To resolve the conflicts, the productions that
                              12857                 :                :  * conflict with the select_with_parens productions are manually given
                              12858                 :                :  * precedences lower than the precedence of ')', thereby ensuring that we
                              12859                 :                :  * shift ')' (and then reduce to select_with_parens) rather than trying to
                              12860                 :                :  * reduce the inner <select> nonterminal to something else.  We use UMINUS
                              12861                 :                :  * precedence for this, which is a fairly arbitrary choice.
                              12862                 :                :  *
                              12863                 :                :  * To be able to define select_with_parens itself without ambiguity, we need
                              12864                 :                :  * a nonterminal select_no_parens that represents a SELECT structure with no
                              12865                 :                :  * outermost parentheses.  This is a little bit tedious, but it works.
                              12866                 :                :  *
                              12867                 :                :  * In non-expression contexts, we use SelectStmt which can represent a SELECT
                              12868                 :                :  * with or without outer parentheses.
                              12869                 :                :  */
                              12870                 :                : 
                              12871                 :                : SelectStmt: select_no_parens            %prec UMINUS
                              12872                 :                :             | select_with_parens        %prec UMINUS
                              12873                 :                :         ;
                              12874                 :                : 
                              12875                 :                : select_with_parens:
   86 michael@paquier.xyz     12876                 :          32631 :             '(' select_no_parens ')'                { $$ = $2; }
 8482 bruce@momjian.us        12877                 :             78 :             | '(' select_with_parens ')'            { $$ = $2; }
                              12878                 :                :         ;
                              12879                 :                : 
                              12880                 :                : /*
                              12881                 :                :  * This rule parses the equivalent of the standard's <query expression>.
                              12882                 :                :  * The duplicative productions are annoying, but hard to get rid of without
                              12883                 :                :  * creating shift/reduce conflicts.
                              12884                 :                :  *
                              12885                 :                :  *  The locking clause (FOR UPDATE etc) may be before or after LIMIT/OFFSET.
                              12886                 :                :  *  In <=7.2.X, LIMIT/OFFSET had to be after FOR UPDATE
                              12887                 :                :  *  We now support both orderings, but prefer LIMIT/OFFSET before the locking
                              12888                 :                :  * clause.
                              12889                 :                :  *  2002-08-28 bjm
                              12890                 :                :  */
                              12891                 :                : select_no_parens:
                              12892                 :         197485 :             simple_select                       { $$ = $1; }
                              12893                 :                :             | select_clause sort_clause
                              12894                 :                :                 {
 7069 tgl@sss.pgh.pa.us       12895                 :          35340 :                     insertSelectOptions((SelectStmt *) $1, $2, NIL,
                              12896                 :                :                                         NULL, NULL,
                              12897                 :                :                                         yyscanner);
 8482 bruce@momjian.us        12898                 :          35340 :                     $$ = $1;
                              12899                 :                :                 }
                              12900                 :                :             | select_clause opt_sort_clause for_locking_clause opt_select_limit
                              12901                 :                :                 {
 8410                         12902                 :           2391 :                     insertSelectOptions((SelectStmt *) $1, $2, $3,
 1978 alvherre@alvh.no-ip.    12903                 :           2391 :                                         $4,
                              12904                 :                :                                         NULL,
                              12905                 :                :                                         yyscanner);
 8482 bruce@momjian.us        12906                 :           2391 :                     $$ = $1;
                              12907                 :                :                 }
                              12908                 :                :             | select_clause opt_sort_clause select_limit opt_for_locking_clause
                              12909                 :                :                 {
 8410                         12910                 :           2439 :                     insertSelectOptions((SelectStmt *) $1, $2, $4,
 1978 alvherre@alvh.no-ip.    12911                 :           2439 :                                         $3,
                              12912                 :                :                                         NULL,
                              12913                 :                :                                         yyscanner);
 8482 bruce@momjian.us        12914                 :           2433 :                     $$ = $1;
                              12915                 :                :                 }
                              12916                 :                :             | with_clause select_clause
                              12917                 :                :                 {
 6181 tgl@sss.pgh.pa.us       12918                 :           1097 :                     insertSelectOptions((SelectStmt *) $2, NULL, NIL,
                              12919                 :                :                                         NULL,
 5899                         12920                 :           1097 :                                         $1,
                              12921                 :                :                                         yyscanner);
 6181                         12922                 :           1097 :                     $$ = $2;
                              12923                 :                :                 }
                              12924                 :                :             | with_clause select_clause sort_clause
                              12925                 :                :                 {
                              12926                 :            307 :                     insertSelectOptions((SelectStmt *) $2, $3, NIL,
                              12927                 :                :                                         NULL,
 5899                         12928                 :            307 :                                         $1,
                              12929                 :                :                                         yyscanner);
 6181                         12930                 :            307 :                     $$ = $2;
                              12931                 :                :                 }
                              12932                 :                :             | with_clause select_clause opt_sort_clause for_locking_clause opt_select_limit
                              12933                 :                :                 {
                              12934                 :              3 :                     insertSelectOptions((SelectStmt *) $2, $3, $4,
 1978 alvherre@alvh.no-ip.    12935                 :              3 :                                         $5,
 5899 tgl@sss.pgh.pa.us       12936                 :              3 :                                         $1,
                              12937                 :                :                                         yyscanner);
 6181                         12938                 :              3 :                     $$ = $2;
                              12939                 :                :                 }
                              12940                 :                :             | with_clause select_clause opt_sort_clause select_limit opt_for_locking_clause
                              12941                 :                :                 {
                              12942                 :             32 :                     insertSelectOptions((SelectStmt *) $2, $3, $5,
 1978 alvherre@alvh.no-ip.    12943                 :             32 :                                         $4,
 5899 tgl@sss.pgh.pa.us       12944                 :             32 :                                         $1,
                              12945                 :                :                                         yyscanner);
 6181                         12946                 :             32 :                     $$ = $2;
                              12947                 :                :                 }
                              12948                 :                :         ;
                              12949                 :                : 
                              12950                 :                : select_clause:
 8482 bruce@momjian.us        12951                 :          60673 :             simple_select                           { $$ = $1; }
                              12952                 :            294 :             | select_with_parens                    { $$ = $1; }
                              12953                 :                :         ;
                              12954                 :                : 
                              12955                 :                : /*
                              12956                 :                :  * This rule parses SELECT statements that can appear within set operations,
                              12957                 :                :  * including UNION, INTERSECT and EXCEPT.  '(' and ')' can be used to specify
                              12958                 :                :  * the ordering of the set operations.  Without '(' and ')' we want the
                              12959                 :                :  * operations to be ordered per the precedence specs at the head of this file.
                              12960                 :                :  *
                              12961                 :                :  * As with select_no_parens, simple_select cannot have outer parentheses,
                              12962                 :                :  * but can have parenthesized subclauses.
                              12963                 :                :  *
                              12964                 :                :  * It might appear that we could fold the first two alternatives into one
                              12965                 :                :  * by using opt_distinct_clause.  However, that causes a shift/reduce conflict
                              12966                 :                :  * against INSERT ... SELECT ... ON CONFLICT.  We avoid the ambiguity by
                              12967                 :                :  * requiring SELECT DISTINCT [ON] to be followed by a non-empty target_list.
                              12968                 :                :  *
                              12969                 :                :  * Note that sort clauses cannot be included at this level --- SQL requires
                              12970                 :                :  *      SELECT foo UNION SELECT bar ORDER BY baz
                              12971                 :                :  * to be parsed as
                              12972                 :                :  *      (SELECT foo UNION SELECT bar) ORDER BY baz
                              12973                 :                :  * not
                              12974                 :                :  *      SELECT foo UNION (SELECT bar ORDER BY baz)
                              12975                 :                :  * Likewise for WITH, FOR UPDATE and LIMIT.  Therefore, those clauses are
                              12976                 :                :  * described as part of the select_no_parens production, not simple_select.
                              12977                 :                :  * This does not limit functionality, because you can reintroduce these
                              12978                 :                :  * clauses inside parentheses.
                              12979                 :                :  *
                              12980                 :                :  * NOTE: only the leftmost component SelectStmt should have INTO.
                              12981                 :                :  * However, this is not checked by the grammar; parse analysis must check it.
                              12982                 :                :  */
                              12983                 :                : simple_select:
                              12984                 :                :             SELECT opt_all_clause opt_target_list
                              12985                 :                :             into_clause from_clause where_clause
                              12986                 :                :             group_clause having_clause window_clause
                              12987                 :                :                 {
 3774 andres@anarazel.de      12988                 :         215404 :                     SelectStmt *n = makeNode(SelectStmt);
                              12989                 :                : 
                              12990                 :         215404 :                     n->targetList = $3;
                              12991                 :         215404 :                     n->intoClause = $4;
                              12992                 :         215404 :                     n->fromClause = $5;
                              12993                 :         215404 :                     n->whereClause = $6;
 1633 tomas.vondra@postgre    12994                 :         215404 :                     n->groupClause = ($7)->list;
                              12995                 :         215404 :                     n->groupDistinct = ($7)->distinct;
 3774 andres@anarazel.de      12996                 :         215404 :                     n->havingClause = $8;
                              12997                 :         215404 :                     n->windowClause = $9;
 1212 peter@eisentraut.org    12998                 :         215404 :                     $$ = (Node *) n;
                              12999                 :                :                 }
                              13000                 :                :             | SELECT distinct_clause target_list
                              13001                 :                :             into_clause from_clause where_clause
                              13002                 :                :             group_clause having_clause window_clause
                              13003                 :                :                 {
10102 bruce@momjian.us        13004                 :           1837 :                     SelectStmt *n = makeNode(SelectStmt);
                              13005                 :                : 
 9354 tgl@sss.pgh.pa.us       13006                 :           1837 :                     n->distinctClause = $2;
10225 bruce@momjian.us        13007                 :           1837 :                     n->targetList = $3;
 6707 tgl@sss.pgh.pa.us       13008                 :           1837 :                     n->intoClause = $4;
10225 bruce@momjian.us        13009                 :           1837 :                     n->fromClause = $5;
                              13010                 :           1837 :                     n->whereClause = $6;
 1633 tomas.vondra@postgre    13011                 :           1837 :                     n->groupClause = ($7)->list;
                              13012                 :           1837 :                     n->groupDistinct = ($7)->distinct;
10225 bruce@momjian.us        13013                 :           1837 :                     n->havingClause = $8;
 6096 tgl@sss.pgh.pa.us       13014                 :           1837 :                     n->windowClause = $9;
 1212 peter@eisentraut.org    13015                 :           1837 :                     $$ = (Node *) n;
                              13016                 :                :                 }
 6975 mail@joeconway.com      13017                 :          31082 :             | values_clause                         { $$ = $1; }
                              13018                 :                :             | TABLE relation_expr
                              13019                 :                :                 {
                              13020                 :                :                     /* same as SELECT * FROM relation_expr */
 1212 peter@eisentraut.org    13021                 :            159 :                     ColumnRef  *cr = makeNode(ColumnRef);
                              13022                 :            159 :                     ResTarget  *rt = makeNode(ResTarget);
 6134 peter_e@gmx.net         13023                 :            159 :                     SelectStmt *n = makeNode(SelectStmt);
                              13024                 :                : 
                              13025                 :            159 :                     cr->fields = list_make1(makeNode(A_Star));
                              13026                 :            159 :                     cr->location = -1;
                              13027                 :                : 
                              13028                 :            159 :                     rt->name = NULL;
                              13029                 :            159 :                     rt->indirection = NIL;
 1212 peter@eisentraut.org    13030                 :            159 :                     rt->val = (Node *) cr;
 6134 peter_e@gmx.net         13031                 :            159 :                     rt->location = -1;
                              13032                 :                : 
                              13033                 :            159 :                     n->targetList = list_make1(rt);
                              13034                 :            159 :                     n->fromClause = list_make1($2);
 1212 peter@eisentraut.org    13035                 :            159 :                     $$ = (Node *) n;
                              13036                 :                :                 }
                              13037                 :                :             | select_clause UNION set_quantifier select_clause
                              13038                 :                :                 {
   86 michael@paquier.xyz     13039                 :           9309 :                     $$ = makeSetOp(SETOP_UNION, $3 == SET_QUANTIFIER_ALL, $1, $4);
                              13040                 :                :                 }
                              13041                 :                :             | select_clause INTERSECT set_quantifier select_clause
                              13042                 :                :                 {
                              13043                 :            129 :                     $$ = makeSetOp(SETOP_INTERSECT, $3 == SET_QUANTIFIER_ALL, $1, $4);
                              13044                 :                :                 }
                              13045                 :                :             | select_clause EXCEPT set_quantifier select_clause
                              13046                 :                :                 {
                              13047                 :            238 :                     $$ = makeSetOp(SETOP_EXCEPT, $3 == SET_QUANTIFIER_ALL, $1, $4);
                              13048                 :                :                 }
                              13049                 :                :         ;
                              13050                 :                : 
                              13051                 :                : /*
                              13052                 :                :  * SQL standard WITH clause looks like:
                              13053                 :                :  *
                              13054                 :                :  * WITH [ RECURSIVE ] <query name> [ (<column>,...) ]
                              13055                 :                :  *      AS (query) [ SEARCH or CYCLE clause ]
                              13056                 :                :  *
                              13057                 :                :  * Recognizing WITH_LA here allows a CTE to be named TIME or ORDINALITY.
                              13058                 :                :  */
                              13059                 :                : with_clause:
                              13060                 :                :         WITH cte_list
                              13061                 :                :             {
 6181 tgl@sss.pgh.pa.us       13062                 :           1036 :                 $$ = makeNode(WithClause);
                              13063                 :           1036 :                 $$->ctes = $2;
                              13064                 :           1036 :                 $$->recursive = false;
                              13065                 :           1036 :                 $$->location = @1;
                              13066                 :                :             }
                              13067                 :                :         | WITH_LA cte_list
                              13068                 :                :             {
 3847                         13069                 :              3 :                 $$ = makeNode(WithClause);
                              13070                 :              3 :                 $$->ctes = $2;
                              13071                 :              3 :                 $$->recursive = false;
                              13072                 :              3 :                 $$->location = @1;
                              13073                 :                :             }
                              13074                 :                :         | WITH RECURSIVE cte_list
                              13075                 :                :             {
 6181                         13076                 :            625 :                 $$ = makeNode(WithClause);
                              13077                 :            625 :                 $$->ctes = $3;
                              13078                 :            625 :                 $$->recursive = true;
                              13079                 :            625 :                 $$->location = @1;
                              13080                 :                :             }
                              13081                 :                :         ;
                              13082                 :                : 
                              13083                 :                : cte_list:
                              13084                 :           1664 :         common_table_expr                       { $$ = list_make1($1); }
                              13085                 :            639 :         | cte_list ',' common_table_expr        { $$ = lappend($1, $3); }
                              13086                 :                :         ;
                              13087                 :                : 
                              13088                 :                : common_table_expr:  name opt_name_list AS opt_materialized '(' PreparableStmt ')' opt_search_clause opt_cycle_clause
                              13089                 :                :             {
                              13090                 :           2303 :                 CommonTableExpr *n = makeNode(CommonTableExpr);
                              13091                 :                : 
                              13092                 :           2303 :                 n->ctename = $1;
                              13093                 :           2303 :                 n->aliascolnames = $2;
 2394                         13094                 :           2303 :                 n->ctematerialized = $4;
                              13095                 :           2303 :                 n->ctequery = $6;
 1678 peter@eisentraut.org    13096                 :           2303 :                 n->search_clause = castNode(CTESearchClause, $8);
                              13097                 :           2303 :                 n->cycle_clause = castNode(CTECycleClause, $9);
 6181 tgl@sss.pgh.pa.us       13098                 :           2303 :                 n->location = @1;
                              13099                 :           2303 :                 $$ = (Node *) n;
                              13100                 :                :             }
                              13101                 :                :         ;
                              13102                 :                : 
                              13103                 :                : opt_materialized:
 2394                         13104                 :             89 :         MATERIALIZED                            { $$ = CTEMaterializeAlways; }
                              13105                 :             24 :         | NOT MATERIALIZED                      { $$ = CTEMaterializeNever; }
                              13106                 :           2190 :         | /*EMPTY*/                             { $$ = CTEMaterializeDefault; }
                              13107                 :                :         ;
                              13108                 :                : 
                              13109                 :                : opt_search_clause:
                              13110                 :                :         SEARCH DEPTH FIRST_P BY columnList SET ColId
                              13111                 :                :             {
 1678 peter@eisentraut.org    13112                 :             45 :                 CTESearchClause *n = makeNode(CTESearchClause);
                              13113                 :                : 
                              13114                 :             45 :                 n->search_col_list = $5;
                              13115                 :             45 :                 n->search_breadth_first = false;
                              13116                 :             45 :                 n->search_seq_column = $7;
                              13117                 :             45 :                 n->location = @1;
                              13118                 :             45 :                 $$ = (Node *) n;
                              13119                 :                :             }
                              13120                 :                :         | SEARCH BREADTH FIRST_P BY columnList SET ColId
                              13121                 :                :             {
                              13122                 :             18 :                 CTESearchClause *n = makeNode(CTESearchClause);
                              13123                 :                : 
                              13124                 :             18 :                 n->search_col_list = $5;
                              13125                 :             18 :                 n->search_breadth_first = true;
                              13126                 :             18 :                 n->search_seq_column = $7;
                              13127                 :             18 :                 n->location = @1;
                              13128                 :             18 :                 $$ = (Node *) n;
                              13129                 :                :             }
                              13130                 :                :         | /*EMPTY*/
                              13131                 :                :             {
                              13132                 :           2240 :                 $$ = NULL;
                              13133                 :                :             }
                              13134                 :                :         ;
                              13135                 :                : 
                              13136                 :                : opt_cycle_clause:
                              13137                 :                :         CYCLE columnList SET ColId TO AexprConst DEFAULT AexprConst USING ColId
                              13138                 :                :             {
                              13139                 :             33 :                 CTECycleClause *n = makeNode(CTECycleClause);
                              13140                 :                : 
                              13141                 :             33 :                 n->cycle_col_list = $2;
                              13142                 :             33 :                 n->cycle_mark_column = $4;
                              13143                 :             33 :                 n->cycle_mark_value = $6;
                              13144                 :             33 :                 n->cycle_mark_default = $8;
                              13145                 :             33 :                 n->cycle_path_column = $10;
                              13146                 :             33 :                 n->location = @1;
                              13147                 :             33 :                 $$ = (Node *) n;
                              13148                 :                :             }
                              13149                 :                :         | CYCLE columnList SET ColId USING ColId
                              13150                 :                :             {
 1652                         13151                 :             30 :                 CTECycleClause *n = makeNode(CTECycleClause);
                              13152                 :                : 
                              13153                 :             30 :                 n->cycle_col_list = $2;
                              13154                 :             30 :                 n->cycle_mark_column = $4;
                              13155                 :             30 :                 n->cycle_mark_value = makeBoolAConst(true, -1);
                              13156                 :             30 :                 n->cycle_mark_default = makeBoolAConst(false, -1);
                              13157                 :             30 :                 n->cycle_path_column = $6;
                              13158                 :             30 :                 n->location = @1;
                              13159                 :             30 :                 $$ = (Node *) n;
                              13160                 :                :             }
                              13161                 :                :         | /*EMPTY*/
                              13162                 :                :             {
 1678                         13163                 :           2240 :                 $$ = NULL;
                              13164                 :                :             }
                              13165                 :                :         ;
                              13166                 :                : 
                              13167                 :                : opt_with_clause:
 5440 tgl@sss.pgh.pa.us       13168                 :            225 :         with_clause                             { $$ = $1; }
                              13169                 :          46152 :         | /*EMPTY*/                             { $$ = NULL; }
                              13170                 :                :         ;
                              13171                 :                : 
                              13172                 :                : into_clause:
                              13173                 :                :             INTO OptTempTableName
                              13174                 :                :                 {
 6773                         13175                 :             68 :                     $$ = makeNode(IntoClause);
                              13176                 :             68 :                     $$->rel = $2;
                              13177                 :             68 :                     $$->colNames = NIL;
                              13178                 :             68 :                     $$->options = NIL;
                              13179                 :             68 :                     $$->onCommit = ONCOMMIT_NOOP;
                              13180                 :             68 :                     $$->tableSpaceName = NULL;
 4530                         13181                 :             68 :                     $$->viewQuery = NULL;
 5035                         13182                 :             68 :                     $$->skipData = false;
                              13183                 :                :                 }
                              13184                 :                :             | /*EMPTY*/
 6773                         13185                 :         217188 :                 { $$ = NULL; }
                              13186                 :                :         ;
                              13187                 :                : 
                              13188                 :                : /*
                              13189                 :                :  * Redundancy here is needed to avoid shift/reduce conflicts,
                              13190                 :                :  * since TEMP is not a reserved word.  See also OptTemp.
                              13191                 :                :  */
                              13192                 :                : OptTempTableName:
                              13193                 :                :             TEMPORARY opt_table qualified_name
                              13194                 :                :                 {
 8570 tgl@sss.pgh.pa.us       13195                 :UBC           0 :                     $$ = $3;
 5381 rhaas@postgresql.org    13196                 :              0 :                     $$->relpersistence = RELPERSISTENCE_TEMP;
                              13197                 :                :                 }
                              13198                 :                :             | TEMP opt_table qualified_name
                              13199                 :                :                 {
 8570 tgl@sss.pgh.pa.us       13200                 :CBC           3 :                     $$ = $3;
 5381 rhaas@postgresql.org    13201                 :              3 :                     $$->relpersistence = RELPERSISTENCE_TEMP;
                              13202                 :                :                 }
                              13203                 :                :             | LOCAL TEMPORARY opt_table qualified_name
                              13204                 :                :                 {
 8570 tgl@sss.pgh.pa.us       13205                 :UBC           0 :                     $$ = $4;
 5381 rhaas@postgresql.org    13206                 :              0 :                     $$->relpersistence = RELPERSISTENCE_TEMP;
                              13207                 :                :                 }
                              13208                 :                :             | LOCAL TEMP opt_table qualified_name
                              13209                 :                :                 {
 8570 tgl@sss.pgh.pa.us       13210                 :              0 :                     $$ = $4;
 5381 rhaas@postgresql.org    13211                 :              0 :                     $$->relpersistence = RELPERSISTENCE_TEMP;
                              13212                 :                :                 }
                              13213                 :                :             | GLOBAL TEMPORARY opt_table qualified_name
                              13214                 :                :                 {
 4833 tgl@sss.pgh.pa.us       13215         [ #  # ]:              0 :                     ereport(WARNING,
                              13216                 :                :                             (errmsg("GLOBAL is deprecated in temporary table creation"),
                              13217                 :                :                              parser_errposition(@1)));
 8570                         13218                 :              0 :                     $$ = $4;
 5381 rhaas@postgresql.org    13219                 :              0 :                     $$->relpersistence = RELPERSISTENCE_TEMP;
                              13220                 :                :                 }
                              13221                 :                :             | GLOBAL TEMP opt_table qualified_name
                              13222                 :                :                 {
 4833 tgl@sss.pgh.pa.us       13223         [ #  # ]:              0 :                     ereport(WARNING,
                              13224                 :                :                             (errmsg("GLOBAL is deprecated in temporary table creation"),
                              13225                 :                :                              parser_errposition(@1)));
 8570                         13226                 :              0 :                     $$ = $4;
 5381 rhaas@postgresql.org    13227                 :              0 :                     $$->relpersistence = RELPERSISTENCE_TEMP;
                              13228                 :                :                 }
                              13229                 :                :             | UNLOGGED opt_table qualified_name
                              13230                 :                :                 {
 5365                         13231                 :              0 :                     $$ = $3;
                              13232                 :              0 :                     $$->relpersistence = RELPERSISTENCE_UNLOGGED;
                              13233                 :                :                 }
                              13234                 :                :             | TABLE qualified_name
                              13235                 :                :                 {
 8570 tgl@sss.pgh.pa.us       13236                 :CBC          15 :                     $$ = $2;
 5381 rhaas@postgresql.org    13237                 :             15 :                     $$->relpersistence = RELPERSISTENCE_PERMANENT;
                              13238                 :                :                 }
                              13239                 :                :             | qualified_name
                              13240                 :                :                 {
 8570 tgl@sss.pgh.pa.us       13241                 :             50 :                     $$ = $1;
 5381 rhaas@postgresql.org    13242                 :             50 :                     $$->relpersistence = RELPERSISTENCE_PERMANENT;
                              13243                 :                :                 }
                              13244                 :                :         ;
                              13245                 :                : 
                              13246                 :                : opt_table:  TABLE
                              13247                 :                :             | /*EMPTY*/
                              13248                 :                :         ;
                              13249                 :                : 
                              13250                 :                : set_quantifier:
 1633 tomas.vondra@postgre    13251                 :           5388 :             ALL                                     { $$ = SET_QUANTIFIER_ALL; }
                              13252                 :             16 :             | DISTINCT                              { $$ = SET_QUANTIFIER_DISTINCT; }
                              13253                 :           6590 :             | /*EMPTY*/                             { $$ = SET_QUANTIFIER_DEFAULT; }
                              13254                 :                :         ;
                              13255                 :                : 
                              13256                 :                : /* We use (NIL) as a placeholder to indicate that all target expressions
                              13257                 :                :  * should be placed in the DISTINCT list during parsetree analysis.
                              13258                 :                :  */
                              13259                 :                : distinct_clause:
 7769 neilc@samurai.com       13260                 :           1707 :             DISTINCT                                { $$ = list_make1(NIL); }
 8482 bruce@momjian.us        13261                 :            133 :             | DISTINCT ON '(' expr_list ')'         { $$ = $4; }
                              13262                 :                :         ;
                              13263                 :                : 
                              13264                 :                : opt_all_clause:
                              13265                 :                :             ALL
                              13266                 :                :             | /*EMPTY*/
                              13267                 :                :         ;
                              13268                 :                : 
                              13269                 :                : opt_distinct_clause:
 1688 tgl@sss.pgh.pa.us       13270                 :UBC           0 :             distinct_clause                         { $$ = $1; }
 1688 tgl@sss.pgh.pa.us       13271                 :CBC       20684 :             | opt_all_clause                        { $$ = NIL; }
                              13272                 :                :         ;
                              13273                 :                : 
                              13274                 :                : opt_sort_clause:
                              13275                 :           3697 :             sort_clause                             { $$ = $1; }
 8410 bruce@momjian.us        13276                 :         182054 :             | /*EMPTY*/                             { $$ = NIL; }
                              13277                 :                :         ;
                              13278                 :                : 
                              13279                 :                : sort_clause:
 8482                         13280                 :          39518 :             ORDER BY sortby_list                    { $$ = $3; }
                              13281                 :                :         ;
                              13282                 :                : 
                              13283                 :                : sortby_list:
 7769 neilc@samurai.com       13284                 :          39527 :             sortby                                  { $$ = list_make1($1); }
 8482 bruce@momjian.us        13285                 :          14393 :             | sortby_list ',' sortby                { $$ = lappend($1, $3); }
                              13286                 :                :         ;
                              13287                 :                : 
                              13288                 :                : sortby:     a_expr USING qual_all_Op opt_nulls_order
                              13289                 :                :                 {
 8056 tgl@sss.pgh.pa.us       13290                 :            110 :                     $$ = makeNode(SortBy);
 9894 scrappy@hub.org         13291                 :            110 :                     $$->node = $1;
 6815 tgl@sss.pgh.pa.us       13292                 :            110 :                     $$->sortby_dir = SORTBY_USING;
                              13293                 :            110 :                     $$->sortby_nulls = $4;
 8056                         13294                 :            110 :                     $$->useOp = $3;
 6214                         13295                 :            110 :                     $$->location = @3;
                              13296                 :                :                 }
                              13297                 :                :             | a_expr opt_asc_desc opt_nulls_order
                              13298                 :                :                 {
 8056                         13299                 :          53810 :                     $$ = makeNode(SortBy);
                              13300                 :          53810 :                     $$->node = $1;
 6748 meskes@postgresql.or    13301                 :          53810 :                     $$->sortby_dir = $2;
 6815 tgl@sss.pgh.pa.us       13302                 :          53810 :                     $$->sortby_nulls = $3;
 8056                         13303                 :          53810 :                     $$->useOp = NIL;
 6214                         13304                 :          53810 :                     $$->location = -1;       /* no operator */
                              13305                 :                :                 }
                              13306                 :                :         ;
                              13307                 :                : 
                              13308                 :                : 
                              13309                 :                : select_limit:
                              13310                 :                :             limit_clause offset_clause
                              13311                 :                :                 {
 1978 alvherre@alvh.no-ip.    13312                 :             86 :                     $$ = $1;
                              13313                 :             86 :                     ($$)->limitOffset = $2;
  310 tgl@sss.pgh.pa.us       13314                 :             86 :                     ($$)->offsetLoc = @2;
                              13315                 :                :                 }
                              13316                 :                :             | offset_clause limit_clause
                              13317                 :                :                 {
 1978 alvherre@alvh.no-ip.    13318                 :            111 :                     $$ = $2;
                              13319                 :            111 :                     ($$)->limitOffset = $1;
  310 tgl@sss.pgh.pa.us       13320                 :            111 :                     ($$)->offsetLoc = @1;
                              13321                 :                :                 }
                              13322                 :                :             | limit_clause
                              13323                 :                :                 {
 1978 alvherre@alvh.no-ip.    13324                 :           2144 :                     $$ = $1;
                              13325                 :                :                 }
                              13326                 :                :             | offset_clause
                              13327                 :                :                 {
                              13328                 :            225 :                     SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit));
                              13329                 :                : 
                              13330                 :            225 :                     n->limitOffset = $1;
                              13331                 :            225 :                     n->limitCount = NULL;
                              13332                 :            225 :                     n->limitOption = LIMIT_OPTION_COUNT;
  310 tgl@sss.pgh.pa.us       13333                 :            225 :                     n->offsetLoc = @1;
                              13334                 :            225 :                     n->countLoc = -1;
                              13335                 :            225 :                     n->optionLoc = -1;
 1978 alvherre@alvh.no-ip.    13336                 :            225 :                     $$ = n;
                              13337                 :                :                 }
                              13338                 :                :         ;
                              13339                 :                : 
                              13340                 :                : opt_select_limit:
 5863 tgl@sss.pgh.pa.us       13341                 :             95 :             select_limit                        { $$ = $1; }
 1978 alvherre@alvh.no-ip.    13342                 :          22983 :             | /* EMPTY */                       { $$ = NULL; }
                              13343                 :                :         ;
                              13344                 :                : 
                              13345                 :                : limit_clause:
                              13346                 :                :             LIMIT select_limit_value
                              13347                 :                :                 {
                              13348                 :           2293 :                     SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit));
                              13349                 :                : 
                              13350                 :           2293 :                     n->limitOffset = NULL;
                              13351                 :           2293 :                     n->limitCount = $2;
                              13352                 :           2293 :                     n->limitOption = LIMIT_OPTION_COUNT;
  310 tgl@sss.pgh.pa.us       13353                 :           2293 :                     n->offsetLoc = -1;
                              13354                 :           2293 :                     n->countLoc = @1;
                              13355                 :           2293 :                     n->optionLoc = -1;
 1978 alvherre@alvh.no-ip.    13356                 :           2293 :                     $$ = n;
                              13357                 :                :                 }
                              13358                 :                :             | LIMIT select_limit_value ',' select_offset_value
                              13359                 :                :                 {
                              13360                 :                :                     /* Disabled because it was too confusing, bjm 2002-02-18 */
 8085 tgl@sss.pgh.pa.us       13361         [ #  # ]:UBC           0 :                     ereport(ERROR,
                              13362                 :                :                             (errcode(ERRCODE_SYNTAX_ERROR),
                              13363                 :                :                              errmsg("LIMIT #,# syntax is not supported"),
                              13364                 :                :                              errhint("Use separate LIMIT and OFFSET clauses."),
                              13365                 :                :                              parser_errposition(@1)));
                              13366                 :                :                 }
                              13367                 :                :             /* SQL:2008 syntax */
                              13368                 :                :             /* to avoid shift/reduce conflicts, handle the optional value with
                              13369                 :                :              * a separate production rather than an opt_ expression.  The fact
                              13370                 :                :              * that ONLY is fully reserved means that this way, we defer any
                              13371                 :                :              * decision about what rule reduces ROW or ROWS to the point where
                              13372                 :                :              * we can see the ONLY token in the lookahead slot.
                              13373                 :                :              */
                              13374                 :                :             | FETCH first_or_next select_fetch_first_value row_or_rows ONLY
                              13375                 :                :                 {
 1978 alvherre@alvh.no-ip.    13376                 :CBC          12 :                     SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit));
                              13377                 :                : 
                              13378                 :             12 :                     n->limitOffset = NULL;
                              13379                 :             12 :                     n->limitCount = $3;
                              13380                 :             12 :                     n->limitOption = LIMIT_OPTION_COUNT;
  310 tgl@sss.pgh.pa.us       13381                 :             12 :                     n->offsetLoc = -1;
                              13382                 :             12 :                     n->countLoc = @1;
                              13383                 :             12 :                     n->optionLoc = -1;
 1978 alvherre@alvh.no-ip.    13384                 :             12 :                     $$ = n;
                              13385                 :                :                 }
                              13386                 :                :             | FETCH first_or_next select_fetch_first_value row_or_rows WITH TIES
                              13387                 :                :                 {
                              13388                 :             33 :                     SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit));
                              13389                 :                : 
                              13390                 :             33 :                     n->limitOffset = NULL;
                              13391                 :             33 :                     n->limitCount = $3;
                              13392                 :             33 :                     n->limitOption = LIMIT_OPTION_WITH_TIES;
  310 tgl@sss.pgh.pa.us       13393                 :             33 :                     n->offsetLoc = -1;
                              13394                 :             33 :                     n->countLoc = @1;
                              13395                 :             33 :                     n->optionLoc = @5;
 1978 alvherre@alvh.no-ip.    13396                 :             33 :                     $$ = n;
                              13397                 :                :                 }
                              13398                 :                :             | FETCH first_or_next row_or_rows ONLY
                              13399                 :                :                 {
 1978 alvherre@alvh.no-ip.    13400                 :UBC           0 :                     SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit));
                              13401                 :                : 
                              13402                 :              0 :                     n->limitOffset = NULL;
                              13403                 :              0 :                     n->limitCount = makeIntConst(1, -1);
                              13404                 :              0 :                     n->limitOption = LIMIT_OPTION_COUNT;
  310 tgl@sss.pgh.pa.us       13405                 :              0 :                     n->offsetLoc = -1;
                              13406                 :              0 :                     n->countLoc = @1;
                              13407                 :              0 :                     n->optionLoc = -1;
 1978 alvherre@alvh.no-ip.    13408                 :              0 :                     $$ = n;
                              13409                 :                :                 }
                              13410                 :                :             | FETCH first_or_next row_or_rows WITH TIES
                              13411                 :                :                 {
 1937 alvherre@alvh.no-ip.    13412                 :CBC           3 :                     SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit));
                              13413                 :                : 
                              13414                 :              3 :                     n->limitOffset = NULL;
                              13415                 :              3 :                     n->limitCount = makeIntConst(1, -1);
                              13416                 :              3 :                     n->limitOption = LIMIT_OPTION_WITH_TIES;
  310 tgl@sss.pgh.pa.us       13417                 :              3 :                     n->offsetLoc = -1;
                              13418                 :              3 :                     n->countLoc = @1;
                              13419                 :              3 :                     n->optionLoc = @4;
 1937 alvherre@alvh.no-ip.    13420                 :              3 :                     $$ = n;
                              13421                 :                :                 }
                              13422                 :                :         ;
                              13423                 :                : 
                              13424                 :                : offset_clause:
                              13425                 :                :             OFFSET select_offset_value
 5863 tgl@sss.pgh.pa.us       13426                 :            422 :                 { $$ = $2; }
                              13427                 :                :             /* SQL:2008 syntax */
                              13428                 :                :             | OFFSET select_fetch_first_value row_or_rows
 5863 tgl@sss.pgh.pa.us       13429                 :UBC           0 :                 { $$ = $2; }
                              13430                 :                :         ;
                              13431                 :                : 
                              13432                 :                : select_limit_value:
 8101 tgl@sss.pgh.pa.us       13433                 :CBC        2292 :             a_expr                                  { $$ = $1; }
                              13434                 :                :             | ALL
                              13435                 :                :                 {
                              13436                 :                :                     /* LIMIT ALL is represented as a NULL constant */
 6218                         13437                 :              1 :                     $$ = makeNullAConst(@1);
                              13438                 :                :                 }
                              13439                 :                :         ;
                              13440                 :                : 
                              13441                 :                : select_offset_value:
 5863                         13442                 :            422 :             a_expr                                  { $$ = $1; }
                              13443                 :                :         ;
                              13444                 :                : 
                              13445                 :                : /*
                              13446                 :                :  * Allowing full expressions without parentheses causes various parsing
                              13447                 :                :  * problems with the trailing ROW/ROWS key words.  SQL spec only calls for
                              13448                 :                :  * <simple value specification>, which is either a literal or a parameter (but
                              13449                 :                :  * an <SQL parameter reference> could be an identifier, bringing up conflicts
                              13450                 :                :  * with ROW/ROWS). We solve this by leveraging the presence of ONLY (see above)
                              13451                 :                :  * to determine whether the expression is missing rather than trying to make it
                              13452                 :                :  * optional in this rule.
                              13453                 :                :  *
                              13454                 :                :  * c_expr covers almost all the spec-required cases (and more), but it doesn't
                              13455                 :                :  * cover signed numeric literals, which are allowed by the spec. So we include
                              13456                 :                :  * those here explicitly. We need FCONST as well as ICONST because values that
                              13457                 :                :  * don't fit in the platform's "long", but do fit in bigint, should still be
                              13458                 :                :  * accepted here. (This is possible in 64-bit Windows as well as all 32-bit
                              13459                 :                :  * builds.)
                              13460                 :                :  */
                              13461                 :                : select_fetch_first_value:
 2665 rhodiumtoad@postgres    13462                 :             45 :             c_expr                                  { $$ = $1; }
                              13463                 :                :             | '+' I_or_F_const
 2665 rhodiumtoad@postgres    13464                 :UBC           0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", NULL, $2, @1); }
                              13465                 :                :             | '-' I_or_F_const
                              13466                 :              0 :                 { $$ = doNegate($2, @1); }
                              13467                 :                :         ;
                              13468                 :                : 
                              13469                 :                : I_or_F_const:
                              13470                 :              0 :             Iconst                                  { $$ = makeIntConst($1,@1); }
                              13471                 :              0 :             | FCONST                                { $$ = makeFloatConst($1,@1); }
                              13472                 :                :         ;
                              13473                 :                : 
                              13474                 :                : /* noise words */
 5863 tgl@sss.pgh.pa.us       13475                 :CBC          18 : row_or_rows: ROW                                    { $$ = 0; }
                              13476                 :             30 :             | ROWS                                  { $$ = 0; }
                              13477                 :                :         ;
                              13478                 :                : 
                              13479                 :             48 : first_or_next: FIRST_P                              { $$ = 0; }
 5863 tgl@sss.pgh.pa.us       13480                 :UBC           0 :             | NEXT                                  { $$ = 0; }
                              13481                 :                :         ;
                              13482                 :                : 
                              13483                 :                : 
                              13484                 :                : /*
                              13485                 :                :  * This syntax for group_clause tries to follow the spec quite closely.
                              13486                 :                :  * However, the spec allows only column references, not expressions,
                              13487                 :                :  * which introduces an ambiguity between implicit row constructors
                              13488                 :                :  * (a,b) and lists of column references.
                              13489                 :                :  *
                              13490                 :                :  * We handle this by using the a_expr production for what the spec calls
                              13491                 :                :  * <ordinary grouping set>, which in the spec represents either one column
                              13492                 :                :  * reference or a parenthesized list of column references. Then, we check the
                              13493                 :                :  * top node of the a_expr to see if it's an implicit RowExpr, and if so, just
                              13494                 :                :  * grab and use the list, discarding the node. (this is done in parse analysis,
                              13495                 :                :  * not here)
                              13496                 :                :  *
                              13497                 :                :  * (we abuse the row_format field of RowExpr to distinguish implicit and
                              13498                 :                :  * explicit row constructors; it's debatable if anyone sanely wants to use them
                              13499                 :                :  * in a group clause, but if they have a reason to, we make it possible.)
                              13500                 :                :  *
                              13501                 :                :  * Each item in the group_clause list is either an expression tree or a
                              13502                 :                :  * GroupingSet node of some type.
                              13503                 :                :  */
                              13504                 :                : group_clause:
                              13505                 :                :             GROUP_P BY set_quantifier group_by_list
                              13506                 :                :                 {
 1633 tomas.vondra@postgre    13507                 :CBC        2312 :                     GroupClause *n = (GroupClause *) palloc(sizeof(GroupClause));
                              13508                 :                : 
                              13509                 :           2312 :                     n->distinct = $3 == SET_QUANTIFIER_DISTINCT;
                              13510                 :           2312 :                     n->list = $4;
                              13511                 :           2312 :                     $$ = n;
                              13512                 :                :                 }
                              13513                 :                :             | /*EMPTY*/
                              13514                 :                :                 {
                              13515                 :         235613 :                     GroupClause *n = (GroupClause *) palloc(sizeof(GroupClause));
                              13516                 :                : 
                              13517                 :         235613 :                     n->distinct = false;
                              13518                 :         235613 :                     n->list = NIL;
                              13519                 :         235613 :                     $$ = n;
                              13520                 :                :                 }
                              13521                 :                :         ;
                              13522                 :                : 
                              13523                 :                : group_by_list:
 3766 andres@anarazel.de      13524                 :           2611 :             group_by_item                           { $$ = list_make1($1); }
                              13525                 :           1513 :             | group_by_list ',' group_by_item       { $$ = lappend($1,$3); }
                              13526                 :                :         ;
                              13527                 :                : 
                              13528                 :                : group_by_item:
                              13529                 :           3479 :             a_expr                                  { $$ = $1; }
                              13530                 :            111 :             | empty_grouping_set                    { $$ = $1; }
                              13531                 :             92 :             | cube_clause                           { $$ = $1; }
                              13532                 :            143 :             | rollup_clause                         { $$ = $1; }
                              13533                 :            299 :             | grouping_sets_clause                  { $$ = $1; }
                              13534                 :                :         ;
                              13535                 :                : 
                              13536                 :                : empty_grouping_set:
                              13537                 :                :             '(' ')'
                              13538                 :                :                 {
                              13539                 :            111 :                     $$ = (Node *) makeGroupingSet(GROUPING_SET_EMPTY, NIL, @1);
                              13540                 :                :                 }
                              13541                 :                :         ;
                              13542                 :                : 
                              13543                 :                : /*
                              13544                 :                :  * These hacks rely on setting precedence of CUBE and ROLLUP below that of '(',
                              13545                 :                :  * so that they shift in these rules rather than reducing the conflicting
                              13546                 :                :  * unreserved_keyword rule.
                              13547                 :                :  */
                              13548                 :                : 
                              13549                 :                : rollup_clause:
                              13550                 :                :             ROLLUP '(' expr_list ')'
                              13551                 :                :                 {
                              13552                 :            143 :                     $$ = (Node *) makeGroupingSet(GROUPING_SET_ROLLUP, $3, @1);
                              13553                 :                :                 }
                              13554                 :                :         ;
                              13555                 :                : 
                              13556                 :                : cube_clause:
                              13557                 :                :             CUBE '(' expr_list ')'
                              13558                 :                :                 {
                              13559                 :             92 :                     $$ = (Node *) makeGroupingSet(GROUPING_SET_CUBE, $3, @1);
                              13560                 :                :                 }
                              13561                 :                :         ;
                              13562                 :                : 
                              13563                 :                : grouping_sets_clause:
                              13564                 :                :             GROUPING SETS '(' group_by_list ')'
                              13565                 :                :                 {
                              13566                 :            299 :                     $$ = (Node *) makeGroupingSet(GROUPING_SET_SETS, $4, @1);
                              13567                 :                :                 }
                              13568                 :                :         ;
                              13569                 :                : 
                              13570                 :                : having_clause:
 8482 bruce@momjian.us        13571                 :            339 :             HAVING a_expr                           { $$ = $2; }
                              13572                 :         237586 :             | /*EMPTY*/                             { $$ = NULL; }
                              13573                 :                :         ;
                              13574                 :                : 
                              13575                 :                : for_locking_clause:
 7069 tgl@sss.pgh.pa.us       13576                 :           2564 :             for_locking_items                       { $$ = $1; }
 7069 tgl@sss.pgh.pa.us       13577                 :UBC           0 :             | FOR READ ONLY                         { $$ = NIL; }
                              13578                 :                :         ;
                              13579                 :                : 
                              13580                 :                : opt_for_locking_clause:
 7069 tgl@sss.pgh.pa.us       13581                 :CBC         170 :             for_locking_clause                      { $$ = $1; }
                              13582                 :          22985 :             | /* EMPTY */                           { $$ = NIL; }
                              13583                 :                :         ;
                              13584                 :                : 
                              13585                 :                : for_locking_items:
                              13586                 :           2564 :             for_locking_item                        { $$ = list_make1($1); }
                              13587                 :             51 :             | for_locking_items for_locking_item    { $$ = lappend($1, $2); }
                              13588                 :                :         ;
                              13589                 :                : 
                              13590                 :                : for_locking_item:
                              13591                 :                :             for_locking_strength locked_rels_list opt_nowait_or_skip
                              13592                 :                :                 {
 7341                         13593                 :           2615 :                     LockingClause *n = makeNode(LockingClause);
                              13594                 :                : 
 4609 alvherre@alvh.no-ip.    13595                 :           2615 :                     n->lockedRels = $2;
                              13596                 :           2615 :                     n->strength = $1;
 3987                         13597                 :           2615 :                     n->waitPolicy = $3;
 7341 tgl@sss.pgh.pa.us       13598                 :           2615 :                     $$ = (Node *) n;
                              13599                 :                :                 }
                              13600                 :                :         ;
                              13601                 :                : 
                              13602                 :                : for_locking_strength:
 1760 peter@eisentraut.org    13603                 :            767 :             FOR UPDATE                          { $$ = LCS_FORUPDATE; }
                              13604                 :             38 :             | FOR NO KEY UPDATE                 { $$ = LCS_FORNOKEYUPDATE; }
                              13605                 :            107 :             | FOR SHARE                         { $$ = LCS_FORSHARE; }
                              13606                 :           1703 :             | FOR KEY SHARE                     { $$ = LCS_FORKEYSHARE; }
                              13607                 :                :         ;
                              13608                 :                : 
                              13609                 :                : locked_rels_list:
 6214 tgl@sss.pgh.pa.us       13610                 :           1716 :             OF qualified_name_list                  { $$ = $2; }
 7341                         13611                 :            899 :             | /* EMPTY */                           { $$ = NIL; }
                              13612                 :                :         ;
                              13613                 :                : 
                              13614                 :                : 
                              13615                 :                : /*
                              13616                 :                :  * We should allow ROW '(' expr_list ')' too, but that seems to require
                              13617                 :                :  * making VALUES a fully reserved word, which will probably break more apps
                              13618                 :                :  * than allowing the noise-word is worth.
                              13619                 :                :  */
                              13620                 :                : values_clause:
                              13621                 :                :             VALUES '(' expr_list ')'
                              13622                 :                :                 {
 6975 mail@joeconway.com      13623                 :          31082 :                     SelectStmt *n = makeNode(SelectStmt);
                              13624                 :                : 
 3210 tgl@sss.pgh.pa.us       13625                 :          31082 :                     n->valuesLists = list_make1($3);
 6975 mail@joeconway.com      13626                 :          31082 :                     $$ = (Node *) n;
                              13627                 :                :                 }
                              13628                 :                :             | values_clause ',' '(' expr_list ')'
                              13629                 :                :                 {
                              13630                 :          12555 :                     SelectStmt *n = (SelectStmt *) $1;
                              13631                 :                : 
 3210 tgl@sss.pgh.pa.us       13632                 :          12555 :                     n->valuesLists = lappend(n->valuesLists, $4);
 6975 mail@joeconway.com      13633                 :          12555 :                     $$ = (Node *) n;
                              13634                 :                :                 }
                              13635                 :                :         ;
                              13636                 :                : 
                              13637                 :                : 
                              13638                 :                : /*****************************************************************************
                              13639                 :                :  *
                              13640                 :                :  *  clauses common to all Optimizable Stmts:
                              13641                 :                :  *      from_clause     - allow list of both JOIN expressions and table names
                              13642                 :                :  *      where_clause    - qualifications for joins or restrictions
                              13643                 :                :  *
                              13644                 :                :  *****************************************************************************/
                              13645                 :                : 
                              13646                 :                : from_clause:
 8482 bruce@momjian.us        13647                 :         158673 :             FROM from_list                          { $$ = $2; }
                              13648                 :          86325 :             | /*EMPTY*/                             { $$ = NIL; }
                              13649                 :                :         ;
                              13650                 :                : 
                              13651                 :                : from_list:
 7769 neilc@samurai.com       13652                 :         159095 :             table_ref                               { $$ = list_make1($1); }
 8481 bruce@momjian.us        13653                 :          31304 :             | from_list ',' table_ref               { $$ = lappend($1, $3); }
                              13654                 :                :         ;
                              13655                 :                : 
                              13656                 :                : /*
                              13657                 :                :  * table_ref is where an alias clause can be attached.
                              13658                 :                :  */
                              13659                 :                : table_ref:  relation_expr opt_alias_clause
                              13660                 :                :                 {
 8570 tgl@sss.pgh.pa.us       13661                 :         200623 :                     $1->alias = $2;
 9125                         13662                 :         200623 :                     $$ = (Node *) $1;
                              13663                 :                :                 }
                              13664                 :                :             | relation_expr opt_alias_clause tablesample_clause
                              13665                 :                :                 {
 3696                         13666                 :            133 :                     RangeTableSample *n = (RangeTableSample *) $3;
                              13667                 :                : 
                              13668                 :            133 :                     $1->alias = $2;
                              13669                 :                :                     /* relation_expr goes inside the RangeTableSample node */
                              13670                 :            133 :                     n->relation = (Node *) $1;
                              13671                 :            133 :                     $$ = (Node *) n;
                              13672                 :                :                 }
                              13673                 :                :             | func_table func_alias_clause
                              13674                 :                :                 {
 4307                         13675                 :          23570 :                     RangeFunction *n = (RangeFunction *) $1;
                              13676                 :                : 
 4778                         13677                 :          23570 :                     n->alias = linitial($2);
                              13678                 :          23570 :                     n->coldeflist = lsecond($2);
 8434 bruce@momjian.us        13679                 :          23570 :                     $$ = (Node *) n;
                              13680                 :                :                 }
                              13681                 :                :             | LATERAL_P func_table func_alias_clause
                              13682                 :                :                 {
 4307 tgl@sss.pgh.pa.us       13683                 :            583 :                     RangeFunction *n = (RangeFunction *) $2;
                              13684                 :                : 
 4778                         13685                 :            583 :                     n->lateral = true;
                              13686                 :            583 :                     n->alias = linitial($3);
                              13687                 :            583 :                     n->coldeflist = lsecond($3);
 8518                         13688                 :            583 :                     $$ = (Node *) n;
                              13689                 :                :                 }
                              13690                 :                :             | xmltable opt_alias_clause
                              13691                 :                :                 {
 3104 alvherre@alvh.no-ip.    13692                 :             43 :                     RangeTableFunc *n = (RangeTableFunc *) $1;
                              13693                 :                : 
                              13694                 :             43 :                     n->alias = $2;
                              13695                 :             43 :                     $$ = (Node *) n;
                              13696                 :                :                 }
                              13697                 :                :             | LATERAL_P xmltable opt_alias_clause
                              13698                 :                :                 {
                              13699                 :             70 :                     RangeTableFunc *n = (RangeTableFunc *) $2;
                              13700                 :                : 
                              13701                 :             70 :                     n->lateral = true;
                              13702                 :             70 :                     n->alias = $3;
                              13703                 :             70 :                     $$ = (Node *) n;
                              13704                 :                :                 }
                              13705                 :                :             | select_with_parens opt_alias_clause
                              13706                 :                :                 {
 4778 tgl@sss.pgh.pa.us       13707                 :           7041 :                     RangeSubselect *n = makeNode(RangeSubselect);
                              13708                 :                : 
                              13709                 :           7041 :                     n->lateral = false;
                              13710                 :           7041 :                     n->subquery = $1;
                              13711                 :           7041 :                     n->alias = $2;
                              13712                 :           7041 :                     $$ = (Node *) n;
                              13713                 :                :                 }
                              13714                 :                :             | LATERAL_P select_with_parens opt_alias_clause
                              13715                 :                :                 {
 9125                         13716                 :            951 :                     RangeSubselect *n = makeNode(RangeSubselect);
                              13717                 :                : 
 4778                         13718                 :            951 :                     n->lateral = true;
                              13719                 :            951 :                     n->subquery = $2;
                              13720                 :            951 :                     n->alias = $3;
 9125                         13721                 :            951 :                     $$ = (Node *) n;
                              13722                 :                :                 }
                              13723                 :                :             | joined_table
                              13724                 :                :                 {
                              13725                 :          41711 :                     $$ = (Node *) $1;
                              13726                 :                :                 }
                              13727                 :                :             | '(' joined_table ')' alias_clause
                              13728                 :                :                 {
                              13729                 :             87 :                     $2->alias = $4;
                              13730                 :             87 :                     $$ = (Node *) $2;
                              13731                 :                :                 }
                              13732                 :                :             | json_table opt_alias_clause
                              13733                 :                :                 {
  520 amitlan@postgresql.o    13734                 :            263 :                     JsonTable  *jt = castNode(JsonTable, $1);
                              13735                 :                : 
                              13736                 :            263 :                     jt->alias = $2;
                              13737                 :            263 :                     $$ = (Node *) jt;
                              13738                 :                :                 }
                              13739                 :                :             | LATERAL_P json_table opt_alias_clause
                              13740                 :                :                 {
  520 amitlan@postgresql.o    13741                 :UBC           0 :                     JsonTable  *jt = castNode(JsonTable, $2);
                              13742                 :                : 
                              13743                 :              0 :                     jt->alias = $3;
                              13744                 :              0 :                     jt->lateral = true;
                              13745                 :              0 :                     $$ = (Node *) jt;
                              13746                 :                :                 }
                              13747                 :                :         ;
                              13748                 :                : 
                              13749                 :                : 
                              13750                 :                : /*
                              13751                 :                :  * It may seem silly to separate joined_table from table_ref, but there is
                              13752                 :                :  * method in SQL's madness: if you don't do it this way you get reduce-
                              13753                 :                :  * reduce conflicts, because it's not clear to the parser generator whether
                              13754                 :                :  * to expect alias_clause after ')' or not.  For the same reason we must
                              13755                 :                :  * treat 'JOIN' and 'join_type JOIN' separately, rather than allowing
                              13756                 :                :  * join_type to expand to empty; if we try it, the parser generator can't
                              13757                 :                :  * figure out when to reduce an empty join_type right after table_ref.
                              13758                 :                :  *
                              13759                 :                :  * Note that a CROSS JOIN is the same as an unqualified
                              13760                 :                :  * INNER JOIN, and an INNER JOIN/ON has the same shape
                              13761                 :                :  * but a qualification expression to limit membership.
                              13762                 :                :  * A NATURAL JOIN implicitly matches column names between
                              13763                 :                :  * tables and the shape is determined by which columns are
                              13764                 :                :  * in common. We'll collect columns during the later transformations.
                              13765                 :                :  */
                              13766                 :                : 
                              13767                 :                : joined_table:
                              13768                 :                :             '(' joined_table ')'
                              13769                 :                :                 {
 9125 tgl@sss.pgh.pa.us       13770                 :CBC        1981 :                     $$ = $2;
                              13771                 :                :                 }
                              13772                 :                :             | table_ref CROSS JOIN table_ref
                              13773                 :                :                 {
                              13774                 :                :                     /* CROSS JOIN is same as unqualified inner join */
 1212 peter@eisentraut.org    13775                 :            255 :                     JoinExpr   *n = makeNode(JoinExpr);
                              13776                 :                : 
 9125 tgl@sss.pgh.pa.us       13777                 :            255 :                     n->jointype = JOIN_INNER;
 2943 peter_e@gmx.net         13778                 :            255 :                     n->isNatural = false;
 9125 tgl@sss.pgh.pa.us       13779                 :            255 :                     n->larg = $1;
                              13780                 :            255 :                     n->rarg = $4;
 5896 peter_e@gmx.net         13781                 :            255 :                     n->usingClause = NIL;
 1620 peter@eisentraut.org    13782                 :            255 :                     n->join_using_alias = NULL;
 9125 tgl@sss.pgh.pa.us       13783                 :            255 :                     n->quals = NULL;
 9335 lockhart@fourpalms.o    13784                 :            255 :                     $$ = n;
                              13785                 :                :                 }
                              13786                 :                :             | table_ref join_type JOIN table_ref join_qual
                              13787                 :                :                 {
 1212 peter@eisentraut.org    13788                 :          23670 :                     JoinExpr   *n = makeNode(JoinExpr);
                              13789                 :                : 
 9125 tgl@sss.pgh.pa.us       13790                 :          23670 :                     n->jointype = $2;
 2943 peter_e@gmx.net         13791                 :          23670 :                     n->isNatural = false;
 9125 tgl@sss.pgh.pa.us       13792                 :          23670 :                     n->larg = $1;
                              13793                 :          23670 :                     n->rarg = $4;
                              13794   [ +  -  +  + ]:          23670 :                     if ($5 != NULL && IsA($5, List))
                              13795                 :                :                     {
                              13796                 :                :                          /* USING clause */
 1620 peter@eisentraut.org    13797                 :            249 :                         n->usingClause = linitial_node(List, castNode(List, $5));
                              13798                 :            249 :                         n->join_using_alias = lsecond_node(Alias, castNode(List, $5));
                              13799                 :                :                     }
                              13800                 :                :                     else
                              13801                 :                :                     {
                              13802                 :                :                         /* ON clause */
                              13803                 :          23421 :                         n->quals = $5;
                              13804                 :                :                     }
 9335 lockhart@fourpalms.o    13805                 :          23670 :                     $$ = n;
                              13806                 :                :                 }
                              13807                 :                :             | table_ref JOIN table_ref join_qual
                              13808                 :                :                 {
                              13809                 :                :                     /* letting join_type reduce to empty doesn't work */
 1212 peter@eisentraut.org    13810                 :          17741 :                     JoinExpr   *n = makeNode(JoinExpr);
                              13811                 :                : 
 9125 tgl@sss.pgh.pa.us       13812                 :          17741 :                     n->jointype = JOIN_INNER;
 2943 peter_e@gmx.net         13813                 :          17741 :                     n->isNatural = false;
 9125 tgl@sss.pgh.pa.us       13814                 :          17741 :                     n->larg = $1;
                              13815                 :          17741 :                     n->rarg = $3;
                              13816   [ +  -  +  + ]:          17741 :                     if ($4 != NULL && IsA($4, List))
                              13817                 :                :                     {
                              13818                 :                :                         /* USING clause */
 1620 peter@eisentraut.org    13819                 :            372 :                         n->usingClause = linitial_node(List, castNode(List, $4));
                              13820                 :            372 :                         n->join_using_alias = lsecond_node(Alias, castNode(List, $4));
                              13821                 :                :                     }
                              13822                 :                :                     else
                              13823                 :                :                     {
                              13824                 :                :                         /* ON clause */
                              13825                 :          17369 :                         n->quals = $4;
                              13826                 :                :                     }
 9125 tgl@sss.pgh.pa.us       13827                 :          17741 :                     $$ = n;
                              13828                 :                :                 }
                              13829                 :                :             | table_ref NATURAL join_type JOIN table_ref
                              13830                 :                :                 {
 1212 peter@eisentraut.org    13831                 :             39 :                     JoinExpr   *n = makeNode(JoinExpr);
                              13832                 :                : 
 9125 tgl@sss.pgh.pa.us       13833                 :             39 :                     n->jointype = $3;
 2943 peter_e@gmx.net         13834                 :             39 :                     n->isNatural = true;
 9125 tgl@sss.pgh.pa.us       13835                 :             39 :                     n->larg = $1;
                              13836                 :             39 :                     n->rarg = $5;
 5896 peter_e@gmx.net         13837                 :             39 :                     n->usingClause = NIL; /* figure out which columns later... */
 1620 peter@eisentraut.org    13838                 :             39 :                     n->join_using_alias = NULL;
 9125 tgl@sss.pgh.pa.us       13839                 :             39 :                     n->quals = NULL; /* fill later */
                              13840                 :             39 :                     $$ = n;
                              13841                 :                :                 }
                              13842                 :                :             | table_ref NATURAL JOIN table_ref
                              13843                 :                :                 {
                              13844                 :                :                     /* letting join_type reduce to empty doesn't work */
 1212 peter@eisentraut.org    13845                 :             93 :                     JoinExpr   *n = makeNode(JoinExpr);
                              13846                 :                : 
 9125 tgl@sss.pgh.pa.us       13847                 :             93 :                     n->jointype = JOIN_INNER;
 2943 peter_e@gmx.net         13848                 :             93 :                     n->isNatural = true;
 9125 tgl@sss.pgh.pa.us       13849                 :             93 :                     n->larg = $1;
                              13850                 :             93 :                     n->rarg = $4;
 5896 peter_e@gmx.net         13851                 :             93 :                     n->usingClause = NIL; /* figure out which columns later... */
 1620 peter@eisentraut.org    13852                 :             93 :                     n->join_using_alias = NULL;
 9125 tgl@sss.pgh.pa.us       13853                 :             93 :                     n->quals = NULL; /* fill later */
 9335 lockhart@fourpalms.o    13854                 :             93 :                     $$ = n;
                              13855                 :                :                 }
                              13856                 :                :         ;
                              13857                 :                : 
                              13858                 :                : alias_clause:
                              13859                 :                :             AS ColId '(' name_list ')'
                              13860                 :                :                 {
 8570 tgl@sss.pgh.pa.us       13861                 :           3352 :                     $$ = makeNode(Alias);
                              13862                 :           3352 :                     $$->aliasname = $2;
                              13863                 :           3352 :                     $$->colnames = $4;
                              13864                 :                :                 }
                              13865                 :                :             | AS ColId
                              13866                 :                :                 {
                              13867                 :           5456 :                     $$ = makeNode(Alias);
                              13868                 :           5456 :                     $$->aliasname = $2;
                              13869                 :                :                 }
                              13870                 :                :             | ColId '(' name_list ')'
                              13871                 :                :                 {
                              13872                 :           2919 :                     $$ = makeNode(Alias);
                              13873                 :           2919 :                     $$->aliasname = $1;
                              13874                 :           2919 :                     $$->colnames = $3;
                              13875                 :                :                 }
                              13876                 :                :             | ColId
                              13877                 :                :                 {
                              13878                 :         134901 :                     $$ = makeNode(Alias);
                              13879                 :         134901 :                     $$->aliasname = $1;
                              13880                 :                :                 }
                              13881                 :                :         ;
                              13882                 :                : 
 4778                         13883                 :         131924 : opt_alias_clause: alias_clause                      { $$ = $1; }
                              13884                 :          77200 :             | /*EMPTY*/                             { $$ = NULL; }
                              13885                 :                :         ;
                              13886                 :                : 
                              13887                 :                : /*
                              13888                 :                :  * The alias clause after JOIN ... USING only accepts the AS ColId spelling,
                              13889                 :                :  * per SQL standard.  (The grammar could parse the other variants, but they
                              13890                 :                :  * don't seem to be useful, and it might lead to parser problems in the
                              13891                 :                :  * future.)
                              13892                 :                :  */
                              13893                 :                : opt_alias_clause_for_join_using:
                              13894                 :                :             AS ColId
                              13895                 :                :                 {
 1620 peter@eisentraut.org    13896                 :             42 :                     $$ = makeNode(Alias);
                              13897                 :             42 :                     $$->aliasname = $2;
                              13898                 :                :                     /* the column name list will be inserted later */
                              13899                 :                :                 }
                              13900                 :            579 :             | /*EMPTY*/                             { $$ = NULL; }
                              13901                 :                :         ;
                              13902                 :                : 
                              13903                 :                : /*
                              13904                 :                :  * func_alias_clause can include both an Alias and a coldeflist, so we make it
                              13905                 :                :  * return a 2-element list that gets disassembled by calling production.
                              13906                 :                :  */
                              13907                 :                : func_alias_clause:
                              13908                 :                :             alias_clause
                              13909                 :                :                 {
 4778 tgl@sss.pgh.pa.us       13910                 :          14617 :                     $$ = list_make2($1, NIL);
                              13911                 :                :                 }
                              13912                 :                :             | AS '(' TableFuncElementList ')'
                              13913                 :                :                 {
                              13914                 :             57 :                     $$ = list_make2(NULL, $3);
                              13915                 :                :                 }
                              13916                 :                :             | AS ColId '(' TableFuncElementList ')'
                              13917                 :                :                 {
 1212 peter@eisentraut.org    13918                 :            304 :                     Alias      *a = makeNode(Alias);
                              13919                 :                : 
 4778 tgl@sss.pgh.pa.us       13920                 :            304 :                     a->aliasname = $2;
                              13921                 :            304 :                     $$ = list_make2(a, $4);
                              13922                 :                :                 }
                              13923                 :                :             | ColId '(' TableFuncElementList ')'
                              13924                 :                :                 {
 1212 peter@eisentraut.org    13925                 :             25 :                     Alias      *a = makeNode(Alias);
                              13926                 :                : 
 4778 tgl@sss.pgh.pa.us       13927                 :             25 :                     a->aliasname = $1;
                              13928                 :             25 :                     $$ = list_make2(a, $3);
                              13929                 :                :                 }
                              13930                 :                :             | /*EMPTY*/
                              13931                 :                :                 {
                              13932                 :           9150 :                     $$ = list_make2(NULL, NIL);
                              13933                 :                :                 }
                              13934                 :                :         ;
                              13935                 :                : 
 1759 peter@eisentraut.org    13936                 :            521 : join_type:  FULL opt_outer                          { $$ = JOIN_FULL; }
                              13937                 :          20998 :             | LEFT opt_outer                        { $$ = JOIN_LEFT; }
                              13938                 :            189 :             | RIGHT opt_outer                       { $$ = JOIN_RIGHT; }
 8482 bruce@momjian.us        13939                 :           2001 :             | INNER_P                               { $$ = JOIN_INNER; }
                              13940                 :                :         ;
                              13941                 :                : 
                              13942                 :                : /* OUTER is just noise... */
                              13943                 :                : opt_outer: OUTER_P
                              13944                 :                :             | /*EMPTY*/
                              13945                 :                :         ;
                              13946                 :                : 
                              13947                 :                : /* JOIN qualification clauses
                              13948                 :                :  * Possibilities are:
                              13949                 :                :  *  USING ( column list ) [ AS alias ]
                              13950                 :                :  *                        allows only unqualified column names,
                              13951                 :                :  *                        which must match between tables.
                              13952                 :                :  *  ON expr allows more general qualifications.
                              13953                 :                :  *
                              13954                 :                :  * We return USING as a two-element List (the first item being a sub-List
                              13955                 :                :  * of the common column names, and the second either an Alias item or NULL).
                              13956                 :                :  * An ON-expr will not be a List, so it can be told apart that way.
                              13957                 :                :  */
                              13958                 :                : 
                              13959                 :                : join_qual: USING '(' name_list ')' opt_alias_clause_for_join_using
                              13960                 :                :                 {
 1620 peter@eisentraut.org    13961                 :            621 :                     $$ = (Node *) list_make2($3, $5);
                              13962                 :                :                 }
                              13963                 :                :             | ON a_expr
                              13964                 :                :                 {
                              13965                 :          40790 :                     $$ = $2;
                              13966                 :                :                 }
                              13967                 :                :         ;
                              13968                 :                : 
                              13969                 :                : 
                              13970                 :                : relation_expr:
                              13971                 :                :             qualified_name
                              13972                 :                :                 {
                              13973                 :                :                     /* inheritance query, implicitly */
 8570 tgl@sss.pgh.pa.us       13974                 :         241383 :                     $$ = $1;
 3179                         13975                 :         241383 :                     $$->inh = true;
 8570                         13976                 :         241383 :                     $$->alias = NULL;
                              13977                 :                :                 }
                              13978                 :                :             | extended_relation_expr
                              13979                 :                :                 {
 1410 akapila@postgresql.o    13980                 :           3596 :                     $$ = $1;
                              13981                 :                :                 }
                              13982                 :                :         ;
                              13983                 :                : 
                              13984                 :                : extended_relation_expr:
                              13985                 :                :             qualified_name '*'
                              13986                 :                :                 {
                              13987                 :                :                     /* inheritance query, explicitly */
 8570 tgl@sss.pgh.pa.us       13988                 :            102 :                     $$ = $1;
 3179                         13989                 :            102 :                     $$->inh = true;
 8570                         13990                 :            102 :                     $$->alias = NULL;
                              13991                 :                :                 }
                              13992                 :                :             | ONLY qualified_name
                              13993                 :                :                 {
                              13994                 :                :                     /* no inheritance */
                              13995                 :           3497 :                     $$ = $2;
 3179                         13996                 :           3497 :                     $$->inh = false;
 8570                         13997                 :           3497 :                     $$->alias = NULL;
                              13998                 :                :                 }
                              13999                 :                :             | ONLY '(' qualified_name ')'
                              14000                 :                :                 {
                              14001                 :                :                     /* no inheritance, SQL99-style syntax */
 8434 lockhart@fourpalms.o    14002                 :UBC           0 :                     $$ = $3;
 3179 tgl@sss.pgh.pa.us       14003                 :              0 :                     $$->inh = false;
 8434 lockhart@fourpalms.o    14004                 :              0 :                     $$->alias = NULL;
                              14005                 :                :                 }
                              14006                 :                :         ;
                              14007                 :                : 
                              14008                 :                : 
                              14009                 :                : relation_expr_list:
 6081 peter_e@gmx.net         14010                 :CBC        1499 :             relation_expr                           { $$ = list_make1($1); }
                              14011                 :           5918 :             | relation_expr_list ',' relation_expr  { $$ = lappend($1, $3); }
                              14012                 :                :         ;
                              14013                 :                : 
                              14014                 :                : 
                              14015                 :                : /*
                              14016                 :                :  * Given "UPDATE foo set set ...", we have to decide without looking any
                              14017                 :                :  * further ahead whether the first "set" is an alias or the UPDATE's SET
                              14018                 :                :  * keyword.  Since "set" is allowed as a column name both interpretations
                              14019                 :                :  * are feasible.  We resolve the shift/reduce conflict by giving the first
                              14020                 :                :  * relation_expr_opt_alias production a higher precedence than the SET token
                              14021                 :                :  * has, causing the parser to prefer to reduce, in effect assuming that the
                              14022                 :                :  * SET is not an alias.
                              14023                 :                :  */
                              14024                 :                : relation_expr_opt_alias: relation_expr                  %prec UMINUS
                              14025                 :                :                 {
 7167 neilc@samurai.com       14026                 :           9312 :                     $$ = $1;
                              14027                 :                :                 }
                              14028                 :                :             | relation_expr ColId
                              14029                 :                :                 {
 1212 peter@eisentraut.org    14030                 :           1125 :                     Alias      *alias = makeNode(Alias);
                              14031                 :                : 
 7167 tgl@sss.pgh.pa.us       14032                 :           1125 :                     alias->aliasname = $2;
                              14033                 :           1125 :                     $1->alias = alias;
                              14034                 :           1125 :                     $$ = $1;
                              14035                 :                :                 }
                              14036                 :                :             | relation_expr AS ColId
                              14037                 :                :                 {
 1212 peter@eisentraut.org    14038                 :             45 :                     Alias      *alias = makeNode(Alias);
                              14039                 :                : 
 7167 neilc@samurai.com       14040                 :             45 :                     alias->aliasname = $3;
                              14041                 :             45 :                     $1->alias = alias;
                              14042                 :             45 :                     $$ = $1;
                              14043                 :                :                 }
                              14044                 :                :         ;
                              14045                 :                : 
                              14046                 :                : /*
                              14047                 :                :  * TABLESAMPLE decoration in a FROM item
                              14048                 :                :  */
                              14049                 :                : tablesample_clause:
                              14050                 :                :             TABLESAMPLE func_name '(' expr_list ')' opt_repeatable_clause
                              14051                 :                :                 {
 3767 simon@2ndQuadrant.co    14052                 :            133 :                     RangeTableSample *n = makeNode(RangeTableSample);
                              14053                 :                : 
                              14054                 :                :                     /* n->relation will be filled in later */
                              14055                 :            133 :                     n->method = $2;
                              14056                 :            133 :                     n->args = $4;
                              14057                 :            133 :                     n->repeatable = $6;
 3696 tgl@sss.pgh.pa.us       14058                 :            133 :                     n->location = @2;
 3767 simon@2ndQuadrant.co    14059                 :            133 :                     $$ = (Node *) n;
                              14060                 :                :                 }
                              14061                 :                :         ;
                              14062                 :                : 
                              14063                 :                : opt_repeatable_clause:
                              14064                 :             54 :             REPEATABLE '(' a_expr ')'   { $$ = (Node *) $3; }
                              14065                 :             79 :             | /*EMPTY*/                 { $$ = NULL; }
                              14066                 :                :         ;
                              14067                 :                : 
                              14068                 :                : /*
                              14069                 :                :  * func_table represents a function invocation in a FROM list. It can be
                              14070                 :                :  * a plain function call, like "foo(...)", or a ROWS FROM expression with
                              14071                 :                :  * one or more function calls, "ROWS FROM (foo(...), bar(...))",
                              14072                 :                :  * optionally with WITH ORDINALITY attached.
                              14073                 :                :  * In the ROWS FROM syntax, a column definition list can be given for each
                              14074                 :                :  * function, for example:
                              14075                 :                :  *     ROWS FROM (foo() AS (foo_res_a text, foo_res_b text),
                              14076                 :                :  *                bar() AS (bar_res_a text, bar_res_b text))
                              14077                 :                :  * It's also possible to attach a column definition list to the RangeFunction
                              14078                 :                :  * as a whole, but that's handled by the table_ref production.
                              14079                 :                :  */
                              14080                 :                : func_table: func_expr_windowless opt_ordinality
                              14081                 :                :                 {
 4307 tgl@sss.pgh.pa.us       14082                 :          24090 :                     RangeFunction *n = makeNode(RangeFunction);
                              14083                 :                : 
                              14084                 :          24090 :                     n->lateral = false;
                              14085                 :          24090 :                     n->ordinality = $2;
 4288 noah@leadboat.com       14086                 :          24090 :                     n->is_rowsfrom = false;
 4307 tgl@sss.pgh.pa.us       14087                 :          24090 :                     n->functions = list_make1(list_make2($1, NIL));
                              14088                 :                :                     /* alias and coldeflist are set by table_ref production */
                              14089                 :          24090 :                     $$ = (Node *) n;
                              14090                 :                :                 }
                              14091                 :                :             | ROWS FROM '(' rowsfrom_list ')' opt_ordinality
                              14092                 :                :                 {
                              14093                 :             66 :                     RangeFunction *n = makeNode(RangeFunction);
                              14094                 :                : 
                              14095                 :             66 :                     n->lateral = false;
 4288 noah@leadboat.com       14096                 :             66 :                     n->ordinality = $6;
                              14097                 :             66 :                     n->is_rowsfrom = true;
                              14098                 :             66 :                     n->functions = $4;
                              14099                 :                :                     /* alias and coldeflist are set by table_ref production */
 4307 tgl@sss.pgh.pa.us       14100                 :             66 :                     $$ = (Node *) n;
                              14101                 :                :                 }
                              14102                 :                :         ;
                              14103                 :                : 
                              14104                 :                : rowsfrom_item: func_expr_windowless opt_col_def_list
                              14105                 :            159 :                 { $$ = list_make2($1, $2); }
                              14106                 :                :         ;
                              14107                 :                : 
                              14108                 :                : rowsfrom_list:
 4288 noah@leadboat.com       14109                 :             66 :             rowsfrom_item                       { $$ = list_make1($1); }
                              14110                 :             93 :             | rowsfrom_list ',' rowsfrom_item   { $$ = lappend($1, $3); }
                              14111                 :                :         ;
                              14112                 :                : 
 4307 tgl@sss.pgh.pa.us       14113                 :             27 : opt_col_def_list: AS '(' TableFuncElementList ')'   { $$ = $3; }
                              14114                 :            132 :             | /*EMPTY*/                             { $$ = NIL; }
                              14115                 :                :         ;
                              14116                 :                : 
 3847                         14117                 :            459 : opt_ordinality: WITH_LA ORDINALITY                  { $$ = true; }
 4307                         14118                 :          23697 :             | /*EMPTY*/                             { $$ = false; }
                              14119                 :                :         ;
                              14120                 :                : 
                              14121                 :                : 
                              14122                 :                : where_clause:
 8482 bruce@momjian.us        14123                 :         107551 :             WHERE a_expr                            { $$ = $2; }
 8481                         14124                 :         141296 :             | /*EMPTY*/                             { $$ = NULL; }
                              14125                 :                :         ;
                              14126                 :                : 
                              14127                 :                : /* variant for UPDATE and DELETE */
                              14128                 :                : where_or_current_clause:
 6662 tgl@sss.pgh.pa.us       14129                 :           6719 :             WHERE a_expr                            { $$ = $2; }
                              14130                 :                :             | WHERE CURRENT_P OF cursor_name
                              14131                 :                :                 {
                              14132                 :            133 :                     CurrentOfExpr *n = makeNode(CurrentOfExpr);
                              14133                 :                : 
                              14134                 :                :                     /* cvarno is filled in by parse analysis */
                              14135                 :            133 :                     n->cursor_name = $4;
                              14136                 :            133 :                     n->cursor_param = 0;
                              14137                 :            133 :                     $$ = (Node *) n;
                              14138                 :                :                 }
                              14139                 :           2544 :             | /*EMPTY*/                             { $$ = NULL; }
                              14140                 :                :         ;
                              14141                 :                : 
                              14142                 :                : 
                              14143                 :                : OptTableFuncElementList:
 5459 peter_e@gmx.net         14144                 :            359 :             TableFuncElementList                { $$ = $1; }
                              14145                 :              3 :             | /*EMPTY*/                         { $$ = NIL; }
                              14146                 :                :         ;
                              14147                 :                : 
                              14148                 :                : TableFuncElementList:
                              14149                 :                :             TableFuncElement
                              14150                 :                :                 {
 7769 neilc@samurai.com       14151                 :            772 :                     $$ = list_make1($1);
                              14152                 :                :                 }
                              14153                 :                :             | TableFuncElementList ',' TableFuncElement
                              14154                 :                :                 {
 8409 tgl@sss.pgh.pa.us       14155                 :           1031 :                     $$ = lappend($1, $3);
                              14156                 :                :                 }
                              14157                 :                :         ;
                              14158                 :                : 
                              14159                 :                : TableFuncElement:   ColId Typename opt_collate_clause
                              14160                 :                :                 {
 8434 bruce@momjian.us        14161                 :           1835 :                     ColumnDef *n = makeNode(ColumnDef);
                              14162                 :                : 
                              14163                 :           1835 :                     n->colname = $1;
 5896 peter_e@gmx.net         14164                 :           1835 :                     n->typeName = $2;
 5295 tgl@sss.pgh.pa.us       14165                 :           1835 :                     n->inhcount = 0;
 8385                         14166                 :           1835 :                     n->is_local = true;
 5295                         14167                 :           1835 :                     n->is_not_null = false;
                              14168                 :           1835 :                     n->is_from_type = false;
  564 peter@eisentraut.org    14169                 :           1835 :                     n->storage = 0;
 5295 tgl@sss.pgh.pa.us       14170                 :           1835 :                     n->raw_default = NULL;
                              14171                 :           1835 :                     n->cooked_default = NULL;
                              14172                 :           1835 :                     n->collClause = (CollateClause *) $3;
                              14173                 :           1835 :                     n->collOid = InvalidOid;
                              14174                 :           1835 :                     n->constraints = NIL;
 4307                         14175                 :           1835 :                     n->location = @1;
 1212 peter@eisentraut.org    14176                 :           1835 :                     $$ = (Node *) n;
                              14177                 :                :                 }
                              14178                 :                :         ;
                              14179                 :                : 
                              14180                 :                : /*
                              14181                 :                :  * XMLTABLE
                              14182                 :                :  */
                              14183                 :                : xmltable:
                              14184                 :                :             XMLTABLE '(' c_expr xmlexists_argument COLUMNS xmltable_column_list ')'
                              14185                 :                :                 {
 3104 alvherre@alvh.no-ip.    14186                 :            103 :                     RangeTableFunc *n = makeNode(RangeTableFunc);
                              14187                 :                : 
                              14188                 :            103 :                     n->rowexpr = $3;
                              14189                 :            103 :                     n->docexpr = $4;
                              14190                 :            103 :                     n->columns = $6;
                              14191                 :            103 :                     n->namespaces = NIL;
                              14192                 :            103 :                     n->location = @1;
 1212 peter@eisentraut.org    14193                 :            103 :                     $$ = (Node *) n;
                              14194                 :                :                 }
                              14195                 :                :             | XMLTABLE '(' XMLNAMESPACES '(' xml_namespace_list ')' ','
                              14196                 :                :                 c_expr xmlexists_argument COLUMNS xmltable_column_list ')'
                              14197                 :                :                 {
 3104 alvherre@alvh.no-ip.    14198                 :             10 :                     RangeTableFunc *n = makeNode(RangeTableFunc);
                              14199                 :                : 
                              14200                 :             10 :                     n->rowexpr = $8;
                              14201                 :             10 :                     n->docexpr = $9;
                              14202                 :             10 :                     n->columns = $11;
                              14203                 :             10 :                     n->namespaces = $5;
                              14204                 :             10 :                     n->location = @1;
 1212 peter@eisentraut.org    14205                 :             10 :                     $$ = (Node *) n;
                              14206                 :                :                 }
                              14207                 :                :         ;
                              14208                 :                : 
 3104 alvherre@alvh.no-ip.    14209                 :            113 : xmltable_column_list: xmltable_column_el                    { $$ = list_make1($1); }
                              14210                 :            265 :             | xmltable_column_list ',' xmltable_column_el   { $$ = lappend($1, $3); }
                              14211                 :                :         ;
                              14212                 :                : 
                              14213                 :                : xmltable_column_el:
                              14214                 :                :             ColId Typename
                              14215                 :                :                 {
 1212 peter@eisentraut.org    14216                 :            102 :                     RangeTableFuncCol *fc = makeNode(RangeTableFuncCol);
                              14217                 :                : 
 3104 alvherre@alvh.no-ip.    14218                 :            102 :                     fc->colname = $1;
                              14219                 :            102 :                     fc->for_ordinality = false;
                              14220                 :            102 :                     fc->typeName = $2;
                              14221                 :            102 :                     fc->is_not_null = false;
                              14222                 :            102 :                     fc->colexpr = NULL;
                              14223                 :            102 :                     fc->coldefexpr = NULL;
                              14224                 :            102 :                     fc->location = @1;
                              14225                 :                : 
                              14226                 :            102 :                     $$ = (Node *) fc;
                              14227                 :                :                 }
                              14228                 :                :             | ColId Typename xmltable_column_option_list
                              14229                 :                :                 {
 1212 peter@eisentraut.org    14230                 :            245 :                     RangeTableFuncCol *fc = makeNode(RangeTableFuncCol);
                              14231                 :                :                     ListCell   *option;
                              14232                 :            245 :                     bool        nullability_seen = false;
                              14233                 :                : 
 3104 alvherre@alvh.no-ip.    14234                 :            245 :                     fc->colname = $1;
                              14235                 :            245 :                     fc->typeName = $2;
                              14236                 :            245 :                     fc->for_ordinality = false;
                              14237                 :            245 :                     fc->is_not_null = false;
                              14238                 :            245 :                     fc->colexpr = NULL;
                              14239                 :            245 :                     fc->coldefexpr = NULL;
                              14240                 :            245 :                     fc->location = @1;
                              14241                 :                : 
                              14242   [ +  -  +  +  :            546 :                     foreach(option, $3)
                                              +  + ]
                              14243                 :                :                     {
                              14244                 :            301 :                         DefElem   *defel = (DefElem *) lfirst(option);
                              14245                 :                : 
                              14246         [ +  + ]:            301 :                         if (strcmp(defel->defname, "default") == 0)
                              14247                 :                :                         {
                              14248         [ -  + ]:             28 :                             if (fc->coldefexpr != NULL)
 3104 alvherre@alvh.no-ip.    14249         [ #  # ]:UBC           0 :                                 ereport(ERROR,
                              14250                 :                :                                         (errcode(ERRCODE_SYNTAX_ERROR),
                              14251                 :                :                                          errmsg("only one DEFAULT value is allowed"),
                              14252                 :                :                                          parser_errposition(defel->location)));
 3104 alvherre@alvh.no-ip.    14253                 :CBC          28 :                             fc->coldefexpr = defel->arg;
                              14254                 :                :                         }
                              14255         [ +  + ]:            273 :                         else if (strcmp(defel->defname, "path") == 0)
                              14256                 :                :                         {
                              14257         [ -  + ]:            245 :                             if (fc->colexpr != NULL)
 3104 alvherre@alvh.no-ip.    14258         [ #  # ]:UBC           0 :                                 ereport(ERROR,
                              14259                 :                :                                         (errcode(ERRCODE_SYNTAX_ERROR),
                              14260                 :                :                                          errmsg("only one PATH value per column is allowed"),
                              14261                 :                :                                          parser_errposition(defel->location)));
 3104 alvherre@alvh.no-ip.    14262                 :CBC         245 :                             fc->colexpr = defel->arg;
                              14263                 :                :                         }
  114 rguo@postgresql.org     14264         [ +  - ]:             28 :                         else if (strcmp(defel->defname, "__pg__is_not_null") == 0)
                              14265                 :                :                         {
 3104 alvherre@alvh.no-ip.    14266         [ -  + ]:             28 :                             if (nullability_seen)
 3104 alvherre@alvh.no-ip.    14267         [ #  # ]:UBC           0 :                                 ereport(ERROR,
                              14268                 :                :                                         (errcode(ERRCODE_SYNTAX_ERROR),
                              14269                 :                :                                          errmsg("conflicting or redundant NULL / NOT NULL declarations for column \"%s\"", fc->colname),
                              14270                 :                :                                          parser_errposition(defel->location)));
 1331 peter@eisentraut.org    14271                 :CBC          28 :                             fc->is_not_null = boolVal(defel->arg);
 3104 alvherre@alvh.no-ip.    14272                 :             28 :                             nullability_seen = true;
                              14273                 :                :                         }
                              14274                 :                :                         else
                              14275                 :                :                         {
 3104 alvherre@alvh.no-ip.    14276         [ #  # ]:UBC           0 :                             ereport(ERROR,
                              14277                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              14278                 :                :                                      errmsg("unrecognized column option \"%s\"",
                              14279                 :                :                                             defel->defname),
                              14280                 :                :                                      parser_errposition(defel->location)));
                              14281                 :                :                         }
                              14282                 :                :                     }
 3104 alvherre@alvh.no-ip.    14283                 :CBC         245 :                     $$ = (Node *) fc;
                              14284                 :                :                 }
                              14285                 :                :             | ColId FOR ORDINALITY
                              14286                 :                :                 {
 1212 peter@eisentraut.org    14287                 :             31 :                     RangeTableFuncCol *fc = makeNode(RangeTableFuncCol);
                              14288                 :                : 
 3104 alvherre@alvh.no-ip.    14289                 :             31 :                     fc->colname = $1;
                              14290                 :             31 :                     fc->for_ordinality = true;
                              14291                 :                :                     /* other fields are ignored, initialized by makeNode */
                              14292                 :             31 :                     fc->location = @1;
                              14293                 :                : 
                              14294                 :             31 :                     $$ = (Node *) fc;
                              14295                 :                :                 }
                              14296                 :                :         ;
                              14297                 :                : 
                              14298                 :                : xmltable_column_option_list:
                              14299                 :                :             xmltable_column_option_el
                              14300                 :            245 :                 { $$ = list_make1($1); }
                              14301                 :                :             | xmltable_column_option_list xmltable_column_option_el
                              14302                 :             56 :                 { $$ = lappend($1, $2); }
                              14303                 :                :         ;
                              14304                 :                : 
                              14305                 :                : xmltable_column_option_el:
                              14306                 :                :             IDENT b_expr
                              14307                 :                :                 {
  114 rguo@postgresql.org     14308         [ +  - ]:              3 :                     if (strcmp($1, "__pg__is_not_null") == 0)
                              14309         [ +  - ]:              3 :                         ereport(ERROR,
                              14310                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                              14311                 :                :                                  errmsg("option name \"%s\" cannot be used in XMLTABLE", $1),
                              14312                 :                :                                  parser_errposition(@1)));
  114 rguo@postgresql.org     14313                 :UBC           0 :                     $$ = makeDefElem($1, $2, @1);
                              14314                 :                :                 }
                              14315                 :                :             | DEFAULT b_expr
 3104 alvherre@alvh.no-ip.    14316                 :CBC          28 :                 { $$ = makeDefElem("default", $2, @1); }
                              14317                 :                :             | NOT NULL_P
  114 rguo@postgresql.org     14318                 :             28 :                 { $$ = makeDefElem("__pg__is_not_null", (Node *) makeBoolean(true), @1); }
                              14319                 :                :             | NULL_P
  114 rguo@postgresql.org     14320                 :UBC           0 :                 { $$ = makeDefElem("__pg__is_not_null", (Node *) makeBoolean(false), @1); }
                              14321                 :                :             | PATH b_expr
  520 amitlan@postgresql.o    14322                 :CBC         245 :                 { $$ = makeDefElem("path", $2, @1); }
                              14323                 :                :         ;
                              14324                 :                : 
                              14325                 :                : xml_namespace_list:
                              14326                 :                :             xml_namespace_el
 3104 alvherre@alvh.no-ip.    14327                 :             10 :                 { $$ = list_make1($1); }
                              14328                 :                :             | xml_namespace_list ',' xml_namespace_el
 3104 alvherre@alvh.no-ip.    14329                 :UBC           0 :                 { $$ = lappend($1, $3); }
                              14330                 :                :         ;
                              14331                 :                : 
                              14332                 :                : xml_namespace_el:
                              14333                 :                :             b_expr AS ColLabel
                              14334                 :                :                 {
 3104 alvherre@alvh.no-ip.    14335                 :CBC           7 :                     $$ = makeNode(ResTarget);
                              14336                 :              7 :                     $$->name = $3;
                              14337                 :              7 :                     $$->indirection = NIL;
                              14338                 :              7 :                     $$->val = $1;
                              14339                 :              7 :                     $$->location = @1;
                              14340                 :                :                 }
                              14341                 :                :             | DEFAULT b_expr
                              14342                 :                :                 {
                              14343                 :              3 :                     $$ = makeNode(ResTarget);
                              14344                 :              3 :                     $$->name = NULL;
                              14345                 :              3 :                     $$->indirection = NIL;
                              14346                 :              3 :                     $$->val = $2;
                              14347                 :              3 :                     $$->location = @1;
                              14348                 :                :                 }
                              14349                 :                :         ;
                              14350                 :                : 
                              14351                 :                : json_table:
                              14352                 :                :             JSON_TABLE '('
                              14353                 :                :                 json_value_expr ',' a_expr json_table_path_name_opt
                              14354                 :                :                 json_passing_clause_opt
                              14355                 :                :                 COLUMNS '(' json_table_column_definition_list ')'
                              14356                 :                :                 json_on_error_clause_opt
                              14357                 :                :             ')'
                              14358                 :                :                 {
  520 amitlan@postgresql.o    14359                 :            266 :                     JsonTable *n = makeNode(JsonTable);
                              14360                 :                :                     char      *pathstring;
                              14361                 :                : 
                              14362                 :            266 :                     n->context_item = (JsonValueExpr *) $3;
                              14363         [ +  + ]:            266 :                     if (!IsA($5, A_Const) ||
                              14364         [ -  + ]:            263 :                         castNode(A_Const, $5)->val.node.type != T_String)
                              14365         [ +  - ]:              3 :                         ereport(ERROR,
                              14366                 :                :                                 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              14367                 :                :                                 errmsg("only string constants are supported in JSON_TABLE path specification"),
                              14368                 :                :                                 parser_errposition(@5));
                              14369                 :            263 :                     pathstring = castNode(A_Const, $5)->val.sval.sval;
                              14370                 :            263 :                     n->pathspec = makeJsonTablePathSpec(pathstring, $6, @5, @6);
                              14371                 :            263 :                     n->passing = $7;
                              14372                 :            263 :                     n->columns = $10;
                              14373                 :            263 :                     n->on_error = (JsonBehavior *) $12;
                              14374                 :            263 :                     n->location = @1;
                              14375                 :            263 :                     $$ = (Node *) n;
                              14376                 :                :                 }
                              14377                 :                :         ;
                              14378                 :                : 
                              14379                 :                : json_table_path_name_opt:
                              14380                 :             29 :             AS name         { $$ = $2; }
                              14381                 :            243 :             | /* empty */   { $$ = NULL; }
                              14382                 :                :         ;
                              14383                 :                : 
                              14384                 :                : json_table_column_definition_list:
                              14385                 :                :             json_table_column_definition
                              14386                 :            409 :                 { $$ = list_make1($1); }
                              14387                 :                :             | json_table_column_definition_list ',' json_table_column_definition
                              14388                 :            264 :                 { $$ = lappend($1, $3); }
                              14389                 :                :         ;
                              14390                 :                : 
                              14391                 :                : json_table_column_definition:
                              14392                 :                :             ColId FOR ORDINALITY
                              14393                 :                :                 {
                              14394                 :             42 :                     JsonTableColumn *n = makeNode(JsonTableColumn);
                              14395                 :                : 
                              14396                 :             42 :                     n->coltype = JTC_FOR_ORDINALITY;
                              14397                 :             42 :                     n->name = $1;
                              14398                 :             42 :                     n->location = @1;
                              14399                 :             42 :                     $$ = (Node *) n;
                              14400                 :                :                 }
                              14401                 :                :             | ColId Typename
                              14402                 :                :                 json_table_column_path_clause_opt
                              14403                 :                :                 json_wrapper_behavior
                              14404                 :                :                 json_quotes_clause_opt
                              14405                 :                :                 json_behavior_clause_opt
                              14406                 :                :                 {
                              14407                 :            365 :                     JsonTableColumn *n = makeNode(JsonTableColumn);
                              14408                 :                : 
                              14409                 :            365 :                     n->coltype = JTC_REGULAR;
                              14410                 :            365 :                     n->name = $1;
                              14411                 :            365 :                     n->typeName = $2;
                              14412                 :            365 :                     n->format = makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1);
                              14413                 :            365 :                     n->pathspec = (JsonTablePathSpec *) $3;
                              14414                 :            365 :                     n->wrapper = $4;
                              14415                 :            365 :                     n->quotes = $5;
                              14416                 :            365 :                     n->on_empty = (JsonBehavior *) linitial($6);
                              14417                 :            365 :                     n->on_error = (JsonBehavior *) lsecond($6);
                              14418                 :            365 :                     n->location = @1;
                              14419                 :            365 :                     $$ = (Node *) n;
                              14420                 :                :                 }
                              14421                 :                :             | ColId Typename json_format_clause
                              14422                 :                :                 json_table_column_path_clause_opt
                              14423                 :                :                 json_wrapper_behavior
                              14424                 :                :                 json_quotes_clause_opt
                              14425                 :                :                 json_behavior_clause_opt
                              14426                 :                :                 {
                              14427                 :             54 :                     JsonTableColumn *n = makeNode(JsonTableColumn);
                              14428                 :                : 
                              14429                 :             54 :                     n->coltype = JTC_FORMATTED;
                              14430                 :             54 :                     n->name = $1;
                              14431                 :             54 :                     n->typeName = $2;
                              14432                 :             54 :                     n->format = (JsonFormat *) $3;
                              14433                 :             54 :                     n->pathspec = (JsonTablePathSpec *) $4;
                              14434                 :             54 :                     n->wrapper = $5;
                              14435                 :             54 :                     n->quotes = $6;
                              14436                 :             54 :                     n->on_empty = (JsonBehavior *) linitial($7);
                              14437                 :             54 :                     n->on_error = (JsonBehavior *) lsecond($7);
                              14438                 :             54 :                     n->location = @1;
                              14439                 :             54 :                     $$ = (Node *) n;
                              14440                 :                :                 }
                              14441                 :                :             | ColId Typename
                              14442                 :                :                 EXISTS json_table_column_path_clause_opt
                              14443                 :                :                 json_on_error_clause_opt
                              14444                 :                :                 {
                              14445                 :             69 :                     JsonTableColumn *n = makeNode(JsonTableColumn);
                              14446                 :                : 
                              14447                 :             69 :                     n->coltype = JTC_EXISTS;
                              14448                 :             69 :                     n->name = $1;
                              14449                 :             69 :                     n->typeName = $2;
                              14450                 :             69 :                     n->format = makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1);
                              14451                 :             69 :                     n->wrapper = JSW_NONE;
                              14452                 :             69 :                     n->quotes = JS_QUOTES_UNSPEC;
                              14453                 :             69 :                     n->pathspec = (JsonTablePathSpec *) $4;
  435                         14454                 :             69 :                     n->on_empty = NULL;
                              14455                 :             69 :                     n->on_error = (JsonBehavior *) $5;
  520                         14456                 :             69 :                     n->location = @1;
                              14457                 :             69 :                     $$ = (Node *) n;
                              14458                 :                :                 }
                              14459                 :                :             | NESTED path_opt Sconst
                              14460                 :                :                 COLUMNS '(' json_table_column_definition_list ')'
                              14461                 :                :                 {
  516                         14462                 :             72 :                     JsonTableColumn *n = makeNode(JsonTableColumn);
                              14463                 :                : 
                              14464                 :             72 :                     n->coltype = JTC_NESTED;
                              14465                 :            144 :                     n->pathspec = (JsonTablePathSpec *)
                              14466                 :             72 :                         makeJsonTablePathSpec($3, NULL, @3, -1);
                              14467                 :             72 :                     n->columns = $6;
                              14468                 :             72 :                     n->location = @1;
                              14469                 :             72 :                     $$ = (Node *) n;
                              14470                 :                :                 }
                              14471                 :                :             | NESTED path_opt Sconst AS name
                              14472                 :                :                 COLUMNS '(' json_table_column_definition_list ')'
                              14473                 :                :                 {
                              14474                 :             71 :                     JsonTableColumn *n = makeNode(JsonTableColumn);
                              14475                 :                : 
                              14476                 :             71 :                     n->coltype = JTC_NESTED;
                              14477                 :            142 :                     n->pathspec = (JsonTablePathSpec *)
                              14478                 :             71 :                         makeJsonTablePathSpec($3, $5, @3, @5);
                              14479                 :             71 :                     n->columns = $8;
                              14480                 :             71 :                     n->location = @1;
                              14481                 :             71 :                     $$ = (Node *) n;
                              14482                 :                :                 }
                              14483                 :                :         ;
                              14484                 :                : 
                              14485                 :                : path_opt:
                              14486                 :                :             PATH
                              14487                 :                :             | /* EMPTY */
                              14488                 :                :         ;
                              14489                 :                : 
                              14490                 :                : json_table_column_path_clause_opt:
                              14491                 :                :             PATH Sconst
  520                         14492                 :            414 :                 { $$ = (Node *) makeJsonTablePathSpec($2, NULL, @2, -1); }
                              14493                 :                :             | /* EMPTY */
                              14494                 :             77 :                 { $$ = NULL; }
                              14495                 :                :         ;
                              14496                 :                : 
                              14497                 :                : /*****************************************************************************
                              14498                 :                :  *
                              14499                 :                :  *  Type syntax
                              14500                 :                :  *      SQL introduces a large amount of type-specific syntax.
                              14501                 :                :  *      Define individual clauses to handle these cases, and use
                              14502                 :                :  *       the generic case to handle regular type-extensible Postgres syntax.
                              14503                 :                :  *      - thomas 1997-10-10
                              14504                 :                :  *
                              14505                 :                :  *****************************************************************************/
                              14506                 :                : 
                              14507                 :                : Typename:   SimpleTypename opt_array_bounds
                              14508                 :                :                 {
10178 lockhart@fourpalms.o    14509                 :         261756 :                     $$ = $1;
                              14510                 :         261756 :                     $$->arrayBounds = $2;
                              14511                 :                :                 }
                              14512                 :                :             | SETOF SimpleTypename opt_array_bounds
                              14513                 :                :                 {
                              14514                 :           1162 :                     $$ = $2;
 8249 tgl@sss.pgh.pa.us       14515                 :           1162 :                     $$->arrayBounds = $3;
 2943 peter_e@gmx.net         14516                 :           1162 :                     $$->setof = true;
                              14517                 :                :                 }
                              14518                 :                :             /* SQL standard syntax, currently only one-dimensional */
                              14519                 :                :             | SimpleTypename ARRAY '[' Iconst ']'
                              14520                 :                :                 {
 8187 tgl@sss.pgh.pa.us       14521                 :              3 :                     $$ = $1;
 7769 neilc@samurai.com       14522                 :              3 :                     $$->arrayBounds = list_make1(makeInteger($4));
                              14523                 :                :                 }
                              14524                 :                :             | SETOF SimpleTypename ARRAY '[' Iconst ']'
                              14525                 :                :                 {
 8187 tgl@sss.pgh.pa.us       14526                 :UBC           0 :                     $$ = $2;
 7769 neilc@samurai.com       14527                 :              0 :                     $$->arrayBounds = list_make1(makeInteger($5));
 2943 peter_e@gmx.net         14528                 :              0 :                     $$->setof = true;
                              14529                 :                :                 }
                              14530                 :                :             | SimpleTypename ARRAY
                              14531                 :                :                 {
 6156                         14532                 :              0 :                     $$ = $1;
                              14533                 :              0 :                     $$->arrayBounds = list_make1(makeInteger(-1));
                              14534                 :                :                 }
                              14535                 :                :             | SETOF SimpleTypename ARRAY
                              14536                 :                :                 {
                              14537                 :              0 :                     $$ = $2;
                              14538                 :              0 :                     $$->arrayBounds = list_make1(makeInteger(-1));
 2943                         14539                 :              0 :                     $$->setof = true;
                              14540                 :                :                 }
                              14541                 :                :         ;
                              14542                 :                : 
                              14543                 :                : opt_array_bounds:
                              14544                 :                :             opt_array_bounds '[' ']'
 8482 bruce@momjian.us        14545                 :CBC        7349 :                     {  $$ = lappend($1, makeInteger(-1)); }
                              14546                 :                :             | opt_array_bounds '[' Iconst ']'
                              14547                 :             26 :                     {  $$ = lappend($1, makeInteger($3)); }
                              14548                 :                :             | /*EMPTY*/
                              14549                 :         262918 :                     {  $$ = NIL; }
                              14550                 :                :         ;
                              14551                 :                : 
                              14552                 :                : SimpleTypename:
 8434 lockhart@fourpalms.o    14553                 :         206072 :             GenericType                             { $$ = $1; }
                              14554                 :          49070 :             | Numeric                               { $$ = $1; }
                              14555                 :            986 :             | Bit                                   { $$ = $1; }
                              14556                 :           1471 :             | Character                             { $$ = $1; }
                              14557                 :           2650 :             | ConstDatetime                         { $$ = $1; }
                              14558                 :                :             | ConstInterval opt_interval
                              14559                 :                :                 {
 8724                         14560                 :           1932 :                     $$ = $1;
 6204 tgl@sss.pgh.pa.us       14561                 :           1932 :                     $$->typmods = $2;
                              14562                 :                :                 }
                              14563                 :                :             | ConstInterval '(' Iconst ')'
                              14564                 :                :                 {
 8724 lockhart@fourpalms.o    14565                 :UBC           0 :                     $$ = $1;
 3976 bruce@momjian.us        14566                 :              0 :                     $$->typmods = list_make2(makeIntConst(INTERVAL_FULL_RANGE, -1),
                              14567                 :                :                                              makeIntConst($3, @3));
                              14568                 :                :                 }
  779 amitlan@postgresql.o    14569                 :CBC         944 :             | JsonType                              { $$ = $1; }
                              14570                 :                :         ;
                              14571                 :                : 
                              14572                 :                : /* We have a separate ConstTypename to allow defaulting fixed-length
                              14573                 :                :  * types such as CHAR() and BIT() to an unspecified length.
                              14574                 :                :  * SQL9x requires that these default to a length of one, but this
                              14575                 :                :  * makes no sense for constructs like CHAR 'hi' and BIT '0101',
                              14576                 :                :  * where there is an obvious better choice to make.
                              14577                 :                :  * Note that ConstInterval is not included here since it must
                              14578                 :                :  * be pushed up higher in the rules to accommodate the postfix
                              14579                 :                :  * options (e.g. INTERVAL '1' YEAR). Likewise, we have to handle
                              14580                 :                :  * the generic-type-name case in AexprConst to avoid premature
                              14581                 :                :  * reduce/reduce conflicts against function names.
                              14582                 :                :  */
                              14583                 :                : ConstTypename:
 6825 tgl@sss.pgh.pa.us       14584                 :             39 :             Numeric                                 { $$ = $1; }
 8434 lockhart@fourpalms.o    14585                 :UBC           0 :             | ConstBit                              { $$ = $1; }
 8434 lockhart@fourpalms.o    14586                 :CBC          16 :             | ConstCharacter                        { $$ = $1; }
                              14587                 :           1399 :             | ConstDatetime                         { $$ = $1; }
  779 amitlan@postgresql.o    14588                 :            132 :             | JsonType                              { $$ = $1; }
                              14589                 :                :         ;
                              14590                 :                : 
                              14591                 :                : /*
                              14592                 :                :  * GenericType covers all type names that don't have special syntax mandated
                              14593                 :                :  * by the standard, including qualified names.  We also allow type modifiers.
                              14594                 :                :  * To avoid parsing conflicts against function invocations, the modifiers
                              14595                 :                :  * have to be shown as expr_list here, but parse analysis will only accept
                              14596                 :                :  * constants for them.
                              14597                 :                :  */
                              14598                 :                : GenericType:
                              14599                 :                :             type_function_name opt_type_modifiers
                              14600                 :                :                 {
 8527 tgl@sss.pgh.pa.us       14601                 :         145383 :                     $$ = makeTypeName($1);
 6825                         14602                 :         145383 :                     $$->typmods = $2;
                              14603                 :         145383 :                     $$->location = @1;
                              14604                 :                :                 }
                              14605                 :                :             | type_function_name attrs opt_type_modifiers
                              14606                 :                :                 {
                              14607                 :          60689 :                     $$ = makeTypeNameFromNameList(lcons(makeString($1), $2));
                              14608                 :          60689 :                     $$->typmods = $3;
 7116                         14609                 :          60689 :                     $$->location = @1;
                              14610                 :                :                 }
                              14611                 :                :         ;
                              14612                 :                : 
 6825                         14613                 :            670 : opt_type_modifiers: '(' expr_list ')'               { $$ = $2; }
                              14614                 :         208487 :                     | /* EMPTY */                   { $$ = NIL; }
                              14615                 :                :         ;
                              14616                 :                : 
                              14617                 :                : /*
                              14618                 :                :  * SQL numeric data types
                              14619                 :                :  */
                              14620                 :                : Numeric:    INT_P
                              14621                 :                :                 {
 8527                         14622                 :          19299 :                     $$ = SystemTypeName("int4");
 6825                         14623                 :          19299 :                     $$->location = @1;
                              14624                 :                :                 }
                              14625                 :                :             | INTEGER
                              14626                 :                :                 {
 8527                         14627                 :          12681 :                     $$ = SystemTypeName("int4");
 6825                         14628                 :          12681 :                     $$->location = @1;
                              14629                 :                :                 }
                              14630                 :                :             | SMALLINT
                              14631                 :                :                 {
 8527                         14632                 :            706 :                     $$ = SystemTypeName("int2");
 6825                         14633                 :            706 :                     $$->location = @1;
                              14634                 :                :                 }
                              14635                 :                :             | BIGINT
                              14636                 :                :                 {
 8527                         14637                 :           2510 :                     $$ = SystemTypeName("int8");
 6825                         14638                 :           2510 :                     $$->location = @1;
                              14639                 :                :                 }
                              14640                 :                :             | REAL
                              14641                 :                :                 {
 8527                         14642                 :           3750 :                     $$ = SystemTypeName("float4");
 6825                         14643                 :           3750 :                     $$->location = @1;
                              14644                 :                :                 }
                              14645                 :                :             | FLOAT_P opt_float
                              14646                 :                :                 {
 8527                         14647                 :            267 :                     $$ = $2;
 6825                         14648                 :            267 :                     $$->location = @1;
                              14649                 :                :                 }
                              14650                 :                :             | DOUBLE_P PRECISION
                              14651                 :                :                 {
 8527                         14652                 :            380 :                     $$ = SystemTypeName("float8");
 6825                         14653                 :            380 :                     $$->location = @1;
                              14654                 :                :                 }
                              14655                 :                :             | DECIMAL_P opt_type_modifiers
                              14656                 :                :                 {
 8527                         14657                 :             16 :                     $$ = SystemTypeName("numeric");
 6825                         14658                 :             16 :                     $$->typmods = $2;
                              14659                 :             16 :                     $$->location = @1;
                              14660                 :                :                 }
                              14661                 :                :             | DEC opt_type_modifiers
                              14662                 :                :                 {
 8527 tgl@sss.pgh.pa.us       14663                 :UBC           0 :                     $$ = SystemTypeName("numeric");
 6825                         14664                 :              0 :                     $$->typmods = $2;
                              14665                 :              0 :                     $$->location = @1;
                              14666                 :                :                 }
                              14667                 :                :             | NUMERIC opt_type_modifiers
                              14668                 :                :                 {
 8527 tgl@sss.pgh.pa.us       14669                 :CBC        3069 :                     $$ = SystemTypeName("numeric");
 6825                         14670                 :           3069 :                     $$->typmods = $2;
                              14671                 :           3069 :                     $$->location = @1;
                              14672                 :                :                 }
                              14673                 :                :             | BOOLEAN_P
                              14674                 :                :                 {
 8527                         14675                 :           6431 :                     $$ = SystemTypeName("bool");
 6825                         14676                 :           6431 :                     $$->location = @1;
                              14677                 :                :                 }
                              14678                 :                :         ;
                              14679                 :                : 
                              14680                 :                : opt_float:  '(' Iconst ')'
                              14681                 :                :                 {
                              14682                 :                :                     /*
                              14683                 :                :                      * Check FLOAT() precision limits assuming IEEE floating
                              14684                 :                :                      * types - thomas 1997-09-18
                              14685                 :                :                      */
10178 lockhart@fourpalms.o    14686         [ -  + ]:              1 :                     if ($2 < 1)
 8085 tgl@sss.pgh.pa.us       14687         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              14688                 :                :                                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                              14689                 :                :                                  errmsg("precision for type float must be at least 1 bit"),
                              14690                 :                :                                  parser_errposition(@2)));
 8117 tgl@sss.pgh.pa.us       14691         [ +  - ]:CBC           1 :                     else if ($2 <= 24)
 8527                         14692                 :              1 :                         $$ = SystemTypeName("float4");
 8117 tgl@sss.pgh.pa.us       14693         [ #  # ]:UBC           0 :                     else if ($2 <= 53)
 8527                         14694                 :              0 :                         $$ = SystemTypeName("float8");
                              14695                 :                :                     else
 8085                         14696         [ #  # ]:              0 :                         ereport(ERROR,
                              14697                 :                :                                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                              14698                 :                :                                  errmsg("precision for type float must be less than 54 bits"),
                              14699                 :                :                                  parser_errposition(@2)));
                              14700                 :                :                 }
                              14701                 :                :             | /*EMPTY*/
                              14702                 :                :                 {
 8527 tgl@sss.pgh.pa.us       14703                 :CBC         266 :                     $$ = SystemTypeName("float8");
                              14704                 :                :                 }
                              14705                 :                :         ;
                              14706                 :                : 
                              14707                 :                : /*
                              14708                 :                :  * SQL bit-field data types
                              14709                 :                :  * The following implements BIT() and BIT VARYING().
                              14710                 :                :  */
                              14711                 :                : Bit:        BitWithLength
                              14712                 :                :                 {
 8434 lockhart@fourpalms.o    14713                 :            848 :                     $$ = $1;
                              14714                 :                :                 }
                              14715                 :                :             | BitWithoutLength
                              14716                 :                :                 {
                              14717                 :            138 :                     $$ = $1;
                              14718                 :                :                 }
                              14719                 :                :         ;
                              14720                 :                : 
                              14721                 :                : /* ConstBit is like Bit except "BIT" defaults to unspecified length */
                              14722                 :                : /* See notes for ConstCharacter, which addresses same issue for "CHAR" */
                              14723                 :                : ConstBit:   BitWithLength
                              14724                 :                :                 {
 8434 lockhart@fourpalms.o    14725                 :UBC           0 :                     $$ = $1;
                              14726                 :                :                 }
                              14727                 :                :             | BitWithoutLength
                              14728                 :                :                 {
                              14729                 :              0 :                     $$ = $1;
 6825 tgl@sss.pgh.pa.us       14730                 :              0 :                     $$->typmods = NIL;
                              14731                 :                :                 }
                              14732                 :                :         ;
                              14733                 :                : 
                              14734                 :                : BitWithLength:
                              14735                 :                :             BIT opt_varying '(' expr_list ')'
                              14736                 :                :                 {
                              14737                 :                :                     char *typname;
                              14738                 :                : 
 8527 tgl@sss.pgh.pa.us       14739         [ +  + ]:CBC         848 :                     typname = $2 ? "varbit" : "bit";
                              14740                 :            848 :                     $$ = SystemTypeName(typname);
 6825                         14741                 :            848 :                     $$->typmods = $4;
                              14742                 :            848 :                     $$->location = @1;
                              14743                 :                :                 }
                              14744                 :                :         ;
                              14745                 :                : 
                              14746                 :                : BitWithoutLength:
                              14747                 :                :             BIT opt_varying
                              14748                 :                :                 {
                              14749                 :                :                     /* bit defaults to bit(1), varbit to no limit */
 8527                         14750         [ +  + ]:            138 :                     if ($2)
                              14751                 :                :                     {
                              14752                 :             10 :                         $$ = SystemTypeName("varbit");
                              14753                 :                :                     }
                              14754                 :                :                     else
                              14755                 :                :                     {
                              14756                 :            128 :                         $$ = SystemTypeName("bit");
 6218                         14757                 :            128 :                         $$->typmods = list_make1(makeIntConst(1, -1));
                              14758                 :                :                     }
 6825                         14759                 :            138 :                     $$->location = @1;
                              14760                 :                :                 }
                              14761                 :                :         ;
                              14762                 :                : 
                              14763                 :                : 
                              14764                 :                : /*
                              14765                 :                :  * SQL character data types
                              14766                 :                :  * The following implements CHAR() and VARCHAR().
                              14767                 :                :  */
                              14768                 :                : Character:  CharacterWithLength
                              14769                 :                :                 {
 8434 lockhart@fourpalms.o    14770                 :            830 :                     $$ = $1;
                              14771                 :                :                 }
                              14772                 :                :             | CharacterWithoutLength
                              14773                 :                :                 {
                              14774                 :            641 :                     $$ = $1;
                              14775                 :                :                 }
                              14776                 :                :         ;
                              14777                 :                : 
                              14778                 :                : ConstCharacter:  CharacterWithLength
                              14779                 :                :                 {
                              14780                 :              6 :                     $$ = $1;
                              14781                 :                :                 }
                              14782                 :                :             | CharacterWithoutLength
                              14783                 :                :                 {
                              14784                 :                :                     /* Length was not specified so allow to be unrestricted.
                              14785                 :                :                      * This handles problems with fixed-length (bpchar) strings
                              14786                 :                :                      * which in column definitions must default to a length
                              14787                 :                :                      * of one, but should not be constrained if the length
                              14788                 :                :                      * was not specified.
                              14789                 :                :                      */
                              14790                 :             10 :                     $$ = $1;
 6825 tgl@sss.pgh.pa.us       14791                 :             10 :                     $$->typmods = NIL;
                              14792                 :                :                 }
                              14793                 :                :         ;
                              14794                 :                : 
                              14795                 :                : CharacterWithLength:  character '(' Iconst ')'
                              14796                 :                :                 {
 8527                         14797                 :            836 :                     $$ = SystemTypeName($1);
 6218                         14798                 :            836 :                     $$->typmods = list_make1(makeIntConst($3, @3));
 6825                         14799                 :            836 :                     $$->location = @1;
                              14800                 :                :                 }
                              14801                 :                :         ;
                              14802                 :                : 
                              14803                 :                : CharacterWithoutLength:  character
                              14804                 :                :                 {
 8527                         14805                 :            651 :                     $$ = SystemTypeName($1);
                              14806                 :                :                     /* char defaults to char(1), varchar to no limit */
 8699                         14807         [ +  + ]:            651 :                     if (strcmp($1, "bpchar") == 0)
 6218                         14808                 :            127 :                         $$->typmods = list_make1(makeIntConst(1, -1));
 6825                         14809                 :            651 :                     $$->location = @1;
                              14810                 :                :                 }
                              14811                 :                :         ;
                              14812                 :                : 
                              14813                 :                : character:  CHARACTER opt_varying
 8482 bruce@momjian.us        14814         [ +  + ]:            282 :                                         { $$ = $2 ? "varchar": "bpchar"; }
                              14815                 :                :             | CHAR_P opt_varying
                              14816         [ -  + ]:            564 :                                         { $$ = $2 ? "varchar": "bpchar"; }
                              14817                 :                :             | VARCHAR
                              14818                 :            640 :                                         { $$ = "varchar"; }
                              14819                 :                :             | NATIONAL CHARACTER opt_varying
 8482 bruce@momjian.us        14820         [ #  # ]:UBC           0 :                                         { $$ = $3 ? "varchar": "bpchar"; }
                              14821                 :                :             | NATIONAL CHAR_P opt_varying
                              14822         [ #  # ]:              0 :                                         { $$ = $3 ? "varchar": "bpchar"; }
                              14823                 :                :             | NCHAR opt_varying
 8482 bruce@momjian.us        14824         [ -  + ]:CBC           1 :                                         { $$ = $2 ? "varchar": "bpchar"; }
                              14825                 :                :         ;
                              14826                 :                : 
                              14827                 :                : opt_varying:
 2943 peter_e@gmx.net         14828                 :            229 :             VARYING                                 { $$ = true; }
                              14829                 :           1604 :             | /*EMPTY*/                             { $$ = false; }
                              14830                 :                :         ;
                              14831                 :                : 
                              14832                 :                : /*
                              14833                 :                :  * SQL date/time types
                              14834                 :                :  */
                              14835                 :                : ConstDatetime:
                              14836                 :                :             TIMESTAMP '(' Iconst ')' opt_timezone
                              14837                 :                :                 {
 8739 lockhart@fourpalms.o    14838         [ +  + ]:             67 :                     if ($5)
 8527 tgl@sss.pgh.pa.us       14839                 :             55 :                         $$ = SystemTypeName("timestamptz");
                              14840                 :                :                     else
                              14841                 :             12 :                         $$ = SystemTypeName("timestamp");
 6218                         14842                 :             67 :                     $$->typmods = list_make1(makeIntConst($3, @3));
 6825                         14843                 :             67 :                     $$->location = @1;
                              14844                 :                :                 }
                              14845                 :                :             | TIMESTAMP opt_timezone
                              14846                 :                :                 {
 8744 lockhart@fourpalms.o    14847         [ +  + ]:           2675 :                     if ($2)
 8527 tgl@sss.pgh.pa.us       14848                 :            728 :                         $$ = SystemTypeName("timestamptz");
                              14849                 :                :                     else
                              14850                 :           1947 :                         $$ = SystemTypeName("timestamp");
 6825                         14851                 :           2675 :                     $$->location = @1;
                              14852                 :                :                 }
                              14853                 :                :             | TIME '(' Iconst ')' opt_timezone
                              14854                 :                :                 {
 8739 lockhart@fourpalms.o    14855         [ +  + ]:             11 :                     if ($5)
 8527 tgl@sss.pgh.pa.us       14856                 :              4 :                         $$ = SystemTypeName("timetz");
                              14857                 :                :                     else
                              14858                 :              7 :                         $$ = SystemTypeName("time");
 6218                         14859                 :             11 :                     $$->typmods = list_make1(makeIntConst($3, @3));
 6825                         14860                 :             11 :                     $$->location = @1;
                              14861                 :                :                 }
                              14862                 :                :             | TIME opt_timezone
                              14863                 :                :                 {
 9307 lockhart@fourpalms.o    14864         [ +  + ]:           1296 :                     if ($2)
 8527 tgl@sss.pgh.pa.us       14865                 :            174 :                         $$ = SystemTypeName("timetz");
                              14866                 :                :                     else
                              14867                 :           1122 :                         $$ = SystemTypeName("time");
 6825                         14868                 :           1296 :                     $$->location = @1;
                              14869                 :                :                 }
                              14870                 :                :         ;
                              14871                 :                : 
                              14872                 :                : ConstInterval:
                              14873                 :                :             INTERVAL
                              14874                 :                :                 {
                              14875                 :           3587 :                     $$ = SystemTypeName("interval");
                              14876                 :           3587 :                     $$->location = @1;
                              14877                 :                :                 }
                              14878                 :                :         ;
                              14879                 :                : 
                              14880                 :                : opt_timezone:
 2943 peter_e@gmx.net         14881                 :            961 :             WITH_LA TIME ZONE                       { $$ = true; }
  886 alvherre@alvh.no-ip.    14882                 :            311 :             | WITHOUT_LA TIME ZONE                  { $$ = false; }
 2943 peter_e@gmx.net         14883                 :           2777 :             | /*EMPTY*/                             { $$ = false; }
                              14884                 :                :         ;
                              14885                 :                : 
                              14886                 :                : opt_interval:
                              14887                 :                :             YEAR_P
 6204 tgl@sss.pgh.pa.us       14888                 :              6 :                 { $$ = list_make1(makeIntConst(INTERVAL_MASK(YEAR), @1)); }
                              14889                 :                :             | MONTH_P
                              14890                 :              9 :                 { $$ = list_make1(makeIntConst(INTERVAL_MASK(MONTH), @1)); }
                              14891                 :                :             | DAY_P
                              14892                 :              9 :                 { $$ = list_make1(makeIntConst(INTERVAL_MASK(DAY), @1)); }
                              14893                 :                :             | HOUR_P
                              14894                 :              6 :                 { $$ = list_make1(makeIntConst(INTERVAL_MASK(HOUR), @1)); }
                              14895                 :                :             | MINUTE_P
                              14896                 :              6 :                 { $$ = list_make1(makeIntConst(INTERVAL_MASK(MINUTE), @1)); }
                              14897                 :                :             | interval_second
                              14898                 :             18 :                 { $$ = $1; }
                              14899                 :                :             | YEAR_P TO MONTH_P
                              14900                 :                :                 {
                              14901                 :              9 :                     $$ = list_make1(makeIntConst(INTERVAL_MASK(YEAR) |
                              14902                 :                :                                                  INTERVAL_MASK(MONTH), @1));
                              14903                 :                :                 }
                              14904                 :                :             | DAY_P TO HOUR_P
                              14905                 :                :                 {
                              14906                 :             12 :                     $$ = list_make1(makeIntConst(INTERVAL_MASK(DAY) |
                              14907                 :                :                                                  INTERVAL_MASK(HOUR), @1));
                              14908                 :                :                 }
                              14909                 :                :             | DAY_P TO MINUTE_P
                              14910                 :                :                 {
                              14911                 :             12 :                     $$ = list_make1(makeIntConst(INTERVAL_MASK(DAY) |
                              14912                 :                :                                                  INTERVAL_MASK(HOUR) |
                              14913                 :                :                                                  INTERVAL_MASK(MINUTE), @1));
                              14914                 :                :                 }
                              14915                 :                :             | DAY_P TO interval_second
                              14916                 :                :                 {
                              14917                 :             24 :                     $$ = $3;
                              14918                 :             24 :                     linitial($$) = makeIntConst(INTERVAL_MASK(DAY) |
                              14919                 :                :                                                 INTERVAL_MASK(HOUR) |
                              14920                 :                :                                                 INTERVAL_MASK(MINUTE) |
                              14921                 :             24 :                                                 INTERVAL_MASK(SECOND), @1);
                              14922                 :                :                 }
                              14923                 :                :             | HOUR_P TO MINUTE_P
                              14924                 :                :                 {
                              14925                 :              9 :                     $$ = list_make1(makeIntConst(INTERVAL_MASK(HOUR) |
                              14926                 :                :                                                  INTERVAL_MASK(MINUTE), @1));
                              14927                 :                :                 }
                              14928                 :                :             | HOUR_P TO interval_second
                              14929                 :                :                 {
                              14930                 :             18 :                     $$ = $3;
                              14931                 :             18 :                     linitial($$) = makeIntConst(INTERVAL_MASK(HOUR) |
                              14932                 :                :                                                 INTERVAL_MASK(MINUTE) |
                              14933                 :             18 :                                                 INTERVAL_MASK(SECOND), @1);
                              14934                 :                :                 }
                              14935                 :                :             | MINUTE_P TO interval_second
                              14936                 :                :                 {
                              14937                 :             33 :                     $$ = $3;
                              14938                 :             33 :                     linitial($$) = makeIntConst(INTERVAL_MASK(MINUTE) |
                              14939                 :             33 :                                                 INTERVAL_MASK(SECOND), @1);
                              14940                 :                :                 }
                              14941                 :                :             | /*EMPTY*/
                              14942                 :           3410 :                 { $$ = NIL; }
                              14943                 :                :         ;
                              14944                 :                : 
                              14945                 :                : interval_second:
                              14946                 :                :             SECOND_P
                              14947                 :                :                 {
                              14948                 :             51 :                     $$ = list_make1(makeIntConst(INTERVAL_MASK(SECOND), @1));
                              14949                 :                :                 }
                              14950                 :                :             | SECOND_P '(' Iconst ')'
                              14951                 :                :                 {
                              14952                 :             42 :                     $$ = list_make2(makeIntConst(INTERVAL_MASK(SECOND), @1),
                              14953                 :                :                                     makeIntConst($3, @3));
                              14954                 :                :                 }
                              14955                 :                :         ;
                              14956                 :                : 
                              14957                 :                : JsonType:
                              14958                 :                :             JSON
                              14959                 :                :                 {
  779 amitlan@postgresql.o    14960                 :           1076 :                     $$ = SystemTypeName("json");
                              14961                 :           1076 :                     $$->location = @1;
                              14962                 :                :                 }
                              14963                 :                :         ;
                              14964                 :                : 
                              14965                 :                : /*****************************************************************************
                              14966                 :                :  *
                              14967                 :                :  *  expression grammar
                              14968                 :                :  *
                              14969                 :                :  *****************************************************************************/
                              14970                 :                : 
                              14971                 :                : /*
                              14972                 :                :  * General expressions
                              14973                 :                :  * This is the heart of the expression syntax.
                              14974                 :                :  *
                              14975                 :                :  * We have two expression types: a_expr is the unrestricted kind, and
                              14976                 :                :  * b_expr is a subset that must be used in some places to avoid shift/reduce
                              14977                 :                :  * conflicts.  For example, we can't do BETWEEN as "BETWEEN a_expr AND a_expr"
                              14978                 :                :  * because that use of AND conflicts with AND as a boolean operator.  So,
                              14979                 :                :  * b_expr is used in BETWEEN and we remove boolean keywords from b_expr.
                              14980                 :                :  *
                              14981                 :                :  * Note that '(' a_expr ')' is a b_expr, so an unrestricted expression can
                              14982                 :                :  * always be used by surrounding it with parens.
                              14983                 :                :  *
                              14984                 :                :  * c_expr is all the productions that are common to a_expr and b_expr;
                              14985                 :                :  * it's factored out just to eliminate redundant coding.
                              14986                 :                :  *
                              14987                 :                :  * Be careful of productions involving more than one terminal token.
                              14988                 :                :  * By default, bison will assign such productions the precedence of their
                              14989                 :                :  * last terminal, but in nearly all cases you want it to be the precedence
                              14990                 :                :  * of the first terminal instead; otherwise you will not get the behavior
                              14991                 :                :  * you expect!  So we use %prec annotations freely to set precedences.
                              14992                 :                :  */
 8482 bruce@momjian.us        14993                 :        1857314 : a_expr:     c_expr                                  { $$ = $1; }
                              14994                 :                :             | a_expr TYPECAST Typename
 6218 tgl@sss.pgh.pa.us       14995                 :         120249 :                     { $$ = makeTypeCast($1, $3, @2); }
                              14996                 :                :             | a_expr COLLATE any_name
                              14997                 :                :                 {
 5295                         14998                 :           4509 :                     CollateClause *n = makeNode(CollateClause);
                              14999                 :                : 
 5293                         15000                 :           4509 :                     n->arg = $1;
                              15001                 :           4509 :                     n->collname = $3;
 5295                         15002                 :           4509 :                     n->location = @2;
                              15003                 :           4509 :                     $$ = (Node *) n;
                              15004                 :                :                 }
                              15005                 :                :             | a_expr AT TIME ZONE a_expr            %prec AT
                              15006                 :                :                 {
 4450 rhaas@postgresql.org    15007                 :            204 :                     $$ = (Node *) makeFuncCall(SystemFuncName("timezone"),
                              15008                 :            204 :                                                list_make2($5, $1),
                              15009                 :                :                                                COERCE_SQL_SYNTAX,
                              15010                 :            204 :                                                @2);
                              15011                 :                :                 }
                              15012                 :                :             | a_expr AT LOCAL                       %prec AT
                              15013                 :                :                 {
  694 michael@paquier.xyz     15014                 :             21 :                     $$ = (Node *) makeFuncCall(SystemFuncName("timezone"),
                              15015                 :             21 :                                                list_make1($1),
                              15016                 :                :                                                COERCE_SQL_SYNTAX,
                              15017                 :                :                                                -1);
                              15018                 :                :                 }
                              15019                 :                :         /*
                              15020                 :                :          * These operators must be called out explicitly in order to make use
                              15021                 :                :          * of bison's automatic operator-precedence handling.  All other
                              15022                 :                :          * operator names are handled by the generic productions using "Op",
                              15023                 :                :          * below; and all those operators will have the same precedence.
                              15024                 :                :          *
                              15025                 :                :          * If you add more explicitly-known operators, be sure to add them
                              15026                 :                :          * also to b_expr and to the MathOp list below.
                              15027                 :                :          */
                              15028                 :                :             | '+' a_expr                    %prec UMINUS
 7116 tgl@sss.pgh.pa.us       15029                 :              6 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", NULL, $2, @1); }
                              15030                 :                :             | '-' a_expr                    %prec UMINUS
                              15031                 :           4572 :                 { $$ = doNegate($2, @1); }
                              15032                 :                :             | a_expr '+' a_expr
                              15033                 :           7084 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", $1, $3, @2); }
                              15034                 :                :             | a_expr '-' a_expr
                              15035                 :           2288 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "-", $1, $3, @2); }
                              15036                 :                :             | a_expr '*' a_expr
                              15037                 :           3163 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "*", $1, $3, @2); }
                              15038                 :                :             | a_expr '/' a_expr
                              15039                 :           1721 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "/", $1, $3, @2); }
                              15040                 :                :             | a_expr '%' a_expr
                              15041                 :           1429 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "%", $1, $3, @2); }
                              15042                 :                :             | a_expr '^' a_expr
                              15043                 :            238 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "^", $1, $3, @2); }
                              15044                 :                :             | a_expr '<' a_expr
                              15045                 :           5298 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $3, @2); }
                              15046                 :                :             | a_expr '>' a_expr
                              15047                 :           8262 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $3, @2); }
                              15048                 :                :             | a_expr '=' a_expr
                              15049                 :         197060 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "=", $1, $3, @2); }
                              15050                 :                :             | a_expr LESS_EQUALS a_expr
 3832                         15051                 :           2530 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $3, @2); }
                              15052                 :                :             | a_expr GREATER_EQUALS a_expr
                              15053                 :           3573 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $3, @2); }
                              15054                 :                :             | a_expr NOT_EQUALS a_expr
                              15055                 :          20565 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<>", $1, $3, @2); }
                              15056                 :                : 
                              15057                 :                :             | a_expr qual_Op a_expr             %prec Op
 7116                         15058                 :          29322 :                 { $$ = (Node *) makeA_Expr(AEXPR_OP, $2, $1, $3, @2); }
                              15059                 :                :             | qual_Op a_expr                    %prec Op
                              15060                 :            114 :                 { $$ = (Node *) makeA_Expr(AEXPR_OP, $1, NULL, $2, @1); }
                              15061                 :                : 
                              15062                 :                :             | a_expr AND a_expr
 4100                         15063                 :         118551 :                 { $$ = makeAndExpr($1, $3, @2); }
                              15064                 :                :             | a_expr OR a_expr
                              15065                 :           8052 :                 { $$ = makeOrExpr($1, $3, @2); }
                              15066                 :                :             | NOT a_expr
                              15067                 :           8068 :                 { $$ = makeNotExpr($2, @1); }
                              15068                 :                :             | NOT_LA a_expr                     %prec NOT
 3832 tgl@sss.pgh.pa.us       15069                 :UBC           0 :                 { $$ = makeNotExpr($2, @1); }
                              15070                 :                : 
                              15071                 :                :             | a_expr LIKE a_expr
                              15072                 :                :                 {
 3848 tgl@sss.pgh.pa.us       15073                 :CBC         984 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_LIKE, "~~",
                              15074                 :            984 :                                                    $1, $3, @2);
                              15075                 :                :                 }
                              15076                 :                :             | a_expr LIKE a_expr ESCAPE a_expr                  %prec LIKE
                              15077                 :                :                 {
 1212 peter@eisentraut.org    15078                 :             48 :                     FuncCall   *n = makeFuncCall(SystemFuncName("like_escape"),
                              15079                 :             48 :                                                  list_make2($3, $5),
                              15080                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15081                 :             48 :                                                  @2);
 3848 tgl@sss.pgh.pa.us       15082                 :             48 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_LIKE, "~~",
                              15083                 :             48 :                                                    $1, (Node *) n, @2);
                              15084                 :                :                 }
                              15085                 :                :             | a_expr NOT_LA LIKE a_expr                         %prec NOT_LA
                              15086                 :                :                 {
                              15087                 :            107 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_LIKE, "!~~",
                              15088                 :            107 :                                                    $1, $4, @2);
                              15089                 :                :                 }
                              15090                 :                :             | a_expr NOT_LA LIKE a_expr ESCAPE a_expr           %prec NOT_LA
                              15091                 :                :                 {
 1212 peter@eisentraut.org    15092                 :             48 :                     FuncCall   *n = makeFuncCall(SystemFuncName("like_escape"),
                              15093                 :             48 :                                                  list_make2($4, $6),
                              15094                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15095                 :             48 :                                                  @2);
 3848 tgl@sss.pgh.pa.us       15096                 :             48 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_LIKE, "!~~",
                              15097                 :             48 :                                                    $1, (Node *) n, @2);
                              15098                 :                :                 }
                              15099                 :                :             | a_expr ILIKE a_expr
                              15100                 :                :                 {
                              15101                 :             86 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_ILIKE, "~~*",
                              15102                 :             86 :                                                    $1, $3, @2);
                              15103                 :                :                 }
                              15104                 :                :             | a_expr ILIKE a_expr ESCAPE a_expr                 %prec ILIKE
                              15105                 :                :                 {
 1212 peter@eisentraut.org    15106                 :UBC           0 :                     FuncCall   *n = makeFuncCall(SystemFuncName("like_escape"),
                              15107                 :              0 :                                                  list_make2($3, $5),
                              15108                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15109                 :              0 :                                                  @2);
 3848 tgl@sss.pgh.pa.us       15110                 :              0 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_ILIKE, "~~*",
                              15111                 :              0 :                                                    $1, (Node *) n, @2);
                              15112                 :                :                 }
                              15113                 :                :             | a_expr NOT_LA ILIKE a_expr                        %prec NOT_LA
                              15114                 :                :                 {
 3848 tgl@sss.pgh.pa.us       15115                 :CBC          15 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_ILIKE, "!~~*",
                              15116                 :             15 :                                                    $1, $4, @2);
                              15117                 :                :                 }
                              15118                 :                :             | a_expr NOT_LA ILIKE a_expr ESCAPE a_expr          %prec NOT_LA
                              15119                 :                :                 {
 1212 peter@eisentraut.org    15120                 :UBC           0 :                     FuncCall   *n = makeFuncCall(SystemFuncName("like_escape"),
                              15121                 :              0 :                                                  list_make2($4, $6),
                              15122                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15123                 :              0 :                                                  @2);
 3848 tgl@sss.pgh.pa.us       15124                 :              0 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_ILIKE, "!~~*",
                              15125                 :              0 :                                                    $1, (Node *) n, @2);
                              15126                 :                :                 }
                              15127                 :                : 
                              15128                 :                :             | a_expr SIMILAR TO a_expr                          %prec SIMILAR
                              15129                 :                :                 {
 1212 peter@eisentraut.org    15130                 :CBC          44 :                     FuncCall   *n = makeFuncCall(SystemFuncName("similar_to_escape"),
                              15131                 :             44 :                                                  list_make1($4),
                              15132                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15133                 :             44 :                                                  @2);
 3848 tgl@sss.pgh.pa.us       15134                 :             44 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_SIMILAR, "~",
                              15135                 :             44 :                                                    $1, (Node *) n, @2);
                              15136                 :                :                 }
                              15137                 :                :             | a_expr SIMILAR TO a_expr ESCAPE a_expr            %prec SIMILAR
                              15138                 :                :                 {
 1212 peter@eisentraut.org    15139                 :             15 :                     FuncCall   *n = makeFuncCall(SystemFuncName("similar_to_escape"),
                              15140                 :             15 :                                                  list_make2($4, $6),
                              15141                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15142                 :             15 :                                                  @2);
 3848 tgl@sss.pgh.pa.us       15143                 :             15 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_SIMILAR, "~",
                              15144                 :             15 :                                                    $1, (Node *) n, @2);
                              15145                 :                :                 }
                              15146                 :                :             | a_expr NOT_LA SIMILAR TO a_expr                   %prec NOT_LA
                              15147                 :                :                 {
 1212 peter@eisentraut.org    15148                 :UBC           0 :                     FuncCall   *n = makeFuncCall(SystemFuncName("similar_to_escape"),
                              15149                 :              0 :                                                  list_make1($5),
                              15150                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15151                 :              0 :                                                  @2);
 3848 tgl@sss.pgh.pa.us       15152                 :              0 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_SIMILAR, "!~",
                              15153                 :              0 :                                                    $1, (Node *) n, @2);
                              15154                 :                :                 }
                              15155                 :                :             | a_expr NOT_LA SIMILAR TO a_expr ESCAPE a_expr     %prec NOT_LA
                              15156                 :                :                 {
 1212 peter@eisentraut.org    15157                 :              0 :                     FuncCall   *n = makeFuncCall(SystemFuncName("similar_to_escape"),
                              15158                 :              0 :                                                  list_make2($5, $7),
                              15159                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15160                 :              0 :                                                  @2);
 3848 tgl@sss.pgh.pa.us       15161                 :              0 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_SIMILAR, "!~",
                              15162                 :              0 :                                                    $1, (Node *) n, @2);
                              15163                 :                :                 }
                              15164                 :                : 
                              15165                 :                :             /* NullTest clause
                              15166                 :                :              * Define SQL-style Null test clause.
                              15167                 :                :              * Allow two forms described in the standard:
                              15168                 :                :              *  a IS NULL
                              15169                 :                :              *  a IS NOT NULL
                              15170                 :                :              * Allow two SQL extensions
                              15171                 :                :              *  a ISNULL
                              15172                 :                :              *  a NOTNULL
                              15173                 :                :              */
                              15174                 :                :             | a_expr IS NULL_P                          %prec IS
                              15175                 :                :                 {
 1212 peter@eisentraut.org    15176                 :CBC        2639 :                     NullTest   *n = makeNode(NullTest);
                              15177                 :                : 
 6918 tgl@sss.pgh.pa.us       15178                 :           2639 :                     n->arg = (Expr *) $1;
                              15179                 :           2639 :                     n->nulltesttype = IS_NULL;
 3849                         15180                 :           2639 :                     n->location = @2;
 1212 peter@eisentraut.org    15181                 :           2639 :                     $$ = (Node *) n;
                              15182                 :                :                 }
                              15183                 :                :             | a_expr ISNULL
                              15184                 :                :                 {
                              15185                 :             48 :                     NullTest   *n = makeNode(NullTest);
                              15186                 :                : 
 6918 tgl@sss.pgh.pa.us       15187                 :             48 :                     n->arg = (Expr *) $1;
                              15188                 :             48 :                     n->nulltesttype = IS_NULL;
 3849                         15189                 :             48 :                     n->location = @2;
 1212 peter@eisentraut.org    15190                 :             48 :                     $$ = (Node *) n;
                              15191                 :                :                 }
                              15192                 :                :             | a_expr IS NOT NULL_P                      %prec IS
                              15193                 :                :                 {
                              15194                 :           6429 :                     NullTest   *n = makeNode(NullTest);
                              15195                 :                : 
 6918 tgl@sss.pgh.pa.us       15196                 :           6429 :                     n->arg = (Expr *) $1;
                              15197                 :           6429 :                     n->nulltesttype = IS_NOT_NULL;
 3849                         15198                 :           6429 :                     n->location = @2;
 1212 peter@eisentraut.org    15199                 :           6429 :                     $$ = (Node *) n;
                              15200                 :                :                 }
                              15201                 :                :             | a_expr NOTNULL
                              15202                 :                :                 {
                              15203                 :              3 :                     NullTest   *n = makeNode(NullTest);
                              15204                 :                : 
 6918 tgl@sss.pgh.pa.us       15205                 :              3 :                     n->arg = (Expr *) $1;
                              15206                 :              3 :                     n->nulltesttype = IS_NOT_NULL;
 3849                         15207                 :              3 :                     n->location = @2;
 1212 peter@eisentraut.org    15208                 :              3 :                     $$ = (Node *) n;
                              15209                 :                :                 }
                              15210                 :                :             | row OVERLAPS row
                              15211                 :                :                 {
 4218 tgl@sss.pgh.pa.us       15212         [ -  + ]:            483 :                     if (list_length($1) != 2)
 4218 tgl@sss.pgh.pa.us       15213         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              15214                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                              15215                 :                :                                  errmsg("wrong number of parameters on left side of OVERLAPS expression"),
                              15216                 :                :                                  parser_errposition(@1)));
 4218 tgl@sss.pgh.pa.us       15217         [ -  + ]:CBC         483 :                     if (list_length($3) != 2)
 4218 tgl@sss.pgh.pa.us       15218         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              15219                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                              15220                 :                :                                  errmsg("wrong number of parameters on right side of OVERLAPS expression"),
                              15221                 :                :                                  parser_errposition(@3)));
 4218 tgl@sss.pgh.pa.us       15222                 :CBC         483 :                     $$ = (Node *) makeFuncCall(SystemFuncName("overlaps"),
                              15223                 :            483 :                                                list_concat($1, $3),
                              15224                 :                :                                                COERCE_SQL_SYNTAX,
                              15225                 :            483 :                                                @2);
                              15226                 :                :                 }
                              15227                 :                :             | a_expr IS TRUE_P                          %prec IS
                              15228                 :                :                 {
 8845                         15229                 :            218 :                     BooleanTest *b = makeNode(BooleanTest);
                              15230                 :                : 
 8304                         15231                 :            218 :                     b->arg = (Expr *) $1;
 8845                         15232                 :            218 :                     b->booltesttype = IS_TRUE;
 3849                         15233                 :            218 :                     b->location = @2;
 1212 peter@eisentraut.org    15234                 :            218 :                     $$ = (Node *) b;
                              15235                 :                :                 }
                              15236                 :                :             | a_expr IS NOT TRUE_P                      %prec IS
                              15237                 :                :                 {
 8845 tgl@sss.pgh.pa.us       15238                 :             70 :                     BooleanTest *b = makeNode(BooleanTest);
                              15239                 :                : 
 8304                         15240                 :             70 :                     b->arg = (Expr *) $1;
 8845                         15241                 :             70 :                     b->booltesttype = IS_NOT_TRUE;
 3849                         15242                 :             70 :                     b->location = @2;
 1212 peter@eisentraut.org    15243                 :             70 :                     $$ = (Node *) b;
                              15244                 :                :                 }
                              15245                 :                :             | a_expr IS FALSE_P                         %prec IS
                              15246                 :                :                 {
 8845 tgl@sss.pgh.pa.us       15247                 :             77 :                     BooleanTest *b = makeNode(BooleanTest);
                              15248                 :                : 
 8304                         15249                 :             77 :                     b->arg = (Expr *) $1;
 8845                         15250                 :             77 :                     b->booltesttype = IS_FALSE;
 3849                         15251                 :             77 :                     b->location = @2;
 1212 peter@eisentraut.org    15252                 :             77 :                     $$ = (Node *) b;
                              15253                 :                :                 }
                              15254                 :                :             | a_expr IS NOT FALSE_P                     %prec IS
                              15255                 :                :                 {
 8845 tgl@sss.pgh.pa.us       15256                 :             46 :                     BooleanTest *b = makeNode(BooleanTest);
                              15257                 :                : 
 8304                         15258                 :             46 :                     b->arg = (Expr *) $1;
 8845                         15259                 :             46 :                     b->booltesttype = IS_NOT_FALSE;
 3849                         15260                 :             46 :                     b->location = @2;
 1212 peter@eisentraut.org    15261                 :             46 :                     $$ = (Node *) b;
                              15262                 :                :                 }
                              15263                 :                :             | a_expr IS UNKNOWN                         %prec IS
                              15264                 :                :                 {
 8845 tgl@sss.pgh.pa.us       15265                 :             26 :                     BooleanTest *b = makeNode(BooleanTest);
                              15266                 :                : 
 8304                         15267                 :             26 :                     b->arg = (Expr *) $1;
 8845                         15268                 :             26 :                     b->booltesttype = IS_UNKNOWN;
 3849                         15269                 :             26 :                     b->location = @2;
 1212 peter@eisentraut.org    15270                 :             26 :                     $$ = (Node *) b;
                              15271                 :                :                 }
                              15272                 :                :             | a_expr IS NOT UNKNOWN                     %prec IS
                              15273                 :                :                 {
 8845 tgl@sss.pgh.pa.us       15274                 :             24 :                     BooleanTest *b = makeNode(BooleanTest);
                              15275                 :                : 
 8304                         15276                 :             24 :                     b->arg = (Expr *) $1;
 8845                         15277                 :             24 :                     b->booltesttype = IS_NOT_UNKNOWN;
 3849                         15278                 :             24 :                     b->location = @2;
 1212 peter@eisentraut.org    15279                 :             24 :                     $$ = (Node *) b;
                              15280                 :                :                 }
                              15281                 :                :             | a_expr IS DISTINCT FROM a_expr            %prec IS
                              15282                 :                :                 {
 7116 tgl@sss.pgh.pa.us       15283                 :            543 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", $1, $5, @2);
                              15284                 :                :                 }
                              15285                 :                :             | a_expr IS NOT DISTINCT FROM a_expr        %prec IS
                              15286                 :                :                 {
 3327                         15287                 :             34 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_NOT_DISTINCT, "=", $1, $6, @2);
                              15288                 :                :                 }
                              15289                 :                :             | a_expr BETWEEN opt_asymmetric b_expr AND a_expr       %prec BETWEEN
                              15290                 :                :                 {
 3849                         15291                 :            233 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_BETWEEN,
                              15292                 :                :                                                    "BETWEEN",
                              15293                 :            233 :                                                    $1,
                              15294                 :            233 :                                                    (Node *) list_make2($4, $6),
                              15295                 :            233 :                                                    @2);
                              15296                 :                :                 }
                              15297                 :                :             | a_expr NOT_LA BETWEEN opt_asymmetric b_expr AND a_expr %prec NOT_LA
                              15298                 :                :                 {
                              15299                 :              6 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_NOT_BETWEEN,
                              15300                 :                :                                                    "NOT BETWEEN",
                              15301                 :              6 :                                                    $1,
                              15302                 :              6 :                                                    (Node *) list_make2($5, $7),
                              15303                 :              6 :                                                    @2);
                              15304                 :                :                 }
                              15305                 :                :             | a_expr BETWEEN SYMMETRIC b_expr AND a_expr            %prec BETWEEN
                              15306                 :                :                 {
                              15307                 :              6 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_BETWEEN_SYM,
                              15308                 :                :                                                    "BETWEEN SYMMETRIC",
                              15309                 :              6 :                                                    $1,
                              15310                 :              6 :                                                    (Node *) list_make2($4, $6),
                              15311                 :              6 :                                                    @2);
                              15312                 :                :                 }
                              15313                 :                :             | a_expr NOT_LA BETWEEN SYMMETRIC b_expr AND a_expr     %prec NOT_LA
                              15314                 :                :                 {
                              15315                 :              6 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_NOT_BETWEEN_SYM,
                              15316                 :                :                                                    "NOT BETWEEN SYMMETRIC",
                              15317                 :              6 :                                                    $1,
                              15318                 :              6 :                                                    (Node *) list_make2($5, $7),
                              15319                 :              6 :                                                    @2);
                              15320                 :                :                 }
                              15321                 :                :             | a_expr IN_P select_with_parens
                              15322                 :                :                 {
                              15323                 :                :                     /* generate foo = ANY (subquery) */
   86 alvherre@kurilemu.de    15324                 :           2755 :                     SubLink    *n = makeNode(SubLink);
                              15325                 :                : 
                              15326                 :           2755 :                     n->subselect = $3;
                              15327                 :           2755 :                     n->subLinkType = ANY_SUBLINK;
                              15328                 :           2755 :                     n->subLinkId = 0;
                              15329                 :           2755 :                     n->testexpr = $1;
                              15330                 :           2755 :                     n->operName = NIL;       /* show it's IN not = ANY */
                              15331                 :           2755 :                     n->location = @2;
                              15332                 :           2755 :                     $$ = (Node *) n;
                              15333                 :                :                 }
                              15334                 :                :             | a_expr IN_P '(' expr_list ')'
                              15335                 :                :                 {
                              15336                 :                :                     /* generate scalar IN expression */
                              15337                 :           9254 :                     A_Expr *n = makeSimpleA_Expr(AEXPR_IN, "=", $1, (Node *) $4, @2);
                              15338                 :                : 
                              15339                 :           9254 :                     n->rexpr_list_start = @3;
                              15340                 :           9254 :                     n->rexpr_list_end = @5;
                              15341                 :           9254 :                     $$ = (Node *) n;
                              15342                 :                :                 }
                              15343                 :                :             | a_expr NOT_LA IN_P select_with_parens         %prec NOT_LA
                              15344                 :                :                 {
                              15345                 :                :                     /* generate NOT (foo = ANY (subquery)) */
                              15346                 :             60 :                     SubLink    *n = makeNode(SubLink);
                              15347                 :                : 
                              15348                 :             60 :                     n->subselect = $4;
                              15349                 :             60 :                     n->subLinkType = ANY_SUBLINK;
                              15350                 :             60 :                     n->subLinkId = 0;
                              15351                 :             60 :                     n->testexpr = $1;
                              15352                 :             60 :                     n->operName = NIL;       /* show it's IN not = ANY */
                              15353                 :             60 :                     n->location = @2;
                              15354                 :                :                     /* Stick a NOT on top; must have same parse location */
                              15355                 :             60 :                     $$ = makeNotExpr((Node *) n, @2);
                              15356                 :                :                 }
                              15357                 :                :             | a_expr NOT_LA IN_P '(' expr_list ')'
                              15358                 :                :                 {
                              15359                 :                :                     /* generate scalar NOT IN expression */
                              15360                 :           1341 :                     A_Expr *n = makeSimpleA_Expr(AEXPR_IN, "<>", $1, (Node *) $5, @2);
                              15361                 :                : 
                              15362                 :           1341 :                     n->rexpr_list_start = @4;
                              15363                 :           1341 :                     n->rexpr_list_end = @6;
                              15364                 :           1341 :                     $$ = (Node *) n;
                              15365                 :                :                 }
                              15366                 :                :             | a_expr subquery_Op sub_type select_with_parens    %prec Op
                              15367                 :                :                 {
 1212 peter@eisentraut.org    15368                 :             90 :                     SubLink    *n = makeNode(SubLink);
                              15369                 :                : 
 9427 tgl@sss.pgh.pa.us       15370                 :             90 :                     n->subLinkType = $3;
 4098                         15371                 :             90 :                     n->subLinkId = 0;
 7192                         15372                 :             90 :                     n->testexpr = $1;
 8275                         15373                 :             90 :                     n->operName = $2;
 9000                         15374                 :             90 :                     n->subselect = $4;
 6218                         15375                 :             90 :                     n->location = @2;
 1212 peter@eisentraut.org    15376                 :             90 :                     $$ = (Node *) n;
                              15377                 :                :                 }
                              15378                 :                :             | a_expr subquery_Op sub_type '(' a_expr ')'        %prec Op
                              15379                 :                :                 {
 8105 tgl@sss.pgh.pa.us       15380         [ +  + ]:           8445 :                     if ($3 == ANY_SUBLINK)
 7116                         15381                 :           8295 :                         $$ = (Node *) makeA_Expr(AEXPR_OP_ANY, $2, $1, $5, @2);
                              15382                 :                :                     else
                              15383                 :            150 :                         $$ = (Node *) makeA_Expr(AEXPR_OP_ALL, $2, $1, $5, @2);
                              15384                 :                :                 }
                              15385                 :                :             | UNIQUE opt_unique_null_treatment select_with_parens
                              15386                 :                :                 {
                              15387                 :                :                     /* Not sure how to get rid of the parentheses
                              15388                 :                :                      * but there are lots of shift/reduce errors without them.
                              15389                 :                :                      *
                              15390                 :                :                      * Should be able to implement this by plopping the entire
                              15391                 :                :                      * select into a node, then transforming the target expressions
                              15392                 :                :                      * from whatever they are into count(*), and testing the
                              15393                 :                :                      * entire result equal to one.
                              15394                 :                :                      * But, will probably implement a separate node in the executor.
                              15395                 :                :                      */
 8085 tgl@sss.pgh.pa.us       15396         [ #  # ]:UBC           0 :                     ereport(ERROR,
                              15397                 :                :                             (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              15398                 :                :                              errmsg("UNIQUE predicate is not yet implemented"),
                              15399                 :                :                              parser_errposition(@1)));
                              15400                 :                :                 }
                              15401                 :                :             | a_expr IS DOCUMENT_P                  %prec IS
                              15402                 :                :                 {
 6218 tgl@sss.pgh.pa.us       15403                 :CBC           9 :                     $$ = makeXmlExpr(IS_DOCUMENT, NULL, NIL,
                              15404                 :              9 :                                      list_make1($1), @2);
                              15405                 :                :                 }
                              15406                 :                :             | a_expr IS NOT DOCUMENT_P              %prec IS
                              15407                 :                :                 {
 4100                         15408                 :              9 :                     $$ = makeNotExpr(makeXmlExpr(IS_DOCUMENT, NULL, NIL,
                              15409                 :              9 :                                                  list_make1($1), @2),
                              15410                 :              9 :                                      @2);
                              15411                 :                :                 }
                              15412                 :                :             | a_expr IS NORMALIZED                              %prec IS
                              15413                 :                :                 {
 1767                         15414                 :              6 :                     $$ = (Node *) makeFuncCall(SystemFuncName("is_normalized"),
                              15415                 :              6 :                                                list_make1($1),
                              15416                 :                :                                                COERCE_SQL_SYNTAX,
                              15417                 :              6 :                                                @2);
                              15418                 :                :                 }
                              15419                 :                :             | a_expr IS unicode_normal_form NORMALIZED          %prec IS
                              15420                 :                :                 {
                              15421                 :             18 :                     $$ = (Node *) makeFuncCall(SystemFuncName("is_normalized"),
                              15422                 :             18 :                                                list_make2($1, makeStringConst($3, @3)),
                              15423                 :                :                                                COERCE_SQL_SYNTAX,
                              15424                 :             18 :                                                @2);
                              15425                 :                :                 }
                              15426                 :                :             | a_expr IS NOT NORMALIZED                          %prec IS
                              15427                 :                :                 {
 1767 tgl@sss.pgh.pa.us       15428                 :UBC           0 :                     $$ = makeNotExpr((Node *) makeFuncCall(SystemFuncName("is_normalized"),
                              15429                 :              0 :                                                            list_make1($1),
                              15430                 :                :                                                            COERCE_SQL_SYNTAX,
                              15431                 :              0 :                                                            @2),
                              15432                 :              0 :                                      @2);
                              15433                 :                :                 }
                              15434                 :                :             | a_expr IS NOT unicode_normal_form NORMALIZED      %prec IS
                              15435                 :                :                 {
                              15436                 :              0 :                     $$ = makeNotExpr((Node *) makeFuncCall(SystemFuncName("is_normalized"),
                              15437                 :              0 :                                                            list_make2($1, makeStringConst($4, @4)),
                              15438                 :                :                                                            COERCE_SQL_SYNTAX,
                              15439                 :              0 :                                                            @2),
                              15440                 :              0 :                                      @2);
                              15441                 :                :                 }
                              15442                 :                :             | a_expr IS json_predicate_type_constraint
                              15443                 :                :                     json_key_uniqueness_constraint_opt      %prec IS
                              15444                 :                :                 {
  890 alvherre@alvh.no-ip.    15445                 :CBC         145 :                     JsonFormat *format = makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1);
                              15446                 :                : 
                              15447                 :            145 :                     $$ = makeJsonIsPredicate($1, format, $3, $4, @1);
                              15448                 :                :                 }
                              15449                 :                :             /*
                              15450                 :                :              * Required by SQL/JSON, but there are conflicts
                              15451                 :                :             | a_expr
                              15452                 :                :                 json_format_clause
                              15453                 :                :                 IS  json_predicate_type_constraint
                              15454                 :                :                     json_key_uniqueness_constraint_opt      %prec IS
                              15455                 :                :                 {
                              15456                 :                :                     $$ = makeJsonIsPredicate($1, $2, $4, $5, @1);
                              15457                 :                :                 }
                              15458                 :                :             */
                              15459                 :                :             | a_expr IS NOT
                              15460                 :                :                     json_predicate_type_constraint
                              15461                 :                :                     json_key_uniqueness_constraint_opt      %prec IS
                              15462                 :                :                 {
                              15463                 :             22 :                     JsonFormat *format = makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1);
                              15464                 :                : 
                              15465                 :             22 :                     $$ = makeNotExpr(makeJsonIsPredicate($1, format, $4, $5, @1), @1);
                              15466                 :                :                 }
                              15467                 :                :             /*
                              15468                 :                :              * Required by SQL/JSON, but there are conflicts
                              15469                 :                :             | a_expr
                              15470                 :                :                 json_format_clause
                              15471                 :                :                 IS NOT
                              15472                 :                :                     json_predicate_type_constraint
                              15473                 :                :                     json_key_uniqueness_constraint_opt      %prec IS
                              15474                 :                :                 {
                              15475                 :                :                     $$ = makeNotExpr(makeJsonIsPredicate($1, $2, $5, $6, @1), @1);
                              15476                 :                :                 }
                              15477                 :                :             */
                              15478                 :                :             | DEFAULT
                              15479                 :                :                 {
                              15480                 :                :                     /*
                              15481                 :                :                      * The SQL spec only allows DEFAULT in "contextually typed
                              15482                 :                :                      * expressions", but for us, it's easier to allow it in
                              15483                 :                :                      * any a_expr and then throw error during parse analysis
                              15484                 :                :                      * if it's in an inappropriate context.  This way also
                              15485                 :                :                      * lets us say something smarter than "syntax error".
                              15486                 :                :                      */
 3210 tgl@sss.pgh.pa.us       15487                 :            794 :                     SetToDefault *n = makeNode(SetToDefault);
                              15488                 :                : 
                              15489                 :                :                     /* parse analysis will fill in the rest */
                              15490                 :            794 :                     n->location = @1;
 1212 peter@eisentraut.org    15491                 :            794 :                     $$ = (Node *) n;
                              15492                 :                :                 }
                              15493                 :                :         ;
                              15494                 :                : 
                              15495                 :                : /*
                              15496                 :                :  * Restricted expressions
                              15497                 :                :  *
                              15498                 :                :  * b_expr is a subset of the complete expression syntax defined by a_expr.
                              15499                 :                :  *
                              15500                 :                :  * Presently, AND, NOT, IS, and IN are the a_expr keywords that would
                              15501                 :                :  * cause trouble in the places where b_expr is used.  For simplicity, we
                              15502                 :                :  * just eliminate all the boolean-keyword-operator productions from b_expr.
                              15503                 :                :  */
                              15504                 :                : b_expr:     c_expr
 8482 bruce@momjian.us        15505                 :           1877 :                 { $$ = $1; }
                              15506                 :                :             | b_expr TYPECAST Typename
 6218 tgl@sss.pgh.pa.us       15507                 :            106 :                 { $$ = makeTypeCast($1, $3, @2); }
                              15508                 :                :             | '+' b_expr                    %prec UMINUS
 7116 tgl@sss.pgh.pa.us       15509                 :UBC           0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", NULL, $2, @1); }
                              15510                 :                :             | '-' b_expr                    %prec UMINUS
 7116 tgl@sss.pgh.pa.us       15511                 :CBC          33 :                 { $$ = doNegate($2, @1); }
                              15512                 :                :             | b_expr '+' b_expr
                              15513                 :             18 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", $1, $3, @2); }
                              15514                 :                :             | b_expr '-' b_expr
                              15515                 :              6 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "-", $1, $3, @2); }
                              15516                 :                :             | b_expr '*' b_expr
                              15517                 :              6 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "*", $1, $3, @2); }
                              15518                 :                :             | b_expr '/' b_expr
 7116 tgl@sss.pgh.pa.us       15519                 :UBC           0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "/", $1, $3, @2); }
                              15520                 :                :             | b_expr '%' b_expr
                              15521                 :              0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "%", $1, $3, @2); }
                              15522                 :                :             | b_expr '^' b_expr
 7116 tgl@sss.pgh.pa.us       15523                 :CBC           3 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "^", $1, $3, @2); }
                              15524                 :                :             | b_expr '<' b_expr
 7116 tgl@sss.pgh.pa.us       15525                 :UBC           0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $3, @2); }
                              15526                 :                :             | b_expr '>' b_expr
                              15527                 :              0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $3, @2); }
                              15528                 :                :             | b_expr '=' b_expr
                              15529                 :              0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "=", $1, $3, @2); }
                              15530                 :                :             | b_expr LESS_EQUALS b_expr
 3832                         15531                 :              0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $3, @2); }
                              15532                 :                :             | b_expr GREATER_EQUALS b_expr
                              15533                 :              0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $3, @2); }
                              15534                 :                :             | b_expr NOT_EQUALS b_expr
                              15535                 :              0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<>", $1, $3, @2); }
                              15536                 :                :             | b_expr qual_Op b_expr             %prec Op
 7116 tgl@sss.pgh.pa.us       15537                 :CBC           6 :                 { $$ = (Node *) makeA_Expr(AEXPR_OP, $2, $1, $3, @2); }
                              15538                 :                :             | qual_Op b_expr                    %prec Op
 7116 tgl@sss.pgh.pa.us       15539                 :UBC           0 :                 { $$ = (Node *) makeA_Expr(AEXPR_OP, $1, NULL, $2, @1); }
                              15540                 :                :             | b_expr IS DISTINCT FROM b_expr        %prec IS
                              15541                 :                :                 {
                              15542                 :              0 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", $1, $5, @2);
                              15543                 :                :                 }
                              15544                 :                :             | b_expr IS NOT DISTINCT FROM b_expr    %prec IS
                              15545                 :                :                 {
 3327                         15546                 :              0 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_NOT_DISTINCT, "=", $1, $6, @2);
                              15547                 :                :                 }
                              15548                 :                :             | b_expr IS DOCUMENT_P                  %prec IS
                              15549                 :                :                 {
 6218                         15550                 :              0 :                     $$ = makeXmlExpr(IS_DOCUMENT, NULL, NIL,
                              15551                 :              0 :                                      list_make1($1), @2);
                              15552                 :                :                 }
                              15553                 :                :             | b_expr IS NOT DOCUMENT_P              %prec IS
                              15554                 :                :                 {
 4100                         15555                 :              0 :                     $$ = makeNotExpr(makeXmlExpr(IS_DOCUMENT, NULL, NIL,
                              15556                 :              0 :                                                  list_make1($1), @2),
                              15557                 :              0 :                                      @2);
                              15558                 :                :                 }
                              15559                 :                :         ;
                              15560                 :                : 
                              15561                 :                : /*
                              15562                 :                :  * Productions that can be used in both a_expr and b_expr.
                              15563                 :                :  *
                              15564                 :                :  * Note: productions that refer recursively to a_expr or b_expr mostly
                              15565                 :                :  * cannot appear here.  However, it's OK to refer to a_exprs that occur
                              15566                 :                :  * inside parentheses, such as function arguments; that cannot introduce
                              15567                 :                :  * ambiguity to the b_expr syntax.
                              15568                 :                :  */
 7759 tgl@sss.pgh.pa.us       15569                 :CBC      923293 : c_expr:     columnref                               { $$ = $1; }
 8482 bruce@momjian.us        15570                 :         627230 :             | AexprConst                            { $$ = $1; }
                              15571                 :                :             | PARAM opt_indirection
                              15572                 :                :                 {
 1212 peter@eisentraut.org    15573                 :          21126 :                     ParamRef   *p = makeNode(ParamRef);
                              15574                 :                : 
 7759 tgl@sss.pgh.pa.us       15575                 :          21126 :                     p->number = $1;
 6218                         15576                 :          21126 :                     p->location = @1;
 7759                         15577         [ +  + ]:          21126 :                     if ($2)
                              15578                 :                :                     {
                              15579                 :            542 :                         A_Indirection *n = makeNode(A_Indirection);
                              15580                 :                : 
                              15581                 :            542 :                         n->arg = (Node *) p;
 5899                         15582                 :            542 :                         n->indirection = check_indirection($2, yyscanner);
 7759                         15583                 :            542 :                         $$ = (Node *) n;
                              15584                 :                :                     }
                              15585                 :                :                     else
                              15586                 :          20584 :                         $$ = (Node *) p;
                              15587                 :                :                 }
                              15588                 :                :             | '(' a_expr ')' opt_indirection
                              15589                 :                :                 {
 8187                         15590         [ +  + ]:          44929 :                     if ($4)
                              15591                 :                :                     {
 7759                         15592                 :           6171 :                         A_Indirection *n = makeNode(A_Indirection);
                              15593                 :                : 
 8187                         15594                 :           6171 :                         n->arg = $2;
 5899                         15595                 :           6171 :                         n->indirection = check_indirection($4, yyscanner);
 1212 peter@eisentraut.org    15596                 :           6171 :                         $$ = (Node *) n;
                              15597                 :                :                     }
                              15598                 :                :                     else
 8187 tgl@sss.pgh.pa.us       15599                 :          38758 :                         $$ = $2;
                              15600                 :                :                 }
                              15601                 :                :             | case_expr
 8482 bruce@momjian.us        15602                 :          19591 :                 { $$ = $1; }
                              15603                 :                :             | func_expr
 7647 tgl@sss.pgh.pa.us       15604                 :         194981 :                 { $$ = $1; }
                              15605                 :                :             | select_with_parens            %prec UMINUS
                              15606                 :                :                 {
 1212 peter@eisentraut.org    15607                 :          13939 :                     SubLink    *n = makeNode(SubLink);
                              15608                 :                : 
 7647 tgl@sss.pgh.pa.us       15609                 :          13939 :                     n->subLinkType = EXPR_SUBLINK;
 4098                         15610                 :          13939 :                     n->subLinkId = 0;
 7192                         15611                 :          13939 :                     n->testexpr = NULL;
 7647                         15612                 :          13939 :                     n->operName = NIL;
                              15613                 :          13939 :                     n->subselect = $1;
 6218                         15614                 :          13939 :                     n->location = @1;
 1212 peter@eisentraut.org    15615                 :          13939 :                     $$ = (Node *) n;
                              15616                 :                :                 }
                              15617                 :                :             | select_with_parens indirection
                              15618                 :                :                 {
                              15619                 :                :                     /*
                              15620                 :                :                      * Because the select_with_parens nonterminal is designed
                              15621                 :                :                      * to "eat" as many levels of parens as possible, the
                              15622                 :                :                      * '(' a_expr ')' opt_indirection production above will
                              15623                 :                :                      * fail to match a sub-SELECT with indirection decoration;
                              15624                 :                :                      * the sub-SELECT won't be regarded as an a_expr as long
                              15625                 :                :                      * as there are parens around it.  To support applying
                              15626                 :                :                      * subscripting or field selection to a sub-SELECT result,
                              15627                 :                :                      * we need this redundant-looking production.
                              15628                 :                :                      */
                              15629                 :              9 :                     SubLink    *n = makeNode(SubLink);
 4602 tgl@sss.pgh.pa.us       15630                 :              9 :                     A_Indirection *a = makeNode(A_Indirection);
                              15631                 :                : 
                              15632                 :              9 :                     n->subLinkType = EXPR_SUBLINK;
 4098                         15633                 :              9 :                     n->subLinkId = 0;
 4602                         15634                 :              9 :                     n->testexpr = NULL;
                              15635                 :              9 :                     n->operName = NIL;
                              15636                 :              9 :                     n->subselect = $1;
                              15637                 :              9 :                     n->location = @1;
 1212 peter@eisentraut.org    15638                 :              9 :                     a->arg = (Node *) n;
 4602 tgl@sss.pgh.pa.us       15639                 :              9 :                     a->indirection = check_indirection($2, yyscanner);
 1212 peter@eisentraut.org    15640                 :              9 :                     $$ = (Node *) a;
                              15641                 :                :                 }
                              15642                 :                :             | EXISTS select_with_parens
                              15643                 :                :                 {
                              15644                 :           3070 :                     SubLink    *n = makeNode(SubLink);
                              15645                 :                : 
 7647 tgl@sss.pgh.pa.us       15646                 :           3070 :                     n->subLinkType = EXISTS_SUBLINK;
 4098                         15647                 :           3070 :                     n->subLinkId = 0;
 7192                         15648                 :           3070 :                     n->testexpr = NULL;
 7647                         15649                 :           3070 :                     n->operName = NIL;
                              15650                 :           3070 :                     n->subselect = $2;
 6218                         15651                 :           3070 :                     n->location = @1;
 1212 peter@eisentraut.org    15652                 :           3070 :                     $$ = (Node *) n;
                              15653                 :                :                 }
                              15654                 :                :             | ARRAY select_with_parens
                              15655                 :                :                 {
                              15656                 :           4230 :                     SubLink    *n = makeNode(SubLink);
                              15657                 :                : 
 7647 tgl@sss.pgh.pa.us       15658                 :           4230 :                     n->subLinkType = ARRAY_SUBLINK;
 4098                         15659                 :           4230 :                     n->subLinkId = 0;
 7192                         15660                 :           4230 :                     n->testexpr = NULL;
 7647                         15661                 :           4230 :                     n->operName = NIL;
                              15662                 :           4230 :                     n->subselect = $2;
 6218                         15663                 :           4230 :                     n->location = @1;
 1212 peter@eisentraut.org    15664                 :           4230 :                     $$ = (Node *) n;
                              15665                 :                :                 }
                              15666                 :                :             | ARRAY array_expr
                              15667                 :                :                 {
 3119 peter_e@gmx.net         15668                 :           3695 :                     A_ArrayExpr *n = castNode(A_ArrayExpr, $2);
                              15669                 :                : 
                              15670                 :                :                     /* point outermost A_ArrayExpr to the ARRAY keyword */
 6218 tgl@sss.pgh.pa.us       15671                 :           3695 :                     n->location = @1;
 1212 peter@eisentraut.org    15672                 :           3695 :                     $$ = (Node *) n;
                              15673                 :                :                 }
                              15674                 :                :             | explicit_row
                              15675                 :                :                 {
                              15676                 :           1908 :                     RowExpr    *r = makeNode(RowExpr);
                              15677                 :                : 
 3766 andres@anarazel.de      15678                 :           1908 :                     r->args = $1;
                              15679                 :           1908 :                     r->row_typeid = InvalidOid;  /* not analyzed yet */
                              15680                 :           1908 :                     r->colnames = NIL;   /* to be filled in during analysis */
                              15681                 :           1908 :                     r->row_format = COERCE_EXPLICIT_CALL; /* abuse */
                              15682                 :           1908 :                     r->location = @1;
 1212 peter@eisentraut.org    15683                 :           1908 :                     $$ = (Node *) r;
                              15684                 :                :                 }
                              15685                 :                :             | implicit_row
                              15686                 :                :                 {
                              15687                 :           1352 :                     RowExpr    *r = makeNode(RowExpr);
                              15688                 :                : 
 7647 tgl@sss.pgh.pa.us       15689                 :           1352 :                     r->args = $1;
                              15690                 :           1352 :                     r->row_typeid = InvalidOid;  /* not analyzed yet */
 4953                         15691                 :           1352 :                     r->colnames = NIL;   /* to be filled in during analysis */
 3766 andres@anarazel.de      15692                 :           1352 :                     r->row_format = COERCE_IMPLICIT_CAST; /* abuse */
 6218 tgl@sss.pgh.pa.us       15693                 :           1352 :                     r->location = @1;
 1212 peter@eisentraut.org    15694                 :           1352 :                     $$ = (Node *) r;
                              15695                 :                :                 }
                              15696                 :                :             | GROUPING '(' expr_list ')'
                              15697                 :                :               {
 3766 andres@anarazel.de      15698                 :            181 :                   GroupingFunc *g = makeNode(GroupingFunc);
                              15699                 :                : 
                              15700                 :            181 :                   g->args = $3;
                              15701                 :            181 :                   g->location = @1;
 1212 peter@eisentraut.org    15702                 :            181 :                   $$ = (Node *) g;
                              15703                 :                :               }
                              15704                 :                :         ;
                              15705                 :                : 
                              15706                 :                : func_application: func_name '(' ')'
                              15707                 :                :                 {
 1767 tgl@sss.pgh.pa.us       15708                 :          16485 :                     $$ = (Node *) makeFuncCall($1, NIL,
                              15709                 :                :                                                COERCE_EXPLICIT_CALL,
                              15710                 :          16485 :                                                @1);
                              15711                 :                :                 }
                              15712                 :                :             | func_name '(' func_arg_list opt_sort_clause ')'
                              15713                 :                :                 {
 1212 peter@eisentraut.org    15714                 :         157974 :                     FuncCall   *n = makeFuncCall($1, $3,
                              15715                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15716                 :         157974 :                                                  @1);
                              15717                 :                : 
 4275 tgl@sss.pgh.pa.us       15718                 :         157974 :                     n->agg_order = $4;
 1212 peter@eisentraut.org    15719                 :         157974 :                     $$ = (Node *) n;
                              15720                 :                :                 }
                              15721                 :                :             | func_name '(' VARIADIC func_arg_expr opt_sort_clause ')'
                              15722                 :                :                 {
                              15723                 :            309 :                     FuncCall   *n = makeFuncCall($1, list_make1($4),
                              15724                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15725                 :            309 :                                                  @1);
                              15726                 :                : 
 2943 peter_e@gmx.net         15727                 :            309 :                     n->func_variadic = true;
 4275 tgl@sss.pgh.pa.us       15728                 :            309 :                     n->agg_order = $5;
 1212 peter@eisentraut.org    15729                 :            309 :                     $$ = (Node *) n;
                              15730                 :                :                 }
                              15731                 :                :             | func_name '(' func_arg_list ',' VARIADIC func_arg_expr opt_sort_clause ')'
                              15732                 :                :                 {
                              15733                 :             60 :                     FuncCall   *n = makeFuncCall($1, lappend($3, $6),
                              15734                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15735                 :             60 :                                                  @1);
                              15736                 :                : 
 2943 peter_e@gmx.net         15737                 :             60 :                     n->func_variadic = true;
 4275 tgl@sss.pgh.pa.us       15738                 :             60 :                     n->agg_order = $7;
 1212 peter@eisentraut.org    15739                 :             60 :                     $$ = (Node *) n;
                              15740                 :                :                 }
                              15741                 :                :             | func_name '(' ALL func_arg_list opt_sort_clause ')'
                              15742                 :                :                 {
 1212 peter@eisentraut.org    15743                 :UBC           0 :                     FuncCall   *n = makeFuncCall($1, $4,
                              15744                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15745                 :              0 :                                                  @1);
                              15746                 :                : 
 5744 tgl@sss.pgh.pa.us       15747                 :              0 :                     n->agg_order = $5;
                              15748                 :                :                     /* Ideally we'd mark the FuncCall node to indicate
                              15749                 :                :                      * "must be an aggregate", but there's no provision
                              15750                 :                :                      * for that in FuncCall at the moment.
                              15751                 :                :                      */
 1212 peter@eisentraut.org    15752                 :              0 :                     $$ = (Node *) n;
                              15753                 :                :                 }
                              15754                 :                :             | func_name '(' DISTINCT func_arg_list opt_sort_clause ')'
                              15755                 :                :                 {
 1212 peter@eisentraut.org    15756                 :CBC         275 :                     FuncCall   *n = makeFuncCall($1, $4,
                              15757                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15758                 :            275 :                                                  @1);
                              15759                 :                : 
 5744 tgl@sss.pgh.pa.us       15760                 :            275 :                     n->agg_order = $5;
 2943 peter_e@gmx.net         15761                 :            275 :                     n->agg_distinct = true;
 1212 peter@eisentraut.org    15762                 :            275 :                     $$ = (Node *) n;
                              15763                 :                :                 }
                              15764                 :                :             | func_name '(' '*' ')'
                              15765                 :                :                 {
                              15766                 :                :                     /*
                              15767                 :                :                      * We consider AGGREGATE(*) to invoke a parameterless
                              15768                 :                :                      * aggregate.  This does the right thing for COUNT(*),
                              15769                 :                :                      * and there are no other aggregates in SQL that accept
                              15770                 :                :                      * '*' as parameter.
                              15771                 :                :                      *
                              15772                 :                :                      * The FuncCall node is also marked agg_star = true,
                              15773                 :                :                      * so that later processing can detect what the argument
                              15774                 :                :                      * really was.
                              15775                 :                :                      */
                              15776                 :           6323 :                     FuncCall   *n = makeFuncCall($1, NIL,
                              15777                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15778                 :           6323 :                                                  @1);
                              15779                 :                : 
 2943 peter_e@gmx.net         15780                 :           6323 :                     n->agg_star = true;
 1212 peter@eisentraut.org    15781                 :           6323 :                     $$ = (Node *) n;
                              15782                 :                :                 }
                              15783                 :                :         ;
                              15784                 :                : 
                              15785                 :                : 
                              15786                 :                : /*
                              15787                 :                :  * func_expr and its cousin func_expr_windowless are split out from c_expr just
                              15788                 :                :  * so that we have classifications for "everything that is a function call or
                              15789                 :                :  * looks like one".  This isn't very important, but it saves us having to
                              15790                 :                :  * document which variants are legal in places like "FROM function()" or the
                              15791                 :                :  * backwards-compatible functional-index syntax for CREATE INDEX.
                              15792                 :                :  * (Note that many of the special SQL functions wouldn't actually make any
                              15793                 :                :  * sense as functional index entries, but we ignore that consideration here.)
                              15794                 :                :  */
                              15795                 :                : func_expr: func_application within_group_clause filter_clause over_clause
                              15796                 :                :                 {
                              15797                 :         156686 :                     FuncCall   *n = (FuncCall *) $1;
                              15798                 :                : 
                              15799                 :                :                     /*
                              15800                 :                :                      * The order clause for WITHIN GROUP and the one for
                              15801                 :                :                      * plain-aggregate ORDER BY share a field, so we have to
                              15802                 :                :                      * check here that at most one is present.  We also check
                              15803                 :                :                      * for DISTINCT and VARIADIC here to give a better error
                              15804                 :                :                      * location.  Other consistency checks are deferred to
                              15805                 :                :                      * parse analysis.
                              15806                 :                :                      */
 4275 tgl@sss.pgh.pa.us       15807         [ +  + ]:         156686 :                     if ($2 != NIL)
                              15808                 :                :                     {
                              15809         [ +  + ]:            174 :                         if (n->agg_order != NIL)
                              15810         [ +  - ]:              3 :                             ereport(ERROR,
                              15811                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              15812                 :                :                                      errmsg("cannot use multiple ORDER BY clauses with WITHIN GROUP"),
                              15813                 :                :                                      parser_errposition(@2)));
                              15814         [ -  + ]:            171 :                         if (n->agg_distinct)
 4275 tgl@sss.pgh.pa.us       15815         [ #  # ]:UBC           0 :                             ereport(ERROR,
                              15816                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              15817                 :                :                                      errmsg("cannot use DISTINCT with WITHIN GROUP"),
                              15818                 :                :                                      parser_errposition(@2)));
 4275 tgl@sss.pgh.pa.us       15819         [ -  + ]:CBC         171 :                         if (n->func_variadic)
 4275 tgl@sss.pgh.pa.us       15820         [ #  # ]:UBC           0 :                             ereport(ERROR,
                              15821                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              15822                 :                :                                      errmsg("cannot use VARIADIC with WITHIN GROUP"),
                              15823                 :                :                                      parser_errposition(@2)));
 4275 tgl@sss.pgh.pa.us       15824                 :CBC         171 :                         n->agg_order = $2;
 2943 peter_e@gmx.net         15825                 :            171 :                         n->agg_within_group = true;
                              15826                 :                :                     }
 4275 tgl@sss.pgh.pa.us       15827                 :         156683 :                     n->agg_filter = $3;
                              15828                 :         156683 :                     n->over = $4;
                              15829                 :         156683 :                     $$ = (Node *) n;
                              15830                 :                :                 }
                              15831                 :                :             | json_aggregate_func filter_clause over_clause
                              15832                 :                :                 {
  892 alvherre@alvh.no-ip.    15833                 :            360 :                     JsonAggConstructor *n = IsA($1, JsonObjectAgg) ?
                              15834         [ +  + ]:            180 :                         ((JsonObjectAgg *) $1)->constructor :
                              15835                 :             78 :                         ((JsonArrayAgg *) $1)->constructor;
                              15836                 :                : 
                              15837                 :            180 :                     n->agg_filter = $2;
                              15838                 :            180 :                     n->over = $3;
                              15839                 :            180 :                     $$ = (Node *) $1;
                              15840                 :                :                 }
                              15841                 :                :             | func_expr_common_subexpr
 4453 rhaas@postgresql.org    15842                 :          38118 :                 { $$ = $1; }
                              15843                 :                :         ;
                              15844                 :                : 
                              15845                 :                : /*
                              15846                 :                :  * Like func_expr but does not accept WINDOW functions directly
                              15847                 :                :  * (but they can still be contained in arguments for functions etc).
                              15848                 :                :  * Use this when window expressions are not allowed, where needed to
                              15849                 :                :  * disambiguate the grammar (e.g. in CREATE INDEX).
                              15850                 :                :  */
                              15851                 :                : func_expr_windowless:
                              15852                 :          24432 :             func_application                        { $$ = $1; }
 4318 peter_e@gmx.net         15853                 :            201 :             | func_expr_common_subexpr              { $$ = $1; }
  892 alvherre@alvh.no-ip.    15854                 :UBC           0 :             | json_aggregate_func                   { $$ = $1; }
                              15855                 :                :         ;
                              15856                 :                : 
                              15857                 :                : /*
                              15858                 :                :  * Special expressions that are considered to be functions.
                              15859                 :                :  */
                              15860                 :                : func_expr_common_subexpr:
                              15861                 :                :             COLLATION FOR '(' a_expr ')'
                              15862                 :                :                 {
 4450 rhaas@postgresql.org    15863                 :CBC          15 :                     $$ = (Node *) makeFuncCall(SystemFuncName("pg_collation_for"),
                              15864                 :             15 :                                                list_make1($4),
                              15865                 :                :                                                COERCE_SQL_SYNTAX,
                              15866                 :             15 :                                                @1);
                              15867                 :                :                 }
                              15868                 :                :             | CURRENT_DATE
                              15869                 :                :                 {
  843 michael@paquier.xyz     15870                 :            154 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_DATE, -1, @1);
                              15871                 :                :                 }
                              15872                 :                :             | CURRENT_TIME
                              15873                 :                :                 {
                              15874                 :             12 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_TIME, -1, @1);
                              15875                 :                :                 }
                              15876                 :                :             | CURRENT_TIME '(' Iconst ')'
                              15877                 :                :                 {
                              15878                 :             12 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_TIME_N, $3, @1);
                              15879                 :                :                 }
                              15880                 :                :             | CURRENT_TIMESTAMP
                              15881                 :                :                 {
                              15882                 :            144 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_TIMESTAMP, -1, @1);
                              15883                 :                :                 }
                              15884                 :                :             | CURRENT_TIMESTAMP '(' Iconst ')'
                              15885                 :                :                 {
                              15886                 :             87 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_TIMESTAMP_N, $3, @1);
                              15887                 :                :                 }
                              15888                 :                :             | LOCALTIME
                              15889                 :                :                 {
                              15890                 :             12 :                     $$ = makeSQLValueFunction(SVFOP_LOCALTIME, -1, @1);
                              15891                 :                :                 }
                              15892                 :                :             | LOCALTIME '(' Iconst ')'
                              15893                 :                :                 {
                              15894                 :             12 :                     $$ = makeSQLValueFunction(SVFOP_LOCALTIME_N, $3, @1);
                              15895                 :                :                 }
                              15896                 :                :             | LOCALTIMESTAMP
                              15897                 :                :                 {
                              15898                 :             18 :                     $$ = makeSQLValueFunction(SVFOP_LOCALTIMESTAMP, -1, @1);
                              15899                 :                :                 }
                              15900                 :                :             | LOCALTIMESTAMP '(' Iconst ')'
                              15901                 :                :                 {
                              15902                 :             12 :                     $$ = makeSQLValueFunction(SVFOP_LOCALTIMESTAMP_N, $3, @1);
                              15903                 :                :                 }
                              15904                 :                :             | CURRENT_ROLE
                              15905                 :                :                 {
                              15906                 :             34 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_ROLE, -1, @1);
                              15907                 :                :                 }
                              15908                 :                :             | CURRENT_USER
                              15909                 :                :                 {
                              15910                 :            530 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_USER, -1, @1);
                              15911                 :                :                 }
                              15912                 :                :             | SESSION_USER
                              15913                 :                :                 {
                              15914                 :            308 :                     $$ = makeSQLValueFunction(SVFOP_SESSION_USER, -1, @1);
                              15915                 :                :                 }
                              15916                 :                :             | SYSTEM_USER
                              15917                 :                :                 {
 1073                         15918                 :             12 :                     $$ = (Node *) makeFuncCall(SystemFuncName("system_user"),
                              15919                 :                :                                                NIL,
                              15920                 :                :                                                COERCE_SQL_SYNTAX,
                              15921                 :                :                                                @1);
                              15922                 :                :                 }
                              15923                 :                :             | USER
                              15924                 :                :                 {
  843                         15925                 :             12 :                     $$ = makeSQLValueFunction(SVFOP_USER, -1, @1);
                              15926                 :                :                 }
                              15927                 :                :             | CURRENT_CATALOG
                              15928                 :                :                 {
                              15929                 :             26 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_CATALOG, -1, @1);
                              15930                 :                :                 }
                              15931                 :                :             | CURRENT_SCHEMA
                              15932                 :                :                 {
                              15933                 :             15 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_SCHEMA, -1, @1);
                              15934                 :                :                 }
                              15935                 :                :             | CAST '(' a_expr AS Typename ')'
 6218 tgl@sss.pgh.pa.us       15936                 :          31234 :                 { $$ = makeTypeCast($3, $5, @1); }
                              15937                 :                :             | EXTRACT '(' extract_list ')'
                              15938                 :                :                 {
 1614 peter@eisentraut.org    15939                 :            691 :                     $$ = (Node *) makeFuncCall(SystemFuncName("extract"),
 1767 tgl@sss.pgh.pa.us       15940                 :            691 :                                                $3,
                              15941                 :                :                                                COERCE_SQL_SYNTAX,
                              15942                 :            691 :                                                @1);
                              15943                 :                :                 }
                              15944                 :                :             | NORMALIZE '(' a_expr ')'
                              15945                 :                :                 {
                              15946                 :              9 :                     $$ = (Node *) makeFuncCall(SystemFuncName("normalize"),
                              15947                 :              9 :                                                list_make1($3),
                              15948                 :                :                                                COERCE_SQL_SYNTAX,
                              15949                 :              9 :                                                @1);
                              15950                 :                :                 }
                              15951                 :                :             | NORMALIZE '(' a_expr ',' unicode_normal_form ')'
                              15952                 :                :                 {
                              15953                 :             21 :                     $$ = (Node *) makeFuncCall(SystemFuncName("normalize"),
                              15954                 :             21 :                                                list_make2($3, makeStringConst($5, @5)),
                              15955                 :                :                                                COERCE_SQL_SYNTAX,
                              15956                 :             21 :                                                @1);
                              15957                 :                :                 }
                              15958                 :                :             | OVERLAY '(' overlay_list ')'
                              15959                 :                :                 {
                              15960                 :             41 :                     $$ = (Node *) makeFuncCall(SystemFuncName("overlay"),
                              15961                 :             41 :                                                $3,
                              15962                 :                :                                                COERCE_SQL_SYNTAX,
                              15963                 :             41 :                                                @1);
                              15964                 :                :                 }
                              15965                 :                :             | OVERLAY '(' func_arg_list_opt ')'
                              15966                 :                :                 {
                              15967                 :                :                     /*
                              15968                 :                :                      * allow functions named overlay() to be called without
                              15969                 :                :                      * special syntax
                              15970                 :                :                      */
 1767 tgl@sss.pgh.pa.us       15971                 :UBC           0 :                     $$ = (Node *) makeFuncCall(list_make1(makeString("overlay")),
                              15972                 :              0 :                                                $3,
                              15973                 :                :                                                COERCE_EXPLICIT_CALL,
                              15974                 :              0 :                                                @1);
                              15975                 :                :                 }
                              15976                 :                :             | POSITION '(' position_list ')'
                              15977                 :                :                 {
                              15978                 :                :                     /*
                              15979                 :                :                      * position(A in B) is converted to position(B, A)
                              15980                 :                :                      *
                              15981                 :                :                      * We deliberately don't offer a "plain syntax" option
                              15982                 :                :                      * for position(), because the reversal of the arguments
                              15983                 :                :                      * creates too much risk of confusion.
                              15984                 :                :                      */
 1767 tgl@sss.pgh.pa.us       15985                 :CBC         200 :                     $$ = (Node *) makeFuncCall(SystemFuncName("position"),
                              15986                 :            200 :                                                $3,
                              15987                 :                :                                                COERCE_SQL_SYNTAX,
                              15988                 :            200 :                                                @1);
                              15989                 :                :                 }
                              15990                 :                :             | SUBSTRING '(' substr_list ')'
                              15991                 :                :                 {
                              15992                 :                :                     /* substring(A from B for C) is converted to
                              15993                 :                :                      * substring(A, B, C) - thomas 2000-11-28
                              15994                 :                :                      */
                              15995                 :            355 :                     $$ = (Node *) makeFuncCall(SystemFuncName("substring"),
                              15996                 :            355 :                                                $3,
                              15997                 :                :                                                COERCE_SQL_SYNTAX,
                              15998                 :            355 :                                                @1);
                              15999                 :                :                 }
                              16000                 :                :             | SUBSTRING '(' func_arg_list_opt ')'
                              16001                 :                :                 {
                              16002                 :                :                     /*
                              16003                 :                :                      * allow functions named substring() to be called without
                              16004                 :                :                      * special syntax
                              16005                 :                :                      */
                              16006                 :            126 :                     $$ = (Node *) makeFuncCall(list_make1(makeString("substring")),
                              16007                 :            126 :                                                $3,
                              16008                 :                :                                                COERCE_EXPLICIT_CALL,
                              16009                 :            126 :                                                @1);
                              16010                 :                :                 }
                              16011                 :                :             | TREAT '(' a_expr AS Typename ')'
                              16012                 :                :                 {
                              16013                 :                :                     /* TREAT(expr AS target) converts expr of a particular type to target,
                              16014                 :                :                      * which is defined to be a subtype of the original expression.
                              16015                 :                :                      * In SQL99, this is intended for use with structured UDTs,
                              16016                 :                :                      * but let's make this a generally useful form allowing stronger
                              16017                 :                :                      * coercions than are handled by implicit casting.
                              16018                 :                :                      *
                              16019                 :                :                      * Convert SystemTypeName() to SystemFuncName() even though
                              16020                 :                :                      * at the moment they result in the same thing.
                              16021                 :                :                      */
 1738 peter@eisentraut.org    16022                 :UBC           0 :                     $$ = (Node *) makeFuncCall(SystemFuncName(strVal(llast($5->names))),
 1767 tgl@sss.pgh.pa.us       16023                 :              0 :                                                list_make1($3),
                              16024                 :                :                                                COERCE_EXPLICIT_CALL,
                              16025                 :              0 :                                                @1);
                              16026                 :                :                 }
                              16027                 :                :             | TRIM '(' BOTH trim_list ')'
                              16028                 :                :                 {
                              16029                 :                :                     /* various trim expressions are defined in SQL
                              16030                 :                :                      * - thomas 1997-07-19
                              16031                 :                :                      */
 1767 tgl@sss.pgh.pa.us       16032                 :CBC           6 :                     $$ = (Node *) makeFuncCall(SystemFuncName("btrim"),
                              16033                 :              6 :                                                $4,
                              16034                 :                :                                                COERCE_SQL_SYNTAX,
                              16035                 :              6 :                                                @1);
                              16036                 :                :                 }
                              16037                 :                :             | TRIM '(' LEADING trim_list ')'
                              16038                 :                :                 {
                              16039                 :             12 :                     $$ = (Node *) makeFuncCall(SystemFuncName("ltrim"),
                              16040                 :             12 :                                                $4,
                              16041                 :                :                                                COERCE_SQL_SYNTAX,
                              16042                 :             12 :                                                @1);
                              16043                 :                :                 }
                              16044                 :                :             | TRIM '(' TRAILING trim_list ')'
                              16045                 :                :                 {
                              16046                 :            290 :                     $$ = (Node *) makeFuncCall(SystemFuncName("rtrim"),
                              16047                 :            290 :                                                $4,
                              16048                 :                :                                                COERCE_SQL_SYNTAX,
                              16049                 :            290 :                                                @1);
                              16050                 :                :                 }
                              16051                 :                :             | TRIM '(' trim_list ')'
                              16052                 :                :                 {
                              16053                 :             49 :                     $$ = (Node *) makeFuncCall(SystemFuncName("btrim"),
                              16054                 :             49 :                                                $3,
                              16055                 :                :                                                COERCE_SQL_SYNTAX,
                              16056                 :             49 :                                                @1);
                              16057                 :                :                 }
                              16058                 :                :             | NULLIF '(' a_expr ',' a_expr ')'
                              16059                 :                :                 {
 7116                         16060                 :            192 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_NULLIF, "=", $3, $5, @1);
                              16061                 :                :                 }
                              16062                 :                :             | COALESCE '(' expr_list ')'
                              16063                 :                :                 {
 7646                         16064                 :           1602 :                     CoalesceExpr *c = makeNode(CoalesceExpr);
                              16065                 :                : 
                              16066                 :           1602 :                     c->args = $3;
 6218                         16067                 :           1602 :                     c->location = @1;
 1212 peter@eisentraut.org    16068                 :           1602 :                     $$ = (Node *) c;
                              16069                 :                :                 }
                              16070                 :                :             | GREATEST '(' expr_list ')'
                              16071                 :                :                 {
 7377 tgl@sss.pgh.pa.us       16072                 :             73 :                     MinMaxExpr *v = makeNode(MinMaxExpr);
                              16073                 :                : 
                              16074                 :             73 :                     v->args = $3;
                              16075                 :             73 :                     v->op = IS_GREATEST;
 6218                         16076                 :             73 :                     v->location = @1;
 1212 peter@eisentraut.org    16077                 :             73 :                     $$ = (Node *) v;
                              16078                 :                :                 }
                              16079                 :                :             | LEAST '(' expr_list ')'
                              16080                 :                :                 {
 7377 tgl@sss.pgh.pa.us       16081                 :             62 :                     MinMaxExpr *v = makeNode(MinMaxExpr);
                              16082                 :                : 
                              16083                 :             62 :                     v->args = $3;
                              16084                 :             62 :                     v->op = IS_LEAST;
 6218                         16085                 :             62 :                     v->location = @1;
 1212 peter@eisentraut.org    16086                 :             62 :                     $$ = (Node *) v;
                              16087                 :                :                 }
                              16088                 :                :             | XMLCONCAT '(' expr_list ')'
                              16089                 :                :                 {
 6218 tgl@sss.pgh.pa.us       16090                 :             31 :                     $$ = makeXmlExpr(IS_XMLCONCAT, NULL, NIL, $3, @1);
                              16091                 :                :                 }
                              16092                 :                :             | XMLELEMENT '(' NAME_P ColLabel ')'
                              16093                 :                :                 {
                              16094                 :              3 :                     $$ = makeXmlExpr(IS_XMLELEMENT, $4, NIL, NIL, @1);
                              16095                 :                :                 }
                              16096                 :                :             | XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ')'
                              16097                 :                :                 {
                              16098                 :             18 :                     $$ = makeXmlExpr(IS_XMLELEMENT, $4, $6, NIL, @1);
                              16099                 :                :                 }
                              16100                 :                :             | XMLELEMENT '(' NAME_P ColLabel ',' expr_list ')'
                              16101                 :                :                 {
                              16102                 :             58 :                     $$ = makeXmlExpr(IS_XMLELEMENT, $4, NIL, $6, @1);
                              16103                 :                :                 }
                              16104                 :                :             | XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ',' expr_list ')'
                              16105                 :                :                 {
                              16106                 :             10 :                     $$ = makeXmlExpr(IS_XMLELEMENT, $4, $6, $8, @1);
                              16107                 :                :                 }
                              16108                 :                :             | XMLEXISTS '(' c_expr xmlexists_argument ')'
                              16109                 :                :                 {
                              16110                 :                :                     /* xmlexists(A PASSING [BY REF] B [BY REF]) is
                              16111                 :                :                      * converted to xmlexists(A, B)*/
 1767                         16112                 :             27 :                     $$ = (Node *) makeFuncCall(SystemFuncName("xmlexists"),
                              16113                 :             27 :                                                list_make2($3, $4),
                              16114                 :                :                                                COERCE_SQL_SYNTAX,
                              16115                 :             27 :                                                @1);
                              16116                 :                :                 }
                              16117                 :                :             | XMLFOREST '(' xml_attribute_list ')'
                              16118                 :                :                 {
 6218                         16119                 :             16 :                     $$ = makeXmlExpr(IS_XMLFOREST, NULL, $3, NIL, @1);
                              16120                 :                :                 }
                              16121                 :                :             | XMLPARSE '(' document_or_content a_expr xml_whitespace_option ')'
                              16122                 :                :                 {
                              16123                 :                :                     XmlExpr *x = (XmlExpr *)
                              16124                 :             70 :                         makeXmlExpr(IS_XMLPARSE, NULL, NIL,
                              16125                 :             70 :                                     list_make2($4, makeBoolAConst($5, -1)),
                              16126                 :             70 :                                     @1);
                              16127                 :                : 
 6790 peter_e@gmx.net         16128                 :             70 :                     x->xmloption = $3;
 1212 peter@eisentraut.org    16129                 :             70 :                     $$ = (Node *) x;
                              16130                 :                :                 }
                              16131                 :                :             | XMLPI '(' NAME_P ColLabel ')'
                              16132                 :                :                 {
 6218 tgl@sss.pgh.pa.us       16133                 :             15 :                     $$ = makeXmlExpr(IS_XMLPI, $4, NULL, NIL, @1);
                              16134                 :                :                 }
                              16135                 :                :             | XMLPI '(' NAME_P ColLabel ',' a_expr ')'
                              16136                 :                :                 {
                              16137                 :             25 :                     $$ = makeXmlExpr(IS_XMLPI, $4, NULL, list_make1($6), @1);
                              16138                 :                :                 }
                              16139                 :                :             | XMLROOT '(' a_expr ',' xml_root_version opt_xml_root_standalone ')'
                              16140                 :                :                 {
 6831                         16141                 :             34 :                     $$ = makeXmlExpr(IS_XMLROOT, NULL, NIL,
 6218                         16142                 :             34 :                                      list_make3($3, $5, $6), @1);
                              16143                 :                :                 }
                              16144                 :                :             | XMLSERIALIZE '(' document_or_content a_expr AS SimpleTypename xml_indent_option ')'
                              16145                 :                :                 {
 6790 peter_e@gmx.net         16146                 :            109 :                     XmlSerialize *n = makeNode(XmlSerialize);
                              16147                 :                : 
                              16148                 :            109 :                     n->xmloption = $3;
                              16149                 :            109 :                     n->expr = $4;
 5896                         16150                 :            109 :                     n->typeName = $6;
  906 tgl@sss.pgh.pa.us       16151                 :            109 :                     n->indent = $7;
 6218                         16152                 :            109 :                     n->location = @1;
 1212 peter@eisentraut.org    16153                 :            109 :                     $$ = (Node *) n;
                              16154                 :                :                 }
                              16155                 :                :             | JSON_OBJECT '(' func_arg_list ')'
                              16156                 :                :                 {
                              16157                 :                :                     /* Support for legacy (non-standard) json_object() */
  892 alvherre@alvh.no-ip.    16158                 :             45 :                     $$ = (Node *) makeFuncCall(SystemFuncName("json_object"),
                              16159                 :             45 :                                                $3, COERCE_EXPLICIT_CALL, @1);
                              16160                 :                :                 }
                              16161                 :                :             | JSON_OBJECT '(' json_name_and_value_list
                              16162                 :                :                 json_object_constructor_null_clause_opt
                              16163                 :                :                 json_key_uniqueness_constraint_opt
                              16164                 :                :                 json_returning_clause_opt ')'
                              16165                 :                :                 {
                              16166                 :            171 :                     JsonObjectConstructor *n = makeNode(JsonObjectConstructor);
                              16167                 :                : 
                              16168                 :            171 :                     n->exprs = $3;
                              16169                 :            171 :                     n->absent_on_null = $4;
                              16170                 :            171 :                     n->unique = $5;
                              16171                 :            171 :                     n->output = (JsonOutput *) $6;
                              16172                 :            171 :                     n->location = @1;
                              16173                 :            171 :                     $$ = (Node *) n;
                              16174                 :                :                 }
                              16175                 :                :             | JSON_OBJECT '(' json_returning_clause_opt ')'
                              16176                 :                :                 {
                              16177                 :             44 :                     JsonObjectConstructor *n = makeNode(JsonObjectConstructor);
                              16178                 :                : 
                              16179                 :             44 :                     n->exprs = NULL;
                              16180                 :             44 :                     n->absent_on_null = false;
                              16181                 :             44 :                     n->unique = false;
                              16182                 :             44 :                     n->output = (JsonOutput *) $3;
                              16183                 :             44 :                     n->location = @1;
                              16184                 :             44 :                     $$ = (Node *) n;
                              16185                 :                :                 }
                              16186                 :                :             | JSON_ARRAY '('
                              16187                 :                :                 json_value_expr_list
                              16188                 :                :                 json_array_constructor_null_clause_opt
                              16189                 :                :                 json_returning_clause_opt
                              16190                 :                :             ')'
                              16191                 :                :                 {
                              16192                 :             54 :                     JsonArrayConstructor *n = makeNode(JsonArrayConstructor);
                              16193                 :                : 
                              16194                 :             54 :                     n->exprs = $3;
                              16195                 :             54 :                     n->absent_on_null = $4;
                              16196                 :             54 :                     n->output = (JsonOutput *) $5;
                              16197                 :             54 :                     n->location = @1;
                              16198                 :             54 :                     $$ = (Node *) n;
                              16199                 :                :                 }
                              16200                 :                :             | JSON_ARRAY '('
                              16201                 :                :                 select_no_parens
                              16202                 :                :                 json_format_clause_opt
                              16203                 :                :                 /* json_array_constructor_null_clause_opt */
                              16204                 :                :                 json_returning_clause_opt
                              16205                 :                :             ')'
                              16206                 :                :                 {
                              16207                 :             30 :                     JsonArrayQueryConstructor *n = makeNode(JsonArrayQueryConstructor);
                              16208                 :                : 
                              16209                 :             30 :                     n->query = $3;
                              16210                 :             30 :                     n->format = (JsonFormat *) $4;
                              16211                 :             30 :                     n->absent_on_null = true;    /* XXX */
                              16212                 :             30 :                     n->output = (JsonOutput *) $5;
                              16213                 :             30 :                     n->location = @1;
                              16214                 :             30 :                     $$ = (Node *) n;
                              16215                 :                :                 }
                              16216                 :                :             | JSON_ARRAY '('
                              16217                 :                :                 json_returning_clause_opt
                              16218                 :                :             ')'
                              16219                 :                :                 {
                              16220                 :             41 :                     JsonArrayConstructor *n = makeNode(JsonArrayConstructor);
                              16221                 :                : 
                              16222                 :             41 :                     n->exprs = NIL;
                              16223                 :             41 :                     n->absent_on_null = true;
                              16224                 :             41 :                     n->output = (JsonOutput *) $3;
                              16225                 :             41 :                     n->location = @1;
                              16226                 :             41 :                     $$ = (Node *) n;
                              16227                 :                :                 }
                              16228                 :                :             | JSON '(' json_value_expr json_key_uniqueness_constraint_opt ')'
                              16229                 :                :                 {
  779 amitlan@postgresql.o    16230                 :             74 :                     JsonParseExpr *n = makeNode(JsonParseExpr);
                              16231                 :                : 
                              16232                 :             74 :                     n->expr = (JsonValueExpr *) $3;
                              16233                 :             74 :                     n->unique_keys = $4;
                              16234                 :             74 :                     n->output = NULL;
                              16235                 :             74 :                     n->location = @1;
                              16236                 :             74 :                     $$ = (Node *) n;
                              16237                 :                :                 }
                              16238                 :                :             | JSON_SCALAR '(' a_expr ')'
                              16239                 :                :                 {
                              16240                 :             49 :                     JsonScalarExpr *n = makeNode(JsonScalarExpr);
                              16241                 :                : 
                              16242                 :             49 :                     n->expr = (Expr *) $3;
                              16243                 :             49 :                     n->output = NULL;
                              16244                 :             49 :                     n->location = @1;
                              16245                 :             49 :                     $$ = (Node *) n;
                              16246                 :                :                 }
                              16247                 :                :             | JSON_SERIALIZE '(' json_value_expr json_returning_clause_opt ')'
                              16248                 :                :                 {
                              16249                 :             48 :                     JsonSerializeExpr *n = makeNode(JsonSerializeExpr);
                              16250                 :                : 
                              16251                 :             48 :                     n->expr = (JsonValueExpr *) $3;
                              16252                 :             48 :                     n->output = (JsonOutput *) $4;
                              16253                 :             48 :                     n->location = @1;
                              16254                 :             48 :                     $$ = (Node *) n;
                              16255                 :                :                 }
                              16256                 :                :             | MERGE_ACTION '(' ')'
                              16257                 :                :                 {
  538 dean.a.rasheed@gmail    16258                 :            105 :                     MergeSupportFunc *m = makeNode(MergeSupportFunc);
                              16259                 :                : 
                              16260                 :            105 :                     m->msftype = TEXTOID;
                              16261                 :            105 :                     m->location = @1;
                              16262                 :            105 :                     $$ = (Node *) m;
                              16263                 :                :                 }
                              16264                 :                :             | JSON_QUERY '('
                              16265                 :                :                 json_value_expr ',' a_expr json_passing_clause_opt
                              16266                 :                :                 json_returning_clause_opt
                              16267                 :                :                 json_wrapper_behavior
                              16268                 :                :                 json_quotes_clause_opt
                              16269                 :                :                 json_behavior_clause_opt
                              16270                 :                :             ')'
                              16271                 :                :                 {
  534 amitlan@postgresql.o    16272                 :            492 :                     JsonFuncExpr *n = makeNode(JsonFuncExpr);
                              16273                 :                : 
                              16274                 :            492 :                     n->op = JSON_QUERY_OP;
                              16275                 :            492 :                     n->context_item = (JsonValueExpr *) $3;
                              16276                 :            492 :                     n->pathspec = $5;
                              16277                 :            492 :                     n->passing = $6;
                              16278                 :            492 :                     n->output = (JsonOutput *) $7;
                              16279                 :            492 :                     n->wrapper = $8;
                              16280                 :            492 :                     n->quotes = $9;
                              16281                 :            492 :                     n->on_empty = (JsonBehavior *) linitial($10);
                              16282                 :            492 :                     n->on_error = (JsonBehavior *) lsecond($10);
                              16283                 :            492 :                     n->location = @1;
                              16284                 :            492 :                     $$ = (Node *) n;
                              16285                 :                :                 }
                              16286                 :                :             | JSON_EXISTS '('
                              16287                 :                :                 json_value_expr ',' a_expr json_passing_clause_opt
                              16288                 :                :                 json_on_error_clause_opt
                              16289                 :                :             ')'
                              16290                 :                :                 {
                              16291                 :             84 :                     JsonFuncExpr *n = makeNode(JsonFuncExpr);
                              16292                 :                : 
                              16293                 :             84 :                     n->op = JSON_EXISTS_OP;
                              16294                 :             84 :                     n->context_item = (JsonValueExpr *) $3;
                              16295                 :             84 :                     n->pathspec = $5;
                              16296                 :             84 :                     n->passing = $6;
                              16297                 :             84 :                     n->output = NULL;
                              16298                 :             84 :                     n->on_error = (JsonBehavior *) $7;
                              16299                 :             84 :                     n->location = @1;
                              16300                 :             84 :                     $$ = (Node *) n;
                              16301                 :                :                 }
                              16302                 :                :             | JSON_VALUE '('
                              16303                 :                :                 json_value_expr ',' a_expr json_passing_clause_opt
                              16304                 :                :                 json_returning_clause_opt
                              16305                 :                :                 json_behavior_clause_opt
                              16306                 :                :             ')'
                              16307                 :                :                 {
                              16308                 :            288 :                     JsonFuncExpr *n = makeNode(JsonFuncExpr);
                              16309                 :                : 
                              16310                 :            288 :                     n->op = JSON_VALUE_OP;
                              16311                 :            288 :                     n->context_item = (JsonValueExpr *) $3;
                              16312                 :            288 :                     n->pathspec = $5;
                              16313                 :            288 :                     n->passing = $6;
                              16314                 :            288 :                     n->output = (JsonOutput *) $7;
                              16315                 :            288 :                     n->on_empty = (JsonBehavior *) linitial($8);
                              16316                 :            288 :                     n->on_error = (JsonBehavior *) lsecond($8);
                              16317                 :            288 :                     n->location = @1;
                              16318                 :            288 :                     $$ = (Node *) n;
                              16319                 :                :                 }
                              16320                 :                :             ;
                              16321                 :                : 
                              16322                 :                : 
                              16323                 :                : /*
                              16324                 :                :  * SQL/XML support
                              16325                 :                :  */
                              16326                 :                : xml_root_version: VERSION_P a_expr
 6831 tgl@sss.pgh.pa.us       16327                 :             12 :                 { $$ = $2; }
                              16328                 :                :             | VERSION_P NO VALUE_P
 6218                         16329                 :             22 :                 { $$ = makeNullAConst(-1); }
                              16330                 :                :         ;
                              16331                 :                : 
                              16332                 :                : opt_xml_root_standalone: ',' STANDALONE_P YES_P
                              16333                 :             13 :                 { $$ = makeIntConst(XML_STANDALONE_YES, -1); }
                              16334                 :                :             | ',' STANDALONE_P NO
                              16335                 :              6 :                 { $$ = makeIntConst(XML_STANDALONE_NO, -1); }
                              16336                 :                :             | ',' STANDALONE_P NO VALUE_P
                              16337                 :              6 :                 { $$ = makeIntConst(XML_STANDALONE_NO_VALUE, -1); }
                              16338                 :                :             | /*EMPTY*/
                              16339                 :              9 :                 { $$ = makeIntConst(XML_STANDALONE_OMITTED, -1); }
                              16340                 :                :         ;
                              16341                 :                : 
 6831                         16342                 :             28 : xml_attributes: XMLATTRIBUTES '(' xml_attribute_list ')'    { $$ = $3; }
                              16343                 :                :         ;
                              16344                 :                : 
 6834 peter_e@gmx.net         16345                 :             44 : xml_attribute_list: xml_attribute_el                    { $$ = list_make1($1); }
                              16346                 :             72 :             | xml_attribute_list ',' xml_attribute_el   { $$ = lappend($1, $3); }
                              16347                 :                :         ;
                              16348                 :                : 
                              16349                 :                : xml_attribute_el: a_expr AS ColLabel
                              16350                 :                :                 {
                              16351                 :             53 :                     $$ = makeNode(ResTarget);
                              16352                 :             53 :                     $$->name = $3;
 6216 tgl@sss.pgh.pa.us       16353                 :             53 :                     $$->indirection = NIL;
 6834 peter_e@gmx.net         16354                 :             53 :                     $$->val = (Node *) $1;
 6831 tgl@sss.pgh.pa.us       16355                 :             53 :                     $$->location = @1;
                              16356                 :                :                 }
                              16357                 :                :             | a_expr
                              16358                 :                :                 {
 6834 peter_e@gmx.net         16359                 :             63 :                     $$ = makeNode(ResTarget);
                              16360                 :             63 :                     $$->name = NULL;
 6216 tgl@sss.pgh.pa.us       16361                 :             63 :                     $$->indirection = NIL;
 6825                         16362                 :             63 :                     $$->val = (Node *) $1;
 6831                         16363                 :             63 :                     $$->location = @1;
                              16364                 :                :                 }
                              16365                 :                :         ;
                              16366                 :                : 
 6790 peter_e@gmx.net         16367                 :             93 : document_or_content: DOCUMENT_P                     { $$ = XMLOPTION_DOCUMENT; }
                              16368                 :             94 :             | CONTENT_P                             { $$ = XMLOPTION_CONTENT; }
                              16369                 :                :         ;
                              16370                 :                : 
  906 tgl@sss.pgh.pa.us       16371                 :             70 : xml_indent_option: INDENT                           { $$ = true; }
                              16372                 :             18 :             | NO INDENT                             { $$ = false; }
                              16373                 :             21 :             | /*EMPTY*/                             { $$ = false; }
                              16374                 :                :         ;
                              16375                 :                : 
 2943 peter_e@gmx.net         16376                 :UBC           0 : xml_whitespace_option: PRESERVE WHITESPACE_P        { $$ = true; }
 2943 peter_e@gmx.net         16377                 :CBC           1 :             | STRIP_P WHITESPACE_P                  { $$ = false; }
                              16378                 :             69 :             | /*EMPTY*/                             { $$ = false; }
                              16379                 :                :         ;
                              16380                 :                : 
                              16381                 :                : /* We allow several variants for SQL and other compatibility. */
                              16382                 :                : xmlexists_argument:
                              16383                 :                :             PASSING c_expr
                              16384                 :                :                 {
 5511                         16385                 :            119 :                     $$ = $2;
                              16386                 :                :                 }
                              16387                 :                :             | PASSING c_expr xml_passing_mech
                              16388                 :                :                 {
 5511 peter_e@gmx.net         16389                 :UBC           0 :                     $$ = $2;
                              16390                 :                :                 }
                              16391                 :                :             | PASSING xml_passing_mech c_expr
                              16392                 :                :                 {
 2375 alvherre@alvh.no-ip.    16393                 :CBC          21 :                     $$ = $3;
                              16394                 :                :                 }
                              16395                 :                :             | PASSING xml_passing_mech c_expr xml_passing_mech
                              16396                 :                :                 {
                              16397                 :              3 :                     $$ = $3;
                              16398                 :                :                 }
                              16399                 :                :         ;
                              16400                 :                : 
                              16401                 :                : xml_passing_mech:
                              16402                 :                :             BY REF_P
                              16403                 :                :             | BY VALUE_P
                              16404                 :                :         ;
                              16405                 :                : 
                              16406                 :                : 
                              16407                 :                : /*
                              16408                 :                :  * Aggregate decoration clauses
                              16409                 :                :  */
                              16410                 :                : within_group_clause:
 4275 tgl@sss.pgh.pa.us       16411                 :            174 :             WITHIN GROUP_P '(' sort_clause ')'      { $$ = $4; }
                              16412                 :         156515 :             | /*EMPTY*/                             { $$ = NIL; }
                              16413                 :                :         ;
                              16414                 :                : 
                              16415                 :                : filter_clause:
                              16416                 :            431 :             FILTER '(' WHERE a_expr ')'             { $$ = $4; }
                              16417                 :         156438 :             | /*EMPTY*/                             { $$ = NULL; }
                              16418                 :                :         ;
                              16419                 :                : 
                              16420                 :                : 
                              16421                 :                : /*
                              16422                 :                :  * Window Definitions
                              16423                 :                :  */
                              16424                 :                : window_clause:
 6096                         16425                 :            270 :             WINDOW window_definition_list           { $$ = $2; }
                              16426                 :         237655 :             | /*EMPTY*/                             { $$ = NIL; }
                              16427                 :                :         ;
                              16428                 :                : 
                              16429                 :                : window_definition_list:
                              16430                 :            270 :             window_definition                       { $$ = list_make1($1); }
                              16431                 :                :             | window_definition_list ',' window_definition
                              16432                 :              6 :                                                     { $$ = lappend($1, $3); }
                              16433                 :                :         ;
                              16434                 :                : 
                              16435                 :                : window_definition:
                              16436                 :                :             ColId AS window_specification
                              16437                 :                :                 {
 1212 peter@eisentraut.org    16438                 :            276 :                     WindowDef  *n = $3;
                              16439                 :                : 
 6096 tgl@sss.pgh.pa.us       16440                 :            276 :                     n->name = $1;
                              16441                 :            276 :                     $$ = n;
                              16442                 :                :                 }
                              16443                 :                :         ;
                              16444                 :                : 
                              16445                 :                : over_clause: OVER window_specification
                              16446                 :           1308 :                 { $$ = $2; }
                              16447                 :                :             | OVER ColId
                              16448                 :                :                 {
 1212 peter@eisentraut.org    16449                 :            477 :                     WindowDef  *n = makeNode(WindowDef);
                              16450                 :                : 
 6093 tgl@sss.pgh.pa.us       16451                 :            477 :                     n->name = $2;
                              16452                 :            477 :                     n->refname = NULL;
 6096                         16453                 :            477 :                     n->partitionClause = NIL;
                              16454                 :            477 :                     n->orderClause = NIL;
 6093                         16455                 :            477 :                     n->frameOptions = FRAMEOPTION_DEFAULTS;
 5685                         16456                 :            477 :                     n->startOffset = NULL;
                              16457                 :            477 :                     n->endOffset = NULL;
 6096                         16458                 :            477 :                     n->location = @2;
                              16459                 :            477 :                     $$ = n;
                              16460                 :                :                 }
                              16461                 :                :             | /*EMPTY*/
                              16462                 :         155081 :                 { $$ = NULL; }
                              16463                 :                :         ;
                              16464                 :                : 
                              16465                 :                : window_specification: '(' opt_existing_window_name opt_partition_clause
                              16466                 :                :                         opt_sort_clause opt_frame_clause ')'
                              16467                 :                :                 {
 1212 peter@eisentraut.org    16468                 :           1584 :                     WindowDef  *n = makeNode(WindowDef);
                              16469                 :                : 
 6096 tgl@sss.pgh.pa.us       16470                 :           1584 :                     n->name = NULL;
                              16471                 :           1584 :                     n->refname = $2;
                              16472                 :           1584 :                     n->partitionClause = $3;
                              16473                 :           1584 :                     n->orderClause = $4;
                              16474                 :                :                     /* copy relevant fields of opt_frame_clause */
 5685                         16475                 :           1584 :                     n->frameOptions = $5->frameOptions;
                              16476                 :           1584 :                     n->startOffset = $5->startOffset;
                              16477                 :           1584 :                     n->endOffset = $5->endOffset;
 6096                         16478                 :           1584 :                     n->location = @1;
                              16479                 :           1584 :                     $$ = n;
                              16480                 :                :                 }
                              16481                 :                :         ;
                              16482                 :                : 
                              16483                 :                : /*
                              16484                 :                :  * If we see PARTITION, RANGE, ROWS or GROUPS as the first token after the '('
                              16485                 :                :  * of a window_specification, we want the assumption to be that there is
                              16486                 :                :  * no existing_window_name; but those keywords are unreserved and so could
                              16487                 :                :  * be ColIds.  We fix this by making them have the same precedence as IDENT
                              16488                 :                :  * and giving the empty production here a slightly higher precedence, so
                              16489                 :                :  * that the shift/reduce conflict is resolved in favor of reducing the rule.
                              16490                 :                :  * These keywords are thus precluded from being an existing_window_name but
                              16491                 :                :  * are not reserved for any other purpose.
                              16492                 :                :  */
                              16493                 :             27 : opt_existing_window_name: ColId                     { $$ = $1; }
                              16494                 :           1560 :             | /*EMPTY*/             %prec Op        { $$ = NULL; }
                              16495                 :                :         ;
                              16496                 :                : 
                              16497                 :            460 : opt_partition_clause: PARTITION BY expr_list        { $$ = $3; }
                              16498                 :           1124 :             | /*EMPTY*/                             { $$ = NIL; }
                              16499                 :                :         ;
                              16500                 :                : 
                              16501                 :                : /*
                              16502                 :                :  * For frame clauses, we return a WindowDef, but only some fields are used:
                              16503                 :                :  * frameOptions, startOffset, and endOffset.
                              16504                 :                :  */
                              16505                 :                : opt_frame_clause:
                              16506                 :                :             RANGE frame_extent opt_window_exclusion_clause
                              16507                 :                :                 {
 1212 peter@eisentraut.org    16508                 :            398 :                     WindowDef  *n = $2;
                              16509                 :                : 
 5685 tgl@sss.pgh.pa.us       16510                 :            398 :                     n->frameOptions |= FRAMEOPTION_NONDEFAULT | FRAMEOPTION_RANGE;
 2768                         16511                 :            398 :                     n->frameOptions |= $3;
 5685                         16512                 :            398 :                     $$ = n;
                              16513                 :                :                 }
                              16514                 :                :             | ROWS frame_extent opt_window_exclusion_clause
                              16515                 :                :                 {
 1212 peter@eisentraut.org    16516                 :            312 :                     WindowDef  *n = $2;
                              16517                 :                : 
 5685 tgl@sss.pgh.pa.us       16518                 :            312 :                     n->frameOptions |= FRAMEOPTION_NONDEFAULT | FRAMEOPTION_ROWS;
 2768                         16519                 :            312 :                     n->frameOptions |= $3;
                              16520                 :            312 :                     $$ = n;
                              16521                 :                :                 }
                              16522                 :                :             | GROUPS frame_extent opt_window_exclusion_clause
                              16523                 :                :                 {
 1212 peter@eisentraut.org    16524                 :            102 :                     WindowDef  *n = $2;
                              16525                 :                : 
 2768 tgl@sss.pgh.pa.us       16526                 :            102 :                     n->frameOptions |= FRAMEOPTION_NONDEFAULT | FRAMEOPTION_GROUPS;
                              16527                 :            102 :                     n->frameOptions |= $3;
 5685                         16528                 :            102 :                     $$ = n;
                              16529                 :                :                 }
                              16530                 :                :             | /*EMPTY*/
                              16531                 :                :                 {
 1212 peter@eisentraut.org    16532                 :            772 :                     WindowDef  *n = makeNode(WindowDef);
                              16533                 :                : 
 5685 tgl@sss.pgh.pa.us       16534                 :            772 :                     n->frameOptions = FRAMEOPTION_DEFAULTS;
                              16535                 :            772 :                     n->startOffset = NULL;
                              16536                 :            772 :                     n->endOffset = NULL;
                              16537                 :            772 :                     $$ = n;
                              16538                 :                :                 }
                              16539                 :                :         ;
                              16540                 :                : 
                              16541                 :                : frame_extent: frame_bound
                              16542                 :                :                 {
 1212 peter@eisentraut.org    16543                 :              6 :                     WindowDef  *n = $1;
                              16544                 :                : 
                              16545                 :                :                     /* reject invalid cases */
 5685 tgl@sss.pgh.pa.us       16546         [ -  + ]:              6 :                     if (n->frameOptions & FRAMEOPTION_START_UNBOUNDED_FOLLOWING)
 6093 tgl@sss.pgh.pa.us       16547         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              16548                 :                :                                 (errcode(ERRCODE_WINDOWING_ERROR),
                              16549                 :                :                                  errmsg("frame start cannot be UNBOUNDED FOLLOWING"),
                              16550                 :                :                                  parser_errposition(@1)));
 2768 tgl@sss.pgh.pa.us       16551         [ -  + ]:CBC           6 :                     if (n->frameOptions & FRAMEOPTION_START_OFFSET_FOLLOWING)
 6093 tgl@sss.pgh.pa.us       16552         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              16553                 :                :                                 (errcode(ERRCODE_WINDOWING_ERROR),
                              16554                 :                :                                  errmsg("frame starting from following row cannot end with current row"),
                              16555                 :                :                                  parser_errposition(@1)));
 5685 tgl@sss.pgh.pa.us       16556                 :CBC           6 :                     n->frameOptions |= FRAMEOPTION_END_CURRENT_ROW;
                              16557                 :              6 :                     $$ = n;
                              16558                 :                :                 }
                              16559                 :                :             | BETWEEN frame_bound AND frame_bound
                              16560                 :                :                 {
 1212 peter@eisentraut.org    16561                 :            806 :                     WindowDef  *n1 = $2;
                              16562                 :            806 :                     WindowDef  *n2 = $4;
                              16563                 :                : 
                              16564                 :                :                     /* form merged options */
 5685 tgl@sss.pgh.pa.us       16565                 :            806 :                     int     frameOptions = n1->frameOptions;
                              16566                 :                :                     /* shift converts START_ options to END_ options */
                              16567                 :            806 :                     frameOptions |= n2->frameOptions << 1;
                              16568                 :            806 :                     frameOptions |= FRAMEOPTION_BETWEEN;
                              16569                 :                :                     /* reject invalid cases */
                              16570         [ -  + ]:            806 :                     if (frameOptions & FRAMEOPTION_START_UNBOUNDED_FOLLOWING)
 6093 tgl@sss.pgh.pa.us       16571         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              16572                 :                :                                 (errcode(ERRCODE_WINDOWING_ERROR),
                              16573                 :                :                                  errmsg("frame start cannot be UNBOUNDED FOLLOWING"),
                              16574                 :                :                                  parser_errposition(@2)));
 5685 tgl@sss.pgh.pa.us       16575         [ -  + ]:CBC         806 :                     if (frameOptions & FRAMEOPTION_END_UNBOUNDED_PRECEDING)
 6093 tgl@sss.pgh.pa.us       16576         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              16577                 :                :                                 (errcode(ERRCODE_WINDOWING_ERROR),
                              16578                 :                :                                  errmsg("frame end cannot be UNBOUNDED PRECEDING"),
                              16579                 :                :                                  parser_errposition(@4)));
 5685 tgl@sss.pgh.pa.us       16580         [ +  + ]:CBC         806 :                     if ((frameOptions & FRAMEOPTION_START_CURRENT_ROW) &&
 2768                         16581         [ -  + ]:            230 :                         (frameOptions & FRAMEOPTION_END_OFFSET_PRECEDING))
 5685 tgl@sss.pgh.pa.us       16582         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              16583                 :                :                                 (errcode(ERRCODE_WINDOWING_ERROR),
                              16584                 :                :                                  errmsg("frame starting from current row cannot have preceding rows"),
                              16585                 :                :                                  parser_errposition(@4)));
 2768 tgl@sss.pgh.pa.us       16586         [ +  + ]:CBC         806 :                     if ((frameOptions & FRAMEOPTION_START_OFFSET_FOLLOWING) &&
                              16587         [ -  + ]:             84 :                         (frameOptions & (FRAMEOPTION_END_OFFSET_PRECEDING |
                              16588                 :                :                                          FRAMEOPTION_END_CURRENT_ROW)))
 5685 tgl@sss.pgh.pa.us       16589         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              16590                 :                :                                 (errcode(ERRCODE_WINDOWING_ERROR),
                              16591                 :                :                                  errmsg("frame starting from following row cannot have preceding rows"),
                              16592                 :                :                                  parser_errposition(@4)));
 5685 tgl@sss.pgh.pa.us       16593                 :CBC         806 :                     n1->frameOptions = frameOptions;
                              16594                 :            806 :                     n1->endOffset = n2->startOffset;
                              16595                 :            806 :                     $$ = n1;
                              16596                 :                :                 }
                              16597                 :                :         ;
                              16598                 :                : 
                              16599                 :                : /*
                              16600                 :                :  * This is used for both frame start and frame end, with output set up on
                              16601                 :                :  * the assumption it's frame start; the frame_extent productions must reject
                              16602                 :                :  * invalid cases.
                              16603                 :                :  */
                              16604                 :                : frame_bound:
                              16605                 :                :             UNBOUNDED PRECEDING
                              16606                 :                :                 {
 1212 peter@eisentraut.org    16607                 :             99 :                     WindowDef  *n = makeNode(WindowDef);
                              16608                 :                : 
 5685 tgl@sss.pgh.pa.us       16609                 :             99 :                     n->frameOptions = FRAMEOPTION_START_UNBOUNDED_PRECEDING;
                              16610                 :             99 :                     n->startOffset = NULL;
                              16611                 :             99 :                     n->endOffset = NULL;
                              16612                 :             99 :                     $$ = n;
                              16613                 :                :                 }
                              16614                 :                :             | UNBOUNDED FOLLOWING
                              16615                 :                :                 {
 1212 peter@eisentraut.org    16616                 :            188 :                     WindowDef  *n = makeNode(WindowDef);
                              16617                 :                : 
 5685 tgl@sss.pgh.pa.us       16618                 :            188 :                     n->frameOptions = FRAMEOPTION_START_UNBOUNDED_FOLLOWING;
                              16619                 :            188 :                     n->startOffset = NULL;
                              16620                 :            188 :                     n->endOffset = NULL;
                              16621                 :            188 :                     $$ = n;
                              16622                 :                :                 }
                              16623                 :                :             | CURRENT_P ROW
                              16624                 :                :                 {
 1212 peter@eisentraut.org    16625                 :            302 :                     WindowDef  *n = makeNode(WindowDef);
                              16626                 :                : 
 5685 tgl@sss.pgh.pa.us       16627                 :            302 :                     n->frameOptions = FRAMEOPTION_START_CURRENT_ROW;
                              16628                 :            302 :                     n->startOffset = NULL;
                              16629                 :            302 :                     n->endOffset = NULL;
                              16630                 :            302 :                     $$ = n;
                              16631                 :                :                 }
                              16632                 :                :             | a_expr PRECEDING
                              16633                 :                :                 {
 1212 peter@eisentraut.org    16634                 :            453 :                     WindowDef  *n = makeNode(WindowDef);
                              16635                 :                : 
 2768 tgl@sss.pgh.pa.us       16636                 :            453 :                     n->frameOptions = FRAMEOPTION_START_OFFSET_PRECEDING;
 5685                         16637                 :            453 :                     n->startOffset = $1;
                              16638                 :            453 :                     n->endOffset = NULL;
                              16639                 :            453 :                     $$ = n;
                              16640                 :                :                 }
                              16641                 :                :             | a_expr FOLLOWING
                              16642                 :                :                 {
 1212 peter@eisentraut.org    16643                 :            576 :                     WindowDef  *n = makeNode(WindowDef);
                              16644                 :                : 
 2768 tgl@sss.pgh.pa.us       16645                 :            576 :                     n->frameOptions = FRAMEOPTION_START_OFFSET_FOLLOWING;
 5685                         16646                 :            576 :                     n->startOffset = $1;
                              16647                 :            576 :                     n->endOffset = NULL;
                              16648                 :            576 :                     $$ = n;
                              16649                 :                :                 }
                              16650                 :                :         ;
                              16651                 :                : 
                              16652                 :                : opt_window_exclusion_clause:
 2768                         16653                 :             42 :             EXCLUDE CURRENT_P ROW   { $$ = FRAMEOPTION_EXCLUDE_CURRENT_ROW; }
                              16654                 :             48 :             | EXCLUDE GROUP_P       { $$ = FRAMEOPTION_EXCLUDE_GROUP; }
                              16655                 :             75 :             | EXCLUDE TIES          { $$ = FRAMEOPTION_EXCLUDE_TIES; }
                              16656                 :              9 :             | EXCLUDE NO OTHERS     { $$ = 0; }
                              16657                 :            638 :             | /*EMPTY*/             { $$ = 0; }
                              16658                 :                :         ;
                              16659                 :                : 
                              16660                 :                : 
                              16661                 :                : /*
                              16662                 :                :  * Supporting nonterminals for expressions.
                              16663                 :                :  */
                              16664                 :                : 
                              16665                 :                : /* Explicit row production.
                              16666                 :                :  *
                              16667                 :                :  * SQL99 allows an optional ROW keyword, so we can now do single-element rows
                              16668                 :                :  * without conflicting with the parenthesized a_expr production.  Without the
                              16669                 :                :  * ROW keyword, there must be more than one a_expr inside the parens.
                              16670                 :                :  */
 7789 tgl@sss.pgh.pa.us       16671                 :UBC           0 : row:        ROW '(' expr_list ')'                   { $$ = $3; }
                              16672                 :              0 :             | ROW '(' ')'                           { $$ = NIL; }
 7789 tgl@sss.pgh.pa.us       16673                 :CBC         966 :             | '(' expr_list ',' a_expr ')'          { $$ = lappend($2, $4); }
                              16674                 :                :         ;
                              16675                 :                : 
 3766 andres@anarazel.de      16676                 :           1890 : explicit_row:   ROW '(' expr_list ')'               { $$ = $3; }
                              16677                 :             18 :             | ROW '(' ')'                           { $$ = NIL; }
                              16678                 :                :         ;
                              16679                 :                : 
                              16680                 :           1352 : implicit_row:   '(' expr_list ',' a_expr ')'        { $$ = lappend($2, $4); }
                              16681                 :                :         ;
                              16682                 :                : 
 7789 tgl@sss.pgh.pa.us       16683                 :           8373 : sub_type:   ANY                                     { $$ = ANY_SUBLINK; }
 7789 tgl@sss.pgh.pa.us       16684                 :UBC           0 :             | SOME                                  { $$ = ANY_SUBLINK; }
 7789 tgl@sss.pgh.pa.us       16685                 :CBC         162 :             | ALL                                   { $$ = ALL_SUBLINK; }
                              16686                 :                :         ;
                              16687                 :                : 
                              16688                 :           5586 : all_Op:     Op                                      { $$ = $1; }
                              16689                 :          14572 :             | MathOp                                { $$ = $1; }
                              16690                 :                :         ;
                              16691                 :                : 
                              16692                 :             20 : MathOp:      '+'                                    { $$ = "+"; }
                              16693                 :             33 :             | '-'                                   { $$ = "-"; }
                              16694                 :             57 :             | '*'                                   { $$ = "*"; }
 7789 tgl@sss.pgh.pa.us       16695                 :UBC           0 :             | '/'                                   { $$ = "/"; }
 7789 tgl@sss.pgh.pa.us       16696                 :CBC           4 :             | '%'                                   { $$ = "%"; }
 7789 tgl@sss.pgh.pa.us       16697                 :UBC           0 :             | '^'                                   { $$ = "^"; }
 7789 tgl@sss.pgh.pa.us       16698                 :CBC         489 :             | '<'                                    { $$ = "<"; }
                              16699                 :            440 :             | '>'                                    { $$ = ">"; }
                              16700                 :          12296 :             | '='                                   { $$ = "="; }
 3832                         16701                 :            422 :             | LESS_EQUALS                           { $$ = "<="; }
                              16702                 :            418 :             | GREATER_EQUALS                        { $$ = ">="; }
                              16703                 :            393 :             | NOT_EQUALS                            { $$ = "<>"; }
                              16704                 :                :         ;
                              16705                 :                : 
                              16706                 :                : qual_Op:    Op
 7769 neilc@samurai.com       16707                 :          21727 :                     { $$ = list_make1(makeString($1)); }
                              16708                 :                :             | OPERATOR '(' any_operator ')'
 7789 tgl@sss.pgh.pa.us       16709                 :           7718 :                     { $$ = $3; }
                              16710                 :                :         ;
                              16711                 :                : 
                              16712                 :                : qual_all_Op:
                              16713                 :                :             all_Op
 7769 neilc@samurai.com       16714                 :            708 :                     { $$ = list_make1(makeString($1)); }
                              16715                 :                :             | OPERATOR '(' any_operator ')'
 7789 tgl@sss.pgh.pa.us       16716                 :             17 :                     { $$ = $3; }
                              16717                 :                :         ;
                              16718                 :                : 
                              16719                 :                : subquery_Op:
                              16720                 :                :             all_Op
 7769 neilc@samurai.com       16721                 :           8381 :                     { $$ = list_make1(makeString($1)); }
                              16722                 :                :             | OPERATOR '(' any_operator ')'
 7789 tgl@sss.pgh.pa.us       16723                 :            138 :                     { $$ = $3; }
                              16724                 :                :             | LIKE
 7769 neilc@samurai.com       16725                 :             12 :                     { $$ = list_make1(makeString("~~")); }
                              16726                 :                :             | NOT_LA LIKE
                              16727                 :              6 :                     { $$ = list_make1(makeString("!~~")); }
                              16728                 :                :             | ILIKE
                              16729                 :              6 :                     { $$ = list_make1(makeString("~~*")); }
                              16730                 :                :             | NOT_LA ILIKE
 7769 neilc@samurai.com       16731                 :UBC           0 :                     { $$ = list_make1(makeString("!~~*")); }
                              16732                 :                : /* cannot put SIMILAR TO here, because SIMILAR TO is a hack.
                              16733                 :                :  * the regular expression is preprocessed by a function (similar_to_escape),
                              16734                 :                :  * and the ~ operator for posix regular expressions is used.
                              16735                 :                :  *        x SIMILAR TO y     ->    x ~ similar_to_escape(y)
                              16736                 :                :  * this transformation is made on the fly by the parser upwards.
                              16737                 :                :  * however the SubLink structure which handles any/some/all stuff
                              16738                 :                :  * is not ready for such a thing.
                              16739                 :                :  */
                              16740                 :                :             ;
                              16741                 :                : 
                              16742                 :                : expr_list:  a_expr
                              16743                 :                :                 {
 7767 tgl@sss.pgh.pa.us       16744                 :CBC       82073 :                     $$ = list_make1($1);
                              16745                 :                :                 }
                              16746                 :                :             | expr_list ',' a_expr
                              16747                 :                :                 {
                              16748                 :          75029 :                     $$ = lappend($1, $3);
                              16749                 :                :                 }
                              16750                 :                :         ;
                              16751                 :                : 
                              16752                 :                : /* function arguments can have names */
                              16753                 :                : func_arg_list:  func_arg_expr
                              16754                 :                :                 {
 5812                         16755                 :         158480 :                     $$ = list_make1($1);
                              16756                 :                :                 }
                              16757                 :                :             | func_arg_list ',' func_arg_expr
                              16758                 :                :                 {
                              16759                 :         142941 :                     $$ = lappend($1, $3);
                              16760                 :                :                 }
                              16761                 :                :         ;
                              16762                 :                : 
                              16763                 :                : func_arg_expr:  a_expr
                              16764                 :                :                 {
                              16765                 :         276031 :                     $$ = $1;
                              16766                 :                :                 }
                              16767                 :                :             | param_name COLON_EQUALS a_expr
                              16768                 :                :                 {
                              16769                 :          24821 :                     NamedArgExpr *na = makeNode(NamedArgExpr);
                              16770                 :                : 
 5578                         16771                 :          24821 :                     na->name = $1;
                              16772                 :          24821 :                     na->arg = (Expr *) $3;
 5812                         16773                 :          24821 :                     na->argnumber = -1;      /* until determined */
 5578                         16774                 :          24821 :                     na->location = @1;
 5812                         16775                 :          24821 :                     $$ = (Node *) na;
                              16776                 :                :                 }
                              16777                 :                :             | param_name EQUALS_GREATER a_expr
                              16778                 :                :                 {
 3833 rhaas@postgresql.org    16779                 :            938 :                     NamedArgExpr *na = makeNode(NamedArgExpr);
                              16780                 :                : 
                              16781                 :            938 :                     na->name = $1;
                              16782                 :            938 :                     na->arg = (Expr *) $3;
                              16783                 :            938 :                     na->argnumber = -1;      /* until determined */
                              16784                 :            938 :                     na->location = @1;
                              16785                 :            938 :                     $$ = (Node *) na;
                              16786                 :                :                 }
                              16787                 :                :         ;
                              16788                 :                : 
 1767 tgl@sss.pgh.pa.us       16789                 :            126 : func_arg_list_opt:  func_arg_list                   { $$ = $1; }
 1767 tgl@sss.pgh.pa.us       16790                 :UBC           0 :             | /*EMPTY*/                             { $$ = NIL; }
                              16791                 :                :         ;
                              16792                 :                : 
 6801 tgl@sss.pgh.pa.us       16793                 :CBC        1197 : type_list:  Typename                                { $$ = list_make1($1); }
                              16794                 :            466 :             | type_list ',' Typename                { $$ = lappend($1, $3); }
                              16795                 :                :         ;
                              16796                 :                : 
                              16797                 :                : array_expr: '[' expr_list ']'
                              16798                 :                :                 {
   86 alvherre@kurilemu.de    16799                 :           3822 :                     $$ = makeAArrayExpr($2, @1, @3);
                              16800                 :                :                 }
                              16801                 :                :             | '[' array_expr_list ']'
                              16802                 :                :                 {
                              16803                 :            206 :                     $$ = makeAArrayExpr($2, @1, @3);
                              16804                 :                :                 }
                              16805                 :                :             | '[' ']'
                              16806                 :                :                 {
                              16807                 :             44 :                     $$ = makeAArrayExpr(NIL, @1, @2);
                              16808                 :                :                 }
                              16809                 :                :         ;
                              16810                 :                : 
 6379 tgl@sss.pgh.pa.us       16811                 :            206 : array_expr_list: array_expr                         { $$ = list_make1($1); }
                              16812                 :            171 :             | array_expr_list ',' array_expr        { $$ = lappend($1, $3); }
                              16813                 :                :         ;
                              16814                 :                : 
                              16815                 :                : 
                              16816                 :                : extract_list:
                              16817                 :                :             extract_arg FROM a_expr
                              16818                 :                :                 {
 6218                         16819                 :            691 :                     $$ = list_make2(makeStringConst($1, @1), $3);
                              16820                 :                :                 }
                              16821                 :                :         ;
                              16822                 :                : 
                              16823                 :                : /* Allow delimited string Sconst in extract_arg as an SQL extension.
                              16824                 :                :  * - thomas 2001-04-12
                              16825                 :                :  */
                              16826                 :                : extract_arg:
 8482 bruce@momjian.us        16827                 :            562 :             IDENT                                   { $$ = $1; }
                              16828                 :             36 :             | YEAR_P                                { $$ = "year"; }
                              16829                 :             21 :             | MONTH_P                               { $$ = "month"; }
                              16830                 :             27 :             | DAY_P                                 { $$ = "day"; }
                              16831                 :             15 :             | HOUR_P                                { $$ = "hour"; }
                              16832                 :             15 :             | MINUTE_P                              { $$ = "minute"; }
                              16833                 :             15 :             | SECOND_P                              { $$ = "second"; }
 6142 meskes@postgresql.or    16834                 :UBC           0 :             | Sconst                                { $$ = $1; }
                              16835                 :                :         ;
                              16836                 :                : 
                              16837                 :                : unicode_normal_form:
 1767 tgl@sss.pgh.pa.us       16838                 :CBC          12 :             NFC                                     { $$ = "NFC"; }
                              16839                 :              9 :             | NFD                                   { $$ = "NFD"; }
                              16840                 :              9 :             | NFKC                                  { $$ = "NFKC"; }
                              16841                 :              9 :             | NFKD                                  { $$ = "NFKD"; }
                              16842                 :                :         ;
                              16843                 :                : 
                              16844                 :                : /* OVERLAY() arguments */
                              16845                 :                : overlay_list:
                              16846                 :                :             a_expr PLACING a_expr FROM a_expr FOR a_expr
                              16847                 :                :                 {
                              16848                 :                :                     /* overlay(A PLACING B FROM C FOR D) is converted to overlay(A, B, C, D) */
 1895 peter@eisentraut.org    16849                 :             17 :                     $$ = list_make4($1, $3, $5, $7);
                              16850                 :                :                 }
                              16851                 :                :             | a_expr PLACING a_expr FROM a_expr
                              16852                 :                :                 {
                              16853                 :                :                     /* overlay(A PLACING B FROM C) is converted to overlay(A, B, C) */
                              16854                 :             24 :                     $$ = list_make3($1, $3, $5);
                              16855                 :                :                 }
                              16856                 :                :         ;
                              16857                 :                : 
                              16858                 :                : /* position_list uses b_expr not a_expr to avoid conflict with general IN */
                              16859                 :                : position_list:
 7769 neilc@samurai.com       16860                 :            200 :             b_expr IN_P b_expr                      { $$ = list_make2($3, $1); }
                              16861                 :                :         ;
                              16862                 :                : 
                              16863                 :                : /*
                              16864                 :                :  * SUBSTRING() arguments
                              16865                 :                :  *
                              16866                 :                :  * Note that SQL:1999 has both
                              16867                 :                :  *     text FROM int FOR int
                              16868                 :                :  * and
                              16869                 :                :  *     text FROM pattern FOR escape
                              16870                 :                :  *
                              16871                 :                :  * In the parser we map them both to a call to the substring() function and
                              16872                 :                :  * rely on type resolution to pick the right one.
                              16873                 :                :  *
                              16874                 :                :  * In SQL:2003, the second variant was changed to
                              16875                 :                :  *     text SIMILAR pattern ESCAPE escape
                              16876                 :                :  * We could in theory map that to a different function internally, but
                              16877                 :                :  * since we still support the SQL:1999 version, we don't.  However,
                              16878                 :                :  * ruleutils.c will reverse-list the call in the newer style.
                              16879                 :                :  */
                              16880                 :                : substr_list:
                              16881                 :                :             a_expr FROM a_expr FOR a_expr
                              16882                 :                :                 {
 1895 peter@eisentraut.org    16883                 :             61 :                     $$ = list_make3($1, $3, $5);
                              16884                 :                :                 }
                              16885                 :                :             | a_expr FOR a_expr FROM a_expr
                              16886                 :                :                 {
                              16887                 :                :                     /* not legal per SQL, but might as well allow it */
 1895 peter@eisentraut.org    16888                 :UBC           0 :                     $$ = list_make3($1, $5, $3);
                              16889                 :                :                 }
                              16890                 :                :             | a_expr FROM a_expr
                              16891                 :                :                 {
                              16892                 :                :                     /*
                              16893                 :                :                      * Because we aren't restricting data types here, this
                              16894                 :                :                      * syntax can end up resolving to textregexsubstr().
                              16895                 :                :                      * We've historically allowed that to happen, so continue
                              16896                 :                :                      * to accept it.  However, ruleutils.c will reverse-list
                              16897                 :                :                      * such a call in regular function call syntax.
                              16898                 :                :                      */
 1895 peter@eisentraut.org    16899                 :CBC         185 :                     $$ = list_make2($1, $3);
                              16900                 :                :                 }
                              16901                 :                :             | a_expr FOR a_expr
                              16902                 :                :                 {
                              16903                 :                :                     /* not legal per SQL */
                              16904                 :                : 
                              16905                 :                :                     /*
                              16906                 :                :                      * Since there are no cases where this syntax allows
                              16907                 :                :                      * a textual FOR value, we forcibly cast the argument
                              16908                 :                :                      * to int4.  The possible matches in pg_proc are
                              16909                 :                :                      * substring(text,int4) and substring(text,text),
                              16910                 :                :                      * and we don't want the parser to choose the latter,
                              16911                 :                :                      * which it is likely to do if the second argument
                              16912                 :                :                      * is unknown or doesn't have an implicit cast to int4.
                              16913                 :                :                      */
 6218 tgl@sss.pgh.pa.us       16914                 :             18 :                     $$ = list_make3($1, makeIntConst(1, -1),
                              16915                 :                :                                     makeTypeCast($3,
                              16916                 :                :                                                  SystemTypeName("int4"), -1));
                              16917                 :                :                 }
                              16918                 :                :             | a_expr SIMILAR a_expr ESCAPE a_expr
                              16919                 :                :                 {
 1895 peter@eisentraut.org    16920                 :             91 :                     $$ = list_make3($1, $3, $5);
                              16921                 :                :                 }
                              16922                 :                :         ;
                              16923                 :                : 
 8482 bruce@momjian.us        16924                 :            302 : trim_list:  a_expr FROM expr_list                   { $$ = lappend($3, $1); }
                              16925                 :             12 :             | FROM expr_list                        { $$ = $2; }
                              16926                 :             43 :             | expr_list                             { $$ = $1; }
                              16927                 :                :         ;
                              16928                 :                : 
                              16929                 :                : /*
                              16930                 :                :  * Define SQL-style CASE clause.
                              16931                 :                :  * - Full specification
                              16932                 :                :  *  CASE WHEN a = b THEN c ... ELSE d END
                              16933                 :                :  * - Implicit argument
                              16934                 :                :  *  CASE a WHEN b THEN c ... ELSE d END
                              16935                 :                :  */
                              16936                 :                : case_expr:  CASE case_arg when_clause_list case_default END_P
                              16937                 :                :                 {
 1212 peter@eisentraut.org    16938                 :          19591 :                     CaseExpr   *c = makeNode(CaseExpr);
                              16939                 :                : 
 7843 tgl@sss.pgh.pa.us       16940                 :          19591 :                     c->casetype = InvalidOid; /* not analyzed yet */
 8304                         16941                 :          19591 :                     c->arg = (Expr *) $2;
 9773 lockhart@fourpalms.o    16942                 :          19591 :                     c->args = $3;
 8304 tgl@sss.pgh.pa.us       16943                 :          19591 :                     c->defresult = (Expr *) $4;
 6218                         16944                 :          19591 :                     c->location = @1;
 1212 peter@eisentraut.org    16945                 :          19591 :                     $$ = (Node *) c;
                              16946                 :                :                 }
                              16947                 :                :         ;
                              16948                 :                : 
                              16949                 :                : when_clause_list:
                              16950                 :                :             /* There must be at least one */
 7769 neilc@samurai.com       16951                 :          19591 :             when_clause                             { $$ = list_make1($1); }
 8481 bruce@momjian.us        16952                 :          14533 :             | when_clause_list when_clause          { $$ = lappend($1, $2); }
                              16953                 :                :         ;
                              16954                 :                : 
                              16955                 :                : when_clause:
                              16956                 :                :             WHEN a_expr THEN a_expr
                              16957                 :                :                 {
 1212 peter@eisentraut.org    16958                 :          34124 :                     CaseWhen   *w = makeNode(CaseWhen);
                              16959                 :                : 
 8304 tgl@sss.pgh.pa.us       16960                 :          34124 :                     w->expr = (Expr *) $2;
                              16961                 :          34124 :                     w->result = (Expr *) $4;
 6218                         16962                 :          34124 :                     w->location = @1;
 1212 peter@eisentraut.org    16963                 :          34124 :                     $$ = (Node *) w;
                              16964                 :                :                 }
                              16965                 :                :         ;
                              16966                 :                : 
                              16967                 :                : case_default:
 8482 bruce@momjian.us        16968                 :          14727 :             ELSE a_expr                             { $$ = $2; }
                              16969                 :           4864 :             | /*EMPTY*/                             { $$ = NULL; }
                              16970                 :                :         ;
                              16971                 :                : 
                              16972                 :           3379 : case_arg:   a_expr                                  { $$ = $1; }
                              16973                 :          16212 :             | /*EMPTY*/                             { $$ = NULL; }
                              16974                 :                :         ;
                              16975                 :                : 
                              16976                 :                : columnref:  ColId
                              16977                 :                :                 {
 5899 tgl@sss.pgh.pa.us       16978                 :         386945 :                     $$ = makeColumnRef($1, NIL, @1, yyscanner);
                              16979                 :                :                 }
                              16980                 :                :             | ColId indirection
                              16981                 :                :                 {
                              16982                 :         536348 :                     $$ = makeColumnRef($1, $2, @1, yyscanner);
                              16983                 :                :                 }
                              16984                 :                :         ;
                              16985                 :                : 
                              16986                 :                : indirection_el:
                              16987                 :                :             '.' attr_name
                              16988                 :                :                 {
 7759                         16989                 :         728929 :                     $$ = (Node *) makeString($2);
                              16990                 :                :                 }
                              16991                 :                :             | '.' '*'
                              16992                 :                :                 {
 6216                         16993                 :           3488 :                     $$ = (Node *) makeNode(A_Star);
                              16994                 :                :                 }
                              16995                 :                :             | '[' a_expr ']'
                              16996                 :                :                 {
 7759                         16997                 :           6445 :                     A_Indices *ai = makeNode(A_Indices);
                              16998                 :                : 
 3546                         16999                 :           6445 :                     ai->is_slice = false;
 7759                         17000                 :           6445 :                     ai->lidx = NULL;
                              17001                 :           6445 :                     ai->uidx = $2;
                              17002                 :           6445 :                     $$ = (Node *) ai;
                              17003                 :                :                 }
                              17004                 :                :             | '[' opt_slice_bound ':' opt_slice_bound ']'
                              17005                 :                :                 {
                              17006                 :            294 :                     A_Indices *ai = makeNode(A_Indices);
                              17007                 :                : 
 3546                         17008                 :            294 :                     ai->is_slice = true;
 7759                         17009                 :            294 :                     ai->lidx = $2;
                              17010                 :            294 :                     ai->uidx = $4;
                              17011                 :            294 :                     $$ = (Node *) ai;
                              17012                 :                :                 }
                              17013                 :                :         ;
                              17014                 :                : 
                              17015                 :                : opt_slice_bound:
 3546                         17016                 :            498 :             a_expr                                  { $$ = $1; }
                              17017                 :             90 :             | /*EMPTY*/                             { $$ = NULL; }
                              17018                 :                :         ;
                              17019                 :                : 
                              17020                 :                : indirection:
 7759                         17021                 :         728915 :             indirection_el                          { $$ = list_make1($1); }
                              17022                 :           1542 :             | indirection indirection_el            { $$ = lappend($1, $2); }
                              17023                 :                :         ;
                              17024                 :                : 
                              17025                 :                : opt_indirection:
                              17026                 :          94817 :             /*EMPTY*/                               { $$ = NIL; }
                              17027                 :           8699 :             | opt_indirection indirection_el        { $$ = lappend($1, $2); }
                              17028                 :                :         ;
                              17029                 :                : 
                              17030                 :                : opt_asymmetric: ASYMMETRIC
                              17031                 :                :             | /*EMPTY*/
                              17032                 :                :         ;
                              17033                 :                : 
                              17034                 :                : /* SQL/JSON support */
                              17035                 :                : json_passing_clause_opt:
  534 amitlan@postgresql.o    17036                 :            168 :             PASSING json_arguments                  { $$ = $2; }
                              17037                 :            968 :             | /*EMPTY*/                             { $$ = NIL; }
                              17038                 :                :         ;
                              17039                 :                : 
                              17040                 :                : json_arguments:
                              17041                 :            168 :             json_argument                           { $$ = list_make1($1); }
                              17042                 :             63 :             | json_arguments ',' json_argument      { $$ = lappend($1, $3); }
                              17043                 :                :         ;
                              17044                 :                : 
                              17045                 :                : json_argument:
                              17046                 :                :             json_value_expr AS ColLabel
                              17047                 :                :             {
                              17048                 :            231 :                 JsonArgument *n = makeNode(JsonArgument);
                              17049                 :                : 
                              17050                 :            231 :                 n->val = (JsonValueExpr *) $1;
                              17051                 :            231 :                 n->name = $3;
                              17052                 :            231 :                 $$ = (Node *) n;
                              17053                 :                :             }
                              17054                 :                :         ;
                              17055                 :                : 
                              17056                 :                : /* ARRAY is a noise word */
                              17057                 :                : json_wrapper_behavior:
                              17058                 :             21 :               WITHOUT WRAPPER                   { $$ = JSW_NONE; }
  534 amitlan@postgresql.o    17059                 :UBC           0 :             | WITHOUT ARRAY WRAPPER             { $$ = JSW_NONE; }
  534 amitlan@postgresql.o    17060                 :CBC          39 :             | WITH WRAPPER                      { $$ = JSW_UNCONDITIONAL; }
                              17061                 :              6 :             | WITH ARRAY WRAPPER                { $$ = JSW_UNCONDITIONAL; }
  534 amitlan@postgresql.o    17062                 :UBC           0 :             | WITH CONDITIONAL ARRAY WRAPPER    { $$ = JSW_CONDITIONAL; }
  534 amitlan@postgresql.o    17063                 :CBC           6 :             | WITH UNCONDITIONAL ARRAY WRAPPER  { $$ = JSW_UNCONDITIONAL; }
                              17064                 :             18 :             | WITH CONDITIONAL WRAPPER          { $$ = JSW_CONDITIONAL; }
                              17065                 :              3 :             | WITH UNCONDITIONAL WRAPPER        { $$ = JSW_UNCONDITIONAL; }
                              17066                 :            818 :             | /* empty */                       { $$ = JSW_UNSPEC; }
                              17067                 :                :         ;
                              17068                 :                : 
                              17069                 :                : json_behavior:
                              17070                 :                :             DEFAULT a_expr
                              17071                 :            192 :                 { $$ = (Node *) makeJsonBehavior(JSON_BEHAVIOR_DEFAULT, $2, @1); }
                              17072                 :                :             | json_behavior_type
                              17073                 :            351 :                 { $$ = (Node *) makeJsonBehavior($1, NULL, @1); }
                              17074                 :                :         ;
                              17075                 :                : 
                              17076                 :                : json_behavior_type:
                              17077                 :            246 :             ERROR_P     { $$ = JSON_BEHAVIOR_ERROR; }
                              17078                 :             15 :             | NULL_P    { $$ = JSON_BEHAVIOR_NULL; }
                              17079                 :             15 :             | TRUE_P    { $$ = JSON_BEHAVIOR_TRUE; }
                              17080                 :              6 :             | FALSE_P   { $$ = JSON_BEHAVIOR_FALSE; }
                              17081                 :              6 :             | UNKNOWN   { $$ = JSON_BEHAVIOR_UNKNOWN; }
                              17082                 :             15 :             | EMPTY_P ARRAY { $$ = JSON_BEHAVIOR_EMPTY_ARRAY; }
                              17083                 :             36 :             | EMPTY_P OBJECT_P  { $$ = JSON_BEHAVIOR_EMPTY_OBJECT; }
                              17084                 :                :             /* non-standard, for Oracle compatibility only */
                              17085                 :             12 :             | EMPTY_P   { $$ = JSON_BEHAVIOR_EMPTY_ARRAY; }
                              17086                 :                :         ;
                              17087                 :                : 
                              17088                 :                : json_behavior_clause_opt:
                              17089                 :                :             json_behavior ON EMPTY_P
                              17090                 :             87 :                 { $$ = list_make2($1, NULL); }
                              17091                 :                :             | json_behavior ON ERROR_P
                              17092                 :            276 :                 { $$ = list_make2(NULL, $1); }
                              17093                 :                :             | json_behavior ON EMPTY_P json_behavior ON ERROR_P
                              17094                 :             51 :                 { $$ = list_make2($1, $4); }
                              17095                 :                :             | /* EMPTY */
                              17096                 :            785 :                 { $$ = list_make2(NULL, NULL); }
                              17097                 :                :         ;
                              17098                 :                : 
                              17099                 :                : json_on_error_clause_opt:
                              17100                 :                :             json_behavior ON ERROR_P
                              17101                 :             75 :                 { $$ = $1; }
                              17102                 :                :             | /* EMPTY */
                              17103                 :            344 :                 { $$ = NULL; }
                              17104                 :                :         ;
                              17105                 :                : 
                              17106                 :                : json_value_expr:
                              17107                 :                :             a_expr json_format_clause_opt
                              17108                 :                :             {
                              17109                 :                :                 /* formatted_expr will be set during parse-analysis. */
  778                         17110                 :           2081 :                 $$ = (Node *) makeJsonValueExpr((Expr *) $1, NULL,
                              17111                 :           2081 :                                                 castNode(JsonFormat, $2));
                              17112                 :                :             }
                              17113                 :                :         ;
                              17114                 :                : 
                              17115                 :                : json_format_clause:
                              17116                 :                :             FORMAT_LA JSON ENCODING name
                              17117                 :                :                 {
                              17118                 :                :                     int     encoding;
                              17119                 :                : 
  635 alvherre@alvh.no-ip.    17120         [ +  + ]:             49 :                     if (!pg_strcasecmp($4, "utf8"))
                              17121                 :             31 :                         encoding = JS_ENC_UTF8;
                              17122         [ +  + ]:             18 :                     else if (!pg_strcasecmp($4, "utf16"))
                              17123                 :              6 :                         encoding = JS_ENC_UTF16;
                              17124         [ +  + ]:             12 :                     else if (!pg_strcasecmp($4, "utf32"))
                              17125                 :              6 :                         encoding = JS_ENC_UTF32;
                              17126                 :                :                     else
                              17127         [ +  - ]:              6 :                         ereport(ERROR,
                              17128                 :                :                                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                              17129                 :                :                                  errmsg("unrecognized JSON encoding: %s", $4),
                              17130                 :                :                                  parser_errposition(@4)));
                              17131                 :                : 
                              17132                 :             43 :                     $$ = (Node *) makeJsonFormat(JS_FORMAT_JSON, encoding, @1);
                              17133                 :                :                 }
                              17134                 :                :             | FORMAT_LA JSON
                              17135                 :                :                 {
                              17136                 :            202 :                     $$ = (Node *) makeJsonFormat(JS_FORMAT_JSON, JS_ENC_DEFAULT, @1);
                              17137                 :                :                 }
                              17138                 :                :         ;
                              17139                 :                : 
                              17140                 :                : json_format_clause_opt:
                              17141                 :                :             json_format_clause
                              17142                 :                :                 {
                              17143                 :            191 :                     $$ = $1;
                              17144                 :                :                 }
                              17145                 :                :             | /* EMPTY */
                              17146                 :                :                 {
  892                         17147                 :           2635 :                     $$ = (Node *) makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1);
                              17148                 :                :                 }
                              17149                 :                :         ;
                              17150                 :                : 
                              17151                 :                : json_quotes_clause_opt:
  534 amitlan@postgresql.o    17152                 :              6 :             KEEP QUOTES ON SCALAR STRING_P      { $$ = JS_QUOTES_KEEP; }
                              17153                 :             45 :             | KEEP QUOTES                       { $$ = JS_QUOTES_KEEP; }
                              17154                 :              6 :             | OMIT QUOTES ON SCALAR STRING_P    { $$ = JS_QUOTES_OMIT; }
                              17155                 :             84 :             | OMIT QUOTES                       { $$ = JS_QUOTES_OMIT; }
                              17156                 :            770 :             | /* EMPTY */                       { $$ = JS_QUOTES_UNSPEC; }
                              17157                 :                :         ;
                              17158                 :                : 
                              17159                 :                : json_returning_clause_opt:
                              17160                 :                :             RETURNING Typename json_format_clause_opt
                              17161                 :                :                 {
  892 alvherre@alvh.no-ip.    17162                 :            715 :                     JsonOutput *n = makeNode(JsonOutput);
                              17163                 :                : 
                              17164                 :            715 :                     n->typeName = $2;
                              17165                 :            715 :                     n->returning = makeNode(JsonReturning);
                              17166                 :            715 :                     n->returning->format = (JsonFormat *) $3;
                              17167                 :            715 :                     $$ = (Node *) n;
                              17168                 :                :                 }
                              17169                 :            633 :             | /* EMPTY */                           { $$ = NULL; }
                              17170                 :                :         ;
                              17171                 :                : 
                              17172                 :                : /*
                              17173                 :                :  * We must assign the only-JSON production a precedence less than IDENT in
                              17174                 :                :  * order to favor shifting over reduction when JSON is followed by VALUE_P,
                              17175                 :                :  * OBJECT_P, or SCALAR.  (ARRAY doesn't need that treatment, because it's a
                              17176                 :                :  * fully reserved word.)  Because json_predicate_type_constraint is always
                              17177                 :                :  * followed by json_key_uniqueness_constraint_opt, we also need the only-JSON
                              17178                 :                :  * production to have precedence less than WITH and WITHOUT.  UNBOUNDED isn't
                              17179                 :                :  * really related to this syntax, but it's a convenient choice because it
                              17180                 :                :  * already has a precedence less than IDENT for other reasons.
                              17181                 :                :  */
                              17182                 :                : json_predicate_type_constraint:
  648 tgl@sss.pgh.pa.us       17183                 :             97 :             JSON                    %prec UNBOUNDED { $$ = JS_TYPE_ANY; }
  890 alvherre@alvh.no-ip.    17184                 :             13 :             | JSON VALUE_P                          { $$ = JS_TYPE_ANY; }
                              17185                 :             19 :             | JSON ARRAY                            { $$ = JS_TYPE_ARRAY; }
                              17186                 :             19 :             | JSON OBJECT_P                         { $$ = JS_TYPE_OBJECT; }
                              17187                 :             19 :             | JSON SCALAR                           { $$ = JS_TYPE_SCALAR; }
                              17188                 :                :         ;
                              17189                 :                : 
                              17190                 :                : /*
                              17191                 :                :  * KEYS is a noise word here.  To avoid shift/reduce conflicts, assign the
                              17192                 :                :  * KEYS-less productions a precedence less than IDENT (i.e., less than KEYS).
                              17193                 :                :  * This prevents reducing them when the next token is KEYS.
                              17194                 :                :  */
                              17195                 :                : json_key_uniqueness_constraint_opt:
                              17196                 :             51 :             WITH UNIQUE KEYS                            { $$ = true; }
  648 tgl@sss.pgh.pa.us       17197                 :             49 :             | WITH UNIQUE               %prec UNBOUNDED { $$ = true; }
  886 alvherre@alvh.no-ip.    17198                 :             20 :             | WITHOUT UNIQUE KEYS                       { $$ = false; }
  648 tgl@sss.pgh.pa.us       17199                 :              7 :             | WITHOUT UNIQUE            %prec UNBOUNDED { $$ = false; }
                              17200                 :            387 :             | /* EMPTY */               %prec UNBOUNDED { $$ = false; }
                              17201                 :                :         ;
                              17202                 :                : 
                              17203                 :                : json_name_and_value_list:
                              17204                 :                :             json_name_and_value
  892 alvherre@alvh.no-ip.    17205                 :            171 :                 { $$ = list_make1($1); }
                              17206                 :                :             | json_name_and_value_list ',' json_name_and_value
                              17207                 :            124 :                 { $$ = lappend($1, $3); }
                              17208                 :                :         ;
                              17209                 :                : 
                              17210                 :                : json_name_and_value:
                              17211                 :                : /* Supporting this syntax seems to require major surgery
                              17212                 :                :             KEY c_expr VALUE_P json_value_expr
                              17213                 :                :                 { $$ = makeJsonKeyValue($2, $4); }
                              17214                 :                :             |
                              17215                 :                : */
                              17216                 :                :             c_expr VALUE_P json_value_expr
                              17217                 :             12 :                 { $$ = makeJsonKeyValue($1, $3); }
                              17218                 :                :             |
                              17219                 :                :             a_expr ':' json_value_expr
                              17220                 :            385 :                 { $$ = makeJsonKeyValue($1, $3); }
                              17221                 :                :         ;
                              17222                 :                : 
                              17223                 :                : /* empty means false for objects, true for arrays */
                              17224                 :                : json_object_constructor_null_clause_opt:
                              17225                 :             15 :             NULL_P ON NULL_P                    { $$ = false; }
                              17226                 :             53 :             | ABSENT ON NULL_P                  { $$ = true; }
                              17227                 :            205 :             | /* EMPTY */                       { $$ = false; }
                              17228                 :                :         ;
                              17229                 :                : 
                              17230                 :                : json_array_constructor_null_clause_opt:
                              17231                 :             30 :             NULL_P ON NULL_P                        { $$ = false; }
                              17232                 :             18 :             | ABSENT ON NULL_P                      { $$ = true; }
                              17233                 :             84 :             | /* EMPTY */                           { $$ = true; }
                              17234                 :                :         ;
                              17235                 :                : 
                              17236                 :                : json_value_expr_list:
                              17237                 :             54 :             json_value_expr                             { $$ = list_make1($1); }
                              17238                 :             63 :             | json_value_expr_list ',' json_value_expr  { $$ = lappend($1, $3);}
                              17239                 :                :         ;
                              17240                 :                : 
                              17241                 :                : json_aggregate_func:
                              17242                 :                :             JSON_OBJECTAGG '('
                              17243                 :                :                 json_name_and_value
                              17244                 :                :                 json_object_constructor_null_clause_opt
                              17245                 :                :                 json_key_uniqueness_constraint_opt
                              17246                 :                :                 json_returning_clause_opt
                              17247                 :                :             ')'
                              17248                 :                :                 {
                              17249                 :            102 :                     JsonObjectAgg *n = makeNode(JsonObjectAgg);
                              17250                 :                : 
                              17251                 :            102 :                     n->arg = (JsonKeyValue *) $3;
                              17252                 :            102 :                     n->absent_on_null = $4;
                              17253                 :            102 :                     n->unique = $5;
                              17254                 :            102 :                     n->constructor = makeNode(JsonAggConstructor);
                              17255                 :            102 :                     n->constructor->output = (JsonOutput *) $6;
                              17256                 :            102 :                     n->constructor->agg_order = NULL;
                              17257                 :            102 :                     n->constructor->location = @1;
                              17258                 :            102 :                     $$ = (Node *) n;
                              17259                 :                :                 }
                              17260                 :                :             | JSON_ARRAYAGG '('
                              17261                 :                :                 json_value_expr
                              17262                 :                :                 json_array_aggregate_order_by_clause_opt
                              17263                 :                :                 json_array_constructor_null_clause_opt
                              17264                 :                :                 json_returning_clause_opt
                              17265                 :                :             ')'
                              17266                 :                :                 {
                              17267                 :             78 :                     JsonArrayAgg *n = makeNode(JsonArrayAgg);
                              17268                 :                : 
                              17269                 :             78 :                     n->arg = (JsonValueExpr *) $3;
                              17270                 :             78 :                     n->absent_on_null = $5;
                              17271                 :             78 :                     n->constructor = makeNode(JsonAggConstructor);
                              17272                 :             78 :                     n->constructor->agg_order = $4;
                              17273                 :             78 :                     n->constructor->output = (JsonOutput *) $6;
                              17274                 :             78 :                     n->constructor->location = @1;
                              17275                 :             78 :                     $$ = (Node *) n;
                              17276                 :                :                 }
                              17277                 :                :         ;
                              17278                 :                : 
                              17279                 :                : json_array_aggregate_order_by_clause_opt:
                              17280                 :              9 :             ORDER BY sortby_list                    { $$ = $3; }
                              17281                 :             69 :             | /* EMPTY */                           { $$ = NIL; }
                              17282                 :                :         ;
                              17283                 :                : 
                              17284                 :                : /*****************************************************************************
                              17285                 :                :  *
                              17286                 :                :  *  target list for SELECT
                              17287                 :                :  *
                              17288                 :                :  *****************************************************************************/
                              17289                 :                : 
 4284 tgl@sss.pgh.pa.us       17290                 :         235860 : opt_target_list: target_list                        { $$ = $1; }
                              17291                 :            243 :             | /* EMPTY */                           { $$ = NIL; }
                              17292                 :                :         ;
                              17293                 :                : 
                              17294                 :                : target_list:
 7769 neilc@samurai.com       17295                 :         239282 :             target_el                               { $$ = list_make1($1); }
 8481 bruce@momjian.us        17296                 :         351492 :             | target_list ',' target_el             { $$ = lappend($1, $3); }
                              17297                 :                :         ;
                              17298                 :                : 
                              17299                 :                : target_el:  a_expr AS ColLabel
                              17300                 :                :                 {
10225                         17301                 :         117915 :                     $$ = makeNode(ResTarget);
                              17302                 :         117915 :                     $$->name = $3;
 8570 tgl@sss.pgh.pa.us       17303                 :         117915 :                     $$->indirection = NIL;
 1212 peter@eisentraut.org    17304                 :         117915 :                     $$->val = (Node *) $1;
 7107 tgl@sss.pgh.pa.us       17305                 :         117915 :                     $$->location = @1;
                              17306                 :                :                 }
                              17307                 :                :             | a_expr BareColLabel
                              17308                 :                :                 {
 6413                         17309                 :           1758 :                     $$ = makeNode(ResTarget);
                              17310                 :           1758 :                     $$->name = $2;
                              17311                 :           1758 :                     $$->indirection = NIL;
 1212 peter@eisentraut.org    17312                 :           1758 :                     $$->val = (Node *) $1;
 6413 tgl@sss.pgh.pa.us       17313                 :           1758 :                     $$->location = @1;
                              17314                 :                :                 }
                              17315                 :                :             | a_expr
                              17316                 :                :                 {
10225 bruce@momjian.us        17317                 :         442922 :                     $$ = makeNode(ResTarget);
                              17318                 :         442922 :                     $$->name = NULL;
 8570 tgl@sss.pgh.pa.us       17319                 :         442922 :                     $$->indirection = NIL;
 1212 peter@eisentraut.org    17320                 :         442922 :                     $$->val = (Node *) $1;
 7107 tgl@sss.pgh.pa.us       17321                 :         442922 :                     $$->location = @1;
                              17322                 :                :                 }
                              17323                 :                :             | '*'
                              17324                 :                :                 {
 1212 peter@eisentraut.org    17325                 :          28179 :                     ColumnRef  *n = makeNode(ColumnRef);
                              17326                 :                : 
 6216 tgl@sss.pgh.pa.us       17327                 :          28179 :                     n->fields = list_make1(makeNode(A_Star));
 7116                         17328                 :          28179 :                     n->location = @1;
                              17329                 :                : 
10225 bruce@momjian.us        17330                 :          28179 :                     $$ = makeNode(ResTarget);
                              17331                 :          28179 :                     $$->name = NULL;
 8570 tgl@sss.pgh.pa.us       17332                 :          28179 :                     $$->indirection = NIL;
 1212 peter@eisentraut.org    17333                 :          28179 :                     $$->val = (Node *) n;
 7107 tgl@sss.pgh.pa.us       17334                 :          28179 :                     $$->location = @1;
                              17335                 :                :                 }
                              17336                 :                :         ;
                              17337                 :                : 
                              17338                 :                : 
                              17339                 :                : /*****************************************************************************
                              17340                 :                :  *
                              17341                 :                :  *  Names and constants
                              17342                 :                :  *
                              17343                 :                :  *****************************************************************************/
                              17344                 :                : 
                              17345                 :                : qualified_name_list:
 7769 neilc@samurai.com       17346                 :           8768 :             qualified_name                          { $$ = list_make1($1); }
 8482 bruce@momjian.us        17347                 :            227 :             | qualified_name_list ',' qualified_name { $$ = lappend($1, $3); }
                              17348                 :                :         ;
                              17349                 :                : 
                              17350                 :                : /*
                              17351                 :                :  * The production for a qualified relation name has to exactly match the
                              17352                 :                :  * production for a qualified func_name, because in a FROM clause we cannot
                              17353                 :                :  * tell which we are parsing until we see what comes after it ('(' for a
                              17354                 :                :  * func_name, something else for a relation). Therefore we allow 'indirection'
                              17355                 :                :  * which may contain subscripts, and reject that case in the C code.
                              17356                 :                :  */
                              17357                 :                : qualified_name:
                              17358                 :                :             ColId
                              17359                 :                :                 {
 5381 rhaas@postgresql.org    17360                 :         207768 :                     $$ = makeRangeVar(NULL, $1, @1);
                              17361                 :                :                 }
                              17362                 :                :             | ColId indirection
                              17363                 :                :                 {
 1410 akapila@postgresql.o    17364                 :         128571 :                     $$ = makeRangeVarFromQualifiedName($1, $2, @1, yyscanner);
                              17365                 :                :                 }
                              17366                 :                :         ;
                              17367                 :                : 
                              17368                 :                : name_list:  name
 7769 neilc@samurai.com       17369                 :          14147 :                     { $$ = list_make1(makeString($1)); }
                              17370                 :                :             | name_list ',' name
 8481 bruce@momjian.us        17371                 :          30842 :                     { $$ = lappend($1, makeString($3)); }
                              17372                 :                :         ;
                              17373                 :                : 
                              17374                 :                : 
 8482                         17375                 :          87310 : name:       ColId                                   { $$ = $1; };
                              17376                 :                : 
 7683 tgl@sss.pgh.pa.us       17377                 :         794138 : attr_name:  ColLabel                                { $$ = $1; };
                              17378                 :                : 
 8482 bruce@momjian.us        17379                 :             27 : file_name:  Sconst                                  { $$ = $1; };
                              17380                 :                : 
                              17381                 :                : /*
                              17382                 :                :  * The production for a qualified func_name has to exactly match the
                              17383                 :                :  * production for a qualified columnref, because we cannot tell which we
                              17384                 :                :  * are parsing until we see what comes after it ('(' or Sconst for a func_name,
                              17385                 :                :  * anything else for a columnref).  Therefore we allow 'indirection' which
                              17386                 :                :  * may contain subscripts, and reject that case in the C code.  (If we
                              17387                 :                :  * ever implement SQL99-like methods, such syntax may actually become legal!)
                              17388                 :                :  */
                              17389                 :                : func_name:  type_function_name
 7769 neilc@samurai.com       17390                 :         146229 :                     { $$ = list_make1(makeString($1)); }
                              17391                 :                :             | ColId indirection
                              17392                 :                :                     {
 5899 tgl@sss.pgh.pa.us       17393                 :          63957 :                         $$ = check_func_name(lcons(makeString($1), $2),
                              17394                 :                :                                              yyscanner);
                              17395                 :                :                     }
                              17396                 :                :         ;
                              17397                 :                : 
                              17398                 :                : 
                              17399                 :                : /*
                              17400                 :                :  * Constants
                              17401                 :                :  */
                              17402                 :                : AexprConst: Iconst
                              17403                 :                :                 {
 6218                         17404                 :         192358 :                     $$ = makeIntConst($1, @1);
                              17405                 :                :                 }
                              17406                 :                :             | FCONST
                              17407                 :                :                 {
                              17408                 :           5677 :                     $$ = makeFloatConst($1, @1);
                              17409                 :                :                 }
                              17410                 :                :             | Sconst
                              17411                 :                :                 {
                              17412                 :         350942 :                     $$ = makeStringConst($1, @1);
                              17413                 :                :                 }
                              17414                 :                :             | BCONST
                              17415                 :                :                 {
                              17416                 :            376 :                     $$ = makeBitStringConst($1, @1);
                              17417                 :                :                 }
                              17418                 :                :             | XCONST
                              17419                 :                :                 {
                              17420                 :                :                     /* This is a bit constant per SQL99:
                              17421                 :                :                      * Without Feature F511, "BIT data type",
                              17422                 :                :                      * a <general literal> shall not be a
                              17423                 :                :                      * <bit string literal> or a <hex string literal>.
                              17424                 :                :                      */
                              17425                 :           1650 :                     $$ = makeBitStringConst($1, @1);
                              17426                 :                :                 }
                              17427                 :                :             | func_name Sconst
                              17428                 :                :                 {
                              17429                 :                :                     /* generic type 'literal' syntax */
 1212 peter@eisentraut.org    17430                 :           4919 :                     TypeName   *t = makeTypeNameFromNameList($1);
                              17431                 :                : 
 6339 alvherre@alvh.no-ip.    17432                 :           4919 :                     t->location = @1;
 6218 tgl@sss.pgh.pa.us       17433                 :           4919 :                     $$ = makeStringConstCast($2, @2, t);
                              17434                 :                :                 }
                              17435                 :                :             | func_name '(' func_arg_list opt_sort_clause ')' Sconst
                              17436                 :                :                 {
                              17437                 :                :                     /* generic syntax with a type modifier */
 1212 peter@eisentraut.org    17438                 :UBC           0 :                     TypeName   *t = makeTypeNameFromNameList($1);
                              17439                 :                :                     ListCell   *lc;
                              17440                 :                : 
                              17441                 :                :                     /*
                              17442                 :                :                      * We must use func_arg_list and opt_sort_clause in the
                              17443                 :                :                      * production to avoid reduce/reduce conflicts, but we
                              17444                 :                :                      * don't actually wish to allow NamedArgExpr in this
                              17445                 :                :                      * context, nor ORDER BY.
                              17446                 :                :                      */
 5812 tgl@sss.pgh.pa.us       17447   [ #  #  #  #  :              0 :                     foreach(lc, $3)
                                              #  # ]
                              17448                 :                :                     {
                              17449                 :              0 :                         NamedArgExpr *arg = (NamedArgExpr *) lfirst(lc);
                              17450                 :                : 
                              17451         [ #  # ]:              0 :                         if (IsA(arg, NamedArgExpr))
                              17452         [ #  # ]:              0 :                             ereport(ERROR,
                              17453                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              17454                 :                :                                      errmsg("type modifier cannot have parameter name"),
                              17455                 :                :                                      parser_errposition(arg->location)));
                              17456                 :                :                     }
 4275                         17457         [ #  # ]:              0 :                     if ($4 != NIL)
                              17458         [ #  # ]:              0 :                             ereport(ERROR,
                              17459                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              17460                 :                :                                      errmsg("type modifier cannot have ORDER BY"),
                              17461                 :                :                                      parser_errposition(@4)));
                              17462                 :                : 
 6339 alvherre@alvh.no-ip.    17463                 :              0 :                     t->typmods = $3;
                              17464                 :              0 :                     t->location = @1;
 4275 tgl@sss.pgh.pa.us       17465                 :              0 :                     $$ = makeStringConstCast($6, @6, t);
                              17466                 :                :                 }
                              17467                 :                :             | ConstTypename Sconst
                              17468                 :                :                 {
 6218 tgl@sss.pgh.pa.us       17469                 :CBC        1586 :                     $$ = makeStringConstCast($2, @2, $1);
                              17470                 :                :                 }
                              17471                 :                :             | ConstInterval Sconst opt_interval
                              17472                 :                :                 {
 1212 peter@eisentraut.org    17473                 :           1649 :                     TypeName   *t = $1;
                              17474                 :                : 
 6204 tgl@sss.pgh.pa.us       17475                 :           1649 :                     t->typmods = $3;
 6218                         17476                 :           1649 :                     $$ = makeStringConstCast($2, @2, t);
                              17477                 :                :                 }
                              17478                 :                :             | ConstInterval '(' Iconst ')' Sconst
                              17479                 :                :                 {
 1212 peter@eisentraut.org    17480                 :              6 :                     TypeName   *t = $1;
                              17481                 :                : 
 3976 bruce@momjian.us        17482                 :              6 :                     t->typmods = list_make2(makeIntConst(INTERVAL_FULL_RANGE, -1),
                              17483                 :                :                                             makeIntConst($3, @3));
 6218 tgl@sss.pgh.pa.us       17484                 :              6 :                     $$ = makeStringConstCast($5, @5, t);
                              17485                 :                :                 }
                              17486                 :                :             | TRUE_P
                              17487                 :                :                 {
 2943 peter_e@gmx.net         17488                 :          16112 :                     $$ = makeBoolAConst(true, @1);
                              17489                 :                :                 }
                              17490                 :                :             | FALSE_P
                              17491                 :                :                 {
                              17492                 :          18554 :                     $$ = makeBoolAConst(false, @1);
                              17493                 :                :                 }
                              17494                 :                :             | NULL_P
                              17495                 :                :                 {
 6218 tgl@sss.pgh.pa.us       17496                 :          33467 :                     $$ = makeNullAConst(@1);
                              17497                 :                :                 }
                              17498                 :                :         ;
                              17499                 :                : 
 8482 bruce@momjian.us        17500                 :         206404 : Iconst:     ICONST                                  { $$ = $1; };
                              17501                 :         386763 : Sconst:     SCONST                                  { $$ = $1; };
                              17502                 :                : 
 6142 meskes@postgresql.or    17503                 :           8709 : SignedIconst: Iconst                                { $$ = $1; }
 6142 meskes@postgresql.or    17504                 :UBC           0 :             | '+' Iconst                            { $$ = + $2; }
 6142 meskes@postgresql.or    17505                 :CBC         144 :             | '-' Iconst                            { $$ = - $2; }
                              17506                 :                :         ;
                              17507                 :                : 
                              17508                 :                : /* Role specifications */
                              17509                 :                : RoleId:     RoleSpec
                              17510                 :                :                 {
 1212 peter@eisentraut.org    17511                 :            947 :                     RoleSpec   *spc = (RoleSpec *) $1;
                              17512                 :                : 
 3834 alvherre@alvh.no-ip.    17513   [ +  +  +  +  :            947 :                     switch (spc->roletype)
                                              +  - ]
                              17514                 :                :                     {
                              17515                 :            942 :                         case ROLESPEC_CSTRING:
                              17516                 :            942 :                             $$ = spc->rolename;
                              17517                 :            942 :                             break;
                              17518                 :              2 :                         case ROLESPEC_PUBLIC:
                              17519         [ +  - ]:              2 :                             ereport(ERROR,
                              17520                 :                :                                     (errcode(ERRCODE_RESERVED_NAME),
                              17521                 :                :                                      errmsg("role name \"%s\" is reserved",
                              17522                 :                :                                             "public"),
                              17523                 :                :                                      parser_errposition(@1)));
                              17524                 :                :                             break;
                              17525                 :              1 :                         case ROLESPEC_SESSION_USER:
                              17526         [ +  - ]:              1 :                             ereport(ERROR,
                              17527                 :                :                                     (errcode(ERRCODE_RESERVED_NAME),
                              17528                 :                :                                      errmsg("%s cannot be used as a role name here",
                              17529                 :                :                                             "SESSION_USER"),
                              17530                 :                :                                      parser_errposition(@1)));
                              17531                 :                :                             break;
                              17532                 :              1 :                         case ROLESPEC_CURRENT_USER:
                              17533         [ +  - ]:              1 :                             ereport(ERROR,
                              17534                 :                :                                     (errcode(ERRCODE_RESERVED_NAME),
                              17535                 :                :                                      errmsg("%s cannot be used as a role name here",
                              17536                 :                :                                             "CURRENT_USER"),
                              17537                 :                :                                      parser_errposition(@1)));
                              17538                 :                :                             break;
 1815 peter@eisentraut.org    17539                 :              1 :                         case ROLESPEC_CURRENT_ROLE:
                              17540         [ +  - ]:              1 :                             ereport(ERROR,
                              17541                 :                :                                     (errcode(ERRCODE_RESERVED_NAME),
                              17542                 :                :                                      errmsg("%s cannot be used as a role name here",
                              17543                 :                :                                             "CURRENT_ROLE"),
                              17544                 :                :                                      parser_errposition(@1)));
                              17545                 :                :                             break;
                              17546                 :                :                     }
                              17547                 :                :                 }
                              17548                 :                :             ;
                              17549                 :                : 
                              17550                 :                : RoleSpec:   NonReservedWord
                              17551                 :                :                 {
                              17552                 :                :                     /*
                              17553                 :                :                      * "public" and "none" are not keywords, but they must
                              17554                 :                :                      * be treated specially here.
                              17555                 :                :                      */
                              17556                 :                :                     RoleSpec   *n;
                              17557                 :                : 
 1212                         17558         [ +  + ]:          16301 :                     if (strcmp($1, "public") == 0)
                              17559                 :                :                     {
                              17560                 :           8894 :                         n = (RoleSpec *) makeRoleSpec(ROLESPEC_PUBLIC, @1);
                              17561                 :           8894 :                         n->roletype = ROLESPEC_PUBLIC;
                              17562                 :                :                     }
                              17563         [ +  + ]:           7407 :                     else if (strcmp($1, "none") == 0)
                              17564                 :                :                     {
                              17565         [ +  - ]:             13 :                         ereport(ERROR,
                              17566                 :                :                                 (errcode(ERRCODE_RESERVED_NAME),
                              17567                 :                :                                  errmsg("role name \"%s\" is reserved",
                              17568                 :                :                                         "none"),
                              17569                 :                :                                  parser_errposition(@1)));
                              17570                 :                :                     }
                              17571                 :                :                     else
                              17572                 :                :                     {
                              17573                 :           7394 :                         n = makeRoleSpec(ROLESPEC_CSTRING, @1);
                              17574                 :           7394 :                         n->rolename = pstrdup($1);
                              17575                 :                :                     }
                              17576                 :          16288 :                     $$ = n;
                              17577                 :                :                 }
                              17578                 :                :             | CURRENT_ROLE
                              17579                 :                :                 {
                              17580                 :             65 :                     $$ = makeRoleSpec(ROLESPEC_CURRENT_ROLE, @1);
                              17581                 :                :                 }
                              17582                 :                :             | CURRENT_USER
                              17583                 :                :                 {
                              17584                 :            114 :                     $$ = makeRoleSpec(ROLESPEC_CURRENT_USER, @1);
                              17585                 :                :                 }
                              17586                 :                :             | SESSION_USER
                              17587                 :                :                 {
                              17588                 :             18 :                     $$ = makeRoleSpec(ROLESPEC_SESSION_USER, @1);
                              17589                 :                :                 }
                              17590                 :                :         ;
                              17591                 :                : 
                              17592                 :                : role_list:  RoleSpec
                              17593                 :           1635 :                 { $$ = list_make1($1); }
                              17594                 :                :             | role_list ',' RoleSpec
                              17595                 :            135 :                 { $$ = lappend($1, $3); }
                              17596                 :                :         ;
                              17597                 :                : 
                              17598                 :                : 
                              17599                 :                : /*****************************************************************************
                              17600                 :                :  *
                              17601                 :                :  * PL/pgSQL extensions
                              17602                 :                :  *
                              17603                 :                :  * You'd think a PL/pgSQL "expression" should be just an a_expr, but
                              17604                 :                :  * historically it can include just about anything that can follow SELECT.
                              17605                 :                :  * Therefore the returned struct is a SelectStmt.
                              17606                 :                :  *****************************************************************************/
                              17607                 :                : 
                              17608                 :                : PLpgSQL_Expr: opt_distinct_clause opt_target_list
                              17609                 :                :             from_clause where_clause
                              17610                 :                :             group_clause having_clause window_clause
                              17611                 :                :             opt_sort_clause opt_select_limit opt_for_locking_clause
                              17612                 :                :                 {
 1706 tgl@sss.pgh.pa.us       17613                 :          20684 :                     SelectStmt *n = makeNode(SelectStmt);
                              17614                 :                : 
 1688                         17615                 :          20684 :                     n->distinctClause = $1;
                              17616                 :          20684 :                     n->targetList = $2;
                              17617                 :          20684 :                     n->fromClause = $3;
                              17618                 :          20684 :                     n->whereClause = $4;
 1633 tomas.vondra@postgre    17619                 :          20684 :                     n->groupClause = ($5)->list;
                              17620                 :          20684 :                     n->groupDistinct = ($5)->distinct;
 1688 tgl@sss.pgh.pa.us       17621                 :          20684 :                     n->havingClause = $6;
                              17622                 :          20684 :                     n->windowClause = $7;
                              17623                 :          20684 :                     n->sortClause = $8;
                              17624         [ +  + ]:          20684 :                     if ($9)
                              17625                 :                :                     {
                              17626                 :              2 :                         n->limitOffset = $9->limitOffset;
                              17627                 :              2 :                         n->limitCount = $9->limitCount;
 1706                         17628         [ +  - ]:              2 :                         if (!n->sortClause &&
 1688                         17629         [ -  + ]:              2 :                             $9->limitOption == LIMIT_OPTION_WITH_TIES)
 1706 tgl@sss.pgh.pa.us       17630         [ #  # ]:UBC           0 :                             ereport(ERROR,
                              17631                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              17632                 :                :                                      errmsg("WITH TIES cannot be specified without ORDER BY clause"),
                              17633                 :                :                                      parser_errposition($9->optionLoc)));
 1688 tgl@sss.pgh.pa.us       17634                 :CBC           2 :                         n->limitOption = $9->limitOption;
                              17635                 :                :                     }
                              17636                 :          20684 :                     n->lockingClause = $10;
 1706                         17637                 :          20684 :                     $$ = (Node *) n;
                              17638                 :                :                 }
                              17639                 :                :         ;
                              17640                 :                : 
                              17641                 :                : /*
                              17642                 :                :  * PL/pgSQL Assignment statement: name opt_indirection := PLpgSQL_Expr
                              17643                 :                :  */
                              17644                 :                : 
                              17645                 :                : PLAssignStmt: plassign_target opt_indirection plassign_equals PLpgSQL_Expr
                              17646                 :                :                 {
                              17647                 :           3639 :                     PLAssignStmt *n = makeNode(PLAssignStmt);
                              17648                 :                : 
                              17649                 :           3639 :                     n->name = $1;
                              17650                 :           3639 :                     n->indirection = check_indirection($2, yyscanner);
                              17651                 :                :                     /* nnames will be filled by calling production */
                              17652                 :           3639 :                     n->val = (SelectStmt *) $4;
                              17653                 :           3639 :                     n->location = @1;
                              17654                 :           3639 :                     $$ = (Node *) n;
                              17655                 :                :                 }
                              17656                 :                :         ;
                              17657                 :                : 
                              17658                 :           3627 : plassign_target: ColId                          { $$ = $1; }
                              17659                 :             12 :             | PARAM                             { $$ = psprintf("$%d", $1); }
                              17660                 :                :         ;
                              17661                 :                : 
                              17662                 :                : plassign_equals: COLON_EQUALS
                              17663                 :                :             | '='
                              17664                 :                :         ;
                              17665                 :                : 
                              17666                 :                : 
                              17667                 :                : /*
                              17668                 :                :  * Name classification hierarchy.
                              17669                 :                :  *
                              17670                 :                :  * IDENT is the lexeme returned by the lexer for identifiers that match
                              17671                 :                :  * no known keyword.  In most cases, we can accept certain keywords as
                              17672                 :                :  * names, not only IDENTs.  We prefer to accept as many such keywords
                              17673                 :                :  * as possible to minimize the impact of "reserved words" on programmers.
                              17674                 :                :  * So, we divide names into several possible classes.  The classification
                              17675                 :                :  * is chosen in part to make keywords acceptable as names wherever possible.
                              17676                 :                :  */
                              17677                 :                : 
                              17678                 :                : /* Column identifier --- names that can be column, table, etc names.
                              17679                 :                :  */
 8482 bruce@momjian.us        17680                 :        1705564 : ColId:      IDENT                                   { $$ = $1; }
                              17681                 :          28944 :             | unreserved_keyword                    { $$ = pstrdup($1); }
                              17682                 :           3076 :             | col_name_keyword                      { $$ = pstrdup($1); }
                              17683                 :                :         ;
                              17684                 :                : 
                              17685                 :                : /* Type/function identifier --- names that can be type or function names.
                              17686                 :                :  */
 6825 tgl@sss.pgh.pa.us       17687                 :         356745 : type_function_name: IDENT                           { $$ = $1; }
 8482 bruce@momjian.us        17688                 :          37478 :             | unreserved_keyword                    { $$ = pstrdup($1); }
 6825 tgl@sss.pgh.pa.us       17689                 :             33 :             | type_func_name_keyword                { $$ = pstrdup($1); }
                              17690                 :                :         ;
                              17691                 :                : 
                              17692                 :                : /* Any not-fully-reserved word --- these names can be, eg, role names.
                              17693                 :                :  */
 4479                         17694                 :          41386 : NonReservedWord:    IDENT                           { $$ = $1; }
                              17695                 :          15134 :             | unreserved_keyword                    { $$ = pstrdup($1); }
                              17696                 :             89 :             | col_name_keyword                      { $$ = pstrdup($1); }
                              17697                 :           2627 :             | type_func_name_keyword                { $$ = pstrdup($1); }
                              17698                 :                :         ;
                              17699                 :                : 
                              17700                 :                : /* Column label --- allowed labels in "AS" clauses.
                              17701                 :                :  * This presently includes *all* Postgres keywords.
                              17702                 :                :  */
 8482 bruce@momjian.us        17703                 :         904048 : ColLabel:   IDENT                                   { $$ = $1; }
                              17704                 :          19906 :             | unreserved_keyword                    { $$ = pstrdup($1); }
                              17705                 :            142 :             | col_name_keyword                      { $$ = pstrdup($1); }
 6825 tgl@sss.pgh.pa.us       17706                 :            892 :             | type_func_name_keyword                { $$ = pstrdup($1); }
 8482 bruce@momjian.us        17707                 :           3759 :             | reserved_keyword                      { $$ = pstrdup($1); }
                              17708                 :                :         ;
                              17709                 :                : 
                              17710                 :                : /* Bare column label --- names that can be column labels without writing "AS".
                              17711                 :                :  * This classification is orthogonal to the other keyword categories.
                              17712                 :                :  */
 1814 tgl@sss.pgh.pa.us       17713                 :           1749 : BareColLabel:   IDENT                               { $$ = $1; }
                              17714                 :              9 :             | bare_label_keyword                    { $$ = pstrdup($1); }
                              17715                 :                :         ;
                              17716                 :                : 
                              17717                 :                : 
                              17718                 :                : /*
                              17719                 :                :  * Keyword category lists.  Generally, every keyword present in
                              17720                 :                :  * the Postgres grammar should appear in exactly one of these lists.
                              17721                 :                :  *
                              17722                 :                :  * Put a new keyword into the first list that it can go into without causing
                              17723                 :                :  * shift or reduce conflicts.  The earlier lists define "less reserved"
                              17724                 :                :  * categories of keywords.
                              17725                 :                :  *
                              17726                 :                :  * Make sure that each keyword's category in kwlist.h matches where
                              17727                 :                :  * it is listed here.  (Someday we may be able to generate these lists and
                              17728                 :                :  * kwlist.h's table from one source of truth.)
                              17729                 :                :  */
                              17730                 :                : 
                              17731                 :                : /* "Unreserved" keywords --- available for use as any kind of name.
                              17732                 :                :  */
                              17733                 :                : unreserved_keyword:
                              17734                 :                :               ABORT_P
                              17735                 :                :             | ABSENT
                              17736                 :                :             | ABSOLUTE_P
                              17737                 :                :             | ACCESS
                              17738                 :                :             | ACTION
                              17739                 :                :             | ADD_P
                              17740                 :                :             | ADMIN
                              17741                 :                :             | AFTER
                              17742                 :                :             | AGGREGATE
                              17743                 :                :             | ALSO
                              17744                 :                :             | ALTER
                              17745                 :                :             | ALWAYS
                              17746                 :                :             | ASENSITIVE
                              17747                 :                :             | ASSERTION
                              17748                 :                :             | ASSIGNMENT
                              17749                 :                :             | AT
                              17750                 :                :             | ATOMIC
                              17751                 :                :             | ATTACH
                              17752                 :                :             | ATTRIBUTE
                              17753                 :                :             | BACKWARD
                              17754                 :                :             | BEFORE
                              17755                 :                :             | BEGIN_P
                              17756                 :                :             | BREADTH
                              17757                 :                :             | BY
                              17758                 :                :             | CACHE
                              17759                 :                :             | CALL
                              17760                 :                :             | CALLED
                              17761                 :                :             | CASCADE
                              17762                 :                :             | CASCADED
                              17763                 :                :             | CATALOG_P
                              17764                 :                :             | CHAIN
                              17765                 :                :             | CHARACTERISTICS
                              17766                 :                :             | CHECKPOINT
                              17767                 :                :             | CLASS
                              17768                 :                :             | CLOSE
                              17769                 :                :             | CLUSTER
                              17770                 :                :             | COLUMNS
                              17771                 :                :             | COMMENT
                              17772                 :                :             | COMMENTS
                              17773                 :                :             | COMMIT
                              17774                 :                :             | COMMITTED
                              17775                 :                :             | COMPRESSION
                              17776                 :                :             | CONDITIONAL
                              17777                 :                :             | CONFIGURATION
                              17778                 :                :             | CONFLICT
                              17779                 :                :             | CONNECTION
                              17780                 :                :             | CONSTRAINTS
                              17781                 :                :             | CONTENT_P
                              17782                 :                :             | CONTINUE_P
                              17783                 :                :             | CONVERSION_P
                              17784                 :                :             | COPY
                              17785                 :                :             | COST
                              17786                 :                :             | CSV
                              17787                 :                :             | CUBE
                              17788                 :                :             | CURRENT_P
                              17789                 :                :             | CURSOR
                              17790                 :                :             | CYCLE
                              17791                 :                :             | DATA_P
                              17792                 :                :             | DATABASE
                              17793                 :                :             | DAY_P
                              17794                 :                :             | DEALLOCATE
                              17795                 :                :             | DECLARE
                              17796                 :                :             | DEFAULTS
                              17797                 :                :             | DEFERRED
                              17798                 :                :             | DEFINER
                              17799                 :                :             | DELETE_P
                              17800                 :                :             | DELIMITER
                              17801                 :                :             | DELIMITERS
                              17802                 :                :             | DEPENDS
                              17803                 :                :             | DEPTH
                              17804                 :                :             | DETACH
                              17805                 :                :             | DICTIONARY
                              17806                 :                :             | DISABLE_P
                              17807                 :                :             | DISCARD
                              17808                 :                :             | DOCUMENT_P
                              17809                 :                :             | DOMAIN_P
                              17810                 :                :             | DOUBLE_P
                              17811                 :                :             | DROP
                              17812                 :                :             | EACH
                              17813                 :                :             | EMPTY_P
                              17814                 :                :             | ENABLE_P
                              17815                 :                :             | ENCODING
                              17816                 :                :             | ENCRYPTED
                              17817                 :                :             | ENFORCED
                              17818                 :                :             | ENUM_P
                              17819                 :                :             | ERROR_P
                              17820                 :                :             | ESCAPE
                              17821                 :                :             | EVENT
                              17822                 :                :             | EXCLUDE
                              17823                 :                :             | EXCLUDING
                              17824                 :                :             | EXCLUSIVE
                              17825                 :                :             | EXECUTE
                              17826                 :                :             | EXPLAIN
                              17827                 :                :             | EXPRESSION
                              17828                 :                :             | EXTENSION
                              17829                 :                :             | EXTERNAL
                              17830                 :                :             | FAMILY
                              17831                 :                :             | FILTER
                              17832                 :                :             | FINALIZE
                              17833                 :                :             | FIRST_P
                              17834                 :                :             | FOLLOWING
                              17835                 :                :             | FORCE
                              17836                 :                :             | FORMAT
                              17837                 :                :             | FORWARD
                              17838                 :                :             | FUNCTION
                              17839                 :                :             | FUNCTIONS
                              17840                 :                :             | GENERATED
                              17841                 :                :             | GLOBAL
                              17842                 :                :             | GRANTED
                              17843                 :                :             | GROUPS
                              17844                 :                :             | HANDLER
                              17845                 :                :             | HEADER_P
                              17846                 :                :             | HOLD
                              17847                 :                :             | HOUR_P
                              17848                 :                :             | IDENTITY_P
                              17849                 :                :             | IF_P
                              17850                 :                :             | IMMEDIATE
                              17851                 :                :             | IMMUTABLE
                              17852                 :                :             | IMPLICIT_P
                              17853                 :                :             | IMPORT_P
                              17854                 :                :             | INCLUDE
                              17855                 :                :             | INCLUDING
                              17856                 :                :             | INCREMENT
                              17857                 :                :             | INDENT
                              17858                 :                :             | INDEX
                              17859                 :                :             | INDEXES
                              17860                 :                :             | INHERIT
                              17861                 :                :             | INHERITS
                              17862                 :                :             | INLINE_P
                              17863                 :                :             | INPUT_P
                              17864                 :                :             | INSENSITIVE
                              17865                 :                :             | INSERT
                              17866                 :                :             | INSTEAD
                              17867                 :                :             | INVOKER
                              17868                 :                :             | ISOLATION
                              17869                 :                :             | KEEP
                              17870                 :                :             | KEY
                              17871                 :                :             | KEYS
                              17872                 :                :             | LABEL
                              17873                 :                :             | LANGUAGE
                              17874                 :                :             | LARGE_P
                              17875                 :                :             | LAST_P
                              17876                 :                :             | LEAKPROOF
                              17877                 :                :             | LEVEL
                              17878                 :                :             | LISTEN
                              17879                 :                :             | LOAD
                              17880                 :                :             | LOCAL
                              17881                 :                :             | LOCATION
                              17882                 :                :             | LOCK_P
                              17883                 :                :             | LOCKED
                              17884                 :                :             | LOGGED
                              17885                 :                :             | MAPPING
                              17886                 :                :             | MATCH
                              17887                 :                :             | MATCHED
                              17888                 :                :             | MATERIALIZED
                              17889                 :                :             | MAXVALUE
                              17890                 :                :             | MERGE
                              17891                 :                :             | METHOD
                              17892                 :                :             | MINUTE_P
                              17893                 :                :             | MINVALUE
                              17894                 :                :             | MODE
                              17895                 :                :             | MONTH_P
                              17896                 :                :             | MOVE
                              17897                 :                :             | NAME_P
                              17898                 :                :             | NAMES
                              17899                 :                :             | NESTED
                              17900                 :                :             | NEW
                              17901                 :                :             | NEXT
                              17902                 :                :             | NFC
                              17903                 :                :             | NFD
                              17904                 :                :             | NFKC
                              17905                 :                :             | NFKD
                              17906                 :                :             | NO
                              17907                 :                :             | NORMALIZED
                              17908                 :                :             | NOTHING
                              17909                 :                :             | NOTIFY
                              17910                 :                :             | NOWAIT
                              17911                 :                :             | NULLS_P
                              17912                 :                :             | OBJECT_P
                              17913                 :                :             | OBJECTS_P
                              17914                 :                :             | OF
                              17915                 :                :             | OFF
                              17916                 :                :             | OIDS
                              17917                 :                :             | OLD
                              17918                 :                :             | OMIT
                              17919                 :                :             | OPERATOR
                              17920                 :                :             | OPTION
                              17921                 :                :             | OPTIONS
                              17922                 :                :             | ORDINALITY
                              17923                 :                :             | OTHERS
                              17924                 :                :             | OVER
                              17925                 :                :             | OVERRIDING
                              17926                 :                :             | OWNED
                              17927                 :                :             | OWNER
                              17928                 :                :             | PARALLEL
                              17929                 :                :             | PARAMETER
                              17930                 :                :             | PARSER
                              17931                 :                :             | PARTIAL
                              17932                 :                :             | PARTITION
                              17933                 :                :             | PASSING
                              17934                 :                :             | PASSWORD
                              17935                 :                :             | PATH
                              17936                 :                :             | PERIOD
                              17937                 :                :             | PLAN
                              17938                 :                :             | PLANS
                              17939                 :                :             | POLICY
                              17940                 :                :             | PRECEDING
                              17941                 :                :             | PREPARE
                              17942                 :                :             | PREPARED
                              17943                 :                :             | PRESERVE
                              17944                 :                :             | PRIOR
                              17945                 :                :             | PRIVILEGES
                              17946                 :                :             | PROCEDURAL
                              17947                 :                :             | PROCEDURE
                              17948                 :                :             | PROCEDURES
                              17949                 :                :             | PROGRAM
                              17950                 :                :             | PUBLICATION
                              17951                 :                :             | QUOTE
                              17952                 :                :             | QUOTES
                              17953                 :                :             | RANGE
                              17954                 :                :             | READ
                              17955                 :                :             | REASSIGN
                              17956                 :                :             | RECURSIVE
                              17957                 :                :             | REF_P
                              17958                 :                :             | REFERENCING
                              17959                 :                :             | REFRESH
                              17960                 :                :             | REINDEX
                              17961                 :                :             | RELATIVE_P
                              17962                 :                :             | RELEASE
                              17963                 :                :             | RENAME
                              17964                 :                :             | REPEATABLE
                              17965                 :                :             | REPLACE
                              17966                 :                :             | REPLICA
                              17967                 :                :             | RESET
                              17968                 :                :             | RESTART
                              17969                 :                :             | RESTRICT
                              17970                 :                :             | RETURN
                              17971                 :                :             | RETURNS
                              17972                 :                :             | REVOKE
                              17973                 :                :             | ROLE
                              17974                 :                :             | ROLLBACK
                              17975                 :                :             | ROLLUP
                              17976                 :                :             | ROUTINE
                              17977                 :                :             | ROUTINES
                              17978                 :                :             | ROWS
                              17979                 :                :             | RULE
                              17980                 :                :             | SAVEPOINT
                              17981                 :                :             | SCALAR
                              17982                 :                :             | SCHEMA
                              17983                 :                :             | SCHEMAS
                              17984                 :                :             | SCROLL
                              17985                 :                :             | SEARCH
                              17986                 :                :             | SECOND_P
                              17987                 :                :             | SECURITY
                              17988                 :                :             | SEQUENCE
                              17989                 :                :             | SEQUENCES
                              17990                 :                :             | SERIALIZABLE
                              17991                 :                :             | SERVER
                              17992                 :                :             | SESSION
                              17993                 :                :             | SET
                              17994                 :                :             | SETS
                              17995                 :                :             | SHARE
                              17996                 :                :             | SHOW
                              17997                 :                :             | SIMPLE
                              17998                 :                :             | SKIP
                              17999                 :                :             | SNAPSHOT
                              18000                 :                :             | SOURCE
                              18001                 :                :             | SQL_P
                              18002                 :                :             | STABLE
                              18003                 :                :             | STANDALONE_P
                              18004                 :                :             | START
                              18005                 :                :             | STATEMENT
                              18006                 :                :             | STATISTICS
                              18007                 :                :             | STDIN
                              18008                 :                :             | STDOUT
                              18009                 :                :             | STORAGE
                              18010                 :                :             | STORED
                              18011                 :                :             | STRICT_P
                              18012                 :                :             | STRING_P
                              18013                 :                :             | STRIP_P
                              18014                 :                :             | SUBSCRIPTION
                              18015                 :                :             | SUPPORT
                              18016                 :                :             | SYSID
                              18017                 :                :             | SYSTEM_P
                              18018                 :                :             | TABLES
                              18019                 :                :             | TABLESPACE
                              18020                 :                :             | TARGET
                              18021                 :                :             | TEMP
                              18022                 :                :             | TEMPLATE
                              18023                 :                :             | TEMPORARY
                              18024                 :                :             | TEXT_P
                              18025                 :                :             | TIES
                              18026                 :                :             | TRANSACTION
                              18027                 :                :             | TRANSFORM
                              18028                 :                :             | TRIGGER
                              18029                 :                :             | TRUNCATE
                              18030                 :                :             | TRUSTED
                              18031                 :                :             | TYPE_P
                              18032                 :                :             | TYPES_P
                              18033                 :                :             | UESCAPE
                              18034                 :                :             | UNBOUNDED
                              18035                 :                :             | UNCOMMITTED
                              18036                 :                :             | UNCONDITIONAL
                              18037                 :                :             | UNENCRYPTED
                              18038                 :                :             | UNKNOWN
                              18039                 :                :             | UNLISTEN
                              18040                 :                :             | UNLOGGED
                              18041                 :                :             | UNTIL
                              18042                 :                :             | UPDATE
                              18043                 :                :             | VACUUM
                              18044                 :                :             | VALID
                              18045                 :                :             | VALIDATE
                              18046                 :                :             | VALIDATOR
                              18047                 :                :             | VALUE_P
                              18048                 :                :             | VARYING
                              18049                 :                :             | VERSION_P
                              18050                 :                :             | VIEW
                              18051                 :                :             | VIEWS
                              18052                 :                :             | VIRTUAL
                              18053                 :                :             | VOLATILE
                              18054                 :                :             | WHITESPACE_P
                              18055                 :                :             | WITHIN
                              18056                 :                :             | WITHOUT
                              18057                 :                :             | WORK
                              18058                 :                :             | WRAPPER
                              18059                 :                :             | WRITE
                              18060                 :                :             | XML_P
                              18061                 :                :             | YEAR_P
                              18062                 :                :             | YES_P
                              18063                 :                :             | ZONE
                              18064                 :                :         ;
                              18065                 :                : 
                              18066                 :                : /* Column identifier --- keywords that can be column, table, etc names.
                              18067                 :                :  *
                              18068                 :                :  * Many of these keywords will in fact be recognized as type or function
                              18069                 :                :  * names too; but they have special productions for the purpose, and so
                              18070                 :                :  * can't be treated as "generic" type or function names.
                              18071                 :                :  *
                              18072                 :                :  * The type names appearing here are not usable as function names
                              18073                 :                :  * because they can be followed by '(' in typename productions, which
                              18074                 :                :  * looks too much like a function call for an LR(1) parser.
                              18075                 :                :  */
                              18076                 :                : col_name_keyword:
                              18077                 :                :               BETWEEN
                              18078                 :                :             | BIGINT
                              18079                 :                :             | BIT
                              18080                 :                :             | BOOLEAN_P
                              18081                 :                :             | CHAR_P
                              18082                 :                :             | CHARACTER
                              18083                 :                :             | COALESCE
                              18084                 :                :             | DEC
                              18085                 :                :             | DECIMAL_P
                              18086                 :                :             | EXISTS
                              18087                 :                :             | EXTRACT
                              18088                 :                :             | FLOAT_P
                              18089                 :                :             | GREATEST
                              18090                 :                :             | GROUPING
                              18091                 :                :             | INOUT
                              18092                 :                :             | INT_P
                              18093                 :                :             | INTEGER
                              18094                 :                :             | INTERVAL
                              18095                 :                :             | JSON
                              18096                 :                :             | JSON_ARRAY
                              18097                 :                :             | JSON_ARRAYAGG
                              18098                 :                :             | JSON_EXISTS
                              18099                 :                :             | JSON_OBJECT
                              18100                 :                :             | JSON_OBJECTAGG
                              18101                 :                :             | JSON_QUERY
                              18102                 :                :             | JSON_SCALAR
                              18103                 :                :             | JSON_SERIALIZE
                              18104                 :                :             | JSON_TABLE
                              18105                 :                :             | JSON_VALUE
                              18106                 :                :             | LEAST
                              18107                 :                :             | MERGE_ACTION
                              18108                 :                :             | NATIONAL
                              18109                 :                :             | NCHAR
                              18110                 :                :             | NONE
                              18111                 :                :             | NORMALIZE
                              18112                 :                :             | NULLIF
                              18113                 :                :             | NUMERIC
                              18114                 :                :             | OUT_P
                              18115                 :                :             | OVERLAY
                              18116                 :                :             | POSITION
                              18117                 :                :             | PRECISION
                              18118                 :                :             | REAL
                              18119                 :                :             | ROW
                              18120                 :                :             | SETOF
                              18121                 :                :             | SMALLINT
                              18122                 :                :             | SUBSTRING
                              18123                 :                :             | TIME
                              18124                 :                :             | TIMESTAMP
                              18125                 :                :             | TREAT
                              18126                 :                :             | TRIM
                              18127                 :                :             | VALUES
                              18128                 :                :             | VARCHAR
                              18129                 :                :             | XMLATTRIBUTES
                              18130                 :                :             | XMLCONCAT
                              18131                 :                :             | XMLELEMENT
                              18132                 :                :             | XMLEXISTS
                              18133                 :                :             | XMLFOREST
                              18134                 :                :             | XMLNAMESPACES
                              18135                 :                :             | XMLPARSE
                              18136                 :                :             | XMLPI
                              18137                 :                :             | XMLROOT
                              18138                 :                :             | XMLSERIALIZE
                              18139                 :                :             | XMLTABLE
                              18140                 :                :         ;
                              18141                 :                : 
                              18142                 :                : /* Type/function identifier --- keywords that can be type or function names.
                              18143                 :                :  *
                              18144                 :                :  * Most of these are keywords that are used as operators in expressions;
                              18145                 :                :  * in general such keywords can't be column names because they would be
                              18146                 :                :  * ambiguous with variables, but they are unambiguous as function identifiers.
                              18147                 :                :  *
                              18148                 :                :  * Do not include POSITION, SUBSTRING, etc here since they have explicit
                              18149                 :                :  * productions in a_expr to support the goofy SQL9x argument syntax.
                              18150                 :                :  * - thomas 2000-11-28
                              18151                 :                :  */
                              18152                 :                : type_func_name_keyword:
                              18153                 :                :               AUTHORIZATION
                              18154                 :                :             | BINARY
                              18155                 :                :             | COLLATION
                              18156                 :                :             | CONCURRENTLY
                              18157                 :                :             | CROSS
                              18158                 :                :             | CURRENT_SCHEMA
                              18159                 :                :             | FREEZE
                              18160                 :                :             | FULL
                              18161                 :                :             | ILIKE
                              18162                 :                :             | INNER_P
                              18163                 :                :             | IS
                              18164                 :                :             | ISNULL
                              18165                 :                :             | JOIN
                              18166                 :                :             | LEFT
                              18167                 :                :             | LIKE
                              18168                 :                :             | NATURAL
                              18169                 :                :             | NOTNULL
                              18170                 :                :             | OUTER_P
                              18171                 :                :             | OVERLAPS
                              18172                 :                :             | RIGHT
                              18173                 :                :             | SIMILAR
                              18174                 :                :             | TABLESAMPLE
                              18175                 :                :             | VERBOSE
                              18176                 :                :         ;
                              18177                 :                : 
                              18178                 :                : /* Reserved keyword --- these keywords are usable only as a ColLabel.
                              18179                 :                :  *
                              18180                 :                :  * Keywords appear here if they could not be distinguished from variable,
                              18181                 :                :  * type, or function names in some contexts.  Don't put things here unless
                              18182                 :                :  * forced to.
                              18183                 :                :  */
                              18184                 :                : reserved_keyword:
                              18185                 :                :               ALL
                              18186                 :                :             | ANALYSE
                              18187                 :                :             | ANALYZE
                              18188                 :                :             | AND
                              18189                 :                :             | ANY
                              18190                 :                :             | ARRAY
                              18191                 :                :             | AS
                              18192                 :                :             | ASC
                              18193                 :                :             | ASYMMETRIC
                              18194                 :                :             | BOTH
                              18195                 :                :             | CASE
                              18196                 :                :             | CAST
                              18197                 :                :             | CHECK
                              18198                 :                :             | COLLATE
                              18199                 :                :             | COLUMN
                              18200                 :                :             | CONSTRAINT
                              18201                 :                :             | CREATE
                              18202                 :                :             | CURRENT_CATALOG
                              18203                 :                :             | CURRENT_DATE
                              18204                 :                :             | CURRENT_ROLE
                              18205                 :                :             | CURRENT_TIME
                              18206                 :                :             | CURRENT_TIMESTAMP
                              18207                 :                :             | CURRENT_USER
                              18208                 :                :             | DEFAULT
                              18209                 :                :             | DEFERRABLE
                              18210                 :                :             | DESC
                              18211                 :                :             | DISTINCT
                              18212                 :                :             | DO
                              18213                 :                :             | ELSE
                              18214                 :                :             | END_P
                              18215                 :                :             | EXCEPT
                              18216                 :                :             | FALSE_P
                              18217                 :                :             | FETCH
                              18218                 :                :             | FOR
                              18219                 :                :             | FOREIGN
                              18220                 :                :             | FROM
                              18221                 :                :             | GRANT
                              18222                 :                :             | GROUP_P
                              18223                 :                :             | HAVING
                              18224                 :                :             | IN_P
                              18225                 :                :             | INITIALLY
                              18226                 :                :             | INTERSECT
                              18227                 :                :             | INTO
                              18228                 :                :             | LATERAL_P
                              18229                 :                :             | LEADING
                              18230                 :                :             | LIMIT
                              18231                 :                :             | LOCALTIME
                              18232                 :                :             | LOCALTIMESTAMP
                              18233                 :                :             | NOT
                              18234                 :                :             | NULL_P
                              18235                 :                :             | OFFSET
                              18236                 :                :             | ON
                              18237                 :                :             | ONLY
                              18238                 :                :             | OR
                              18239                 :                :             | ORDER
                              18240                 :                :             | PLACING
                              18241                 :                :             | PRIMARY
                              18242                 :                :             | REFERENCES
                              18243                 :                :             | RETURNING
                              18244                 :                :             | SELECT
                              18245                 :                :             | SESSION_USER
                              18246                 :                :             | SOME
                              18247                 :                :             | SYMMETRIC
                              18248                 :                :             | SYSTEM_USER
                              18249                 :                :             | TABLE
                              18250                 :                :             | THEN
                              18251                 :                :             | TO
                              18252                 :                :             | TRAILING
                              18253                 :                :             | TRUE_P
                              18254                 :                :             | UNION
                              18255                 :                :             | UNIQUE
                              18256                 :                :             | USER
                              18257                 :                :             | USING
                              18258                 :                :             | VARIADIC
                              18259                 :                :             | WHEN
                              18260                 :                :             | WHERE
                              18261                 :                :             | WINDOW
                              18262                 :                :             | WITH
                              18263                 :                :         ;
                              18264                 :                : 
                              18265                 :                : /*
                              18266                 :                :  * While all keywords can be used as column labels when preceded by AS,
                              18267                 :                :  * not all of them can be used as a "bare" column label without AS.
                              18268                 :                :  * Those that can be used as a bare label must be listed here,
                              18269                 :                :  * in addition to appearing in one of the category lists above.
                              18270                 :                :  *
                              18271                 :                :  * Always add a new keyword to this list if possible.  Mark it BARE_LABEL
                              18272                 :                :  * in kwlist.h if it is included here, or AS_LABEL if it is not.
                              18273                 :                :  */
                              18274                 :                : bare_label_keyword:
                              18275                 :                :               ABORT_P
                              18276                 :                :             | ABSENT
                              18277                 :                :             | ABSOLUTE_P
                              18278                 :                :             | ACCESS
                              18279                 :                :             | ACTION
                              18280                 :                :             | ADD_P
                              18281                 :                :             | ADMIN
                              18282                 :                :             | AFTER
                              18283                 :                :             | AGGREGATE
                              18284                 :                :             | ALL
                              18285                 :                :             | ALSO
                              18286                 :                :             | ALTER
                              18287                 :                :             | ALWAYS
                              18288                 :                :             | ANALYSE
                              18289                 :                :             | ANALYZE
                              18290                 :                :             | AND
                              18291                 :                :             | ANY
                              18292                 :                :             | ASC
                              18293                 :                :             | ASENSITIVE
                              18294                 :                :             | ASSERTION
                              18295                 :                :             | ASSIGNMENT
                              18296                 :                :             | ASYMMETRIC
                              18297                 :                :             | AT
                              18298                 :                :             | ATOMIC
                              18299                 :                :             | ATTACH
                              18300                 :                :             | ATTRIBUTE
                              18301                 :                :             | AUTHORIZATION
                              18302                 :                :             | BACKWARD
                              18303                 :                :             | BEFORE
                              18304                 :                :             | BEGIN_P
                              18305                 :                :             | BETWEEN
                              18306                 :                :             | BIGINT
                              18307                 :                :             | BINARY
                              18308                 :                :             | BIT
                              18309                 :                :             | BOOLEAN_P
                              18310                 :                :             | BOTH
                              18311                 :                :             | BREADTH
                              18312                 :                :             | BY
                              18313                 :                :             | CACHE
                              18314                 :                :             | CALL
                              18315                 :                :             | CALLED
                              18316                 :                :             | CASCADE
                              18317                 :                :             | CASCADED
                              18318                 :                :             | CASE
                              18319                 :                :             | CAST
                              18320                 :                :             | CATALOG_P
                              18321                 :                :             | CHAIN
                              18322                 :                :             | CHARACTERISTICS
                              18323                 :                :             | CHECK
                              18324                 :                :             | CHECKPOINT
                              18325                 :                :             | CLASS
                              18326                 :                :             | CLOSE
                              18327                 :                :             | CLUSTER
                              18328                 :                :             | COALESCE
                              18329                 :                :             | COLLATE
                              18330                 :                :             | COLLATION
                              18331                 :                :             | COLUMN
                              18332                 :                :             | COLUMNS
                              18333                 :                :             | COMMENT
                              18334                 :                :             | COMMENTS
                              18335                 :                :             | COMMIT
                              18336                 :                :             | COMMITTED
                              18337                 :                :             | COMPRESSION
                              18338                 :                :             | CONCURRENTLY
                              18339                 :                :             | CONDITIONAL
                              18340                 :                :             | CONFIGURATION
                              18341                 :                :             | CONFLICT
                              18342                 :                :             | CONNECTION
                              18343                 :                :             | CONSTRAINT
                              18344                 :                :             | CONSTRAINTS
                              18345                 :                :             | CONTENT_P
                              18346                 :                :             | CONTINUE_P
                              18347                 :                :             | CONVERSION_P
                              18348                 :                :             | COPY
                              18349                 :                :             | COST
                              18350                 :                :             | CROSS
                              18351                 :                :             | CSV
                              18352                 :                :             | CUBE
                              18353                 :                :             | CURRENT_P
                              18354                 :                :             | CURRENT_CATALOG
                              18355                 :                :             | CURRENT_DATE
                              18356                 :                :             | CURRENT_ROLE
                              18357                 :                :             | CURRENT_SCHEMA
                              18358                 :                :             | CURRENT_TIME
                              18359                 :                :             | CURRENT_TIMESTAMP
                              18360                 :                :             | CURRENT_USER
                              18361                 :                :             | CURSOR
                              18362                 :                :             | CYCLE
                              18363                 :                :             | DATA_P
                              18364                 :                :             | DATABASE
                              18365                 :                :             | DEALLOCATE
                              18366                 :                :             | DEC
                              18367                 :                :             | DECIMAL_P
                              18368                 :                :             | DECLARE
                              18369                 :                :             | DEFAULT
                              18370                 :                :             | DEFAULTS
                              18371                 :                :             | DEFERRABLE
                              18372                 :                :             | DEFERRED
                              18373                 :                :             | DEFINER
                              18374                 :                :             | DELETE_P
                              18375                 :                :             | DELIMITER
                              18376                 :                :             | DELIMITERS
                              18377                 :                :             | DEPENDS
                              18378                 :                :             | DEPTH
                              18379                 :                :             | DESC
                              18380                 :                :             | DETACH
                              18381                 :                :             | DICTIONARY
                              18382                 :                :             | DISABLE_P
                              18383                 :                :             | DISCARD
                              18384                 :                :             | DISTINCT
                              18385                 :                :             | DO
                              18386                 :                :             | DOCUMENT_P
                              18387                 :                :             | DOMAIN_P
                              18388                 :                :             | DOUBLE_P
                              18389                 :                :             | DROP
                              18390                 :                :             | EACH
                              18391                 :                :             | ELSE
                              18392                 :                :             | EMPTY_P
                              18393                 :                :             | ENABLE_P
                              18394                 :                :             | ENCODING
                              18395                 :                :             | ENCRYPTED
                              18396                 :                :             | END_P
                              18397                 :                :             | ENFORCED
                              18398                 :                :             | ENUM_P
                              18399                 :                :             | ERROR_P
                              18400                 :                :             | ESCAPE
                              18401                 :                :             | EVENT
                              18402                 :                :             | EXCLUDE
                              18403                 :                :             | EXCLUDING
                              18404                 :                :             | EXCLUSIVE
                              18405                 :                :             | EXECUTE
                              18406                 :                :             | EXISTS
                              18407                 :                :             | EXPLAIN
                              18408                 :                :             | EXPRESSION
                              18409                 :                :             | EXTENSION
                              18410                 :                :             | EXTERNAL
                              18411                 :                :             | EXTRACT
                              18412                 :                :             | FALSE_P
                              18413                 :                :             | FAMILY
                              18414                 :                :             | FINALIZE
                              18415                 :                :             | FIRST_P
                              18416                 :                :             | FLOAT_P
                              18417                 :                :             | FOLLOWING
                              18418                 :                :             | FORCE
                              18419                 :                :             | FOREIGN
                              18420                 :                :             | FORMAT
                              18421                 :                :             | FORWARD
                              18422                 :                :             | FREEZE
                              18423                 :                :             | FULL
                              18424                 :                :             | FUNCTION
                              18425                 :                :             | FUNCTIONS
                              18426                 :                :             | GENERATED
                              18427                 :                :             | GLOBAL
                              18428                 :                :             | GRANTED
                              18429                 :                :             | GREATEST
                              18430                 :                :             | GROUPING
                              18431                 :                :             | GROUPS
                              18432                 :                :             | HANDLER
                              18433                 :                :             | HEADER_P
                              18434                 :                :             | HOLD
                              18435                 :                :             | IDENTITY_P
                              18436                 :                :             | IF_P
                              18437                 :                :             | ILIKE
                              18438                 :                :             | IMMEDIATE
                              18439                 :                :             | IMMUTABLE
                              18440                 :                :             | IMPLICIT_P
                              18441                 :                :             | IMPORT_P
                              18442                 :                :             | IN_P
                              18443                 :                :             | INCLUDE
                              18444                 :                :             | INCLUDING
                              18445                 :                :             | INCREMENT
                              18446                 :                :             | INDENT
                              18447                 :                :             | INDEX
                              18448                 :                :             | INDEXES
                              18449                 :                :             | INHERIT
                              18450                 :                :             | INHERITS
                              18451                 :                :             | INITIALLY
                              18452                 :                :             | INLINE_P
                              18453                 :                :             | INNER_P
                              18454                 :                :             | INOUT
                              18455                 :                :             | INPUT_P
                              18456                 :                :             | INSENSITIVE
                              18457                 :                :             | INSERT
                              18458                 :                :             | INSTEAD
                              18459                 :                :             | INT_P
                              18460                 :                :             | INTEGER
                              18461                 :                :             | INTERVAL
                              18462                 :                :             | INVOKER
                              18463                 :                :             | IS
                              18464                 :                :             | ISOLATION
                              18465                 :                :             | JOIN
                              18466                 :                :             | JSON
                              18467                 :                :             | JSON_ARRAY
                              18468                 :                :             | JSON_ARRAYAGG
                              18469                 :                :             | JSON_EXISTS
                              18470                 :                :             | JSON_OBJECT
                              18471                 :                :             | JSON_OBJECTAGG
                              18472                 :                :             | JSON_QUERY
                              18473                 :                :             | JSON_SCALAR
                              18474                 :                :             | JSON_SERIALIZE
                              18475                 :                :             | JSON_TABLE
                              18476                 :                :             | JSON_VALUE
                              18477                 :                :             | KEEP
                              18478                 :                :             | KEY
                              18479                 :                :             | KEYS
                              18480                 :                :             | LABEL
                              18481                 :                :             | LANGUAGE
                              18482                 :                :             | LARGE_P
                              18483                 :                :             | LAST_P
                              18484                 :                :             | LATERAL_P
                              18485                 :                :             | LEADING
                              18486                 :                :             | LEAKPROOF
                              18487                 :                :             | LEAST
                              18488                 :                :             | LEFT
                              18489                 :                :             | LEVEL
                              18490                 :                :             | LIKE
                              18491                 :                :             | LISTEN
                              18492                 :                :             | LOAD
                              18493                 :                :             | LOCAL
                              18494                 :                :             | LOCALTIME
                              18495                 :                :             | LOCALTIMESTAMP
                              18496                 :                :             | LOCATION
                              18497                 :                :             | LOCK_P
                              18498                 :                :             | LOCKED
                              18499                 :                :             | LOGGED
                              18500                 :                :             | MAPPING
                              18501                 :                :             | MATCH
                              18502                 :                :             | MATCHED
                              18503                 :                :             | MATERIALIZED
                              18504                 :                :             | MAXVALUE
                              18505                 :                :             | MERGE
                              18506                 :                :             | MERGE_ACTION
                              18507                 :                :             | METHOD
                              18508                 :                :             | MINVALUE
                              18509                 :                :             | MODE
                              18510                 :                :             | MOVE
                              18511                 :                :             | NAME_P
                              18512                 :                :             | NAMES
                              18513                 :                :             | NATIONAL
                              18514                 :                :             | NATURAL
                              18515                 :                :             | NCHAR
                              18516                 :                :             | NESTED
                              18517                 :                :             | NEW
                              18518                 :                :             | NEXT
                              18519                 :                :             | NFC
                              18520                 :                :             | NFD
                              18521                 :                :             | NFKC
                              18522                 :                :             | NFKD
                              18523                 :                :             | NO
                              18524                 :                :             | NONE
                              18525                 :                :             | NORMALIZE
                              18526                 :                :             | NORMALIZED
                              18527                 :                :             | NOT
                              18528                 :                :             | NOTHING
                              18529                 :                :             | NOTIFY
                              18530                 :                :             | NOWAIT
                              18531                 :                :             | NULL_P
                              18532                 :                :             | NULLIF
                              18533                 :                :             | NULLS_P
                              18534                 :                :             | NUMERIC
                              18535                 :                :             | OBJECT_P
                              18536                 :                :             | OBJECTS_P
                              18537                 :                :             | OF
                              18538                 :                :             | OFF
                              18539                 :                :             | OIDS
                              18540                 :                :             | OLD
                              18541                 :                :             | OMIT
                              18542                 :                :             | ONLY
                              18543                 :                :             | OPERATOR
                              18544                 :                :             | OPTION
                              18545                 :                :             | OPTIONS
                              18546                 :                :             | OR
                              18547                 :                :             | ORDINALITY
                              18548                 :                :             | OTHERS
                              18549                 :                :             | OUT_P
                              18550                 :                :             | OUTER_P
                              18551                 :                :             | OVERLAY
                              18552                 :                :             | OVERRIDING
                              18553                 :                :             | OWNED
                              18554                 :                :             | OWNER
                              18555                 :                :             | PARALLEL
                              18556                 :                :             | PARAMETER
                              18557                 :                :             | PARSER
                              18558                 :                :             | PARTIAL
                              18559                 :                :             | PARTITION
                              18560                 :                :             | PASSING
                              18561                 :                :             | PASSWORD
                              18562                 :                :             | PATH
                              18563                 :                :             | PERIOD
                              18564                 :                :             | PLACING
                              18565                 :                :             | PLAN
                              18566                 :                :             | PLANS
                              18567                 :                :             | POLICY
                              18568                 :                :             | POSITION
                              18569                 :                :             | PRECEDING
                              18570                 :                :             | PREPARE
                              18571                 :                :             | PREPARED
                              18572                 :                :             | PRESERVE
                              18573                 :                :             | PRIMARY
                              18574                 :                :             | PRIOR
                              18575                 :                :             | PRIVILEGES
                              18576                 :                :             | PROCEDURAL
                              18577                 :                :             | PROCEDURE
                              18578                 :                :             | PROCEDURES
                              18579                 :                :             | PROGRAM
                              18580                 :                :             | PUBLICATION
                              18581                 :                :             | QUOTE
                              18582                 :                :             | QUOTES
                              18583                 :                :             | RANGE
                              18584                 :                :             | READ
                              18585                 :                :             | REAL
                              18586                 :                :             | REASSIGN
                              18587                 :                :             | RECURSIVE
                              18588                 :                :             | REF_P
                              18589                 :                :             | REFERENCES
                              18590                 :                :             | REFERENCING
                              18591                 :                :             | REFRESH
                              18592                 :                :             | REINDEX
                              18593                 :                :             | RELATIVE_P
                              18594                 :                :             | RELEASE
                              18595                 :                :             | RENAME
                              18596                 :                :             | REPEATABLE
                              18597                 :                :             | REPLACE
                              18598                 :                :             | REPLICA
                              18599                 :                :             | RESET
                              18600                 :                :             | RESTART
                              18601                 :                :             | RESTRICT
                              18602                 :                :             | RETURN
                              18603                 :                :             | RETURNS
                              18604                 :                :             | REVOKE
                              18605                 :                :             | RIGHT
                              18606                 :                :             | ROLE
                              18607                 :                :             | ROLLBACK
                              18608                 :                :             | ROLLUP
                              18609                 :                :             | ROUTINE
                              18610                 :                :             | ROUTINES
                              18611                 :                :             | ROW
                              18612                 :                :             | ROWS
                              18613                 :                :             | RULE
                              18614                 :                :             | SAVEPOINT
                              18615                 :                :             | SCALAR
                              18616                 :                :             | SCHEMA
                              18617                 :                :             | SCHEMAS
                              18618                 :                :             | SCROLL
                              18619                 :                :             | SEARCH
                              18620                 :                :             | SECURITY
                              18621                 :                :             | SELECT
                              18622                 :                :             | SEQUENCE
                              18623                 :                :             | SEQUENCES
                              18624                 :                :             | SERIALIZABLE
                              18625                 :                :             | SERVER
                              18626                 :                :             | SESSION
                              18627                 :                :             | SESSION_USER
                              18628                 :                :             | SET
                              18629                 :                :             | SETOF
                              18630                 :                :             | SETS
                              18631                 :                :             | SHARE
                              18632                 :                :             | SHOW
                              18633                 :                :             | SIMILAR
                              18634                 :                :             | SIMPLE
                              18635                 :                :             | SKIP
                              18636                 :                :             | SMALLINT
                              18637                 :                :             | SNAPSHOT
                              18638                 :                :             | SOME
                              18639                 :                :             | SOURCE
                              18640                 :                :             | SQL_P
                              18641                 :                :             | STABLE
                              18642                 :                :             | STANDALONE_P
                              18643                 :                :             | START
                              18644                 :                :             | STATEMENT
                              18645                 :                :             | STATISTICS
                              18646                 :                :             | STDIN
                              18647                 :                :             | STDOUT
                              18648                 :                :             | STORAGE
                              18649                 :                :             | STORED
                              18650                 :                :             | STRICT_P
                              18651                 :                :             | STRING_P
                              18652                 :                :             | STRIP_P
                              18653                 :                :             | SUBSCRIPTION
                              18654                 :                :             | SUBSTRING
                              18655                 :                :             | SUPPORT
                              18656                 :                :             | SYMMETRIC
                              18657                 :                :             | SYSID
                              18658                 :                :             | SYSTEM_P
                              18659                 :                :             | SYSTEM_USER
                              18660                 :                :             | TABLE
                              18661                 :                :             | TABLES
                              18662                 :                :             | TABLESAMPLE
                              18663                 :                :             | TABLESPACE
                              18664                 :                :             | TARGET
                              18665                 :                :             | TEMP
                              18666                 :                :             | TEMPLATE
                              18667                 :                :             | TEMPORARY
                              18668                 :                :             | TEXT_P
                              18669                 :                :             | THEN
                              18670                 :                :             | TIES
                              18671                 :                :             | TIME
                              18672                 :                :             | TIMESTAMP
                              18673                 :                :             | TRAILING
                              18674                 :                :             | TRANSACTION
                              18675                 :                :             | TRANSFORM
                              18676                 :                :             | TREAT
                              18677                 :                :             | TRIGGER
                              18678                 :                :             | TRIM
                              18679                 :                :             | TRUE_P
                              18680                 :                :             | TRUNCATE
                              18681                 :                :             | TRUSTED
                              18682                 :                :             | TYPE_P
                              18683                 :                :             | TYPES_P
                              18684                 :                :             | UESCAPE
                              18685                 :                :             | UNBOUNDED
                              18686                 :                :             | UNCOMMITTED
                              18687                 :                :             | UNCONDITIONAL
                              18688                 :                :             | UNENCRYPTED
                              18689                 :                :             | UNIQUE
                              18690                 :                :             | UNKNOWN
                              18691                 :                :             | UNLISTEN
                              18692                 :                :             | UNLOGGED
                              18693                 :                :             | UNTIL
                              18694                 :                :             | UPDATE
                              18695                 :                :             | USER
                              18696                 :                :             | USING
                              18697                 :                :             | VACUUM
                              18698                 :                :             | VALID
                              18699                 :                :             | VALIDATE
                              18700                 :                :             | VALIDATOR
                              18701                 :                :             | VALUE_P
                              18702                 :                :             | VALUES
                              18703                 :                :             | VARCHAR
                              18704                 :                :             | VARIADIC
                              18705                 :                :             | VERBOSE
                              18706                 :                :             | VERSION_P
                              18707                 :                :             | VIEW
                              18708                 :                :             | VIEWS
                              18709                 :                :             | VIRTUAL
                              18710                 :                :             | VOLATILE
                              18711                 :                :             | WHEN
                              18712                 :                :             | WHITESPACE_P
                              18713                 :                :             | WORK
                              18714                 :                :             | WRAPPER
                              18715                 :                :             | WRITE
                              18716                 :                :             | XML_P
                              18717                 :                :             | XMLATTRIBUTES
                              18718                 :                :             | XMLCONCAT
                              18719                 :                :             | XMLELEMENT
                              18720                 :                :             | XMLEXISTS
                              18721                 :                :             | XMLFOREST
                              18722                 :                :             | XMLNAMESPACES
                              18723                 :                :             | XMLPARSE
                              18724                 :                :             | XMLPI
                              18725                 :                :             | XMLROOT
                              18726                 :                :             | XMLSERIALIZE
                              18727                 :                :             | XMLTABLE
                              18728                 :                :             | YES_P
                              18729                 :                :             | ZONE
                              18730                 :                :         ;
                              18731                 :                : 
                              18732                 :                : %%
                              18733                 :                : 
                              18734                 :                : /*
                              18735                 :                :  * The signature of this function is required by bison.  However, we
                              18736                 :                :  * ignore the passed yylloc and instead use the last token position
                              18737                 :                :  * available from the scanner.
                              18738                 :                :  */
                              18739                 :                : static void
 5780                         18740                 :            346 : base_yyerror(YYLTYPE *yylloc, core_yyscan_t yyscanner, const char *msg)
                              18741                 :                : {
 5899                         18742                 :            346 :     parser_yyerror(msg);
                              18743                 :                : }
                              18744                 :                : 
                              18745                 :                : static RawStmt *
 3157                         18746                 :         405094 : makeRawStmt(Node *stmt, int stmt_location)
                              18747                 :                : {
                              18748                 :         405094 :     RawStmt    *rs = makeNode(RawStmt);
                              18749                 :                : 
                              18750                 :         405094 :     rs->stmt = stmt;
                              18751                 :         405094 :     rs->stmt_location = stmt_location;
                              18752                 :         405094 :     rs->stmt_len = 0;            /* might get changed later */
                              18753                 :         405094 :     return rs;
                              18754                 :                : }
                              18755                 :                : 
                              18756                 :                : /* Adjust a RawStmt to reflect that it doesn't run to the end of the string */
                              18757                 :                : static void
                              18758                 :         292487 : updateRawStmtEnd(RawStmt *rs, int end_location)
                              18759                 :                : {
                              18760                 :                :     /*
                              18761                 :                :      * If we already set the length, don't change it.  This is for situations
                              18762                 :                :      * like "select foo ;; select bar" where the same statement will be last
                              18763                 :                :      * in the string for more than one semicolon.
                              18764                 :                :      */
                              18765         [ +  + ]:         292487 :     if (rs->stmt_len > 0)
                              18766                 :            321 :         return;
                              18767                 :                : 
                              18768                 :                :     /* OK, update length of RawStmt */
                              18769                 :         292166 :     rs->stmt_len = end_location - rs->stmt_location;
                              18770                 :                : }
                              18771                 :                : 
                              18772                 :                : static Node *
 5899                         18773                 :         923300 : makeColumnRef(char *colname, List *indirection,
                              18774                 :                :               int location, core_yyscan_t yyscanner)
                              18775                 :                : {
                              18776                 :                :     /*
                              18777                 :                :      * Generate a ColumnRef node, with an A_Indirection node added if there is
                              18778                 :                :      * any subscripting in the specified indirection list.  However, any field
                              18779                 :                :      * selection at the start of the indirection list must be transposed into
                              18780                 :                :      * the "fields" part of the ColumnRef node.
                              18781                 :                :      */
 7759                         18782                 :         923300 :     ColumnRef  *c = makeNode(ColumnRef);
 1212 peter@eisentraut.org    18783                 :         923300 :     int         nfields = 0;
                              18784                 :                :     ListCell   *l;
                              18785                 :                : 
 7116 tgl@sss.pgh.pa.us       18786                 :         923300 :     c->location = location;
 7759                         18787   [ +  +  +  +  :        1456093 :     foreach(l, indirection)
                                              +  + ]
                              18788                 :                :     {
                              18789         [ +  + ]:         537750 :         if (IsA(lfirst(l), A_Indices))
                              18790                 :                :         {
                              18791                 :           4957 :             A_Indirection *i = makeNode(A_Indirection);
                              18792                 :                : 
                              18793         [ +  + ]:           4957 :             if (nfields == 0)
                              18794                 :                :             {
                              18795                 :                :                 /* easy case - all indirection goes to A_Indirection */
 6216                         18796                 :           3598 :                 c->fields = list_make1(makeString(colname));
 5899                         18797                 :           3598 :                 i->indirection = check_indirection(indirection, yyscanner);
                              18798                 :                :             }
                              18799                 :                :             else
                              18800                 :                :             {
                              18801                 :                :                 /* got to split the list in two */
 6216                         18802                 :           1359 :                 i->indirection = check_indirection(list_copy_tail(indirection,
                              18803                 :                :                                                                   nfields),
                              18804                 :                :                                                    yyscanner);
 7759                         18805                 :           1359 :                 indirection = list_truncate(indirection, nfields);
 6216                         18806                 :           1359 :                 c->fields = lcons(makeString(colname), indirection);
                              18807                 :                :             }
 7759                         18808                 :           4957 :             i->arg = (Node *) c;
                              18809                 :           4957 :             return (Node *) i;
                              18810                 :                :         }
 6216                         18811         [ +  + ]:         532793 :         else if (IsA(lfirst(l), A_Star))
                              18812                 :                :         {
                              18813                 :                :             /* We only allow '*' at the end of a ColumnRef */
 2245                         18814         [ -  + ]:           2760 :             if (lnext(indirection, l) != NULL)
 5899 tgl@sss.pgh.pa.us       18815                 :UBC           0 :                 parser_yyerror("improper use of \"*\"");
                              18816                 :                :         }
 7759 tgl@sss.pgh.pa.us       18817                 :CBC      532793 :         nfields++;
                              18818                 :                :     }
                              18819                 :                :     /* No subscripting, so all indirection gets added to field list */
 6216                         18820                 :         918343 :     c->fields = lcons(makeString(colname), indirection);
 7759                         18821                 :         918343 :     return (Node *) c;
                              18822                 :                : }
                              18823                 :                : 
                              18824                 :                : static Node *
 6218                         18825                 :         159767 : makeTypeCast(Node *arg, TypeName *typename, int location)
                              18826                 :                : {
 1212 peter@eisentraut.org    18827                 :         159767 :     TypeCast   *n = makeNode(TypeCast);
                              18828                 :                : 
 8463 bruce@momjian.us        18829                 :         159767 :     n->arg = arg;
 5896 peter_e@gmx.net         18830                 :         159767 :     n->typeName = typename;
 6218 tgl@sss.pgh.pa.us       18831                 :         159767 :     n->location = location;
 8463 bruce@momjian.us        18832                 :         159767 :     return (Node *) n;
                              18833                 :                : }
                              18834                 :                : 
                              18835                 :                : static Node *
 6218 tgl@sss.pgh.pa.us       18836                 :           8160 : makeStringConstCast(char *str, int location, TypeName *typename)
                              18837                 :                : {
 1212 peter@eisentraut.org    18838                 :           8160 :     Node       *s = makeStringConst(str, location);
                              18839                 :                : 
 6218 tgl@sss.pgh.pa.us       18840                 :           8160 :     return makeTypeCast(s, typename, -1);
                              18841                 :                : }
                              18842                 :                : 
                              18843                 :                : static Node *
                              18844                 :         197237 : makeIntConst(int val, int location)
                              18845                 :                : {
  255 peter@eisentraut.org    18846                 :         197237 :     A_Const    *n = makeNode(A_Const);
                              18847                 :                : 
 1458                         18848                 :         197237 :     n->val.ival.type = T_Integer;
 1331                         18849                 :         197237 :     n->val.ival.ival = val;
 6218 tgl@sss.pgh.pa.us       18850                 :         197237 :     n->location = location;
                              18851                 :                : 
  255 peter@eisentraut.org    18852                 :         197237 :     return (Node *) n;
                              18853                 :                : }
                              18854                 :                : 
                              18855                 :                : static Node *
 6218 tgl@sss.pgh.pa.us       18856                 :           5786 : makeFloatConst(char *str, int location)
                              18857                 :                : {
  255 peter@eisentraut.org    18858                 :           5786 :     A_Const    *n = makeNode(A_Const);
                              18859                 :                : 
 1458                         18860                 :           5786 :     n->val.fval.type = T_Float;
 1331                         18861                 :           5786 :     n->val.fval.fval = str;
 6218 tgl@sss.pgh.pa.us       18862                 :           5786 :     n->location = location;
                              18863                 :                : 
  255 peter@eisentraut.org    18864                 :           5786 :     return (Node *) n;
                              18865                 :                : }
                              18866                 :                : 
                              18867                 :                : static Node *
 1331                         18868                 :          34796 : makeBoolAConst(bool state, int location)
                              18869                 :                : {
  255                         18870                 :          34796 :     A_Const    *n = makeNode(A_Const);
                              18871                 :                : 
 1331                         18872                 :          34796 :     n->val.boolval.type = T_Boolean;
                              18873                 :          34796 :     n->val.boolval.boolval = state;
                              18874                 :          34796 :     n->location = location;
                              18875                 :                : 
  255                         18876                 :          34796 :     return (Node *) n;
                              18877                 :                : }
                              18878                 :                : 
                              18879                 :                : static Node *
 6218 tgl@sss.pgh.pa.us       18880                 :           2026 : makeBitStringConst(char *str, int location)
                              18881                 :                : {
  255 peter@eisentraut.org    18882                 :           2026 :     A_Const    *n = makeNode(A_Const);
                              18883                 :                : 
 1458                         18884                 :           2026 :     n->val.bsval.type = T_BitString;
 1331                         18885                 :           2026 :     n->val.bsval.bsval = str;
 6218 tgl@sss.pgh.pa.us       18886                 :           2026 :     n->location = location;
                              18887                 :                : 
  255 peter@eisentraut.org    18888                 :           2026 :     return (Node *) n;
                              18889                 :                : }
                              18890                 :                : 
                              18891                 :                : static Node *
 6218 tgl@sss.pgh.pa.us       18892                 :          33490 : makeNullAConst(int location)
                              18893                 :                : {
  255 peter@eisentraut.org    18894                 :          33490 :     A_Const    *n = makeNode(A_Const);
                              18895                 :                : 
 1458                         18896                 :          33490 :     n->isnull = true;
 6218 tgl@sss.pgh.pa.us       18897                 :          33490 :     n->location = location;
                              18898                 :                : 
 1212 peter@eisentraut.org    18899                 :          33490 :     return (Node *) n;
                              18900                 :                : }
                              18901                 :                : 
                              18902                 :                : static Node *
 1458                         18903                 :           2683 : makeAConst(Node *v, int location)
                              18904                 :                : {
                              18905                 :                :     Node       *n;
                              18906                 :                : 
 8539 lockhart@fourpalms.o    18907      [ +  +  - ]:           2683 :     switch (v->type)
                              18908                 :                :     {
                              18909                 :            109 :         case T_Float:
 1331 peter@eisentraut.org    18910                 :            109 :             n = makeFloatConst(castNode(Float, v)->fval, location);
 8539 lockhart@fourpalms.o    18911                 :            109 :             break;
                              18912                 :                : 
                              18913                 :           2574 :         case T_Integer:
 1331 peter@eisentraut.org    18914                 :           2574 :             n = makeIntConst(castNode(Integer, v)->ival, location);
 8539 lockhart@fourpalms.o    18915                 :           2574 :             break;
                              18916                 :                : 
 8539 lockhart@fourpalms.o    18917                 :UBC           0 :         default:
                              18918                 :                :             /* currently not used */
 1331 peter@eisentraut.org    18919                 :              0 :             Assert(false);
                              18920                 :                :             n = NULL;
                              18921                 :                :     }
                              18922                 :                : 
 8539 lockhart@fourpalms.o    18923                 :CBC        2683 :     return n;
                              18924                 :                : }
                              18925                 :                : 
                              18926                 :                : /* makeRoleSpec
                              18927                 :                :  * Create a RoleSpec with the given type
                              18928                 :                :  */
                              18929                 :                : static RoleSpec *
 3834 alvherre@alvh.no-ip.    18930                 :          16805 : makeRoleSpec(RoleSpecType type, int location)
                              18931                 :                : {
 1212 peter@eisentraut.org    18932                 :          16805 :     RoleSpec   *spec = makeNode(RoleSpec);
                              18933                 :                : 
 3834 alvherre@alvh.no-ip.    18934                 :          16805 :     spec->roletype = type;
                              18935                 :          16805 :     spec->location = location;
                              18936                 :                : 
 3174 peter_e@gmx.net         18937                 :          16805 :     return spec;
                              18938                 :                : }
                              18939                 :                : 
                              18940                 :                : /* check_qualified_name --- check the result of qualified_name production
                              18941                 :                :  *
                              18942                 :                :  * It's easiest to let the grammar production for qualified_name allow
                              18943                 :                :  * subscripts and '*', which we then must reject here.
                              18944                 :                :  */
                              18945                 :                : static void
 5780 tgl@sss.pgh.pa.us       18946                 :         128587 : check_qualified_name(List *names, core_yyscan_t yyscanner)
                              18947                 :                : {
                              18948                 :                :     ListCell   *i;
                              18949                 :                : 
 7607                         18950   [ +  -  +  +  :         257174 :     foreach(i, names)
                                              +  + ]
                              18951                 :                :     {
                              18952         [ -  + ]:         128587 :         if (!IsA(lfirst(i), String))
 5899 tgl@sss.pgh.pa.us       18953                 :UBC           0 :             parser_yyerror("syntax error");
                              18954                 :                :     }
 7607 tgl@sss.pgh.pa.us       18955                 :CBC      128587 : }
                              18956                 :                : 
                              18957                 :                : /* check_func_name --- check the result of func_name production
                              18958                 :                :  *
                              18959                 :                :  * It's easiest to let the grammar production for func_name allow subscripts
                              18960                 :                :  * and '*', which we then must reject here.
                              18961                 :                :  */
                              18962                 :                : static List *
 5780                         18963                 :          63971 : check_func_name(List *names, core_yyscan_t yyscanner)
                              18964                 :                : {
                              18965                 :                :     ListCell   *i;
                              18966                 :                : 
 7759                         18967   [ +  -  +  +  :         191913 :     foreach(i, names)
                                              +  + ]
                              18968                 :                :     {
                              18969         [ -  + ]:         127942 :         if (!IsA(lfirst(i), String))
 5899 tgl@sss.pgh.pa.us       18970                 :UBC           0 :             parser_yyerror("syntax error");
                              18971                 :                :     }
 7759 tgl@sss.pgh.pa.us       18972                 :CBC       63971 :     return names;
                              18973                 :                : }
                              18974                 :                : 
                              18975                 :                : /* check_indirection --- check the result of indirection production
                              18976                 :                :  *
                              18977                 :                :  * We only allow '*' at the end of the list, but it's hard to enforce that
                              18978                 :                :  * in the grammar, so do it here.
                              18979                 :                :  */
                              18980                 :                : static List *
 5780                         18981                 :          40441 : check_indirection(List *indirection, core_yyscan_t yyscanner)
                              18982                 :                : {
                              18983                 :                :     ListCell   *l;
                              18984                 :                : 
 6216                         18985   [ +  +  +  +  :          54246 :     foreach(l, indirection)
                                              +  + ]
                              18986                 :                :     {
                              18987         [ +  + ]:          13805 :         if (IsA(lfirst(l), A_Star))
                              18988                 :                :         {
 2245                         18989         [ -  + ]:            728 :             if (lnext(indirection, l) != NULL)
 5899 tgl@sss.pgh.pa.us       18990                 :UBC           0 :                 parser_yyerror("improper use of \"*\"");
                              18991                 :                :         }
                              18992                 :                :     }
 6216 tgl@sss.pgh.pa.us       18993                 :CBC       40441 :     return indirection;
                              18994                 :                : }
                              18995                 :                : 
                              18996                 :                : /* extractArgTypes()
                              18997                 :                :  * Given a list of FunctionParameter nodes, extract a list of just the
                              18998                 :                :  * argument types (TypeNames) for input parameters only.  This is what
                              18999                 :                :  * is needed to look up an existing function, which is what is wanted by
                              19000                 :                :  * the productions that use this call.
                              19001                 :                :  */
                              19002                 :                : static List *
 1549                         19003                 :           9168 : extractArgTypes(List *parameters)
                              19004                 :                : {
 7914                         19005                 :           9168 :     List       *result = NIL;
                              19006                 :                :     ListCell   *i;
                              19007                 :                : 
                              19008   [ +  +  +  +  :          21014 :     foreach(i, parameters)
                                              +  + ]
                              19009                 :                :     {
                              19010                 :          11846 :         FunctionParameter *p = (FunctionParameter *) lfirst(i);
                              19011                 :                : 
 1549                         19012   [ +  +  +  - ]:          11846 :         if (p->mode != FUNC_PARAM_OUT && p->mode != FUNC_PARAM_TABLE)
 7466                         19013                 :          11768 :             result = lappend(result, p->argType);
                              19014                 :                :     }
 7914                         19015                 :           9168 :     return result;
                              19016                 :                : }
                              19017                 :                : 
                              19018                 :                : /* extractAggrArgTypes()
                              19019                 :                :  * As above, but work from the output of the aggr_args production.
                              19020                 :                :  */
                              19021                 :                : static List *
 4275                         19022                 :            181 : extractAggrArgTypes(List *aggrargs)
                              19023                 :                : {
                              19024         [ -  + ]:            181 :     Assert(list_length(aggrargs) == 2);
 1549                         19025                 :            181 :     return extractArgTypes((List *) linitial(aggrargs));
                              19026                 :                : }
                              19027                 :                : 
                              19028                 :                : /* makeOrderedSetArgs()
                              19029                 :                :  * Build the result of the aggr_args production (which see the comments for).
                              19030                 :                :  * This handles only the case where both given lists are nonempty, so that
                              19031                 :                :  * we have to deal with multiple VARIADIC arguments.
                              19032                 :                :  */
                              19033                 :                : static List *
 4275                         19034                 :             16 : makeOrderedSetArgs(List *directargs, List *orderedargs,
                              19035                 :                :                    core_yyscan_t yyscanner)
                              19036                 :                : {
                              19037                 :             16 :     FunctionParameter *lastd = (FunctionParameter *) llast(directargs);
                              19038                 :                :     Integer    *ndirectargs;
                              19039                 :                : 
                              19040                 :                :     /* No restriction unless last direct arg is VARIADIC */
                              19041         [ +  + ]:             16 :     if (lastd->mode == FUNC_PARAM_VARIADIC)
                              19042                 :                :     {
                              19043                 :              8 :         FunctionParameter *firsto = (FunctionParameter *) linitial(orderedargs);
                              19044                 :                : 
                              19045                 :                :         /*
                              19046                 :                :          * We ignore the names, though the aggr_arg production allows them; it
                              19047                 :                :          * doesn't allow default values, so those need not be checked.
                              19048                 :                :          */
                              19049         [ +  - ]:              8 :         if (list_length(orderedargs) != 1 ||
                              19050         [ +  - ]:              8 :             firsto->mode != FUNC_PARAM_VARIADIC ||
                              19051         [ -  + ]:              8 :             !equal(lastd->argType, firsto->argType))
 4275 tgl@sss.pgh.pa.us       19052         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19053                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19054                 :                :                      errmsg("an ordered-set aggregate with a VARIADIC direct argument must have one VARIADIC aggregated argument of the same data type"),
                              19055                 :                :                      parser_errposition(firsto->location)));
                              19056                 :                : 
                              19057                 :                :         /* OK, drop the duplicate VARIADIC argument from the internal form */
 4275 tgl@sss.pgh.pa.us       19058                 :CBC           8 :         orderedargs = NIL;
                              19059                 :                :     }
                              19060                 :                : 
                              19061                 :                :     /* don't merge into the next line, as list_concat changes directargs */
 1795                         19062                 :             16 :     ndirectargs = makeInteger(list_length(directargs));
                              19063                 :                : 
 4275                         19064                 :             16 :     return list_make2(list_concat(directargs, orderedargs),
                              19065                 :                :                       ndirectargs);
                              19066                 :                : }
                              19067                 :                : 
                              19068                 :                : /* insertSelectOptions()
                              19069                 :                :  * Insert ORDER BY, etc into an already-constructed SelectStmt.
                              19070                 :                :  *
                              19071                 :                :  * This routine is just to avoid duplicating code in SelectStmt productions.
                              19072                 :                :  */
                              19073                 :                : static void
 9071                         19074                 :          41609 : insertSelectOptions(SelectStmt *stmt,
                              19075                 :                :                     List *sortClause, List *lockingClause,
                              19076                 :                :                     SelectLimit *limitClause,
                              19077                 :                :                     WithClause *withClause,
                              19078                 :                :                     core_yyscan_t yyscanner)
                              19079                 :                : {
 6181                         19080         [ -  + ]:          41609 :     Assert(IsA(stmt, SelectStmt));
                              19081                 :                : 
                              19082                 :                :     /*
                              19083                 :                :      * Tests here are to reject constructs like
                              19084                 :                :      *  (SELECT foo ORDER BY bar) ORDER BY baz
                              19085                 :                :      */
 9071                         19086         [ +  + ]:          41609 :     if (sortClause)
                              19087                 :                :     {
                              19088         [ -  + ]:          36937 :         if (stmt->sortClause)
 8085 tgl@sss.pgh.pa.us       19089         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19090                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19091                 :                :                      errmsg("multiple ORDER BY clauses not allowed"),
                              19092                 :                :                      parser_errposition(exprLocation((Node *) sortClause))));
 9071 tgl@sss.pgh.pa.us       19093                 :CBC       36937 :         stmt->sortClause = sortClause;
                              19094                 :                :     }
                              19095                 :                :     /* We can handle multiple locking clauses, though */
 7069                         19096                 :          41609 :     stmt->lockingClause = list_concat(stmt->lockingClause, lockingClause);
 1978 alvherre@alvh.no-ip.    19097   [ +  +  +  + ]:          41609 :     if (limitClause && limitClause->limitOffset)
                              19098                 :                :     {
 9071 tgl@sss.pgh.pa.us       19099         [ -  + ]:            422 :         if (stmt->limitOffset)
 8085 tgl@sss.pgh.pa.us       19100         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19101                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19102                 :                :                      errmsg("multiple OFFSET clauses not allowed"),
                              19103                 :                :                      parser_errposition(limitClause->offsetLoc)));
 1978 alvherre@alvh.no-ip.    19104                 :CBC         422 :         stmt->limitOffset = limitClause->limitOffset;
                              19105                 :                :     }
                              19106   [ +  +  +  + ]:          41609 :     if (limitClause && limitClause->limitCount)
                              19107                 :                :     {
 9071 tgl@sss.pgh.pa.us       19108         [ -  + ]:           2339 :         if (stmt->limitCount)
 8085 tgl@sss.pgh.pa.us       19109         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19110                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19111                 :                :                      errmsg("multiple LIMIT clauses not allowed"),
                              19112                 :                :                      parser_errposition(limitClause->countLoc)));
 1978 alvherre@alvh.no-ip.    19113                 :CBC        2339 :         stmt->limitCount = limitClause->limitCount;
                              19114                 :                :     }
  630                         19115         [ +  + ]:          41609 :     if (limitClause)
                              19116                 :                :     {
                              19117                 :                :         /* If there was a conflict, we must have detected it above */
  310 tgl@sss.pgh.pa.us       19118         [ -  + ]:           2564 :         Assert(!stmt->limitOption);
 1978 alvherre@alvh.no-ip.    19119   [ +  +  +  + ]:           2564 :         if (!stmt->sortClause && limitClause->limitOption == LIMIT_OPTION_WITH_TIES)
                              19120         [ +  - ]:              3 :             ereport(ERROR,
                              19121                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19122                 :                :                      errmsg("WITH TIES cannot be specified without ORDER BY clause"),
                              19123                 :                :                      parser_errposition(limitClause->optionLoc)));
 1436                         19124   [ +  +  +  + ]:           2561 :         if (limitClause->limitOption == LIMIT_OPTION_WITH_TIES && stmt->lockingClause)
                              19125                 :                :         {
                              19126                 :                :             ListCell   *lc;
                              19127                 :                : 
                              19128   [ +  -  +  -  :              3 :             foreach(lc, stmt->lockingClause)
                                              +  - ]
                              19129                 :                :             {
                              19130                 :              3 :                 LockingClause *lock = lfirst_node(LockingClause, lc);
                              19131                 :                : 
                              19132         [ +  - ]:              3 :                 if (lock->waitPolicy == LockWaitSkip)
                              19133         [ +  - ]:              3 :                     ereport(ERROR,
                              19134                 :                :                             (errcode(ERRCODE_SYNTAX_ERROR),
                              19135                 :                :                              errmsg("%s and %s options cannot be used together",
                              19136                 :                :                                     "SKIP LOCKED", "WITH TIES"),
                              19137                 :                :                              parser_errposition(limitClause->optionLoc)));
                              19138                 :                :             }
                              19139                 :                :         }
 1978                         19140                 :           2558 :         stmt->limitOption = limitClause->limitOption;
                              19141                 :                :     }
 6181 tgl@sss.pgh.pa.us       19142         [ +  + ]:          41603 :     if (withClause)
                              19143                 :                :     {
                              19144         [ -  + ]:           1439 :         if (stmt->withClause)
 6181 tgl@sss.pgh.pa.us       19145         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19146                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19147                 :                :                      errmsg("multiple WITH clauses not allowed"),
                              19148                 :                :                      parser_errposition(exprLocation((Node *) withClause))));
 6181 tgl@sss.pgh.pa.us       19149                 :CBC        1439 :         stmt->withClause = withClause;
                              19150                 :                :     }
 9071                         19151                 :          41603 : }
                              19152                 :                : 
                              19153                 :                : static Node *
   86 michael@paquier.xyz     19154                 :           9676 : makeSetOp(SetOperation op, bool all, Node *larg, Node *rarg)
                              19155                 :                : {
 9071 tgl@sss.pgh.pa.us       19156                 :           9676 :     SelectStmt *n = makeNode(SelectStmt);
                              19157                 :                : 
                              19158                 :           9676 :     n->op = op;
                              19159                 :           9676 :     n->all = all;
                              19160                 :           9676 :     n->larg = (SelectStmt *) larg;
                              19161                 :           9676 :     n->rarg = (SelectStmt *) rarg;
                              19162                 :           9676 :     return (Node *) n;
                              19163                 :                : }
                              19164                 :                : 
                              19165                 :                : /* SystemFuncName()
                              19166                 :                :  * Build a properly-qualified reference to a built-in function.
                              19167                 :                :  */
                              19168                 :                : List *
 8551                         19169                 :           9598 : SystemFuncName(char *name)
                              19170                 :                : {
 7769 neilc@samurai.com       19171                 :           9598 :     return list_make2(makeString("pg_catalog"), makeString(name));
                              19172                 :                : }
                              19173                 :                : 
                              19174                 :                : /* SystemTypeName()
                              19175                 :                :  * Build a properly-qualified reference to a built-in type.
                              19176                 :                :  *
                              19177                 :                :  * typmod is defaulted, but may be changed afterwards by caller.
                              19178                 :                :  * Likewise for the location.
                              19179                 :                :  */
                              19180                 :                : TypeName *
 8527 tgl@sss.pgh.pa.us       19181                 :          60813 : SystemTypeName(char *name)
                              19182                 :                : {
 6825                         19183                 :          60813 :     return makeTypeNameFromNameList(list_make2(makeString("pg_catalog"),
                              19184                 :                :                                                makeString(name)));
                              19185                 :                : }
                              19186                 :                : 
                              19187                 :                : /* doNegate()
                              19188                 :                :  * Handle negation of a numeric constant.
                              19189                 :                :  *
                              19190                 :                :  * Formerly, we did this here because the optimizer couldn't cope with
                              19191                 :                :  * indexquals that looked like "var = -4" --- it wants "var = const"
                              19192                 :                :  * and a unary minus operator applied to a constant didn't qualify.
                              19193                 :                :  * As of Postgres 7.0, that problem doesn't exist anymore because there
                              19194                 :                :  * is a constant-subexpression simplifier in the optimizer.  However,
                              19195                 :                :  * there's still a good reason for doing this here, which is that we can
                              19196                 :                :  * postpone committing to a particular internal representation for simple
                              19197                 :                :  * negative constants.  It's better to leave "-123.456" in string form
                              19198                 :                :  * until we know what the desired type is.
                              19199                 :                :  */
                              19200                 :                : static Node *
 7116                         19201                 :           4605 : doNegate(Node *n, int location)
                              19202                 :                : {
 9669 bruce@momjian.us        19203         [ +  + ]:           4605 :     if (IsA(n, A_Const))
                              19204                 :                :     {
  255 peter@eisentraut.org    19205                 :           4104 :         A_Const    *con = (A_Const *) n;
                              19206                 :                : 
                              19207                 :                :         /* report the constant's location as that of the '-' sign */
 6218 tgl@sss.pgh.pa.us       19208                 :           4104 :         con->location = location;
                              19209                 :                : 
 1458 peter@eisentraut.org    19210         [ +  + ]:           4104 :         if (IsA(&con->val, Integer))
                              19211                 :                :         {
 1331                         19212                 :           3625 :             con->val.ival.ival = -con->val.ival.ival;
 9669 bruce@momjian.us        19213                 :           3625 :             return n;
                              19214                 :                :         }
 1458 peter@eisentraut.org    19215         [ +  - ]:            479 :         if (IsA(&con->val, Float))
                              19216                 :                :         {
                              19217                 :            479 :             doNegateFloat(&con->val.fval);
 9669 bruce@momjian.us        19218                 :            479 :             return n;
                              19219                 :                :         }
                              19220                 :                :     }
                              19221                 :                : 
 7116 tgl@sss.pgh.pa.us       19222                 :            501 :     return (Node *) makeSimpleA_Expr(AEXPR_OP, "-", NULL, n, location);
                              19223                 :                : }
                              19224                 :                : 
                              19225                 :                : static void
 1458 peter@eisentraut.org    19226                 :            489 : doNegateFloat(Float *v)
                              19227                 :                : {
 1212                         19228                 :            489 :     char       *oldval = v->fval;
                              19229                 :                : 
 9329 tgl@sss.pgh.pa.us       19230         [ -  + ]:            489 :     if (*oldval == '+')
 9329 tgl@sss.pgh.pa.us       19231                 :UBC           0 :         oldval++;
 9329 tgl@sss.pgh.pa.us       19232         [ -  + ]:CBC         489 :     if (*oldval == '-')
  255 peter@eisentraut.org    19233                 :UBC           0 :         v->fval = oldval + 1;    /* just strip the '-' */
                              19234                 :                :     else
 1331 peter@eisentraut.org    19235                 :CBC         489 :         v->fval = psprintf("-%s", oldval);
 9329 tgl@sss.pgh.pa.us       19236                 :            489 : }
                              19237                 :                : 
                              19238                 :                : static Node *
 4100                         19239                 :         118551 : makeAndExpr(Node *lexpr, Node *rexpr, int location)
                              19240                 :                : {
                              19241                 :                :     /* Flatten "a AND b AND c ..." to a single BoolExpr on sight */
 1733                         19242         [ +  + ]:         118551 :     if (IsA(lexpr, BoolExpr))
                              19243                 :                :     {
 1212 peter@eisentraut.org    19244                 :          56898 :         BoolExpr   *blexpr = (BoolExpr *) lexpr;
                              19245                 :                : 
 4100 tgl@sss.pgh.pa.us       19246         [ +  + ]:          56898 :         if (blexpr->boolop == AND_EXPR)
                              19247                 :                :         {
                              19248                 :          55623 :             blexpr->args = lappend(blexpr->args, rexpr);
                              19249                 :          55623 :             return (Node *) blexpr;
                              19250                 :                :         }
                              19251                 :                :     }
                              19252                 :          62928 :     return (Node *) makeBoolExpr(AND_EXPR, list_make2(lexpr, rexpr), location);
                              19253                 :                : }
                              19254                 :                : 
                              19255                 :                : static Node *
                              19256                 :           8052 : makeOrExpr(Node *lexpr, Node *rexpr, int location)
                              19257                 :                : {
                              19258                 :                :     /* Flatten "a OR b OR c ..." to a single BoolExpr on sight */
 1733                         19259         [ +  + ]:           8052 :     if (IsA(lexpr, BoolExpr))
                              19260                 :                :     {
 1212 peter@eisentraut.org    19261                 :           2835 :         BoolExpr   *blexpr = (BoolExpr *) lexpr;
                              19262                 :                : 
 4100 tgl@sss.pgh.pa.us       19263         [ +  + ]:           2835 :         if (blexpr->boolop == OR_EXPR)
                              19264                 :                :         {
                              19265                 :           2076 :             blexpr->args = lappend(blexpr->args, rexpr);
                              19266                 :           2076 :             return (Node *) blexpr;
                              19267                 :                :         }
                              19268                 :                :     }
                              19269                 :           5976 :     return (Node *) makeBoolExpr(OR_EXPR, list_make2(lexpr, rexpr), location);
                              19270                 :                : }
                              19271                 :                : 
                              19272                 :                : static Node *
                              19273                 :           8159 : makeNotExpr(Node *expr, int location)
                              19274                 :                : {
                              19275                 :           8159 :     return (Node *) makeBoolExpr(NOT_EXPR, list_make1(expr), location);
                              19276                 :                : }
                              19277                 :                : 
                              19278                 :                : static Node *
   86 alvherre@kurilemu.de    19279                 :           4072 : makeAArrayExpr(List *elements, int location, int location_end)
                              19280                 :                : {
 6379 tgl@sss.pgh.pa.us       19281                 :           4072 :     A_ArrayExpr *n = makeNode(A_ArrayExpr);
                              19282                 :                : 
                              19283                 :           4072 :     n->elements = elements;
 6218                         19284                 :           4072 :     n->location = location;
   86 alvherre@kurilemu.de    19285                 :           4072 :     n->list_start = location;
                              19286                 :           4072 :     n->list_end = location_end;
 6379 tgl@sss.pgh.pa.us       19287                 :           4072 :     return (Node *) n;
                              19288                 :                : }
                              19289                 :                : 
                              19290                 :                : static Node *
  843 michael@paquier.xyz     19291                 :           1388 : makeSQLValueFunction(SQLValueFunctionOp op, int32 typmod, int location)
                              19292                 :                : {
                              19293                 :           1388 :     SQLValueFunction *svf = makeNode(SQLValueFunction);
                              19294                 :                : 
                              19295                 :           1388 :     svf->op = op;
                              19296                 :                :     /* svf->type will be filled during parse analysis */
                              19297                 :           1388 :     svf->typmod = typmod;
                              19298                 :           1388 :     svf->location = location;
                              19299                 :           1388 :     return (Node *) svf;
                              19300                 :                : }
                              19301                 :                : 
                              19302                 :                : static Node *
 6218 tgl@sss.pgh.pa.us       19303                 :            298 : makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args,
                              19304                 :                :             int location)
                              19305                 :                : {
  255 peter@eisentraut.org    19306                 :            298 :     XmlExpr    *x = makeNode(XmlExpr);
                              19307                 :                : 
 6834 peter_e@gmx.net         19308                 :            298 :     x->op = op;
                              19309                 :            298 :     x->name = name;
                              19310                 :                : 
                              19311                 :                :     /*
                              19312                 :                :      * named_args is a list of ResTarget; it'll be split apart into separate
                              19313                 :                :      * expression and name lists in transformXmlExpr().
                              19314                 :                :      */
                              19315                 :            298 :     x->named_args = named_args;
 6831 tgl@sss.pgh.pa.us       19316                 :            298 :     x->arg_names = NIL;
 6834 peter_e@gmx.net         19317                 :            298 :     x->args = args;
                              19318                 :                :     /* xmloption, if relevant, must be filled in by caller */
                              19319                 :                :     /* type and typmod will be filled in during parse analysis */
  255 peter@eisentraut.org    19320                 :            298 :     x->type = InvalidOid;        /* marks the node as not analyzed */
 6218 tgl@sss.pgh.pa.us       19321                 :            298 :     x->location = location;
 6834 peter_e@gmx.net         19322                 :            298 :     return (Node *) x;
                              19323                 :                : }
                              19324                 :                : 
                              19325                 :                : /*
                              19326                 :                :  * Merge the input and output parameters of a table function.
                              19327                 :                :  */
                              19328                 :                : static List *
  310 tgl@sss.pgh.pa.us       19329                 :             97 : mergeTableFuncParameters(List *func_args, List *columns, core_yyscan_t yyscanner)
                              19330                 :                : {
                              19331                 :                :     ListCell   *lc;
                              19332                 :                : 
                              19333                 :                :     /* Explicit OUT and INOUT parameters shouldn't be used in this syntax */
 6259                         19334   [ +  +  +  +  :            197 :     foreach(lc, func_args)
                                              +  + ]
                              19335                 :                :     {
                              19336                 :            100 :         FunctionParameter *p = (FunctionParameter *) lfirst(lc);
                              19337                 :                : 
 1549                         19338         [ -  + ]:            100 :         if (p->mode != FUNC_PARAM_DEFAULT &&
 1549 tgl@sss.pgh.pa.us       19339         [ #  # ]:UBC           0 :             p->mode != FUNC_PARAM_IN &&
                              19340         [ #  # ]:              0 :             p->mode != FUNC_PARAM_VARIADIC)
 6259                         19341         [ #  # ]:              0 :             ereport(ERROR,
                              19342                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19343                 :                :                      errmsg("OUT and INOUT arguments aren't allowed in TABLE functions"),
                              19344                 :                :                      parser_errposition(p->location)));
                              19345                 :                :     }
                              19346                 :                : 
 6259 tgl@sss.pgh.pa.us       19347                 :CBC          97 :     return list_concat(func_args, columns);
                              19348                 :                : }
                              19349                 :                : 
                              19350                 :                : /*
                              19351                 :                :  * Determine return type of a TABLE function.  A single result column
                              19352                 :                :  * returns setof that column's type; otherwise return setof record.
                              19353                 :                :  */
                              19354                 :                : static TypeName *
                              19355                 :             97 : TableFuncTypeName(List *columns)
                              19356                 :                : {
                              19357                 :                :     TypeName   *result;
                              19358                 :                : 
                              19359         [ +  + ]:             97 :     if (list_length(columns) == 1)
                              19360                 :                :     {
                              19361                 :             31 :         FunctionParameter *p = (FunctionParameter *) linitial(columns);
                              19362                 :                : 
 3103 peter_e@gmx.net         19363                 :             31 :         result = copyObject(p->argType);
                              19364                 :                :     }
                              19365                 :                :     else
 6259 tgl@sss.pgh.pa.us       19366                 :             66 :         result = SystemTypeName("record");
                              19367                 :                : 
                              19368                 :             97 :     result->setof = true;
                              19369                 :                : 
                              19370                 :             97 :     return result;
                              19371                 :                : }
                              19372                 :                : 
                              19373                 :                : /*
                              19374                 :                :  * Convert a list of (dotted) names to a RangeVar (like
                              19375                 :                :  * makeRangeVarFromNameList, but with position support).  The
                              19376                 :                :  * "AnyName" refers to the any_name production in the grammar.
                              19377                 :                :  */
                              19378                 :                : static RangeVar *
 5459 peter_e@gmx.net         19379                 :            479 : makeRangeVarFromAnyName(List *names, int position, core_yyscan_t yyscanner)
                              19380                 :                : {
 1212 peter@eisentraut.org    19381                 :            479 :     RangeVar   *r = makeNode(RangeVar);
                              19382                 :                : 
 5459 peter_e@gmx.net         19383   [ +  +  -  - ]:            479 :     switch (list_length(names))
                              19384                 :                :     {
                              19385                 :            434 :         case 1:
                              19386                 :            434 :             r->catalogname = NULL;
                              19387                 :            434 :             r->schemaname = NULL;
                              19388                 :            434 :             r->relname = strVal(linitial(names));
                              19389                 :            434 :             break;
                              19390                 :             45 :         case 2:
                              19391                 :             45 :             r->catalogname = NULL;
                              19392                 :             45 :             r->schemaname = strVal(linitial(names));
                              19393                 :             45 :             r->relname = strVal(lsecond(names));
                              19394                 :             45 :             break;
 5459 peter_e@gmx.net         19395                 :UBC           0 :         case 3:
 3812 heikki.linnakangas@i    19396                 :              0 :             r->catalogname = strVal(linitial(names));
 5459 peter_e@gmx.net         19397                 :              0 :             r->schemaname = strVal(lsecond(names));
                              19398                 :              0 :             r->relname = strVal(lthird(names));
                              19399                 :              0 :             break;
                              19400                 :              0 :         default:
                              19401         [ #  # ]:              0 :             ereport(ERROR,
                              19402                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19403                 :                :                      errmsg("improper qualified name (too many dotted names): %s",
                              19404                 :                :                             NameListToString(names)),
                              19405                 :                :                      parser_errposition(position)));
                              19406                 :                :             break;
                              19407                 :                :     }
                              19408                 :                : 
 5381 rhaas@postgresql.org    19409                 :CBC         479 :     r->relpersistence = RELPERSISTENCE_PERMANENT;
 5459 peter_e@gmx.net         19410                 :            479 :     r->location = position;
                              19411                 :                : 
                              19412                 :            479 :     return r;
                              19413                 :                : }
                              19414                 :                : 
                              19415                 :                : /*
                              19416                 :                :  * Convert a relation_name with name and namelist to a RangeVar using
                              19417                 :                :  * makeRangeVar.
                              19418                 :                :  */
                              19419                 :                : static RangeVar *
 1410 akapila@postgresql.o    19420                 :         128587 : makeRangeVarFromQualifiedName(char *name, List *namelist, int location,
                              19421                 :                :                               core_yyscan_t yyscanner)
                              19422                 :                : {
                              19423                 :                :     RangeVar   *r;
                              19424                 :                : 
                              19425                 :         128587 :     check_qualified_name(namelist, yyscanner);
                              19426                 :         128587 :     r = makeRangeVar(NULL, NULL, location);
                              19427                 :                : 
                              19428      [ +  -  - ]:         128587 :     switch (list_length(namelist))
                              19429                 :                :     {
                              19430                 :         128587 :         case 1:
                              19431                 :         128587 :             r->catalogname = NULL;
                              19432                 :         128587 :             r->schemaname = name;
                              19433                 :         128587 :             r->relname = strVal(linitial(namelist));
                              19434                 :         128587 :             break;
 1410 akapila@postgresql.o    19435                 :UBC           0 :         case 2:
                              19436                 :              0 :             r->catalogname = name;
                              19437                 :              0 :             r->schemaname = strVal(linitial(namelist));
                              19438                 :              0 :             r->relname = strVal(lsecond(namelist));
                              19439                 :              0 :             break;
                              19440                 :              0 :         default:
                              19441         [ #  # ]:              0 :             ereport(ERROR,
                              19442                 :                :                     errcode(ERRCODE_SYNTAX_ERROR),
                              19443                 :                :                     errmsg("improper qualified name (too many dotted names): %s",
                              19444                 :                :                            NameListToString(lcons(makeString(name), namelist))),
                              19445                 :                :                     parser_errposition(location));
                              19446                 :                :             break;
                              19447                 :                :     }
                              19448                 :                : 
 1410 akapila@postgresql.o    19449                 :CBC      128587 :     return r;
                              19450                 :                : }
                              19451                 :                : 
                              19452                 :                : /* Separate Constraint nodes from COLLATE clauses in a ColQualList */
                              19453                 :                : static void
 5295 tgl@sss.pgh.pa.us       19454                 :          34558 : SplitColQualList(List *qualList,
                              19455                 :                :                  List **constraintList, CollateClause **collClause,
                              19456                 :                :                  core_yyscan_t yyscanner)
                              19457                 :                : {
                              19458                 :                :     ListCell   *cell;
                              19459                 :                : 
                              19460                 :          34558 :     *collClause = NULL;
 2245                         19461   [ +  +  +  +  :          44478 :     foreach(cell, qualList)
                                              +  + ]
                              19462                 :                :     {
 1212 peter@eisentraut.org    19463                 :           9920 :         Node       *n = (Node *) lfirst(cell);
                              19464                 :                : 
 5295 tgl@sss.pgh.pa.us       19465         [ +  + ]:           9920 :         if (IsA(n, Constraint))
                              19466                 :                :         {
                              19467                 :                :             /* keep it in list */
                              19468                 :           9539 :             continue;
                              19469                 :                :         }
                              19470         [ +  - ]:            381 :         if (IsA(n, CollateClause))
                              19471                 :                :         {
                              19472                 :            381 :             CollateClause *c = (CollateClause *) n;
                              19473                 :                : 
                              19474         [ -  + ]:            381 :             if (*collClause)
 5295 tgl@sss.pgh.pa.us       19475         [ #  # ]:UBC           0 :                 ereport(ERROR,
                              19476                 :                :                         (errcode(ERRCODE_SYNTAX_ERROR),
                              19477                 :                :                          errmsg("multiple COLLATE clauses not allowed"),
                              19478                 :                :                          parser_errposition(c->location)));
 5295 tgl@sss.pgh.pa.us       19479                 :CBC         381 :             *collClause = c;
                              19480                 :                :         }
                              19481                 :                :         else
 5295 tgl@sss.pgh.pa.us       19482         [ #  # ]:UBC           0 :             elog(ERROR, "unexpected node type %d", (int) n->type);
                              19483                 :                :         /* remove non-Constraint nodes from qualList */
 2245 tgl@sss.pgh.pa.us       19484                 :CBC         381 :         qualList = foreach_delete_current(qualList, cell);
                              19485                 :                :     }
 5295                         19486                 :          34558 :     *constraintList = qualList;
                              19487                 :          34558 : }
                              19488                 :                : 
                              19489                 :                : /*
                              19490                 :                :  * Process result of ConstraintAttributeSpec, and set appropriate bool flags
                              19491                 :                :  * in the output command node.  Pass NULL for any flags the particular
                              19492                 :                :  * command doesn't support.
                              19493                 :                :  */
                              19494                 :                : static void
 5197                         19495                 :           8903 : processCASbits(int cas_bits, int location, const char *constrType,
                              19496                 :                :                bool *deferrable, bool *initdeferred, bool *is_enforced,
                              19497                 :                :                bool *not_valid, bool *no_inherit, core_yyscan_t yyscanner)
                              19498                 :                : {
                              19499                 :                :     /* defaults */
                              19500         [ +  + ]:           8903 :     if (deferrable)
                              19501                 :           7874 :         *deferrable = false;
                              19502         [ +  + ]:           8903 :     if (initdeferred)
                              19503                 :           7874 :         *initdeferred = false;
                              19504         [ +  + ]:           8903 :     if (not_valid)
                              19505                 :           1918 :         *not_valid = false;
  238 peter@eisentraut.org    19506         [ +  + ]:           8903 :     if (is_enforced)
                              19507                 :           1682 :         *is_enforced = true;
                              19508                 :                : 
 5197 tgl@sss.pgh.pa.us       19509         [ +  + ]:           8903 :     if (cas_bits & (CAS_DEFERRABLE | CAS_INITIALLY_DEFERRED))
                              19510                 :                :     {
                              19511         [ +  - ]:            115 :         if (deferrable)
                              19512                 :            115 :             *deferrable = true;
                              19513                 :                :         else
 5197 tgl@sss.pgh.pa.us       19514         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19515                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19516                 :                :             /* translator: %s is CHECK, UNIQUE, or similar */
                              19517                 :                :                      errmsg("%s constraints cannot be marked DEFERRABLE",
                              19518                 :                :                             constrType),
                              19519                 :                :                      parser_errposition(location)));
                              19520                 :                :     }
                              19521                 :                : 
 5197 tgl@sss.pgh.pa.us       19522         [ +  + ]:CBC        8903 :     if (cas_bits & CAS_INITIALLY_DEFERRED)
                              19523                 :                :     {
                              19524         [ +  - ]:             73 :         if (initdeferred)
                              19525                 :             73 :             *initdeferred = true;
                              19526                 :                :         else
 5197 tgl@sss.pgh.pa.us       19527         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19528                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19529                 :                :             /* translator: %s is CHECK, UNIQUE, or similar */
                              19530                 :                :                      errmsg("%s constraints cannot be marked DEFERRABLE",
                              19531                 :                :                             constrType),
                              19532                 :                :                      parser_errposition(location)));
                              19533                 :                :     }
                              19534                 :                : 
 5197 tgl@sss.pgh.pa.us       19535         [ +  + ]:CBC        8903 :     if (cas_bits & CAS_NOT_VALID)
                              19536                 :                :     {
                              19537         [ +  - ]:            354 :         if (not_valid)
                              19538                 :            354 :             *not_valid = true;
                              19539                 :                :         else
 5197 tgl@sss.pgh.pa.us       19540         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19541                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19542                 :                :             /* translator: %s is CHECK, UNIQUE, or similar */
                              19543                 :                :                      errmsg("%s constraints cannot be marked NOT VALID",
                              19544                 :                :                             constrType),
                              19545                 :                :                      parser_errposition(location)));
                              19546                 :                :     }
                              19547                 :                : 
 4792 alvherre@alvh.no-ip.    19548         [ +  + ]:CBC        8903 :     if (cas_bits & CAS_NO_INHERIT)
                              19549                 :                :     {
                              19550         [ +  - ]:            122 :         if (no_inherit)
                              19551                 :            122 :             *no_inherit = true;
                              19552                 :                :         else
 4792 alvherre@alvh.no-ip.    19553         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19554                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19555                 :                :             /* translator: %s is CHECK, UNIQUE, or similar */
                              19556                 :                :                      errmsg("%s constraints cannot be marked NO INHERIT",
                              19557                 :                :                             constrType),
                              19558                 :                :                      parser_errposition(location)));
                              19559                 :                :     }
                              19560                 :                : 
  238 peter@eisentraut.org    19561         [ +  + ]:CBC        8903 :     if (cas_bits & CAS_NOT_ENFORCED)
                              19562                 :                :     {
                              19563         [ +  + ]:             78 :         if (is_enforced)
                              19564                 :             75 :             *is_enforced = false;
                              19565                 :                :         else
                              19566         [ +  - ]:              3 :             ereport(ERROR,
                              19567                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19568                 :                :                      /* translator: %s is CHECK, UNIQUE, or similar */
                              19569                 :                :                      errmsg("%s constraints cannot be marked NOT ENFORCED",
                              19570                 :                :                             constrType),
                              19571                 :                :                      parser_errposition(location)));
                              19572                 :                : 
                              19573                 :                :         /*
                              19574                 :                :          * NB: The validated status is irrelevant when the constraint is set to
                              19575                 :                :          * NOT ENFORCED, but for consistency, it should be set accordingly.
                              19576                 :                :          * This ensures that if the constraint is later changed to ENFORCED, it
                              19577                 :                :          * will automatically be in the correct NOT VALIDATED state.
                              19578                 :                :          */
                              19579         [ +  + ]:             75 :         if (not_valid)
                              19580                 :             57 :             *not_valid = true;
                              19581                 :                :     }
                              19582                 :                : 
                              19583         [ +  + ]:           8900 :     if (cas_bits & CAS_ENFORCED)
                              19584                 :                :     {
                              19585         [ +  + ]:             51 :         if (is_enforced)
                              19586                 :             48 :             *is_enforced = true;
                              19587                 :                :         else
                              19588         [ +  - ]:              3 :             ereport(ERROR,
                              19589                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19590                 :                :                      /* translator: %s is CHECK, UNIQUE, or similar */
                              19591                 :                :                      errmsg("%s constraints cannot be marked ENFORCED",
                              19592                 :                :                             constrType),
                              19593                 :                :                      parser_errposition(location)));
                              19594                 :                :     }
 5197 tgl@sss.pgh.pa.us       19595                 :           8897 : }
                              19596                 :                : 
                              19597                 :                : /*
                              19598                 :                :  * Parse a user-supplied partition strategy string into parse node
                              19599                 :                :  * PartitionStrategy representation, or die trying.
                              19600                 :                :  */
                              19601                 :                : static PartitionStrategy
  310                         19602                 :           2517 : parsePartitionStrategy(char *strategy, int location, core_yyscan_t yyscanner)
                              19603                 :                : {
 1038 alvherre@alvh.no-ip.    19604         [ +  + ]:           2517 :     if (pg_strcasecmp(strategy, "list") == 0)
                              19605                 :           1270 :         return PARTITION_STRATEGY_LIST;
                              19606         [ +  + ]:           1247 :     else if (pg_strcasecmp(strategy, "range") == 0)
                              19607                 :           1114 :         return PARTITION_STRATEGY_RANGE;
                              19608         [ +  + ]:            133 :     else if (pg_strcasecmp(strategy, "hash") == 0)
                              19609                 :            130 :         return PARTITION_STRATEGY_HASH;
                              19610                 :                : 
                              19611         [ +  - ]:              3 :     ereport(ERROR,
                              19612                 :                :             (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                              19613                 :                :              errmsg("unrecognized partitioning strategy \"%s\"", strategy),
                              19614                 :                :              parser_errposition(location)));
                              19615                 :                :     return PARTITION_STRATEGY_LIST; /* keep compiler quiet */
                              19616                 :                : 
                              19617                 :                : }
                              19618                 :                : 
                              19619                 :                : /*
                              19620                 :                :  * Process pubobjspec_list to check for errors in any of the objects and
                              19621                 :                :  * convert PUBLICATIONOBJ_CONTINUATION into appropriate PublicationObjSpecType.
                              19622                 :                :  */
                              19623                 :                : static void
 1410 akapila@postgresql.o    19624                 :            822 : preprocess_pubobj_list(List *pubobjspec_list, core_yyscan_t yyscanner)
                              19625                 :                : {
                              19626                 :                :     ListCell   *cell;
                              19627                 :                :     PublicationObjSpec *pubobj;
                              19628                 :            822 :     PublicationObjSpecType prevobjtype = PUBLICATIONOBJ_CONTINUATION;
                              19629                 :                : 
                              19630         [ -  + ]:            822 :     if (!pubobjspec_list)
 1410 akapila@postgresql.o    19631                 :UBC           0 :         return;
                              19632                 :                : 
 1410 akapila@postgresql.o    19633                 :CBC         822 :     pubobj = (PublicationObjSpec *) linitial(pubobjspec_list);
                              19634         [ +  + ]:            822 :     if (pubobj->pubobjtype == PUBLICATIONOBJ_CONTINUATION)
                              19635         [ +  - ]:              6 :         ereport(ERROR,
                              19636                 :                :                 errcode(ERRCODE_SYNTAX_ERROR),
                              19637                 :                :                 errmsg("invalid publication object list"),
                              19638                 :                :                 errdetail("One of TABLE or TABLES IN SCHEMA must be specified before a standalone table or schema name."),
                              19639                 :                :                 parser_errposition(pubobj->location));
                              19640                 :                : 
                              19641   [ +  -  +  +  :           1747 :     foreach(cell, pubobjspec_list)
                                              +  + ]
                              19642                 :                :     {
                              19643                 :            943 :         pubobj = (PublicationObjSpec *) lfirst(cell);
                              19644                 :                : 
                              19645         [ +  + ]:            943 :         if (pubobj->pubobjtype == PUBLICATIONOBJ_CONTINUATION)
                              19646                 :             87 :             pubobj->pubobjtype = prevobjtype;
                              19647                 :                : 
 1248 tomas.vondra@postgre    19648         [ +  + ]:            943 :         if (pubobj->pubobjtype == PUBLICATIONOBJ_TABLE)
                              19649                 :                :         {
                              19650                 :                :             /* relation name or pubtable must be set for this type of object */
 1410 akapila@postgresql.o    19651   [ +  +  +  + ]:            721 :             if (!pubobj->name && !pubobj->pubtable)
                              19652         [ +  - ]:              3 :                 ereport(ERROR,
                              19653                 :                :                         errcode(ERRCODE_SYNTAX_ERROR),
                              19654                 :                :                         errmsg("invalid table name"),
                              19655                 :                :                         parser_errposition(pubobj->location));
                              19656                 :                : 
 1292                         19657         [ +  + ]:            718 :             if (pubobj->name)
                              19658                 :                :             {
                              19659                 :                :                 /* convert it to PublicationTable */
 1410                         19660                 :             29 :                 PublicationTable *pubtable = makeNode(PublicationTable);
                              19661                 :                : 
 1346 alvherre@alvh.no-ip.    19662                 :             29 :                 pubtable->relation =
                              19663                 :             29 :                     makeRangeVar(NULL, pubobj->name, pubobj->location);
 1410 akapila@postgresql.o    19664                 :             29 :                 pubobj->pubtable = pubtable;
                              19665                 :             29 :                 pubobj->name = NULL;
                              19666                 :                :             }
                              19667                 :                :         }
 1346 alvherre@alvh.no-ip.    19668         [ +  + ]:            222 :         else if (pubobj->pubobjtype == PUBLICATIONOBJ_TABLES_IN_SCHEMA ||
                              19669         [ +  - ]:             12 :                  pubobj->pubobjtype == PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA)
                              19670                 :                :         {
                              19671                 :                :             /* WHERE clause is not allowed on a schema object */
 1292 akapila@postgresql.o    19672   [ +  +  +  + ]:            222 :             if (pubobj->pubtable && pubobj->pubtable->whereClause)
                              19673         [ +  - ]:              3 :                 ereport(ERROR,
                              19674                 :                :                         errcode(ERRCODE_SYNTAX_ERROR),
                              19675                 :                :                         errmsg("WHERE clause not allowed for schema"),
                              19676                 :                :                         parser_errposition(pubobj->location));
                              19677                 :                : 
                              19678                 :                :             /* Column list is not allowed on a schema object */
 1260 tomas.vondra@postgre    19679   [ +  +  +  + ]:            219 :             if (pubobj->pubtable && pubobj->pubtable->columns)
                              19680         [ +  - ]:              3 :                 ereport(ERROR,
                              19681                 :                :                         errcode(ERRCODE_SYNTAX_ERROR),
                              19682                 :                :                         errmsg("column specification not allowed for schema"),
                              19683                 :                :                         parser_errposition(pubobj->location));
                              19684                 :                : 
                              19685                 :                :             /*
                              19686                 :                :              * We can distinguish between the different type of schema objects
                              19687                 :                :              * based on whether name and pubtable is set.
                              19688                 :                :              */
 1410 akapila@postgresql.o    19689         [ +  + ]:            216 :             if (pubobj->name)
 1346 alvherre@alvh.no-ip.    19690                 :            201 :                 pubobj->pubobjtype = PUBLICATIONOBJ_TABLES_IN_SCHEMA;
 1410 akapila@postgresql.o    19691   [ +  -  +  + ]:             15 :             else if (!pubobj->name && !pubobj->pubtable)
 1346 alvherre@alvh.no-ip.    19692                 :             12 :                 pubobj->pubobjtype = PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA;
                              19693                 :                :             else
 1410 akapila@postgresql.o    19694         [ +  - ]:              3 :                 ereport(ERROR,
                              19695                 :                :                         errcode(ERRCODE_SYNTAX_ERROR),
                              19696                 :                :                         errmsg("invalid schema name"),
                              19697                 :                :                         parser_errposition(pubobj->location));
                              19698                 :                :         }
                              19699                 :                : 
                              19700                 :            931 :         prevobjtype = pubobj->pubobjtype;
                              19701                 :                :     }
                              19702                 :                : }
                              19703                 :                : 
                              19704                 :                : /*----------
                              19705                 :                :  * Recursive view transformation
                              19706                 :                :  *
                              19707                 :                :  * Convert
                              19708                 :                :  *
                              19709                 :                :  *     CREATE RECURSIVE VIEW relname (aliases) AS query
                              19710                 :                :  *
                              19711                 :                :  * to
                              19712                 :                :  *
                              19713                 :                :  *     CREATE VIEW relname (aliases) AS
                              19714                 :                :  *         WITH RECURSIVE relname (aliases) AS (query)
                              19715                 :                :  *         SELECT aliases FROM relname
                              19716                 :                :  *
                              19717                 :                :  * Actually, just the WITH ... part, which is then inserted into the original
                              19718                 :                :  * view definition as the query.
                              19719                 :                :  * ----------
                              19720                 :                :  */
                              19721                 :                : static Node *
 4601 peter_e@gmx.net         19722                 :              7 : makeRecursiveViewSelect(char *relname, List *aliases, Node *query)
                              19723                 :                : {
                              19724                 :              7 :     SelectStmt *s = makeNode(SelectStmt);
                              19725                 :              7 :     WithClause *w = makeNode(WithClause);
                              19726                 :              7 :     CommonTableExpr *cte = makeNode(CommonTableExpr);
                              19727                 :              7 :     List       *tl = NIL;
                              19728                 :                :     ListCell   *lc;
                              19729                 :                : 
                              19730                 :                :     /* create common table expression */
                              19731                 :              7 :     cte->ctename = relname;
                              19732                 :              7 :     cte->aliascolnames = aliases;
 2394 tgl@sss.pgh.pa.us       19733                 :              7 :     cte->ctematerialized = CTEMaterializeDefault;
 4601 peter_e@gmx.net         19734                 :              7 :     cte->ctequery = query;
                              19735                 :              7 :     cte->location = -1;
                              19736                 :                : 
                              19737                 :                :     /* create WITH clause and attach CTE */
                              19738                 :              7 :     w->recursive = true;
                              19739                 :              7 :     w->ctes = list_make1(cte);
                              19740                 :              7 :     w->location = -1;
                              19741                 :                : 
                              19742                 :                :     /*
                              19743                 :                :      * create target list for the new SELECT from the alias list of the
                              19744                 :                :      * recursive view specification
                              19745                 :                :      */
  255 peter@eisentraut.org    19746   [ +  -  +  +  :             14 :     foreach(lc, aliases)
                                              +  + ]
                              19747                 :                :     {
                              19748                 :              7 :         ResTarget  *rt = makeNode(ResTarget);
                              19749                 :                : 
 4601 peter_e@gmx.net         19750                 :              7 :         rt->name = NULL;
                              19751                 :              7 :         rt->indirection = NIL;
                              19752                 :              7 :         rt->val = makeColumnRef(strVal(lfirst(lc)), NIL, -1, 0);
                              19753                 :              7 :         rt->location = -1;
                              19754                 :                : 
                              19755                 :              7 :         tl = lappend(tl, rt);
                              19756                 :                :     }
                              19757                 :                : 
                              19758                 :                :     /*
                              19759                 :                :      * create new SELECT combining WITH clause, target list, and fake FROM
                              19760                 :                :      * clause
                              19761                 :                :      */
                              19762                 :              7 :     s->withClause = w;
                              19763                 :              7 :     s->targetList = tl;
                              19764                 :              7 :     s->fromClause = list_make1(makeRangeVar(NULL, relname, -1));
                              19765                 :                : 
                              19766                 :              7 :     return (Node *) s;
                              19767                 :                : }
                              19768                 :                : 
                              19769                 :                : /* parser_init()
                              19770                 :                :  * Initialize to parse one query string
                              19771                 :                :  */
                              19772                 :                : void
 5295 tgl@sss.pgh.pa.us       19773                 :         382579 : parser_init(base_yy_extra_type *yyext)
                              19774                 :                : {
                              19775                 :         382579 :     yyext->parsetree = NIL;      /* in case grammar forgets to set it */
                              19776                 :         382579 : }
        

Generated by: LCOV version 2.4-beta