LCOV - differential code coverage report
Current view: top level - src/backend/parser - gram.y (source / functions) Coverage Total Hit UBC GBC GNC CBC DCB
Current: c38de3ae6098ccf1904109f2e550eb4777f66024 vs e352ac8c5c90ed6ce792f044c22145578542a330 Lines: 91.2 % 7649 6974 675 2 25 6947 5
Current Date: 2026-11-05 14:14:01 +0100 Functions: 100.0 % 42 42 42
Baseline: lcov-20261105-baseline Branches: 62.9 % 754 474 280 474
Baseline Date: 2026-11-05 14:14:01 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(30,360] days: 95.4 % 173 165 8 25 140
(360..) days: 91.1 % 7476 6809 667 2 6807
Function coverage date bins:
(30,360] days: 100.0 % 1 1 1
(360..) days: 100.0 % 41 41 41
Branch coverage date bins:
(360..) days: 62.9 % 754 474 280 474

 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-2026, 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 location_end);
                                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_pub_all_objtype_list(List *all_objects_list,
                                205                 :                :                                             List **pubobjects,
                                206                 :                :                                             bool *all_tables,
                                207                 :                :                                             bool *all_sequences,
                                208                 :                :                                             core_yyscan_t yyscanner);
                                209                 :                : static void preprocess_pubobj_list(List *pubobjspec_list,
                                210                 :                :                                    core_yyscan_t yyscanner);
                                211                 :                : static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
                                212                 :                : 
                                213                 :                : %}
                                214                 :                : 
                                215                 :                : %pure-parser
                                216                 :                : %expect 0
                                217                 :                : %name-prefix="base_yy"
                                218                 :                : %locations
                                219                 :                : 
                                220                 :                : %parse-param {core_yyscan_t yyscanner}
                                221                 :                : %lex-param   {core_yyscan_t yyscanner}
                                222                 :                : 
                                223                 :                : %union
                                224                 :                : {
                                225                 :                :     core_YYSTYPE core_yystype;
                                226                 :                :     /* these fields must match core_YYSTYPE: */
                                227                 :                :     int         ival;
                                228                 :                :     char       *str;
                                229                 :                :     const char *keyword;
                                230                 :                : 
                                231                 :                :     char        chr;
                                232                 :                :     bool        boolean;
                                233                 :                :     JoinType    jtype;
                                234                 :                :     DropBehavior dbehavior;
                                235                 :                :     OnCommitAction oncommit;
                                236                 :                :     List       *list;
                                237                 :                :     Node       *node;
                                238                 :                :     ObjectType  objtype;
                                239                 :                :     TypeName   *typnam;
                                240                 :                :     FunctionParameter *fun_param;
                                241                 :                :     FunctionParameterMode fun_param_mode;
                                242                 :                :     ObjectWithArgs *objwithargs;
                                243                 :                :     DefElem    *defelt;
                                244                 :                :     SortBy     *sortby;
                                245                 :                :     WindowDef  *windef;
                                246                 :                :     JoinExpr   *jexpr;
                                247                 :                :     IndexElem  *ielem;
                                248                 :                :     StatsElem  *selem;
                                249                 :                :     Alias      *alias;
                                250                 :                :     RangeVar   *range;
                                251                 :                :     IntoClause *into;
                                252                 :                :     WithClause *with;
                                253                 :                :     InferClause *infer;
                                254                 :                :     OnConflictClause *onconflict;
                                255                 :                :     A_Indices  *aind;
                                256                 :                :     ResTarget  *target;
                                257                 :                :     struct PrivTarget *privtarget;
                                258                 :                :     AccessPriv *accesspriv;
                                259                 :                :     struct ImportQual *importqual;
                                260                 :                :     InsertStmt *istmt;
                                261                 :                :     VariableSetStmt *vsetstmt;
                                262                 :                :     PartitionElem *partelem;
                                263                 :                :     PartitionSpec *partspec;
                                264                 :                :     PartitionBoundSpec *partboundspec;
                                265                 :                :     RoleSpec   *rolespec;
                                266                 :                :     PublicationObjSpec *publicationobjectspec;
                                267                 :                :     PublicationAllObjSpec *publicationallobjectspec;
                                268                 :                :     struct SelectLimit *selectlimit;
                                269                 :                :     SetQuantifier setquantifier;
                                270                 :                :     struct GroupClause *groupclause;
                                271                 :                :     MergeMatchKind mergematch;
                                272                 :                :     MergeWhenClause *mergewhen;
                                273                 :                :     struct KeyActions *keyactions;
                                274                 :                :     struct KeyAction *keyaction;
                                275                 :                :     ReturningClause *retclause;
                                276                 :                :     ReturningOptionKind retoptionkind;
                                277                 :                : }
                                278                 :                : 
                                279                 :                : %type <node>  stmt toplevel_stmt schema_stmt routine_body_stmt
                                280                 :                :         AlterEventTrigStmt AlterCollationStmt
                                281                 :                :         AlterDatabaseStmt AlterDatabaseSetStmt AlterDomainStmt AlterEnumStmt
                                282                 :                :         AlterFdwStmt AlterForeignServerStmt AlterGroupStmt
                                283                 :                :         AlterObjectDependsStmt AlterObjectSchemaStmt AlterOwnerStmt
                                284                 :                :         AlterOperatorStmt AlterTypeStmt AlterSeqStmt AlterSystemStmt AlterTableStmt
                                285                 :                :         AlterTblSpcStmt AlterExtensionStmt AlterExtensionContentsStmt
                                286                 :                :         AlterCompositeTypeStmt AlterUserMappingStmt
                                287                 :                :         AlterRoleStmt AlterRoleSetStmt AlterPolicyStmt AlterStatsStmt
                                288                 :                :         AlterDefaultPrivilegesStmt DefACLAction
                                289                 :                :         AnalyzeStmt CallStmt ClosePortalStmt CommentStmt
                                290                 :                :         ConstraintsSetStmt CopyStmt CreateAsStmt CreateCastStmt
                                291                 :                :         CreateDomainStmt CreateExtensionStmt CreateGroupStmt CreateOpClassStmt
                                292                 :                :         CreateOpFamilyStmt AlterOpFamilyStmt CreatePLangStmt
                                293                 :                :         CreateSchemaStmt CreateSeqStmt CreateStmt CreateStatsStmt CreateTableSpaceStmt
                                294                 :                :         CreateFdwStmt CreateForeignServerStmt CreateForeignTableStmt
                                295                 :                :         CreateAssertionStmt CreateTransformStmt CreateTrigStmt CreateEventTrigStmt
                                296                 :                :         CreateUserStmt CreateUserMappingStmt CreateRoleStmt CreatePolicyStmt
                                297                 :                :         CreatedbStmt DeclareCursorStmt DefineStmt DeleteStmt DiscardStmt DoStmt
                                298                 :                :         DropOpClassStmt DropOpFamilyStmt DropStmt
                                299                 :                :         DropCastStmt DropRoleStmt
                                300                 :                :         DropdbStmt DropTableSpaceStmt
                                301                 :                :         DropTransformStmt
                                302                 :                :         DropUserMappingStmt ExplainStmt FetchStmt
                                303                 :                :         GrantStmt GrantRoleStmt ImportForeignSchemaStmt IndexStmt InsertStmt
                                304                 :                :         ListenStmt LoadStmt LockStmt MergeStmt NotifyStmt ExplainableStmt PreparableStmt
                                305                 :                :         CreateFunctionStmt AlterFunctionStmt ReindexStmt RemoveAggrStmt
                                306                 :                :         RemoveFuncStmt RemoveOperStmt RenameStmt RepackStmt ReturnStmt RevokeStmt RevokeRoleStmt
                                307                 :                :         RuleActionStmt RuleActionStmtOrEmpty RuleStmt
                                308                 :                :         SecLabelStmt SelectStmt TransactionStmt TransactionStmtLegacy TruncateStmt
                                309                 :                :         UnlistenStmt UpdateStmt VacuumStmt
                                310                 :                :         VariableResetStmt VariableSetStmt VariableShowStmt
                                311                 :                :         ViewStmt WaitStmt CheckPointStmt CreateConversionStmt
                                312                 :                :         DeallocateStmt PrepareStmt ExecuteStmt
                                313                 :                :         DropOwnedStmt ReassignOwnedStmt
                                314                 :                :         AlterTSConfigurationStmt AlterTSDictionaryStmt
                                315                 :                :         CreateMatViewStmt RefreshMatViewStmt CreateAmStmt
                                316                 :                :         CreatePublicationStmt AlterPublicationStmt
                                317                 :                :         CreateSubscriptionStmt AlterSubscriptionStmt DropSubscriptionStmt
                                318                 :                : 
                                319                 :                : %type <node>  select_no_parens select_with_parens select_clause
                                320                 :                :                 simple_select values_clause
                                321                 :                :                 PLpgSQL_Expr PLAssignStmt
                                322                 :                : 
                                323                 :                : %type <str>           opt_single_name
                                324                 :                : %type <list>      opt_qualified_name
                                325                 :                : %type <boolean>       opt_concurrently opt_usingindex
                                326                 :                : %type <dbehavior> opt_drop_behavior
                                327                 :                : %type <list>      opt_utility_option_list
                                328                 :                : %type <list>      opt_wait_with_clause
                                329                 :                : %type <list>      utility_option_list
                                330                 :                : %type <defelt>        utility_option_elem
                                331                 :                : %type <str>           utility_option_name
                                332                 :                : %type <node>      utility_option_arg
                                333                 :                : 
                                334                 :                : %type <node>  alter_column_default opclass_item opclass_drop alter_using
                                335                 :                : %type <ival>  add_drop opt_asc_desc opt_nulls_order
                                336                 :                : 
                                337                 :                : %type <node>  alter_table_cmd alter_type_cmd opt_collate_clause
                                338                 :                :        replica_identity partition_cmd index_partition_cmd
                                339                 :                : %type <list>  alter_table_cmds alter_type_cmds
                                340                 :                : %type <list>    alter_identity_column_option_list
                                341                 :                : %type <defelt>  alter_identity_column_option
                                342                 :                : %type <node>  set_statistics_value
                                343                 :                : %type <str>       set_access_method_name
                                344                 :                : 
                                345                 :                : %type <list>  createdb_opt_list createdb_opt_items copy_opt_list
                                346                 :                :                 transaction_mode_list
                                347                 :                :                 create_extension_opt_list alter_extension_opt_list
                                348                 :                : %type <defelt>    createdb_opt_item copy_opt_item
                                349                 :                :                 transaction_mode_item
                                350                 :                :                 create_extension_opt_item alter_extension_opt_item
                                351                 :                : 
                                352                 :                : %type <ival>  opt_lock lock_type cast_context
                                353                 :                : %type <defelt>    drop_option
                                354                 :                : %type <boolean>   opt_or_replace opt_no
                                355                 :                :                 opt_grant_grant_option
                                356                 :                :                 opt_nowait opt_if_exists opt_with_data
                                357                 :                :                 opt_transaction_chain
                                358                 :                : %type <list>  grant_role_opt_list
                                359                 :                : %type <defelt>    grant_role_opt
                                360                 :                : %type <node>  grant_role_opt_value
                                361                 :                : %type <ival>  opt_nowait_or_skip
                                362                 :                : 
                                363                 :                : %type <list>  OptRoleList AlterOptRoleList
                                364                 :                : %type <defelt>    CreateOptRoleElem AlterOptRoleElem
                                365                 :                : 
                                366                 :                : %type <str>       opt_type
                                367                 :                : %type <str>       foreign_server_version opt_foreign_server_version
                                368                 :                : %type <str>       opt_in_database
                                369                 :                : 
                                370                 :                : %type <str>       parameter_name
                                371                 :                : %type <list>  OptSchemaEltList parameter_name_list
                                372                 :                : 
                                373                 :                : %type <chr>       am_type
                                374                 :                : 
                                375                 :                : %type <boolean> TriggerForSpec TriggerForType
                                376                 :                : %type <ival>  TriggerActionTime
                                377                 :                : %type <list>  TriggerEvents TriggerOneEvent
                                378                 :                : %type <node>  TriggerFuncArg
                                379                 :                : %type <node>  TriggerWhen
                                380                 :                : %type <str>       TransitionRelName
                                381                 :                : %type <boolean>   TransitionRowOrTable TransitionOldOrNew
                                382                 :                : %type <node>  TriggerTransition
                                383                 :                : 
                                384                 :                : %type <list>  event_trigger_when_list event_trigger_value_list
                                385                 :                : %type <defelt>    event_trigger_when_item
                                386                 :                : %type <chr>       enable_trigger
                                387                 :                : 
                                388                 :                : %type <str>       copy_file_name
                                389                 :                :                 access_method_clause attr_name
                                390                 :                :                 table_access_method_clause name cursor_name file_name
                                391                 :                :                 cluster_index_specification
                                392                 :                : 
                                393                 :                : %type <list>  func_name handler_name qual_Op qual_all_Op subquery_Op
                                394                 :                :                 opt_inline_handler opt_validator validator_clause
                                395                 :                :                 opt_collate
                                396                 :                : 
                                397                 :                : %type <range> qualified_name insert_target OptConstrFromTable
                                398                 :                : 
                                399                 :                : %type <str>       all_Op MathOp
                                400                 :                : 
                                401                 :                : %type <str>       row_security_cmd RowSecurityDefaultForCmd
                                402                 :                : %type <boolean> RowSecurityDefaultPermissive
                                403                 :                : %type <node>  RowSecurityOptionalWithCheck RowSecurityOptionalExpr
                                404                 :                : %type <list>  RowSecurityDefaultToRole RowSecurityOptionalToRole
                                405                 :                : 
                                406                 :                : %type <str>       iso_level opt_encoding
                                407                 :                : %type <rolespec> grantee
                                408                 :                : %type <list>  grantee_list
                                409                 :                : %type <accesspriv> privilege
                                410                 :                : %type <list>  privileges privilege_list
                                411                 :                : %type <privtarget> privilege_target
                                412                 :                : %type <objwithargs> function_with_argtypes aggregate_with_argtypes operator_with_argtypes
                                413                 :                : %type <list>  function_with_argtypes_list aggregate_with_argtypes_list operator_with_argtypes_list
                                414                 :                : %type <ival>  defacl_privilege_target
                                415                 :                : %type <defelt>    DefACLOption
                                416                 :                : %type <list>  DefACLOptionList
                                417                 :                : %type <ival>  import_qualification_type
                                418                 :                : %type <importqual> import_qualification
                                419                 :                : %type <node>  vacuum_relation
                                420                 :                : %type <selectlimit> opt_select_limit select_limit limit_clause
                                421                 :                : 
                                422                 :                : %type <list>  parse_toplevel stmtmulti routine_body_stmt_list
                                423                 :                :                 OptTableElementList TableElementList OptInherit definition
                                424                 :                :                 OptTypedTableElementList TypedTableElementList
                                425                 :                :                 reloptions opt_reloptions
                                426                 :                :                 OptWith opt_definition func_args func_args_list
                                427                 :                :                 func_args_with_defaults func_args_with_defaults_list
                                428                 :                :                 aggr_args aggr_args_list
                                429                 :                :                 func_as createfunc_opt_list opt_createfunc_opt_list alterfunc_opt_list
                                430                 :                :                 old_aggr_definition old_aggr_list
                                431                 :                :                 oper_argtypes RuleActionList RuleActionMulti
                                432                 :                :                 opt_column_list columnList opt_name_list
                                433                 :                :                 sort_clause opt_sort_clause sortby_list index_params
                                434                 :                :                 stats_params
                                435                 :                :                 opt_include opt_c_include index_including_params
                                436                 :                :                 name_list role_list from_clause from_list opt_array_bounds
                                437                 :                :                 qualified_name_list any_name any_name_list type_name_list
                                438                 :                :                 any_operator expr_list attrs
                                439                 :                :                 distinct_clause opt_distinct_clause
                                440                 :                :                 target_list opt_target_list insert_column_list set_target_list
                                441                 :                :                 merge_values_clause
                                442                 :                :                 set_clause_list set_clause
                                443                 :                :                 def_list operator_def_list indirection opt_indirection
                                444                 :                :                 reloption_list TriggerFuncArgs opclass_item_list opclass_drop_list
                                445                 :                :                 opclass_purpose opt_opfamily transaction_mode_list_or_empty
                                446                 :                :                 OptTableFuncElementList TableFuncElementList opt_type_modifiers
                                447                 :                :                 prep_type_clause
                                448                 :                :                 execute_param_clause using_clause
                                449                 :                :                 returning_with_clause returning_options
                                450                 :                :                 opt_enum_val_list enum_val_list table_func_column_list
                                451                 :                :                 create_generic_options alter_generic_options
                                452                 :                :                 relation_expr_list dostmt_opt_list
                                453                 :                :                 transform_element_list transform_type_list
                                454                 :                :                 TriggerTransitions TriggerReferencing
                                455                 :                :                 vacuum_relation_list opt_vacuum_relation_list
                                456                 :                :                 drop_option_list pub_obj_list pub_all_obj_type_list
                                457                 :                :                 pub_except_obj_list opt_pub_except_clause
                                458                 :                : 
                                459                 :                : %type <retclause> returning_clause
                                460                 :                : %type <node>  returning_option
                                461                 :                : %type <retoptionkind> returning_option_kind
                                462                 :                : %type <node>  opt_routine_body
                                463                 :                : %type <groupclause> group_clause
                                464                 :                : %type <list>  group_by_list
                                465                 :                : %type <node>  group_by_item empty_grouping_set rollup_clause cube_clause
                                466                 :                : %type <node>  grouping_sets_clause
                                467                 :                : 
                                468                 :                : %type <list>  opt_fdw_options fdw_options
                                469                 :                : %type <defelt>    fdw_option
                                470                 :                : 
                                471                 :                : %type <range> OptTempTableName
                                472                 :                : %type <into>  into_clause create_as_target create_mv_target
                                473                 :                : 
                                474                 :                : %type <defelt>    createfunc_opt_item common_func_opt_item dostmt_opt_item
                                475                 :                : %type <fun_param> func_arg func_arg_with_default table_func_column aggr_arg
                                476                 :                : %type <fun_param_mode> arg_class
                                477                 :                : %type <typnam>    func_return func_type
                                478                 :                : 
                                479                 :                : %type <boolean>  opt_trusted opt_restart_seqs
                                480                 :                : %type <ival>   OptTemp
                                481                 :                : %type <ival>   OptNoLog
                                482                 :                : %type <oncommit> OnCommitOption
                                483                 :                : 
                                484                 :                : %type <ival>  for_locking_strength opt_for_locking_strength
                                485                 :                : %type <node>  for_locking_item
                                486                 :                : %type <list>  for_locking_clause opt_for_locking_clause for_locking_items
                                487                 :                : %type <list>  locked_rels_list
                                488                 :                : %type <setquantifier> set_quantifier
                                489                 :                : 
                                490                 :                : %type <node>  join_qual
                                491                 :                : %type <jtype> join_type
                                492                 :                : 
                                493                 :                : %type <list>  extract_list overlay_list position_list
                                494                 :                : %type <list>  substr_list trim_list
                                495                 :                : %type <list>  opt_interval interval_second
                                496                 :                : %type <str>       unicode_normal_form
                                497                 :                : 
                                498                 :                : %type <boolean> opt_instead
                                499                 :                : %type <boolean> opt_unique opt_verbose opt_full
                                500                 :                : %type <boolean> opt_freeze opt_analyze opt_default
                                501                 :                : %type <defelt>    opt_binary copy_delimiter
                                502                 :                : 
                                503                 :                : %type <boolean> copy_from opt_program
                                504                 :                : 
                                505                 :                : %type <ival>  event cursor_options opt_hold opt_set_data
                                506                 :                : %type <objtype>   object_type_any_name object_type_name object_type_name_on_any_name
                                507                 :                :                 drop_type_name
                                508                 :                : 
                                509                 :                : %type <node>  fetch_args select_limit_value
                                510                 :                :                 offset_clause select_offset_value
                                511                 :                :                 select_fetch_first_value I_or_F_const
                                512                 :                : %type <ival>  row_or_rows first_or_next
                                513                 :                : 
                                514                 :                : %type <list>  OptSeqOptList SeqOptList OptParenthesizedSeqOptList
                                515                 :                : %type <defelt>    SeqOptElem
                                516                 :                : 
                                517                 :                : %type <istmt> insert_rest
                                518                 :                : %type <infer> opt_conf_expr
                                519                 :                : %type <onconflict> opt_on_conflict
                                520                 :                : %type <mergewhen> merge_insert merge_update merge_delete
                                521                 :                : 
                                522                 :                : %type <mergematch> merge_when_tgt_matched merge_when_tgt_not_matched
                                523                 :                : %type <node>  merge_when_clause opt_merge_when_condition
                                524                 :                : %type <list>  merge_when_list
                                525                 :                : 
                                526                 :                : %type <vsetstmt> generic_set set_rest set_rest_more generic_reset reset_rest
                                527                 :                :                  SetResetClause FunctionSetResetClause
                                528                 :                : 
                                529                 :                : %type <node>  TableElement TypedTableElement ConstraintElem DomainConstraintElem TableFuncElement
                                530                 :                : %type <node>  columnDef columnOptions optionalPeriodName
                                531                 :                : %type <defelt>    def_elem reloption_elem old_aggr_elem operator_def_elem
                                532                 :                : %type <node>  def_arg columnElem where_clause where_or_current_clause
                                533                 :                :                 a_expr b_expr c_expr AexprConst indirection_el opt_slice_bound
                                534                 :                :                 columnref having_clause func_table xmltable array_expr
                                535                 :                :                 OptWhereClause operator_def_arg
                                536                 :                : %type <list>  opt_column_and_period_list
                                537                 :                : %type <list>  rowsfrom_item rowsfrom_list opt_col_def_list
                                538                 :                : %type <boolean> opt_ordinality opt_without_overlaps
                                539                 :                : %type <list>  ExclusionConstraintList ExclusionConstraintElem
                                540                 :                : %type <list>  func_arg_list func_arg_list_opt
                                541                 :                : %type <node>  func_arg_expr
                                542                 :                : %type <list>  row explicit_row implicit_row type_list array_expr_list
                                543                 :                : %type <node>  case_expr case_arg when_clause case_default
                                544                 :                : %type <list>  when_clause_list
                                545                 :                : %type <node>  opt_search_clause opt_cycle_clause
                                546                 :                : %type <ival>  sub_type opt_materialized
                                547                 :                : %type <node>  NumericOnly
                                548                 :                : %type <list>  NumericOnly_list
                                549                 :                : %type <alias> alias_clause opt_alias_clause opt_alias_clause_for_join_using
                                550                 :                : %type <list>  func_alias_clause
                                551                 :                : %type <sortby>    sortby
                                552                 :                : %type <ielem> index_elem index_elem_options
                                553                 :                : %type <selem> stats_param
                                554                 :                : %type <node>  table_ref
                                555                 :                : %type <jexpr> joined_table
                                556                 :                : %type <range> relation_expr
                                557                 :                : %type <range> extended_relation_expr
                                558                 :                : %type <range> relation_expr_opt_alias
                                559                 :                : %type <node>  tablesample_clause opt_repeatable_clause
                                560                 :                : %type <target>    target_el set_target insert_column_item
                                561                 :                : 
                                562                 :                : %type <str>       generic_option_name
                                563                 :                : %type <node>  generic_option_arg
                                564                 :                : %type <defelt>    generic_option_elem alter_generic_option_elem
                                565                 :                : %type <list>  generic_option_list alter_generic_option_list
                                566                 :                : 
                                567                 :                : %type <ival>  reindex_target_relation reindex_target_all
                                568                 :                : 
                                569                 :                : %type <node>  copy_generic_opt_arg copy_generic_opt_arg_list_item
                                570                 :                : %type <defelt>    copy_generic_opt_elem
                                571                 :                : %type <list>  copy_generic_opt_list copy_generic_opt_arg_list
                                572                 :                : %type <list>  copy_options
                                573                 :                : 
                                574                 :                : %type <typnam>    Typename SimpleTypename ConstTypename
                                575                 :                :                 GenericType Numeric opt_float JsonType
                                576                 :                :                 Character ConstCharacter
                                577                 :                :                 CharacterWithLength CharacterWithoutLength
                                578                 :                :                 ConstDatetime ConstInterval
                                579                 :                :                 Bit ConstBit BitWithLength BitWithoutLength
                                580                 :                : %type <str>       character
                                581                 :                : %type <str>       extract_arg
                                582                 :                : %type <boolean> opt_varying opt_timezone opt_no_inherit
                                583                 :                : 
                                584                 :                : %type <ival>  Iconst SignedIconst
                                585                 :                : %type <str>       Sconst comment_text notify_payload
                                586                 :                : %type <str>       RoleId opt_boolean_or_string
                                587                 :                : %type <list>  var_list
                                588                 :                : %type <str>       ColId ColLabel BareColLabel
                                589                 :                : %type <str>       NonReservedWord NonReservedWord_or_Sconst
                                590                 :                : %type <str>       var_name type_function_name param_name
                                591                 :                : %type <str>       createdb_opt_name plassign_target
                                592                 :                : %type <node>  var_value zone_value
                                593                 :                : %type <rolespec> auth_ident RoleSpec opt_granted_by
                                594                 :                : %type <publicationobjectspec> PublicationObjSpec
                                595                 :                : %type <publicationobjectspec> PublicationExceptObjSpec
                                596                 :                : %type <publicationallobjectspec> PublicationAllObjSpec
                                597                 :                : 
                                598                 :                : %type <keyword> unreserved_keyword type_func_name_keyword
                                599                 :                : %type <keyword> col_name_keyword reserved_keyword
                                600                 :                : %type <keyword> bare_label_keyword
                                601                 :                : 
                                602                 :                : %type <node>  DomainConstraint TableConstraint TableLikeClause
                                603                 :                : %type <ival>  TableLikeOptionList TableLikeOption
                                604                 :                : %type <str>       column_compression opt_column_compression column_storage opt_column_storage
                                605                 :                : %type <list>  ColQualList
                                606                 :                : %type <node>  ColConstraint ColConstraintElem ConstraintAttr
                                607                 :                : %type <ival>  key_match
                                608                 :                : %type <keyaction> key_delete key_update key_action
                                609                 :                : %type <keyactions> key_actions
                                610                 :                : %type <ival>  ConstraintAttributeSpec ConstraintAttributeElem
                                611                 :                : %type <str>       ExistingIndex
                                612                 :                : 
                                613                 :                : %type <list>  constraints_set_list
                                614                 :                : %type <boolean> constraints_set_mode
                                615                 :                : %type <str>       OptTableSpace OptConsTableSpace
                                616                 :                : %type <rolespec> OptTableSpaceOwner
                                617                 :                : %type <ival>  opt_check_option
                                618                 :                : 
                                619                 :                : %type <str>       opt_provider security_label
                                620                 :                : 
                                621                 :                : %type <target>    labeled_expr
                                622                 :                : %type <list>  labeled_expr_list xml_attributes
                                623                 :                : %type <node>  xml_root_version opt_xml_root_standalone
                                624                 :                : %type <node>  xmlexists_argument
                                625                 :                : %type <ival>  document_or_content
                                626                 :                : %type <boolean>   xml_indent_option xml_whitespace_option
                                627                 :                : %type <list>  xmltable_column_list xmltable_column_option_list
                                628                 :                : %type <node>  xmltable_column_el
                                629                 :                : %type <defelt>    xmltable_column_option_el
                                630                 :                : %type <list>  xml_namespace_list
                                631                 :                : %type <target>    xml_namespace_el
                                632                 :                : 
                                633                 :                : %type <node>  func_application func_expr_common_subexpr
                                634                 :                : %type <node>  func_expr func_expr_windowless
                                635                 :                : %type <node>  common_table_expr
                                636                 :                : %type <with>  with_clause opt_with_clause
                                637                 :                : %type <list>  cte_list
                                638                 :                : 
                                639                 :                : %type <list>  within_group_clause
                                640                 :                : %type <node>  filter_clause
                                641                 :                : %type <list>  window_clause window_definition_list opt_partition_clause
                                642                 :                : %type <windef>    window_definition over_clause window_specification
                                643                 :                :                 opt_frame_clause frame_extent frame_bound
                                644                 :                : %type <ival>  null_treatment opt_window_exclusion_clause
                                645                 :                : %type <str>       opt_existing_window_name
                                646                 :                : %type <boolean> opt_if_not_exists
                                647                 :                : %type <boolean> opt_unique_null_treatment
                                648                 :                : %type <ival>  generated_when override_kind opt_virtual_or_stored
                                649                 :                : %type <partspec>  PartitionSpec OptPartitionSpec
                                650                 :                : %type <partelem>  part_elem
                                651                 :                : %type <list>      part_params
                                652                 :                : %type <partboundspec> PartitionBoundSpec
                                653                 :                : %type <list>      hash_partbound
                                654                 :                : %type <defelt>        hash_partbound_elem
                                655                 :                : 
                                656                 :                : %type <node>  json_format_clause
                                657                 :                :                 json_format_clause_opt
                                658                 :                :                 json_value_expr
                                659                 :                :                 json_returning_clause_opt
                                660                 :                :                 json_name_and_value
                                661                 :                :                 json_aggregate_func
                                662                 :                :                 json_argument
                                663                 :                :                 json_behavior
                                664                 :                :                 json_on_error_clause_opt
                                665                 :                :                 json_table
                                666                 :                :                 json_table_column_definition
                                667                 :                :                 json_table_column_path_clause_opt
                                668                 :                :                 json_table_plan_clause_opt
                                669                 :                :                 json_table_plan
                                670                 :                :                 json_table_plan_simple
                                671                 :                :                 json_table_plan_outer
                                672                 :                :                 json_table_plan_inner
                                673                 :                :                 json_table_plan_union
                                674                 :                :                 json_table_plan_cross
                                675                 :                :                 json_table_plan_primary
                                676                 :                : %type <list>  json_name_and_value_list
                                677                 :                :                 json_value_expr_list
                                678                 :                :                 json_array_aggregate_order_by_clause_opt
                                679                 :                :                 json_arguments
                                680                 :                :                 json_behavior_clause_opt
                                681                 :                :                 json_passing_clause_opt
                                682                 :                :                 json_table_column_definition_list
                                683                 :                : %type <str>       json_table_path_name_opt
                                684                 :                : %type <ival>  json_behavior_type
                                685                 :                :                 json_predicate_type_constraint
                                686                 :                :                 json_quotes_clause_opt
                                687                 :                :                 json_table_default_plan_choices
                                688                 :                :                 json_table_default_plan_inner_outer
                                689                 :                :                 json_table_default_plan_union_cross
                                690                 :                :                 json_wrapper_behavior
                                691                 :                : %type <boolean>   json_key_uniqueness_constraint_opt
                                692                 :                :                 json_object_constructor_null_clause_opt
                                693                 :                :                 json_array_constructor_null_clause_opt
                                694                 :                : 
                                695                 :                : /*
                                696                 :                :  * Non-keyword token types.  These are hard-wired into the "flex" lexer.
                                697                 :                :  * They must be listed first so that their numeric codes do not depend on
                                698                 :                :  * the set of keywords.  PL/pgSQL depends on this so that it can share the
                                699                 :                :  * same lexer.  If you add/change tokens here, fix PL/pgSQL to match!
                                700                 :                :  *
                                701                 :                :  * UIDENT and USCONST are reduced to IDENT and SCONST in parser.c, so that
                                702                 :                :  * they need no productions here; but we must assign token codes to them.
                                703                 :                :  *
                                704                 :                :  * DOT_DOT is unused in the core SQL grammar, and so will always provoke
                                705                 :                :  * parse errors.  It is needed by PL/pgSQL.
                                706                 :                :  */
                                707                 :                : %token <str>  IDENT UIDENT FCONST SCONST USCONST BCONST XCONST Op
                                708                 :                : %token <ival> ICONST PARAM
                                709                 :                : %token          TYPECAST DOT_DOT COLON_EQUALS EQUALS_GREATER
                                710                 :                : %token          LESS_EQUALS GREATER_EQUALS NOT_EQUALS
                                711                 :                : 
                                712                 :                : /*
                                713                 :                :  * If you want to make any keyword changes, update the keyword table in
                                714                 :                :  * src/include/parser/kwlist.h and add new keywords to the appropriate one
                                715                 :                :  * of the reserved-or-not-so-reserved keyword lists, below; search
                                716                 :                :  * this file for "Keyword category lists".
                                717                 :                :  */
                                718                 :                : 
                                719                 :                : /* ordinary key words in alphabetical order */
                                720                 :                : %token <keyword> ABORT_P ABSENT ABSOLUTE_P ACCESS ACTION ADD_P ADMIN AFTER
                                721                 :                :     AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY ARRAY AS ASC
                                722                 :                :     ASENSITIVE ASSERTION ASSIGNMENT ASYMMETRIC ATOMIC AT ATTACH ATTRIBUTE AUTHORIZATION
                                723                 :                : 
                                724                 :                :     BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
                                725                 :                :     BOOLEAN_P BOTH BREADTH BY
                                726                 :                : 
                                727                 :                :     CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
                                728                 :                :     CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
                                729                 :                :     CLUSTER COALESCE COLLATE COLLATION COLUMN COLUMNS COMMENT COMMENTS COMMIT
                                730                 :                :     COMMITTED COMPRESSION CONCURRENTLY CONDITIONAL CONFIGURATION CONFLICT
                                731                 :                :     CONNECTION CONSTRAINT CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY
                                732                 :                :     COST CREATE CROSS CSV CUBE CURRENT_P
                                733                 :                :     CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
                                734                 :                :     CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
                                735                 :                : 
                                736                 :                :     DATA_P DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS
                                737                 :                :     DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS DEPENDS DEPTH DESC
                                738                 :                :     DETACH DICTIONARY DISABLE_P DISCARD DISTINCT DO DOCUMENT_P DOMAIN_P
                                739                 :                :     DOUBLE_P DROP
                                740                 :                : 
                                741                 :                :     EACH ELSE EMPTY_P ENABLE_P ENCODING ENCRYPTED END_P ENFORCED ENUM_P ERROR_P
                                742                 :                :     ESCAPE EVENT EXCEPT EXCLUDE EXCLUDING EXCLUSIVE EXECUTE EXISTS EXPLAIN
                                743                 :                :     EXPRESSION EXTENSION EXTERNAL EXTRACT
                                744                 :                : 
                                745                 :                :     FALSE_P FAMILY FETCH FILTER FINALIZE FIRST_P FLOAT_P FOLLOWING FOR
                                746                 :                :     FORCE FOREIGN FORMAT FORWARD FREEZE FROM FULL FUNCTION FUNCTIONS
                                747                 :                : 
                                748                 :                :     GENERATED GLOBAL GRANT GRANTED GREATEST GROUP_P GROUPING GROUPS
                                749                 :                : 
                                750                 :                :     HANDLER HAVING HEADER_P HOLD HOUR_P
                                751                 :                : 
                                752                 :                :     IDENTITY_P IF_P IGNORE_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P IN_P INCLUDE
                                753                 :                :     INCLUDING INCREMENT INDENT INDEX INDEXES INHERIT INHERITS INITIALLY INLINE_P
                                754                 :                :     INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER
                                755                 :                :     INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION
                                756                 :                : 
                                757                 :                :     JOIN JSON JSON_ARRAY JSON_ARRAYAGG JSON_EXISTS JSON_OBJECT JSON_OBJECTAGG
                                758                 :                :     JSON_QUERY JSON_SCALAR JSON_SERIALIZE JSON_TABLE JSON_VALUE
                                759                 :                : 
                                760                 :                :     KEEP KEY KEYS
                                761                 :                : 
                                762                 :                :     LABEL LANGUAGE LARGE_P LAST_P LATERAL_P
                                763                 :                :     LEADING LEAKPROOF LEAST LEFT LEVEL LIKE LIMIT LISTEN LOAD LOCAL
                                764                 :                :     LOCALTIME LOCALTIMESTAMP LOCATION LOCK_P LOCKED LOGGED LSN_P
                                765                 :                : 
                                766                 :                :     MAPPING MATCH MATCHED MATERIALIZED MAXVALUE MERGE MERGE_ACTION METHOD
                                767                 :                :     MINUTE_P MINVALUE MODE MONTH_P MOVE
                                768                 :                : 
                                769                 :                :     NAME_P NAMES NATIONAL NATURAL NCHAR NESTED NEW NEXT NFC NFD NFKC NFKD NO
                                770                 :                :     NONE NORMALIZE NORMALIZED
                                771                 :                :     NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
                                772                 :                :     NULLS_P NUMERIC
                                773                 :                : 
                                774                 :                :     OBJECT_P OBJECTS_P OF OFF OFFSET OIDS OLD OMIT ON ONLY OPERATOR OPTION OPTIONS OR
                                775                 :                :     ORDER ORDINALITY OTHERS OUT_P OUTER_P
                                776                 :                :     OVER OVERLAPS OVERLAY OVERRIDING OWNED OWNER
                                777                 :                : 
                                778                 :                :     PARALLEL PARAMETER PARSER PARTIAL PARTITION PASSING PASSWORD PATH
                                779                 :                :     PERIOD PLACING PLAN PLANS POLICY
                                780                 :                :     POSITION PRECEDING PRECISION PRESERVE PREPARE PREPARED PRIMARY
                                781                 :                :     PRIOR PRIVILEGES PROCEDURAL PROCEDURE PROCEDURES PROGRAM PUBLICATION
                                782                 :                : 
                                783                 :                :     QUOTE QUOTES
                                784                 :                : 
                                785                 :                :     RANGE READ REAL REASSIGN RECURSIVE REF_P REFERENCES REFERENCING
                                786                 :                :     REFRESH REINDEX RELATIVE_P RELEASE RENAME REPACK REPEATABLE REPLACE REPLICA
                                787                 :                :     RESET RESPECT_P RESTART RESTRICT RETURN RETURNING RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP
                                788                 :                :     ROUTINE ROUTINES ROW ROWS RULE
                                789                 :                : 
                                790                 :                :     SAVEPOINT SCALAR SCHEMA SCHEMAS SCROLL SEARCH SECOND_P SECURITY SELECT
                                791                 :                :     SEQUENCE SEQUENCES
                                792                 :                :     SERIALIZABLE SERVER SESSION SESSION_USER SET SETS SETOF SHARE SHOW
                                793                 :                :     SIMILAR SIMPLE SKIP SMALLINT SNAPSHOT SOME SOURCE SQL_P STABLE STANDALONE_P
                                794                 :                :     START STATEMENT STATISTICS STDIN STDOUT STORAGE STORED STRICT_P STRING_P STRIP_P
                                795                 :                :     SUBSCRIPTION SUBSTRING SUPPORT SYMMETRIC SYSID SYSTEM_P SYSTEM_USER
                                796                 :                : 
                                797                 :                :     TABLE TABLES TABLESAMPLE TABLESPACE TARGET TEMP TEMPLATE TEMPORARY TEXT_P THEN
                                798                 :                :     TIES TIME TIMESTAMP TO TRAILING TRANSACTION TRANSFORM
                                799                 :                :     TREAT TRIGGER TRIM TRUE_P
                                800                 :                :     TRUNCATE TRUSTED TYPE_P TYPES_P
                                801                 :                : 
                                802                 :                :     UESCAPE UNBOUNDED UNCONDITIONAL UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN
                                803                 :                :     UNLISTEN UNLOGGED UNTIL UPDATE USER USING
                                804                 :                : 
                                805                 :                :     VACUUM VALID VALIDATE VALIDATOR VALUE_P VALUES VARCHAR VARIADIC VARYING
                                806                 :                :     VERBOSE VERSION_P VIEW VIEWS VIRTUAL VOLATILE
                                807                 :                : 
                                808                 :                :     WAIT WHEN WHERE WHITESPACE_P WINDOW WITH WITHIN WITHOUT WORK WRAPPER WRITE
                                809                 :                : 
                                810                 :                :     XML_P XMLATTRIBUTES XMLCONCAT XMLELEMENT XMLEXISTS XMLFOREST XMLNAMESPACES
                                811                 :                :     XMLPARSE XMLPI XMLROOT XMLSERIALIZE XMLTABLE
                                812                 :                : 
                                813                 :                :     YEAR_P YES_P
                                814                 :                : 
                                815                 :                :     ZONE
                                816                 :                : 
                                817                 :                : /*
                                818                 :                :  * The grammar thinks these are keywords, but they are not in the kwlist.h
                                819                 :                :  * list and so can never be entered directly.  The filter in parser.c
                                820                 :                :  * creates these tokens when required (based on looking one token ahead).
                                821                 :                :  *
                                822                 :                :  * NOT_LA exists so that productions such as NOT LIKE can be given the same
                                823                 :                :  * precedence as LIKE; otherwise they'd effectively have the same precedence
                                824                 :                :  * as NOT, at least with respect to their left-hand subexpression.
                                825                 :                :  * FORMAT_LA, NULLS_LA, WITH_LA, and WITHOUT_LA are needed to make the grammar
                                826                 :                :  * LALR(1).
                                827                 :                :  */
                                828                 :                : %token      FORMAT_LA NOT_LA NULLS_LA WITH_LA WITHOUT_LA
                                829                 :                : 
                                830                 :                : /*
                                831                 :                :  * The grammar likewise thinks these tokens are keywords, but they are never
                                832                 :                :  * generated by the scanner.  Rather, they can be injected by parser.c as
                                833                 :                :  * the initial token of the string (using the lookahead-token mechanism
                                834                 :                :  * implemented there).  This provides a way to tell the grammar to parse
                                835                 :                :  * something other than the usual list of SQL commands.
                                836                 :                :  */
                                837                 :                : %token      MODE_TYPE_NAME
                                838                 :                : %token      MODE_PLPGSQL_EXPR
                                839                 :                : %token      MODE_PLPGSQL_ASSIGN1
                                840                 :                : %token      MODE_PLPGSQL_ASSIGN2
                                841                 :                : %token      MODE_PLPGSQL_ASSIGN3
                                842                 :                : 
                                843                 :                : 
                                844                 :                : /* Precedence: lowest to highest */
                                845                 :                : %left       UNION EXCEPT
                                846                 :                : %left       INTERSECT
                                847                 :                : %left       OR
                                848                 :                : %left       AND
                                849                 :                : %right      NOT
                                850                 :                : %nonassoc   IS ISNULL NOTNULL   /* IS sets precedence for IS NULL, etc */
                                851                 :                : %nonassoc   '<' '>' '=' LESS_EQUALS GREATER_EQUALS NOT_EQUALS
                                852                 :                : %nonassoc   BETWEEN IN_P LIKE ILIKE SIMILAR NOT_LA
                                853                 :                : %nonassoc   ESCAPE          /* ESCAPE must be just above LIKE/ILIKE/SIMILAR */
                                854                 :                : 
                                855                 :                : /*
                                856                 :                :  * Sometimes it is necessary to assign precedence to keywords that are not
                                857                 :                :  * really part of the operator hierarchy, in order to resolve grammar
                                858                 :                :  * ambiguities.  It's best to avoid doing so whenever possible, because such
                                859                 :                :  * assignments have global effect and may hide ambiguities besides the one
                                860                 :                :  * you intended to solve.  (Attaching a precedence to a single rule with
                                861                 :                :  * %prec is far safer and should be preferred.)  If you must give precedence
                                862                 :                :  * to a new keyword, try very hard to give it the same precedence as IDENT.
                                863                 :                :  * If the keyword has IDENT's precedence then it clearly acts the same as
                                864                 :                :  * non-keywords and other similar keywords, thus reducing the risk of
                                865                 :                :  * unexpected precedence effects.
                                866                 :                :  *
                                867                 :                :  * We used to need to assign IDENT an explicit precedence just less than Op,
                                868                 :                :  * to support target_el without AS.  While that's not really necessary since
                                869                 :                :  * we removed postfix operators, we continue to do so because it provides a
                                870                 :                :  * reference point for a precedence level that we can assign to other
                                871                 :                :  * keywords that lack a natural precedence level.
                                872                 :                :  *
                                873                 :                :  * We need to do this for PARTITION, RANGE, ROWS, and GROUPS to support
                                874                 :                :  * opt_existing_window_name (see comment there).
                                875                 :                :  *
                                876                 :                :  * The frame_bound productions UNBOUNDED PRECEDING and UNBOUNDED FOLLOWING
                                877                 :                :  * are even messier: since UNBOUNDED is an unreserved keyword (per spec!),
                                878                 :                :  * there is no principled way to distinguish these from the productions
                                879                 :                :  * a_expr PRECEDING/FOLLOWING.  We hack this up by giving UNBOUNDED slightly
                                880                 :                :  * lower precedence than PRECEDING and FOLLOWING.  At present this doesn't
                                881                 :                :  * appear to cause UNBOUNDED to be treated differently from other unreserved
                                882                 :                :  * keywords anywhere else in the grammar, but it's definitely risky.  We can
                                883                 :                :  * blame any funny behavior of UNBOUNDED on the SQL standard, though.
                                884                 :                :  *
                                885                 :                :  * To support CUBE and ROLLUP in GROUP BY without reserving them, we give them
                                886                 :                :  * an explicit priority lower than '(', so that a rule with CUBE '(' will shift
                                887                 :                :  * rather than reducing a conflicting rule that takes CUBE as a function name.
                                888                 :                :  * Using the same precedence as IDENT seems right for the reasons given above.
                                889                 :                :  *
                                890                 :                :  * SET is likewise assigned the same precedence as IDENT, to support the
                                891                 :                :  * relation_expr_opt_alias production (see comment there).
                                892                 :                :  *
                                893                 :                :  * KEYS, OBJECT_P, SCALAR, VALUE_P, WITH, and WITHOUT are similarly assigned
                                894                 :                :  * the same precedence as IDENT.  This allows resolving conflicts in the
                                895                 :                :  * json_predicate_type_constraint and json_key_uniqueness_constraint_opt
                                896                 :                :  * productions (see comments there).
                                897                 :                :  *
                                898                 :                :  * Like the UNBOUNDED PRECEDING/FOLLOWING case, NESTED is assigned a lower
                                899                 :                :  * precedence than PATH to fix ambiguity in the json_table production.
                                900                 :                :  */
                                901                 :                : %nonassoc   UNBOUNDED NESTED /* ideally would have same precedence as IDENT */
                                902                 :                : %nonassoc   IDENT PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE ROLLUP
                                903                 :                :             SET KEYS OBJECT_P SCALAR VALUE_P WITH WITHOUT PATH
                                904                 :                : %left       Op OPERATOR     /* multi-character ops and user-defined operators */
                                905                 :                : %left       '+' '-'
                                906                 :                : %left       '*' '/' '%'
                                907                 :                : %left       '^'
                                908                 :                : /* Unary Operators */
                                909                 :                : %left       AT              /* sets precedence for AT TIME ZONE, AT LOCAL */
                                910                 :                : %left       COLLATE
                                911                 :                : %right      UMINUS
                                912                 :                : %left       '[' ']'
                                913                 :                : %left       '(' ')'
                                914                 :                : %left       TYPECAST
                                915                 :                : %left       '.'
                                916                 :                : /*
                                917                 :                :  * These might seem to be low-precedence, but actually they are not part
                                918                 :                :  * of the arithmetic hierarchy at all in their use as JOIN operators.
                                919                 :                :  * We make them high-precedence to support their use as function names.
                                920                 :                :  * They wouldn't be given a precedence at all, were it not that we need
                                921                 :                :  * left-associativity among the JOIN rules themselves.
                                922                 :                :  */
                                923                 :                : %left       JOIN CROSS LEFT FULL RIGHT INNER_P NATURAL
                                924                 :                : 
                                925                 :                : %%
                                926                 :                : 
                                927                 :                : /*
                                928                 :                :  *  The target production for the whole parse.
                                929                 :                :  *
                                930                 :                :  * Ordinarily we parse a list of statements, but if we see one of the
                                931                 :                :  * special MODE_XXX symbols as first token, we parse something else.
                                932                 :                :  * The options here correspond to enum RawParseMode, which see for details.
                                933                 :                :  */
                                934                 :                : parse_toplevel:
                                935                 :                :             stmtmulti
                                936                 :                :             {
 6324 tgl@sss.pgh.pa.us         937                 :CBC      461944 :                 pg_yyget_extra(yyscanner)->parsetree = $1;
                                938                 :                :                 (void) yynerrs;     /* suppress compiler warning */
                                939                 :                :             }
                                940                 :                :             | MODE_TYPE_NAME Typename
                                941                 :                :             {
 2131                           942                 :           6382 :                 pg_yyget_extra(yyscanner)->parsetree = list_make1($2);
                                943                 :                :             }
                                944                 :                :             | MODE_PLPGSQL_EXPR PLpgSQL_Expr
                                945                 :                :             {
                                946                 :          20675 :                 pg_yyget_extra(yyscanner)->parsetree =
  744                           947                 :          20675 :                     list_make1(makeRawStmt($2, @2));
                                948                 :                :             }
                                949                 :                :             | MODE_PLPGSQL_ASSIGN1 PLAssignStmt
                                950                 :                :             {
 2131                           951                 :           3819 :                 PLAssignStmt *n = (PLAssignStmt *) $2;
                                952                 :                : 
                                953                 :           3819 :                 n->nnames = 1;
                                954                 :           3819 :                 pg_yyget_extra(yyscanner)->parsetree =
  744                           955                 :           3819 :                     list_make1(makeRawStmt((Node *) n, @2));
                                956                 :                :             }
                                957                 :                :             | MODE_PLPGSQL_ASSIGN2 PLAssignStmt
                                958                 :                :             {
 2131                           959                 :            425 :                 PLAssignStmt *n = (PLAssignStmt *) $2;
                                960                 :                : 
                                961                 :            425 :                 n->nnames = 2;
                                962                 :            425 :                 pg_yyget_extra(yyscanner)->parsetree =
  744                           963                 :            425 :                     list_make1(makeRawStmt((Node *) n, @2));
                                964                 :                :             }
                                965                 :                :             | MODE_PLPGSQL_ASSIGN3 PLAssignStmt
                                966                 :                :             {
 2131                           967                 :             14 :                 PLAssignStmt *n = (PLAssignStmt *) $2;
                                968                 :                : 
                                969                 :             14 :                 n->nnames = 3;
                                970                 :             14 :                 pg_yyget_extra(yyscanner)->parsetree =
  744                           971                 :             14 :                     list_make1(makeRawStmt((Node *) n, @2));
                                972                 :                :             }
                                973                 :                :         ;
                                974                 :                : 
                                975                 :                : /*
                                976                 :                :  * At top level, we wrap each stmt with a RawStmt node carrying start location
                                977                 :                :  * and length of the stmt's text.
                                978                 :                :  * We also take care to discard empty statements entirely (which among other
                                979                 :                :  * things dodges the problem of assigning them a location).
                                980                 :                :  */
                                981                 :                : stmtmulti:  stmtmulti ';' toplevel_stmt
                                982                 :                :                 {
 3582                           983         [ +  + ]:         390255 :                     if ($1 != NIL)
                                984                 :                :                     {
                                985                 :                :                         /* update length of previous stmt */
 3496                           986                 :         389601 :                         updateRawStmtEnd(llast_node(RawStmt, $1), @2);
                                987                 :                :                     }
 6324                           988         [ +  + ]:         390255 :                     if ($3 != NULL)
  744                           989                 :          32054 :                         $$ = lappend($1, makeRawStmt($3, @3));
                                990                 :                :                     else
 6324                           991                 :         358201 :                         $$ = $1;
                                992                 :                :                 }
                                993                 :                :             | toplevel_stmt
                                994                 :                :                 {
                                995         [ +  + ]:         461949 :                     if ($1 != NULL)
  744                           996                 :         460845 :                         $$ = list_make1(makeRawStmt($1, @1));
                                997                 :                :                     else
 8907 bruce@momjian.us          998                 :           1104 :                         $$ = NIL;
                                999                 :                :                 }
                               1000                 :                :         ;
                               1001                 :                : 
                               1002                 :                : /*
                               1003                 :                :  * toplevel_stmt includes BEGIN and END.  stmt does not include them, because
                               1004                 :                :  * those words have different meanings in function bodies.
                               1005                 :                :  */
                               1006                 :                : toplevel_stmt:
                               1007                 :                :             stmt
                               1008                 :                :             | TransactionStmtLegacy
                               1009                 :                :         ;
                               1010                 :                : 
                               1011                 :                : stmt:
                               1012                 :                :             AlterEventTrigStmt
                               1013                 :                :             | AlterCollationStmt
                               1014                 :                :             | AlterDatabaseStmt
                               1015                 :                :             | AlterDatabaseSetStmt
                               1016                 :                :             | AlterDefaultPrivilegesStmt
                               1017                 :                :             | AlterDomainStmt
                               1018                 :                :             | AlterEnumStmt
                               1019                 :                :             | AlterExtensionStmt
                               1020                 :                :             | AlterExtensionContentsStmt
                               1021                 :                :             | AlterFdwStmt
                               1022                 :                :             | AlterForeignServerStmt
                               1023                 :                :             | AlterFunctionStmt
                               1024                 :                :             | AlterGroupStmt
                               1025                 :                :             | AlterObjectDependsStmt
                               1026                 :                :             | AlterObjectSchemaStmt
                               1027                 :                :             | AlterOwnerStmt
                               1028                 :                :             | AlterOperatorStmt
                               1029                 :                :             | AlterTypeStmt
                               1030                 :                :             | AlterPolicyStmt
                               1031                 :                :             | AlterSeqStmt
                               1032                 :                :             | AlterSystemStmt
                               1033                 :                :             | AlterTableStmt
                               1034                 :                :             | AlterTblSpcStmt
                               1035                 :                :             | AlterCompositeTypeStmt
                               1036                 :                :             | AlterPublicationStmt
                               1037                 :                :             | AlterRoleSetStmt
                               1038                 :                :             | AlterRoleStmt
                               1039                 :                :             | AlterSubscriptionStmt
                               1040                 :                :             | AlterStatsStmt
                               1041                 :                :             | AlterTSConfigurationStmt
                               1042                 :                :             | AlterTSDictionaryStmt
                               1043                 :                :             | AlterUserMappingStmt
                               1044                 :                :             | AnalyzeStmt
                               1045                 :                :             | CallStmt
                               1046                 :                :             | CheckPointStmt
                               1047                 :                :             | ClosePortalStmt
                               1048                 :                :             | CommentStmt
                               1049                 :                :             | ConstraintsSetStmt
                               1050                 :                :             | CopyStmt
                               1051                 :                :             | CreateAmStmt
                               1052                 :                :             | CreateAsStmt
                               1053                 :                :             | CreateAssertionStmt
                               1054                 :                :             | CreateCastStmt
                               1055                 :                :             | CreateConversionStmt
                               1056                 :                :             | CreateDomainStmt
                               1057                 :                :             | CreateExtensionStmt
                               1058                 :                :             | CreateFdwStmt
                               1059                 :                :             | CreateForeignServerStmt
                               1060                 :                :             | CreateForeignTableStmt
                               1061                 :                :             | CreateFunctionStmt
                               1062                 :                :             | CreateGroupStmt
                               1063                 :                :             | CreateMatViewStmt
                               1064                 :                :             | CreateOpClassStmt
                               1065                 :                :             | CreateOpFamilyStmt
                               1066                 :                :             | CreatePublicationStmt
                               1067                 :                :             | AlterOpFamilyStmt
                               1068                 :                :             | CreatePolicyStmt
                               1069                 :                :             | CreatePLangStmt
                               1070                 :                :             | CreateSchemaStmt
                               1071                 :                :             | CreateSeqStmt
                               1072                 :                :             | CreateStmt
                               1073                 :                :             | CreateSubscriptionStmt
                               1074                 :                :             | CreateStatsStmt
                               1075                 :                :             | CreateTableSpaceStmt
                               1076                 :                :             | CreateTransformStmt
                               1077                 :                :             | CreateTrigStmt
                               1078                 :                :             | CreateEventTrigStmt
                               1079                 :                :             | CreateRoleStmt
                               1080                 :                :             | CreateUserStmt
                               1081                 :                :             | CreateUserMappingStmt
                               1082                 :                :             | CreatedbStmt
                               1083                 :                :             | DeallocateStmt
                               1084                 :                :             | DeclareCursorStmt
                               1085                 :                :             | DefineStmt
                               1086                 :                :             | DeleteStmt
                               1087                 :                :             | DiscardStmt
                               1088                 :                :             | DoStmt
                               1089                 :                :             | DropCastStmt
                               1090                 :                :             | DropOpClassStmt
                               1091                 :                :             | DropOpFamilyStmt
                               1092                 :                :             | DropOwnedStmt
                               1093                 :                :             | DropStmt
                               1094                 :                :             | DropSubscriptionStmt
                               1095                 :                :             | DropTableSpaceStmt
                               1096                 :                :             | DropTransformStmt
                               1097                 :                :             | DropRoleStmt
                               1098                 :                :             | DropUserMappingStmt
                               1099                 :                :             | DropdbStmt
                               1100                 :                :             | ExecuteStmt
                               1101                 :                :             | ExplainStmt
                               1102                 :                :             | FetchStmt
                               1103                 :                :             | GrantStmt
                               1104                 :                :             | GrantRoleStmt
                               1105                 :                :             | ImportForeignSchemaStmt
                               1106                 :                :             | IndexStmt
                               1107                 :                :             | InsertStmt
                               1108                 :                :             | ListenStmt
                               1109                 :                :             | RefreshMatViewStmt
                               1110                 :                :             | LoadStmt
                               1111                 :                :             | LockStmt
                               1112                 :                :             | MergeStmt
                               1113                 :                :             | NotifyStmt
                               1114                 :                :             | PrepareStmt
                               1115                 :                :             | ReassignOwnedStmt
                               1116                 :                :             | ReindexStmt
                               1117                 :                :             | RemoveAggrStmt
                               1118                 :                :             | RemoveFuncStmt
                               1119                 :                :             | RemoveOperStmt
                               1120                 :                :             | RenameStmt
                               1121                 :                :             | RepackStmt
                               1122                 :                :             | RevokeStmt
                               1123                 :                :             | RevokeRoleStmt
                               1124                 :                :             | RuleStmt
                               1125                 :                :             | SecLabelStmt
                               1126                 :                :             | SelectStmt
                               1127                 :                :             | TransactionStmt
                               1128                 :                :             | TruncateStmt
                               1129                 :                :             | UnlistenStmt
                               1130                 :                :             | UpdateStmt
                               1131                 :                :             | VacuumStmt
                               1132                 :                :             | VariableResetStmt
                               1133                 :                :             | VariableSetStmt
                               1134                 :                :             | VariableShowStmt
                               1135                 :                :             | ViewStmt
                               1136                 :                :             | WaitStmt
                               1137                 :                :             | /*EMPTY*/
 8338 neilc@samurai.com        1138                 :         359321 :                 { $$ = NULL; }
                               1139                 :                :         ;
                               1140                 :                : 
                               1141                 :                : /*
                               1142                 :                :  * Generic supporting productions for DDL
                               1143                 :                :  */
                               1144                 :                : opt_single_name:
 1567 alvherre@alvh.no-ip.     1145                 :           3529 :             ColId                           { $$ = $1; }
                               1146                 :           1265 :             | /* EMPTY */                   { $$ = NULL; }
                               1147                 :                :         ;
                               1148                 :                : 
                               1149                 :                : opt_qualified_name:
                               1150                 :           1451 :             any_name                        { $$ = $1; }
                               1151                 :          10838 :             | /*EMPTY*/                     { $$ = NIL; }
                               1152                 :                :         ;
                               1153                 :                : 
                               1154                 :                : opt_concurrently:
                               1155                 :            679 :             CONCURRENTLY                    { $$ = true; }
                               1156                 :           5248 :             | /*EMPTY*/                     { $$ = false; }
                               1157                 :                :         ;
                               1158                 :                : 
                               1159                 :                : opt_usingindex:
  240 alvherre@kurilemu.de     1160                 :              4 :             USING INDEX                     { $$ = true; }
                               1161                 :             84 :             | /* EMPTY */                   { $$ = false; }
                               1162                 :                :         ;
                               1163                 :                : 
                               1164                 :                : opt_drop_behavior:
 1567 alvherre@alvh.no-ip.     1165                 :           1344 :             CASCADE                         { $$ = DROP_CASCADE; }
                               1166                 :            111 :             | RESTRICT                      { $$ = DROP_RESTRICT; }
                               1167                 :          22114 :             | /* EMPTY */                   { $$ = DROP_RESTRICT; /* default */ }
                               1168                 :                :         ;
                               1169                 :                : 
                               1170                 :                : opt_utility_option_list:
  468 alvherre@kurilemu.de     1171                 :            262 :             '(' utility_option_list ')'     { $$ = $2; }
                               1172                 :           3933 :             | /* EMPTY */                   { $$ = NULL; }
                               1173                 :                :         ;
                               1174                 :                : 
                               1175                 :                : utility_option_list:
                               1176                 :                :             utility_option_elem
                               1177                 :                :                 {
                               1178                 :          16102 :                     $$ = list_make1($1);
                               1179                 :                :                 }
                               1180                 :                :             | utility_option_list ',' utility_option_elem
                               1181                 :                :                 {
                               1182                 :           8950 :                     $$ = lappend($1, $3);
                               1183                 :                :                 }
                               1184                 :                :         ;
                               1185                 :                : 
                               1186                 :                : utility_option_elem:
                               1187                 :                :             utility_option_name utility_option_arg
                               1188                 :                :                 {
                               1189                 :          25052 :                     $$ = makeDefElem($1, $2, @1);
                               1190                 :                :                 }
                               1191                 :                :         ;
                               1192                 :                : 
                               1193                 :                : utility_option_name:
                               1194                 :          22629 :             NonReservedWord                 { $$ = $1; }
                               1195                 :           2333 :             | analyze_keyword               { $$ = "analyze"; }
                               1196                 :             94 :             | FORMAT_LA                     { $$ = "format"; }
                               1197                 :                :         ;
                               1198                 :                : 
                               1199                 :                : utility_option_arg:
                               1200                 :          13929 :             opt_boolean_or_string           { $$ = (Node *) makeString($1); }
                               1201                 :            211 :             | NumericOnly                   { $$ = (Node *) $1; }
                               1202                 :          10912 :             | /* EMPTY */                   { $$ = NULL; }
                               1203                 :                :         ;
                               1204                 :                : 
                               1205                 :                : /*****************************************************************************
                               1206                 :                :  *
                               1207                 :                :  * CALL statement
                               1208                 :                :  *
                               1209                 :                :  *****************************************************************************/
                               1210                 :                : 
                               1211                 :                : CallStmt:   CALL func_application
                               1212                 :                :                 {
 1637 peter@eisentraut.org     1213                 :            364 :                     CallStmt   *n = makeNode(CallStmt);
                               1214                 :                : 
 3262 peter_e@gmx.net          1215                 :            364 :                     n->funccall = castNode(FuncCall, $2);
 1637 peter@eisentraut.org     1216                 :            364 :                     $$ = (Node *) n;
                               1217                 :                :                 }
                               1218                 :                :         ;
                               1219                 :                : 
                               1220                 :                : /*****************************************************************************
                               1221                 :                :  *
                               1222                 :                :  * Create a new Postgres DBMS role
                               1223                 :                :  *
                               1224                 :                :  *****************************************************************************/
                               1225                 :                : 
                               1226                 :                : CreateRoleStmt:
                               1227                 :                :             CREATE ROLE RoleId opt_with OptRoleList
                               1228                 :                :                 {
 7800 tgl@sss.pgh.pa.us        1229                 :            981 :                     CreateRoleStmt *n = makeNode(CreateRoleStmt);
                               1230                 :                : 
 7772                          1231                 :            981 :                     n->stmt_type = ROLESTMT_ROLE;
 7800                          1232                 :            981 :                     n->role = $3;
 9249                          1233                 :            981 :                     n->options = $5;
 1637 peter@eisentraut.org     1234                 :            981 :                     $$ = (Node *) n;
                               1235                 :                :                 }
                               1236                 :                :         ;
                               1237                 :                : 
                               1238                 :                : 
                               1239                 :                : opt_with:   WITH
                               1240                 :                :             | WITH_LA
                               1241                 :                :             | /*EMPTY*/
                               1242                 :                :         ;
                               1243                 :                : 
                               1244                 :                : /*
                               1245                 :                :  * Options for CREATE ROLE and ALTER ROLE (also used by CREATE/ALTER USER
                               1246                 :                :  * for backwards compatibility).  Note: the only option required by SQL99
                               1247                 :                :  * is "WITH ADMIN name".
                               1248                 :                :  */
                               1249                 :                : OptRoleList:
 6238 alvherre@alvh.no-ip.     1250                 :            744 :             OptRoleList CreateOptRoleElem           { $$ = lappend($1, $2); }
 7800 tgl@sss.pgh.pa.us        1251                 :           1289 :             | /* EMPTY */                           { $$ = NIL; }
                               1252                 :                :         ;
                               1253                 :                : 
                               1254                 :                : AlterOptRoleList:
 6238 alvherre@alvh.no-ip.     1255                 :            443 :             AlterOptRoleList AlterOptRoleElem       { $$ = lappend($1, $2); }
                               1256                 :            259 :             | /* EMPTY */                           { $$ = NIL; }
                               1257                 :                :         ;
                               1258                 :                : 
                               1259                 :                : AlterOptRoleElem:
                               1260                 :                :             PASSWORD Sconst
                               1261                 :                :                 {
 7800 tgl@sss.pgh.pa.us        1262                 :            119 :                     $$ = makeDefElem("password",
 1637 peter@eisentraut.org     1263                 :            119 :                                      (Node *) makeString($2), @1);
                               1264                 :                :                 }
                               1265                 :                :             | PASSWORD NULL_P
                               1266                 :                :                 {
 3712 peter_e@gmx.net          1267                 :              8 :                     $$ = makeDefElem("password", NULL, @1);
                               1268                 :                :                 }
                               1269                 :                :             | ENCRYPTED PASSWORD Sconst
                               1270                 :                :                 {
                               1271                 :                :                     /*
                               1272                 :                :                      * These days, passwords are always stored in encrypted
                               1273                 :                :                      * form, so there is no difference between PASSWORD and
                               1274                 :                :                      * ENCRYPTED PASSWORD.
                               1275                 :                :                      */
 3468 heikki.linnakangas@i     1276                 :              6 :                     $$ = makeDefElem("password",
 1637 peter@eisentraut.org     1277                 :              6 :                                      (Node *) makeString($3), @1);
                               1278                 :                :                 }
                               1279                 :                :             | UNENCRYPTED PASSWORD Sconst
                               1280                 :                :                 {
 3468 heikki.linnakangas@i     1281         [ #  # ]:UBC           0 :                     ereport(ERROR,
                               1282                 :                :                             (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               1283                 :                :                              errmsg("UNENCRYPTED PASSWORD is no longer supported"),
                               1284                 :                :                              errhint("Remove UNENCRYPTED to store the password in encrypted form instead."),
                               1285                 :                :                              parser_errposition(@1)));
                               1286                 :                :                 }
                               1287                 :                :             | INHERIT
                               1288                 :                :                 {
 1637 peter@eisentraut.org     1289                 :CBC          61 :                     $$ = makeDefElem("inherit", (Node *) makeBoolean(true), @1);
                               1290                 :                :                 }
                               1291                 :                :             | CONNECTION LIMIT SignedIconst
                               1292                 :                :                 {
                               1293                 :             17 :                     $$ = makeDefElem("connectionlimit", (Node *) makeInteger($3), @1);
                               1294                 :                :                 }
                               1295                 :                :             | VALID UNTIL Sconst
                               1296                 :                :                 {
                               1297                 :              5 :                     $$ = makeDefElem("validUntil", (Node *) makeString($3), @1);
                               1298                 :                :                 }
                               1299                 :                :         /*  Supported but not documented for roles, for use by ALTER GROUP. */
                               1300                 :                :             | USER role_list
                               1301                 :                :                 {
                               1302                 :              4 :                     $$ = makeDefElem("rolemembers", (Node *) $2, @1);
                               1303                 :                :                 }
                               1304                 :                :             | IDENT
                               1305                 :                :                 {
                               1306                 :                :                     /*
                               1307                 :                :                      * We handle identifiers that aren't parser keywords with
                               1308                 :                :                      * the following special-case codes, to avoid bloating the
                               1309                 :                :                      * size of the main parser.
                               1310                 :                :                      */
 5714 rhaas@postgresql.org     1311         [ +  + ]:            857 :                     if (strcmp($1, "superuser") == 0)
 1637 peter@eisentraut.org     1312                 :            114 :                         $$ = makeDefElem("superuser", (Node *) makeBoolean(true), @1);
 5714 rhaas@postgresql.org     1313         [ +  + ]:            743 :                     else if (strcmp($1, "nosuperuser") == 0)
 1637 peter@eisentraut.org     1314                 :             65 :                         $$ = makeDefElem("superuser", (Node *) makeBoolean(false), @1);
 5714 rhaas@postgresql.org     1315         [ +  + ]:            678 :                     else if (strcmp($1, "createrole") == 0)
 1637 peter@eisentraut.org     1316                 :             63 :                         $$ = makeDefElem("createrole", (Node *) makeBoolean(true), @1);
 5714 rhaas@postgresql.org     1317         [ +  + ]:            615 :                     else if (strcmp($1, "nocreaterole") == 0)
 1637 peter@eisentraut.org     1318                 :             29 :                         $$ = makeDefElem("createrole", (Node *) makeBoolean(false), @1);
 5714 rhaas@postgresql.org     1319         [ +  + ]:            586 :                     else if (strcmp($1, "replication") == 0)
 1637 peter@eisentraut.org     1320                 :             78 :                         $$ = makeDefElem("isreplication", (Node *) makeBoolean(true), @1);
 5714 rhaas@postgresql.org     1321         [ +  + ]:            508 :                     else if (strcmp($1, "noreplication") == 0)
 1637 peter@eisentraut.org     1322                 :             58 :                         $$ = makeDefElem("isreplication", (Node *) makeBoolean(false), @1);
 5714 rhaas@postgresql.org     1323         [ +  + ]:            450 :                     else if (strcmp($1, "createdb") == 0)
 1637 peter@eisentraut.org     1324                 :             56 :                         $$ = makeDefElem("createdb", (Node *) makeBoolean(true), @1);
 5714 rhaas@postgresql.org     1325         [ +  + ]:            394 :                     else if (strcmp($1, "nocreatedb") == 0)
 1637 peter@eisentraut.org     1326                 :             34 :                         $$ = makeDefElem("createdb", (Node *) makeBoolean(false), @1);
 5714 rhaas@postgresql.org     1327         [ +  + ]:            360 :                     else if (strcmp($1, "login") == 0)
 1637 peter@eisentraut.org     1328                 :            167 :                         $$ = makeDefElem("canlogin", (Node *) makeBoolean(true), @1);
 5714 rhaas@postgresql.org     1329         [ +  + ]:            193 :                     else if (strcmp($1, "nologin") == 0)
 1637 peter@eisentraut.org     1330                 :             72 :                         $$ = makeDefElem("canlogin", (Node *) makeBoolean(false), @1);
 4430 sfrost@snowman.net       1331         [ +  + ]:            121 :                     else if (strcmp($1, "bypassrls") == 0)
 1637 peter@eisentraut.org     1332                 :             53 :                         $$ = makeDefElem("bypassrls", (Node *) makeBoolean(true), @1);
 4430 sfrost@snowman.net       1333         [ +  + ]:             68 :                     else if (strcmp($1, "nobypassrls") == 0)
 1637 peter@eisentraut.org     1334                 :             44 :                         $$ = makeDefElem("bypassrls", (Node *) makeBoolean(false), @1);
 5714 rhaas@postgresql.org     1335         [ +  - ]:             24 :                     else if (strcmp($1, "noinherit") == 0)
                               1336                 :                :                     {
                               1337                 :                :                         /*
                               1338                 :                :                          * Note that INHERIT is a keyword, so it's handled by main parser, but
                               1339                 :                :                          * NOINHERIT is handled here.
                               1340                 :                :                          */
 1637 peter@eisentraut.org     1341                 :             24 :                         $$ = makeDefElem("inherit", (Node *) makeBoolean(false), @1);
                               1342                 :                :                     }
                               1343                 :                :                     else
 5714 rhaas@postgresql.org     1344         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               1345                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               1346                 :                :                                  errmsg("unrecognized role option \"%s\"", $1),
                               1347                 :                :                                      parser_errposition(@1)));
                               1348                 :                :                 }
                               1349                 :                :         ;
                               1350                 :                : 
                               1351                 :                : CreateOptRoleElem:
 6238 alvherre@alvh.no-ip.     1352                 :CBC         634 :             AlterOptRoleElem            { $$ = $1; }
                               1353                 :                :             /* The following are not supported by ALTER ROLE/USER/GROUP */
                               1354                 :                :             | SYSID Iconst
                               1355                 :                :                 {
 1637 peter@eisentraut.org     1356                 :              4 :                     $$ = makeDefElem("sysid", (Node *) makeInteger($2), @1);
                               1357                 :                :                 }
                               1358                 :                :             | ADMIN role_list
                               1359                 :                :                 {
                               1360                 :             14 :                     $$ = makeDefElem("adminmembers", (Node *) $2, @1);
                               1361                 :                :                 }
                               1362                 :                :             | ROLE role_list
                               1363                 :                :                 {
                               1364                 :             26 :                     $$ = makeDefElem("rolemembers", (Node *) $2, @1);
                               1365                 :                :                 }
                               1366                 :                :             | IN_P ROLE role_list
                               1367                 :                :                 {
                               1368                 :             66 :                     $$ = makeDefElem("addroleto", (Node *) $3, @1);
                               1369                 :                :                 }
                               1370                 :                :             | IN_P GROUP_P role_list
                               1371                 :                :                 {
 1637 peter@eisentraut.org     1372                 :UBC           0 :                     $$ = makeDefElem("addroleto", (Node *) $3, @1);
                               1373                 :                :                 }
                               1374                 :                :         ;
                               1375                 :                : 
                               1376                 :                : 
                               1377                 :                : /*****************************************************************************
                               1378                 :                :  *
                               1379                 :                :  * Create a new Postgres DBMS user (role with implied login ability)
                               1380                 :                :  *
                               1381                 :                :  *****************************************************************************/
                               1382                 :                : 
                               1383                 :                : CreateUserStmt:
                               1384                 :                :             CREATE USER RoleId opt_with OptRoleList
                               1385                 :                :                 {
 7800 tgl@sss.pgh.pa.us        1386                 :CBC         292 :                     CreateRoleStmt *n = makeNode(CreateRoleStmt);
                               1387                 :                : 
 7772                          1388                 :            292 :                     n->stmt_type = ROLESTMT_USER;
 7800                          1389                 :            292 :                     n->role = $3;
 7772                          1390                 :            292 :                     n->options = $5;
 1637 peter@eisentraut.org     1391                 :            292 :                     $$ = (Node *) n;
                               1392                 :                :                 }
                               1393                 :                :         ;
                               1394                 :                : 
                               1395                 :                : 
                               1396                 :                : /*****************************************************************************
                               1397                 :                :  *
                               1398                 :                :  * Alter a postgresql DBMS role
                               1399                 :                :  *
                               1400                 :                :  *****************************************************************************/
                               1401                 :                : 
                               1402                 :                : AlterRoleStmt:
                               1403                 :                :             ALTER ROLE RoleSpec opt_with AlterOptRoleList
                               1404                 :                :                  {
 7800 tgl@sss.pgh.pa.us        1405                 :            213 :                     AlterRoleStmt *n = makeNode(AlterRoleStmt);
                               1406                 :                : 
                               1407                 :            213 :                     n->role = $3;
 7772                          1408                 :            213 :                     n->action = +1;  /* add, if there are members */
 7800                          1409                 :            213 :                     n->options = $5;
 1637 peter@eisentraut.org     1410                 :            213 :                     $$ = (Node *) n;
                               1411                 :                :                  }
                               1412                 :                :             | ALTER USER RoleSpec opt_with AlterOptRoleList
                               1413                 :                :                  {
 3384 peter_e@gmx.net          1414                 :             46 :                     AlterRoleStmt *n = makeNode(AlterRoleStmt);
                               1415                 :                : 
                               1416                 :             46 :                     n->role = $3;
                               1417                 :             46 :                     n->action = +1;  /* add, if there are members */
                               1418                 :             46 :                     n->options = $5;
 1637 peter@eisentraut.org     1419                 :             46 :                     $$ = (Node *) n;
                               1420                 :                :                  }
                               1421                 :                :         ;
                               1422                 :                : 
                               1423                 :                : opt_in_database:
 6238 alvherre@alvh.no-ip.     1424                 :             50 :                /* EMPTY */                  { $$ = NULL; }
 2339 peter@eisentraut.org     1425                 :              4 :             | IN_P DATABASE name    { $$ = $3; }
                               1426                 :                :         ;
                               1427                 :                : 
                               1428                 :                : AlterRoleSetStmt:
                               1429                 :                :             ALTER ROLE RoleSpec opt_in_database SetResetClause
                               1430                 :                :                 {
 7800 tgl@sss.pgh.pa.us        1431                 :             34 :                     AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt);
                               1432                 :                : 
                               1433                 :             34 :                     n->role = $3;
 6238 alvherre@alvh.no-ip.     1434                 :             34 :                     n->database = $4;
                               1435                 :             34 :                     n->setstmt = $5;
 1637 peter@eisentraut.org     1436                 :             34 :                     $$ = (Node *) n;
                               1437                 :                :                 }
                               1438                 :                :             | ALTER ROLE ALL opt_in_database SetResetClause
                               1439                 :                :                 {
 5009 peter_e@gmx.net          1440                 :              2 :                     AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt);
                               1441                 :                : 
                               1442                 :              2 :                     n->role = NULL;
                               1443                 :              2 :                     n->database = $4;
                               1444                 :              2 :                     n->setstmt = $5;
 1637 peter@eisentraut.org     1445                 :              2 :                     $$ = (Node *) n;
                               1446                 :                :                 }
                               1447                 :                :             | ALTER USER RoleSpec opt_in_database SetResetClause
                               1448                 :                :                 {
 3384 peter_e@gmx.net          1449                 :             14 :                     AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt);
                               1450                 :                : 
 7800 tgl@sss.pgh.pa.us        1451                 :             14 :                     n->role = $3;
 3384 peter_e@gmx.net          1452                 :             14 :                     n->database = $4;
                               1453                 :             14 :                     n->setstmt = $5;
 1637 peter@eisentraut.org     1454                 :             14 :                     $$ = (Node *) n;
                               1455                 :                :                 }
                               1456                 :                :             | ALTER USER ALL opt_in_database SetResetClause
                               1457                 :                :                 {
 7800 tgl@sss.pgh.pa.us        1458                 :              2 :                     AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt);
                               1459                 :                : 
 3384 peter_e@gmx.net          1460                 :              2 :                     n->role = NULL;
                               1461                 :              2 :                     n->database = $4;
                               1462                 :              2 :                     n->setstmt = $5;
 1637 peter@eisentraut.org     1463                 :              2 :                     $$ = (Node *) n;
                               1464                 :                :                 }
                               1465                 :                :         ;
                               1466                 :                : 
                               1467                 :                : 
                               1468                 :                : /*****************************************************************************
                               1469                 :                :  *
                               1470                 :                :  * Drop a postgresql DBMS role
                               1471                 :                :  *
                               1472                 :                :  * XXX Ideally this would have CASCADE/RESTRICT options, but a role
                               1473                 :                :  * might own objects in multiple databases, and there is presently no way to
                               1474                 :                :  * implement cascading to other databases.  So we always behave as RESTRICT.
                               1475                 :                :  *****************************************************************************/
                               1476                 :                : 
                               1477                 :                : DropRoleStmt:
                               1478                 :                :             DROP ROLE role_list
                               1479                 :                :                 {
 7800 tgl@sss.pgh.pa.us        1480                 :            784 :                     DropRoleStmt *n = makeNode(DropRoleStmt);
                               1481                 :                : 
 3368 peter_e@gmx.net          1482                 :            784 :                     n->missing_ok = false;
 7800 tgl@sss.pgh.pa.us        1483                 :            784 :                     n->roles = $3;
 1637 peter@eisentraut.org     1484                 :            784 :                     $$ = (Node *) n;
                               1485                 :                :                 }
                               1486                 :                :             | DROP ROLE IF_P EXISTS role_list
                               1487                 :                :                 {
 7579 andrew@dunslane.net      1488                 :            100 :                     DropRoleStmt *n = makeNode(DropRoleStmt);
                               1489                 :                : 
 3368 peter_e@gmx.net          1490                 :            100 :                     n->missing_ok = true;
 7579 andrew@dunslane.net      1491                 :            100 :                     n->roles = $5;
 1637 peter@eisentraut.org     1492                 :            100 :                     $$ = (Node *) n;
                               1493                 :                :                 }
                               1494                 :                :             | DROP USER role_list
                               1495                 :                :                 {
 7800 tgl@sss.pgh.pa.us        1496                 :            276 :                     DropRoleStmt *n = makeNode(DropRoleStmt);
                               1497                 :                : 
 3368 peter_e@gmx.net          1498                 :            276 :                     n->missing_ok = false;
 7800 tgl@sss.pgh.pa.us        1499                 :            276 :                     n->roles = $3;
 1637 peter@eisentraut.org     1500                 :            276 :                     $$ = (Node *) n;
                               1501                 :                :                 }
                               1502                 :                :             | DROP USER IF_P EXISTS role_list
                               1503                 :                :                 {
 7579 andrew@dunslane.net      1504                 :             24 :                     DropRoleStmt *n = makeNode(DropRoleStmt);
                               1505                 :                : 
                               1506                 :             24 :                     n->roles = $5;
 3368 peter_e@gmx.net          1507                 :             24 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     1508                 :             24 :                     $$ = (Node *) n;
                               1509                 :                :                 }
                               1510                 :                :             | DROP GROUP_P role_list
                               1511                 :                :                 {
 3384 peter_e@gmx.net          1512                 :             24 :                     DropRoleStmt *n = makeNode(DropRoleStmt);
                               1513                 :                : 
 3368                          1514                 :             24 :                     n->missing_ok = false;
 3384                          1515                 :             24 :                     n->roles = $3;
 1637 peter@eisentraut.org     1516                 :             24 :                     $$ = (Node *) n;
                               1517                 :                :                 }
                               1518                 :                :             | DROP GROUP_P IF_P EXISTS role_list
                               1519                 :                :                 {
 3384 peter_e@gmx.net          1520                 :              4 :                     DropRoleStmt *n = makeNode(DropRoleStmt);
                               1521                 :                : 
 3368                          1522                 :              4 :                     n->missing_ok = true;
 3384                          1523                 :              4 :                     n->roles = $5;
 1637 peter@eisentraut.org     1524                 :              4 :                     $$ = (Node *) n;
                               1525                 :                :                 }
                               1526                 :                :             ;
                               1527                 :                : 
                               1528                 :                : 
                               1529                 :                : /*****************************************************************************
                               1530                 :                :  *
                               1531                 :                :  * Create a postgresql group (role without login ability)
                               1532                 :                :  *
                               1533                 :                :  *****************************************************************************/
                               1534                 :                : 
                               1535                 :                : CreateGroupStmt:
                               1536                 :                :             CREATE GROUP_P RoleId opt_with OptRoleList
                               1537                 :                :                 {
 7800 tgl@sss.pgh.pa.us        1538                 :             16 :                     CreateRoleStmt *n = makeNode(CreateRoleStmt);
                               1539                 :                : 
 7772                          1540                 :             16 :                     n->stmt_type = ROLESTMT_GROUP;
 7800                          1541                 :             16 :                     n->role = $3;
 9247                          1542                 :             16 :                     n->options = $5;
 1637 peter@eisentraut.org     1543                 :             16 :                     $$ = (Node *) n;
                               1544                 :                :                 }
                               1545                 :                :         ;
                               1546                 :                : 
                               1547                 :                : 
                               1548                 :                : /*****************************************************************************
                               1549                 :                :  *
                               1550                 :                :  * Alter a postgresql group
                               1551                 :                :  *
                               1552                 :                :  *****************************************************************************/
                               1553                 :                : 
                               1554                 :                : AlterGroupStmt:
                               1555                 :                :             ALTER GROUP_P RoleSpec add_drop USER role_list
                               1556                 :                :                 {
 7800 tgl@sss.pgh.pa.us        1557                 :             32 :                     AlterRoleStmt *n = makeNode(AlterRoleStmt);
                               1558                 :                : 
                               1559                 :             32 :                     n->role = $3;
 8907 bruce@momjian.us         1560                 :             32 :                     n->action = $4;
 7800 tgl@sss.pgh.pa.us        1561                 :             32 :                     n->options = list_make1(makeDefElem("rolemembers",
                               1562                 :                :                                                         (Node *) $6, @6));
 1637 peter@eisentraut.org     1563                 :             32 :                     $$ = (Node *) n;
                               1564                 :                :                 }
                               1565                 :                :         ;
                               1566                 :                : 
 7226 tgl@sss.pgh.pa.us        1567                 :             58 : add_drop:   ADD_P                                   { $$ = +1; }
 7800                          1568                 :            120 :             | DROP                                  { $$ = -1; }
                               1569                 :                :         ;
                               1570                 :                : 
                               1571                 :                : 
                               1572                 :                : /*****************************************************************************
                               1573                 :                :  *
                               1574                 :                :  * Manipulate a schema
                               1575                 :                :  *
                               1576                 :                :  *****************************************************************************/
                               1577                 :                : 
                               1578                 :                : CreateSchemaStmt:
                               1579                 :                :             CREATE SCHEMA opt_single_name AUTHORIZATION RoleSpec OptSchemaEltList
                               1580                 :                :                 {
 8995                          1581                 :            102 :                     CreateSchemaStmt *n = makeNode(CreateSchemaStmt);
                               1582                 :                : 
                               1583                 :                :                     /* One can omit the schema name or the authorization id. */
 4259 alvherre@alvh.no-ip.     1584                 :            102 :                     n->schemaname = $3;
                               1585                 :            102 :                     n->authrole = $5;
 8035 tgl@sss.pgh.pa.us        1586                 :            102 :                     n->schemaElts = $6;
 5146                          1587                 :            102 :                     n->if_not_exists = false;
 1637 peter@eisentraut.org     1588                 :            102 :                     $$ = (Node *) n;
                               1589                 :                :                 }
                               1590                 :                :             | CREATE SCHEMA ColId OptSchemaEltList
                               1591                 :                :                 {
 8995 tgl@sss.pgh.pa.us        1592                 :            616 :                     CreateSchemaStmt *n = makeNode(CreateSchemaStmt);
                               1593                 :                : 
                               1594                 :                :                     /* ...but not both */
                               1595                 :            616 :                     n->schemaname = $3;
 4259 alvherre@alvh.no-ip.     1596                 :            616 :                     n->authrole = NULL;
 8035 tgl@sss.pgh.pa.us        1597                 :            616 :                     n->schemaElts = $4;
 5146                          1598                 :            616 :                     n->if_not_exists = false;
 1637 peter@eisentraut.org     1599                 :            616 :                     $$ = (Node *) n;
                               1600                 :                :                 }
                               1601                 :                :             | CREATE SCHEMA IF_P NOT EXISTS opt_single_name AUTHORIZATION RoleSpec OptSchemaEltList
                               1602                 :                :                 {
 5146 tgl@sss.pgh.pa.us        1603                 :              9 :                     CreateSchemaStmt *n = makeNode(CreateSchemaStmt);
                               1604                 :                : 
                               1605                 :                :                     /* schema name can be omitted here, too */
 4259 alvherre@alvh.no-ip.     1606                 :              9 :                     n->schemaname = $6;
                               1607                 :              9 :                     n->authrole = $8;
 5146 tgl@sss.pgh.pa.us        1608         [ -  + ]:              9 :                     if ($9 != NIL)
 5146 tgl@sss.pgh.pa.us        1609         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               1610                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               1611                 :                :                                  errmsg("CREATE SCHEMA IF NOT EXISTS cannot include schema elements"),
                               1612                 :                :                                  parser_errposition(@9)));
 5146 tgl@sss.pgh.pa.us        1613                 :CBC           9 :                     n->schemaElts = $9;
                               1614                 :              9 :                     n->if_not_exists = true;
 1637 peter@eisentraut.org     1615                 :              9 :                     $$ = (Node *) n;
                               1616                 :                :                 }
                               1617                 :                :             | CREATE SCHEMA IF_P NOT EXISTS ColId OptSchemaEltList
                               1618                 :                :                 {
 5146 tgl@sss.pgh.pa.us        1619                 :             19 :                     CreateSchemaStmt *n = makeNode(CreateSchemaStmt);
                               1620                 :                : 
                               1621                 :                :                     /* ...but not here */
                               1622                 :             19 :                     n->schemaname = $6;
 4259 alvherre@alvh.no-ip.     1623                 :             19 :                     n->authrole = NULL;
 5146 tgl@sss.pgh.pa.us        1624         [ +  + ]:             19 :                     if ($7 != NIL)
                               1625         [ +  - ]:              4 :                         ereport(ERROR,
                               1626                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               1627                 :                :                                  errmsg("CREATE SCHEMA IF NOT EXISTS cannot include schema elements"),
                               1628                 :                :                                  parser_errposition(@7)));
                               1629                 :             15 :                     n->schemaElts = $7;
                               1630                 :             15 :                     n->if_not_exists = true;
 1637 peter@eisentraut.org     1631                 :             15 :                     $$ = (Node *) n;
                               1632                 :                :                 }
                               1633                 :                :         ;
                               1634                 :                : 
                               1635                 :                : OptSchemaEltList:
                               1636                 :                :             OptSchemaEltList schema_stmt
                               1637                 :                :                 {
 5145 tgl@sss.pgh.pa.us        1638                 :            419 :                     $$ = lappend($1, $2);
                               1639                 :                :                 }
                               1640                 :                :             | /* EMPTY */
                               1641                 :            746 :                 { $$ = NIL; }
                               1642                 :                :         ;
                               1643                 :                : 
                               1644                 :                : /*
                               1645                 :                :  *  schema_stmt are the ones that can show up inside a CREATE SCHEMA
                               1646                 :                :  *  statement (in addition to by themselves).
                               1647                 :                :  */
                               1648                 :                : schema_stmt:
                               1649                 :                :             CreateStmt
                               1650                 :                :             | IndexStmt
                               1651                 :                :             | CreateSeqStmt
                               1652                 :                :             | CreateTrigStmt
                               1653                 :                :             | GrantStmt
                               1654                 :                :             | ViewStmt
                               1655                 :                :         ;
                               1656                 :                : 
                               1657                 :                : 
                               1658                 :                : /*****************************************************************************
                               1659                 :                :  *
                               1660                 :                :  * Set PG internal variable
                               1661                 :                :  *    SET name TO 'var_value'
                               1662                 :                :  * Include SQL syntax (thomas 1997-10-22):
                               1663                 :                :  *    SET TIME ZONE 'var_value'
                               1664                 :                :  *
                               1665                 :                :  *****************************************************************************/
                               1666                 :                : 
                               1667                 :                : VariableSetStmt:
                               1668                 :                :             SET set_rest
                               1669                 :                :                 {
 8938                          1670                 :          13739 :                     VariableSetStmt *n = $2;
                               1671                 :                : 
                               1672                 :          13739 :                     n->is_local = false;
10650 bruce@momjian.us         1673                 :          13739 :                     $$ = (Node *) n;
                               1674                 :                :                 }
                               1675                 :                :             | SET LOCAL set_rest
                               1676                 :                :                 {
 8938 tgl@sss.pgh.pa.us        1677                 :           1049 :                     VariableSetStmt *n = $3;
                               1678                 :                : 
                               1679                 :           1049 :                     n->is_local = true;
10650 bruce@momjian.us         1680                 :           1049 :                     $$ = (Node *) n;
                               1681                 :                :                 }
                               1682                 :                :             | SET SESSION set_rest
                               1683                 :                :                 {
 8938 tgl@sss.pgh.pa.us        1684                 :             54 :                     VariableSetStmt *n = $3;
                               1685                 :                : 
                               1686                 :             54 :                     n->is_local = false;
10650 bruce@momjian.us         1687                 :             54 :                     $$ = (Node *) n;
                               1688                 :                :                 }
                               1689                 :                :         ;
                               1690                 :                : 
                               1691                 :                : set_rest:
                               1692                 :                :             TRANSACTION transaction_mode_list
                               1693                 :                :                 {
 5377 rhaas@postgresql.org     1694                 :            336 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1695                 :                : 
                               1696                 :            336 :                     n->kind = VAR_SET_MULTI;
                               1697                 :            336 :                     n->name = "TRANSACTION";
                               1698                 :            336 :                     n->args = $2;
  766 michael@paquier.xyz      1699                 :            336 :                     n->jumble_args = true;
                               1700                 :            336 :                     n->location = -1;
 5377 rhaas@postgresql.org     1701                 :            336 :                     $$ = n;
                               1702                 :                :                 }
                               1703                 :                :             | SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list
                               1704                 :                :                 {
                               1705                 :             12 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1706                 :                : 
                               1707                 :             12 :                     n->kind = VAR_SET_MULTI;
                               1708                 :             12 :                     n->name = "SESSION CHARACTERISTICS";
                               1709                 :             12 :                     n->args = $5;
  766 michael@paquier.xyz      1710                 :             12 :                     n->jumble_args = true;
                               1711                 :             12 :                     n->location = -1;
 5377 rhaas@postgresql.org     1712                 :             12 :                     $$ = n;
                               1713                 :                :                 }
                               1714                 :                :             | set_rest_more
                               1715                 :                :             ;
                               1716                 :                : 
                               1717                 :                : generic_set:
                               1718                 :                :             var_name TO var_list
                               1719                 :                :                 {
10184 vadim4o@yahoo.com        1720                 :           3263 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1721                 :                : 
 7003 tgl@sss.pgh.pa.us        1722                 :           3263 :                     n->kind = VAR_SET_VALUE;
 8938                          1723                 :           3263 :                     n->name = $1;
                               1724                 :           3263 :                     n->args = $3;
  766 michael@paquier.xyz      1725                 :           3263 :                     n->location = @3;
 8938 tgl@sss.pgh.pa.us        1726                 :           3263 :                     $$ = n;
                               1727                 :                :                 }
                               1728                 :                :             | var_name '=' var_list
                               1729                 :                :                 {
 9477 peter_e@gmx.net          1730                 :           9403 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1731                 :                : 
 7003 tgl@sss.pgh.pa.us        1732                 :           9403 :                     n->kind = VAR_SET_VALUE;
 8938                          1733                 :           9403 :                     n->name = $1;
                               1734                 :           9403 :                     n->args = $3;
  766 michael@paquier.xyz      1735                 :           9403 :                     n->location = @3;
 1427 akorotkov@postgresql     1736                 :           9403 :                     $$ = n;
                               1737                 :                :                 }
                               1738                 :                :             | var_name TO NULL_P
                               1739                 :                :                 {
  366 tgl@sss.pgh.pa.us        1740                 :              5 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1741                 :                : 
                               1742                 :              5 :                     n->kind = VAR_SET_VALUE;
                               1743                 :              5 :                     n->name = $1;
                               1744                 :              5 :                     n->args = list_make1(makeNullAConst(@3));
                               1745                 :              5 :                     n->location = @3;
                               1746                 :              5 :                     $$ = n;
                               1747                 :                :                 }
                               1748                 :                :             | var_name '=' NULL_P
                               1749                 :                :                 {
                               1750                 :             12 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1751                 :                : 
                               1752                 :             12 :                     n->kind = VAR_SET_VALUE;
                               1753                 :             12 :                     n->name = $1;
                               1754                 :             12 :                     n->args = list_make1(makeNullAConst(@3));
                               1755                 :             12 :                     n->location = @3;
                               1756                 :             12 :                     $$ = n;
                               1757                 :                :                 }
                               1758                 :                :             | var_name TO DEFAULT
                               1759                 :                :                 {
 7003                          1760                 :             90 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1761                 :                : 
                               1762                 :             90 :                     n->kind = VAR_SET_DEFAULT;
                               1763                 :             90 :                     n->name = $1;
  766 michael@paquier.xyz      1764                 :             90 :                     n->location = -1;
 7003 tgl@sss.pgh.pa.us        1765                 :             90 :                     $$ = n;
                               1766                 :                :                 }
                               1767                 :                :             | var_name '=' DEFAULT
                               1768                 :                :                 {
                               1769                 :              7 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1770                 :                : 
                               1771                 :              7 :                     n->kind = VAR_SET_DEFAULT;
                               1772                 :              7 :                     n->name = $1;
  766 michael@paquier.xyz      1773                 :              7 :                     n->location = -1;
 7003 tgl@sss.pgh.pa.us        1774                 :              7 :                     $$ = n;
                               1775                 :                :                 }
                               1776                 :                :         ;
                               1777                 :                : 
                               1778                 :                : set_rest_more:  /* Generic SET syntaxes: */
 2185 peter@eisentraut.org     1779                 :          12677 :             generic_set                         {$$ = $1;}
                               1780                 :                :             | var_name FROM CURRENT_P
                               1781                 :                :                 {
 7003 tgl@sss.pgh.pa.us        1782                 :              2 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1783                 :                : 
                               1784                 :              2 :                     n->kind = VAR_SET_CURRENT;
                               1785                 :              2 :                     n->name = $1;
  766 michael@paquier.xyz      1786                 :              2 :                     n->location = -1;
 7003 tgl@sss.pgh.pa.us        1787                 :              2 :                     $$ = n;
                               1788                 :                :                 }
                               1789                 :                :             /* Special syntaxes mandated by SQL standard: */
                               1790                 :                :             | TIME ZONE zone_value
                               1791                 :                :                 {
10331 scrappy@hub.org          1792                 :             66 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1793                 :                : 
 7003 tgl@sss.pgh.pa.us        1794                 :             66 :                     n->kind = VAR_SET_VALUE;
 8938                          1795                 :             66 :                     n->name = "timezone";
  766 michael@paquier.xyz      1796                 :             66 :                     n->location = -1;
                               1797                 :             66 :                     n->jumble_args = true;
 9007 lockhart@fourpalms.o     1798         [ +  + ]:             66 :                     if ($3 != NULL)
 8194 neilc@samurai.com        1799                 :             56 :                         n->args = list_make1($3);
                               1800                 :                :                     else
 7003 tgl@sss.pgh.pa.us        1801                 :             10 :                         n->kind = VAR_SET_DEFAULT;
 8938                          1802                 :             66 :                     $$ = n;
                               1803                 :                :                 }
                               1804                 :                :             | CATALOG_P Sconst
                               1805                 :                :                 {
 6583 peter_e@gmx.net          1806         [ #  # ]:UBC           0 :                     ereport(ERROR,
                               1807                 :                :                             (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               1808                 :                :                              errmsg("current database cannot be changed"),
                               1809                 :                :                              parser_errposition(@2)));
                               1810                 :                :                     $$ = NULL; /*not reached*/
                               1811                 :                :                 }
                               1812                 :                :             | SCHEMA Sconst
                               1813                 :                :                 {
 6583 peter_e@gmx.net          1814                 :CBC           2 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1815                 :                : 
                               1816                 :              2 :                     n->kind = VAR_SET_VALUE;
                               1817                 :              2 :                     n->name = "search_path";
                               1818                 :              2 :                     n->args = list_make1(makeStringConst($2, @2));
  766 michael@paquier.xyz      1819                 :              2 :                     n->location = @2;
 6583 peter_e@gmx.net          1820                 :              2 :                     $$ = n;
                               1821                 :                :                 }
                               1822                 :                :             | NAMES opt_encoding
                               1823                 :                :                 {
 8938 tgl@sss.pgh.pa.us        1824                 :UBC           0 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1825                 :                : 
 7003                          1826                 :              0 :                     n->kind = VAR_SET_VALUE;
 8938                          1827                 :              0 :                     n->name = "client_encoding";
  766 michael@paquier.xyz      1828                 :              0 :                     n->location = @2;
 8938 tgl@sss.pgh.pa.us        1829         [ #  # ]:              0 :                     if ($2 != NULL)
 6643                          1830                 :              0 :                         n->args = list_make1(makeStringConst($2, @2));
                               1831                 :                :                     else
 7003                          1832                 :              0 :                         n->kind = VAR_SET_DEFAULT;
 8938                          1833                 :              0 :                     $$ = n;
                               1834                 :                :                 }
                               1835                 :                :             | ROLE NonReservedWord_or_Sconst
                               1836                 :                :                 {
 7773 tgl@sss.pgh.pa.us        1837                 :CBC         699 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1838                 :                : 
 7003                          1839                 :            699 :                     n->kind = VAR_SET_VALUE;
 7773                          1840                 :            699 :                     n->name = "role";
 6643                          1841                 :            699 :                     n->args = list_make1(makeStringConst($2, @2));
  766 michael@paquier.xyz      1842                 :            699 :                     n->location = @2;
 7773 tgl@sss.pgh.pa.us        1843                 :            699 :                     $$ = n;
                               1844                 :                :                 }
                               1845                 :                :             | SESSION AUTHORIZATION NonReservedWord_or_Sconst
                               1846                 :                :                 {
 8938                          1847                 :           1807 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1848                 :                : 
 7003                          1849                 :           1807 :                     n->kind = VAR_SET_VALUE;
 8938                          1850                 :           1807 :                     n->name = "session_authorization";
 6643                          1851                 :           1807 :                     n->args = list_make1(makeStringConst($3, @3));
  766 michael@paquier.xyz      1852                 :           1807 :                     n->location = @3;
 8938 tgl@sss.pgh.pa.us        1853                 :           1807 :                     $$ = n;
                               1854                 :                :                 }
                               1855                 :                :             | SESSION AUTHORIZATION DEFAULT
                               1856                 :                :                 {
 8949                          1857                 :              2 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1858                 :                : 
 7003                          1859                 :              2 :                     n->kind = VAR_SET_DEFAULT;
 8949                          1860                 :              2 :                     n->name = "session_authorization";
  766 michael@paquier.xyz      1861                 :              2 :                     n->location = -1;
 8938 tgl@sss.pgh.pa.us        1862                 :              2 :                     $$ = n;
                               1863                 :                :                 }
                               1864                 :                :             | XML_P OPTION document_or_content
                               1865                 :                :                 {
 7224 peter_e@gmx.net          1866                 :             10 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1867                 :                : 
 7003 tgl@sss.pgh.pa.us        1868                 :             10 :                     n->kind = VAR_SET_VALUE;
 7224 peter_e@gmx.net          1869                 :             10 :                     n->name = "xmloption";
 6643 tgl@sss.pgh.pa.us        1870         [ +  + ]:             10 :                     n->args = list_make1(makeStringConst($3 == XMLOPTION_DOCUMENT ? "DOCUMENT" : "CONTENT", @3));
  766 michael@paquier.xyz      1871                 :             10 :                     n->jumble_args = true;
                               1872                 :             10 :                     n->location = -1;
 7224 peter_e@gmx.net          1873                 :             10 :                     $$ = n;
                               1874                 :                :                 }
                               1875                 :                :             /* Special syntaxes invented by PostgreSQL: */
                               1876                 :                :             | TRANSACTION SNAPSHOT Sconst
                               1877                 :                :                 {
 5493 tgl@sss.pgh.pa.us        1878                 :             25 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1879                 :                : 
                               1880                 :             25 :                     n->kind = VAR_SET_MULTI;
                               1881                 :             25 :                     n->name = "TRANSACTION SNAPSHOT";
                               1882                 :             25 :                     n->args = list_make1(makeStringConst($3, @3));
  766 michael@paquier.xyz      1883                 :             25 :                     n->location = @3;
 5493 tgl@sss.pgh.pa.us        1884                 :             25 :                     $$ = n;
                               1885                 :                :                 }
                               1886                 :                :         ;
                               1887                 :                : 
 7003                          1888                 :          16143 : var_name:   ColId                               { $$ = $1; }
                               1889                 :                :             | var_name '.' ColId
 4771 peter_e@gmx.net          1890                 :            504 :                 { $$ = psprintf("%s.%s", $1, $3); }
                               1891                 :                :         ;
                               1892                 :                : 
 8194 neilc@samurai.com        1893                 :          12666 : var_list:   var_value                               { $$ = list_make1($1); }
 8907 bruce@momjian.us         1894                 :            145 :             | var_list ',' var_value                { $$ = lappend($1, $3); }
                               1895                 :                :         ;
                               1896                 :                : 
                               1897                 :                : var_value:  opt_boolean_or_string
 6643 tgl@sss.pgh.pa.us        1898                 :           9632 :                 { $$ = makeStringConst($1, @1); }
                               1899                 :                :             | NumericOnly
                               1900                 :           3179 :                 { $$ = makeAConst($1, @1); }
                               1901                 :                :         ;
                               1902                 :                : 
 8400 peter_e@gmx.net          1903                 :UBC           0 : iso_level:  READ UNCOMMITTED                        { $$ = "read uncommitted"; }
 8400 peter_e@gmx.net          1904                 :CBC         567 :             | READ COMMITTED                        { $$ = "read committed"; }
                               1905                 :           1439 :             | REPEATABLE READ                       { $$ = "repeatable read"; }
 8907 bruce@momjian.us         1906                 :           1657 :             | SERIALIZABLE                          { $$ = "serializable"; }
                               1907                 :                :         ;
                               1908                 :                : 
                               1909                 :                : opt_boolean_or_string:
                               1910                 :            446 :             TRUE_P                                  { $$ = "true"; }
                               1911                 :            882 :             | FALSE_P                               { $$ = "false"; }
                               1912                 :           1609 :             | ON                                    { $$ = "on"; }
                               1913                 :                :             /*
                               1914                 :                :              * OFF is also accepted as a boolean value, but is handled by
                               1915                 :                :              * the NonReservedWord rule.  The action for booleans and strings
                               1916                 :                :              * is the same, so we don't need to distinguish them here.
                               1917                 :                :              */
 4904 tgl@sss.pgh.pa.us        1918                 :          22406 :             | NonReservedWord_or_Sconst             { $$ = $1; }
                               1919                 :                :         ;
                               1920                 :                : 
                               1921                 :                : /* Timezone values can be:
                               1922                 :                :  * - a string such as 'pst8pdt'
                               1923                 :                :  * - an identifier such as "pst8pdt"
                               1924                 :                :  * - an integer or floating point number
                               1925                 :                :  * - a time interval per SQL99
                               1926                 :                :  * ColId gives reduce/reduce errors against ConstInterval and LOCAL,
                               1927                 :                :  * so use IDENT (meaning we reject anything that is a key word).
                               1928                 :                :  */
                               1929                 :                : zone_value:
                               1930                 :                :             Sconst
                               1931                 :                :                 {
 6643                          1932                 :             39 :                     $$ = makeStringConst($1, @1);
                               1933                 :                :                 }
                               1934                 :                :             | IDENT
                               1935                 :                :                 {
                               1936                 :              1 :                     $$ = makeStringConst($1, @1);
                               1937                 :                :                 }
                               1938                 :                :             | ConstInterval Sconst opt_interval
                               1939                 :                :                 {
 1637 peter@eisentraut.org     1940                 :UBC           0 :                     TypeName   *t = $1;
                               1941                 :                : 
 6629 tgl@sss.pgh.pa.us        1942         [ #  # ]:              0 :                     if ($3 != NIL)
                               1943                 :                :                     {
 1637 peter@eisentraut.org     1944                 :              0 :                         A_Const    *n = (A_Const *) linitial($3);
                               1945                 :                : 
 1756                          1946         [ #  # ]:              0 :                         if ((n->val.ival.ival & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0)
 8510 tgl@sss.pgh.pa.us        1947         [ #  # ]:              0 :                             ereport(ERROR,
                               1948                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                               1949                 :                :                                      errmsg("time zone interval must be HOUR or HOUR TO MINUTE"),
                               1950                 :                :                                      parser_errposition(@3)));
                               1951                 :                :                     }
 6629                          1952                 :              0 :                     t->typmods = $3;
 6643                          1953                 :              0 :                     $$ = makeStringConstCast($2, @2, t);
                               1954                 :                :                 }
                               1955                 :                :             | ConstInterval '(' Iconst ')' Sconst
                               1956                 :                :                 {
 1637 peter@eisentraut.org     1957                 :              0 :                     TypeName   *t = $1;
                               1958                 :                : 
 4401 bruce@momjian.us         1959                 :              0 :                     t->typmods = list_make2(makeIntConst(INTERVAL_FULL_RANGE, -1),
                               1960                 :                :                                             makeIntConst($3, @3));
 6643 tgl@sss.pgh.pa.us        1961                 :              0 :                     $$ = makeStringConstCast($5, @5, t);
                               1962                 :                :                 }
 6643 tgl@sss.pgh.pa.us        1963                 :CBC          16 :             | NumericOnly                           { $$ = makeAConst($1, @1); }
 8907 bruce@momjian.us         1964                 :              9 :             | DEFAULT                               { $$ = NULL; }
                               1965                 :              1 :             | LOCAL                                 { $$ = NULL; }
                               1966                 :                :         ;
                               1967                 :                : 
                               1968                 :                : opt_encoding:
 8907 bruce@momjian.us         1969                 :UBC           0 :             Sconst                                  { $$ = $1; }
                               1970                 :              0 :             | DEFAULT                               { $$ = NULL; }
                               1971                 :              0 :             | /*EMPTY*/                             { $$ = NULL; }
                               1972                 :                :         ;
                               1973                 :                : 
                               1974                 :                : NonReservedWord_or_Sconst:
 4904 tgl@sss.pgh.pa.us        1975                 :CBC       34400 :             NonReservedWord                         { $$ = $1; }
 6567 meskes@postgresql.or     1976                 :           4201 :             | Sconst                                { $$ = $1; }
                               1977                 :                :         ;
                               1978                 :                : 
                               1979                 :                : VariableResetStmt:
 4447 fujii@postgresql.org     1980                 :           3360 :             RESET reset_rest                        { $$ = (Node *) $2; }
                               1981                 :                :         ;
                               1982                 :                : 
                               1983                 :                : reset_rest:
                               1984                 :           2777 :             generic_reset                           { $$ = $1; }
                               1985                 :                :             | TIME ZONE
                               1986                 :                :                 {
 7003 tgl@sss.pgh.pa.us        1987                 :              9 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1988                 :                : 
                               1989                 :              9 :                     n->kind = VAR_RESET;
 4447 fujii@postgresql.org     1990                 :              9 :                     n->name = "timezone";
  766 michael@paquier.xyz      1991                 :              9 :                     n->location = -1;
 4447 fujii@postgresql.org     1992                 :              9 :                     $$ = n;
                               1993                 :                :                 }
                               1994                 :                :             | TRANSACTION ISOLATION LEVEL
                               1995                 :                :                 {
 7003 tgl@sss.pgh.pa.us        1996                 :UBC           0 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               1997                 :                : 
                               1998                 :              0 :                     n->kind = VAR_RESET;
 4447 fujii@postgresql.org     1999                 :              0 :                     n->name = "transaction_isolation";
  766 michael@paquier.xyz      2000                 :              0 :                     n->location = -1;
 4447 fujii@postgresql.org     2001                 :              0 :                     $$ = n;
                               2002                 :                :                 }
                               2003                 :                :             | SESSION AUTHORIZATION
                               2004                 :                :                 {
 7003 tgl@sss.pgh.pa.us        2005                 :CBC         574 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               2006                 :                : 
                               2007                 :            574 :                     n->kind = VAR_RESET;
 4447 fujii@postgresql.org     2008                 :            574 :                     n->name = "session_authorization";
  766 michael@paquier.xyz      2009                 :            574 :                     n->location = -1;
 4447 fujii@postgresql.org     2010                 :            574 :                     $$ = n;
                               2011                 :                :                 }
                               2012                 :                :         ;
                               2013                 :                : 
                               2014                 :                : generic_reset:
                               2015                 :                :             var_name
                               2016                 :                :                 {
 7003 tgl@sss.pgh.pa.us        2017                 :           2789 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               2018                 :                : 
                               2019                 :           2789 :                     n->kind = VAR_RESET;
 4447 fujii@postgresql.org     2020                 :           2789 :                     n->name = $1;
  766 michael@paquier.xyz      2021                 :           2789 :                     n->location = -1;
 4447 fujii@postgresql.org     2022                 :           2789 :                     $$ = n;
                               2023                 :                :                 }
                               2024                 :                :             | ALL
                               2025                 :                :                 {
 7003 tgl@sss.pgh.pa.us        2026                 :             17 :                     VariableSetStmt *n = makeNode(VariableSetStmt);
                               2027                 :                : 
                               2028                 :             17 :                     n->kind = VAR_RESET_ALL;
  766 michael@paquier.xyz      2029                 :             17 :                     n->location = -1;
 4447 fujii@postgresql.org     2030                 :             17 :                     $$ = n;
                               2031                 :                :                 }
                               2032                 :                :         ;
                               2033                 :                : 
                               2034                 :                : /* SetResetClause allows SET or RESET without LOCAL */
                               2035                 :                : SetResetClause:
 7003 tgl@sss.pgh.pa.us        2036                 :            707 :             SET set_rest                    { $$ = $2; }
                               2037                 :             21 :             | VariableResetStmt             { $$ = (VariableSetStmt *) $1; }
                               2038                 :                :         ;
                               2039                 :                : 
                               2040                 :                : /* SetResetClause allows SET or RESET without LOCAL */
                               2041                 :                : FunctionSetResetClause:
 5377 rhaas@postgresql.org     2042                 :             89 :             SET set_rest_more               { $$ = $2; }
                               2043                 :              8 :             | VariableResetStmt             { $$ = (VariableSetStmt *) $1; }
                               2044                 :                :         ;
                               2045                 :                : 
                               2046                 :                : 
                               2047                 :                : VariableShowStmt:
                               2048                 :                :             SHOW var_name
                               2049                 :                :                 {
 7003 tgl@sss.pgh.pa.us        2050                 :            572 :                     VariableShowStmt *n = makeNode(VariableShowStmt);
                               2051                 :                : 
 8938                          2052                 :            572 :                     n->name = $2;
10650 bruce@momjian.us         2053                 :            572 :                     $$ = (Node *) n;
                               2054                 :                :                 }
                               2055                 :                :             | SHOW TIME ZONE
                               2056                 :                :                 {
 7003 tgl@sss.pgh.pa.us        2057                 :              5 :                     VariableShowStmt *n = makeNode(VariableShowStmt);
                               2058                 :                : 
 8938                          2059                 :              5 :                     n->name = "timezone";
10598 lockhart@fourpalms.o     2060                 :              5 :                     $$ = (Node *) n;
                               2061                 :                :                 }
                               2062                 :                :             | SHOW TRANSACTION ISOLATION LEVEL
                               2063                 :                :                 {
 7003 tgl@sss.pgh.pa.us        2064                 :              1 :                     VariableShowStmt *n = makeNode(VariableShowStmt);
                               2065                 :                : 
 8700 peter_e@gmx.net          2066                 :              1 :                     n->name = "transaction_isolation";
10184 vadim4o@yahoo.com        2067                 :              1 :                     $$ = (Node *) n;
                               2068                 :                :                 }
                               2069                 :                :             | SHOW SESSION AUTHORIZATION
                               2070                 :                :                 {
 7003 tgl@sss.pgh.pa.us        2071                 :UBC           0 :                     VariableShowStmt *n = makeNode(VariableShowStmt);
                               2072                 :                : 
 8949                          2073                 :              0 :                     n->name = "session_authorization";
                               2074                 :              0 :                     $$ = (Node *) n;
                               2075                 :                :                 }
                               2076                 :                :             | SHOW ALL
                               2077                 :                :                 {
 7003                          2078                 :              0 :                     VariableShowStmt *n = makeNode(VariableShowStmt);
                               2079                 :                : 
 8938                          2080                 :              0 :                     n->name = "all";
 9282 bruce@momjian.us         2081                 :              0 :                     $$ = (Node *) n;
                               2082                 :                :                 }
                               2083                 :                :         ;
                               2084                 :                : 
                               2085                 :                : 
                               2086                 :                : ConstraintsSetStmt:
                               2087                 :                :             SET CONSTRAINTS constraints_set_list constraints_set_mode
                               2088                 :                :                 {
 9899 JanWieck@Yahoo.com       2089                 :CBC          72 :                     ConstraintsSetStmt *n = makeNode(ConstraintsSetStmt);
                               2090                 :                : 
                               2091                 :             72 :                     n->constraints = $3;
 5483 peter_e@gmx.net          2092                 :             72 :                     n->deferred = $4;
 9899 JanWieck@Yahoo.com       2093                 :             72 :                     $$ = (Node *) n;
                               2094                 :                :                 }
                               2095                 :                :         ;
                               2096                 :                : 
                               2097                 :                : constraints_set_list:
 8907 bruce@momjian.us         2098                 :             40 :             ALL                                     { $$ = NIL; }
 7497                          2099                 :             32 :             | qualified_name_list                   { $$ = $1; }
                               2100                 :                :         ;
                               2101                 :                : 
                               2102                 :                : constraints_set_mode:
 3368 peter_e@gmx.net          2103                 :             45 :             DEFERRED                                { $$ = true; }
                               2104                 :             27 :             | IMMEDIATE                             { $$ = false; }
                               2105                 :                :         ;
                               2106                 :                : 
                               2107                 :                : 
                               2108                 :                : /*
                               2109                 :                :  * Checkpoint statement
                               2110                 :                :  */
                               2111                 :                : CheckPointStmt:
                               2112                 :                :             CHECKPOINT opt_utility_option_list
                               2113                 :                :                 {
 9496 vadim4o@yahoo.com        2114                 :            168 :                     CheckPointStmt *n = makeNode(CheckPointStmt);
                               2115                 :                : 
 1637 peter@eisentraut.org     2116                 :            168 :                     $$ = (Node *) n;
  468 alvherre@kurilemu.de     2117                 :            168 :                     n->options = $2;
                               2118                 :                :                 }
                               2119                 :                :         ;
                               2120                 :                : 
                               2121                 :                : 
                               2122                 :                : /*****************************************************************************
                               2123                 :                :  *
                               2124                 :                :  * DISCARD { ALL | TEMP | PLANS | SEQUENCES }
                               2125                 :                :  *
                               2126                 :                :  *****************************************************************************/
                               2127                 :                : 
                               2128                 :                : DiscardStmt:
                               2129                 :                :             DISCARD ALL
                               2130                 :                :                 {
 7133 neilc@samurai.com        2131                 :              4 :                     DiscardStmt *n = makeNode(DiscardStmt);
                               2132                 :                : 
                               2133                 :              4 :                     n->target = DISCARD_ALL;
                               2134                 :              4 :                     $$ = (Node *) n;
                               2135                 :                :                 }
                               2136                 :                :             | DISCARD TEMP
                               2137                 :                :                 {
                               2138                 :              9 :                     DiscardStmt *n = makeNode(DiscardStmt);
                               2139                 :                : 
                               2140                 :              9 :                     n->target = DISCARD_TEMP;
                               2141                 :              9 :                     $$ = (Node *) n;
                               2142                 :                :                 }
                               2143                 :                :             | DISCARD TEMPORARY
                               2144                 :                :                 {
 7133 neilc@samurai.com        2145                 :UBC           0 :                     DiscardStmt *n = makeNode(DiscardStmt);
                               2146                 :                : 
                               2147                 :              0 :                     n->target = DISCARD_TEMP;
                               2148                 :              0 :                     $$ = (Node *) n;
                               2149                 :                :                 }
                               2150                 :                :             | DISCARD PLANS
                               2151                 :                :                 {
 7133 neilc@samurai.com        2152                 :CBC           3 :                     DiscardStmt *n = makeNode(DiscardStmt);
                               2153                 :                : 
                               2154                 :              3 :                     n->target = DISCARD_PLANS;
                               2155                 :              3 :                     $$ = (Node *) n;
                               2156                 :                :                 }
                               2157                 :                :             | DISCARD SEQUENCES
                               2158                 :                :                 {
 4781 rhaas@postgresql.org     2159                 :              8 :                     DiscardStmt *n = makeNode(DiscardStmt);
                               2160                 :                : 
                               2161                 :              8 :                     n->target = DISCARD_SEQUENCES;
                               2162                 :              8 :                     $$ = (Node *) n;
                               2163                 :                :                 }
                               2164                 :                : 
                               2165                 :                :         ;
                               2166                 :                : 
                               2167                 :                : 
                               2168                 :                : /*****************************************************************************
                               2169                 :                :  *
                               2170                 :                :  *  ALTER [ TABLE | INDEX | SEQUENCE | VIEW | MATERIALIZED VIEW | FOREIGN TABLE ] variations
                               2171                 :                :  *
                               2172                 :                :  * Note: we accept all subcommands for each of the variants, and sort
                               2173                 :                :  * out what's really legal at execution time.
                               2174                 :                :  *****************************************************************************/
                               2175                 :                : 
                               2176                 :                : AlterTableStmt:
                               2177                 :                :             ALTER TABLE relation_expr alter_table_cmds
                               2178                 :                :                 {
 9760 lockhart@fourpalms.o     2179                 :          17169 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2180                 :                : 
 8995 tgl@sss.pgh.pa.us        2181                 :          17169 :                     n->relation = $3;
 8219                          2182                 :          17169 :                     n->cmds = $4;
 2308 michael@paquier.xyz      2183                 :          17169 :                     n->objtype = OBJECT_TABLE;
 5400 simon@2ndQuadrant.co     2184                 :          17169 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     2185                 :          17169 :                     $$ = (Node *) n;
                               2186                 :                :                 }
                               2187                 :                :         |   ALTER TABLE IF_P EXISTS relation_expr alter_table_cmds
                               2188                 :                :                 {
 5400 simon@2ndQuadrant.co     2189                 :             36 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2190                 :                : 
                               2191                 :             36 :                     n->relation = $5;
                               2192                 :             36 :                     n->cmds = $6;
 2308 michael@paquier.xyz      2193                 :             36 :                     n->objtype = OBJECT_TABLE;
 5400 simon@2ndQuadrant.co     2194                 :             36 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     2195                 :             36 :                     $$ = (Node *) n;
                               2196                 :                :                 }
                               2197                 :                :         |   ALTER TABLE relation_expr partition_cmd
                               2198                 :                :                 {
 3620 rhaas@postgresql.org     2199                 :           1950 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2200                 :                : 
                               2201                 :           1950 :                     n->relation = $3;
                               2202                 :           1950 :                     n->cmds = list_make1($4);
 2308 michael@paquier.xyz      2203                 :           1950 :                     n->objtype = OBJECT_TABLE;
 3620 rhaas@postgresql.org     2204                 :           1950 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     2205                 :           1950 :                     $$ = (Node *) n;
                               2206                 :                :                 }
                               2207                 :                :         |   ALTER TABLE IF_P EXISTS relation_expr partition_cmd
                               2208                 :                :                 {
 3620 rhaas@postgresql.org     2209                 :UBC           0 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2210                 :                : 
                               2211                 :              0 :                     n->relation = $5;
                               2212                 :              0 :                     n->cmds = list_make1($6);
 2308 michael@paquier.xyz      2213                 :              0 :                     n->objtype = OBJECT_TABLE;
 3620 rhaas@postgresql.org     2214                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     2215                 :              0 :                     $$ = (Node *) n;
                               2216                 :                :                 }
                               2217                 :                :         |   ALTER TABLE ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
                               2218                 :                :                 {
                               2219                 :                :                     AlterTableMoveAllStmt *n =
 4459 sfrost@snowman.net       2220                 :CBC           9 :                         makeNode(AlterTableMoveAllStmt);
                               2221                 :                : 
                               2222                 :              9 :                     n->orig_tablespacename = $6;
                               2223                 :              9 :                     n->objtype = OBJECT_TABLE;
                               2224                 :              9 :                     n->roles = NIL;
                               2225                 :              9 :                     n->new_tablespacename = $9;
                               2226                 :              9 :                     n->nowait = $10;
 1637 peter@eisentraut.org     2227                 :              9 :                     $$ = (Node *) n;
                               2228                 :                :                 }
                               2229                 :                :         |   ALTER TABLE ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
                               2230                 :                :                 {
                               2231                 :                :                     AlterTableMoveAllStmt *n =
 4459 sfrost@snowman.net       2232                 :UBC           0 :                         makeNode(AlterTableMoveAllStmt);
                               2233                 :                : 
                               2234                 :              0 :                     n->orig_tablespacename = $6;
                               2235                 :              0 :                     n->objtype = OBJECT_TABLE;
                               2236                 :              0 :                     n->roles = $9;
                               2237                 :              0 :                     n->new_tablespacename = $12;
                               2238                 :              0 :                     n->nowait = $13;
 1637 peter@eisentraut.org     2239                 :              0 :                     $$ = (Node *) n;
                               2240                 :                :                 }
                               2241                 :                :         |   ALTER INDEX qualified_name alter_table_cmds
                               2242                 :                :                 {
 8112 bruce@momjian.us         2243                 :CBC         148 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2244                 :                : 
                               2245                 :            148 :                     n->relation = $3;
                               2246                 :            148 :                     n->cmds = $4;
 2308 michael@paquier.xyz      2247                 :            148 :                     n->objtype = OBJECT_INDEX;
 5400 simon@2ndQuadrant.co     2248                 :            148 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     2249                 :            148 :                     $$ = (Node *) n;
                               2250                 :                :                 }
                               2251                 :                :         |   ALTER INDEX IF_P EXISTS qualified_name alter_table_cmds
                               2252                 :                :                 {
 5400 simon@2ndQuadrant.co     2253                 :UBC           0 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2254                 :                : 
                               2255                 :              0 :                     n->relation = $5;
                               2256                 :              0 :                     n->cmds = $6;
 2308 michael@paquier.xyz      2257                 :              0 :                     n->objtype = OBJECT_INDEX;
 5400 simon@2ndQuadrant.co     2258                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     2259                 :              0 :                     $$ = (Node *) n;
                               2260                 :                :                 }
                               2261                 :                :         |   ALTER INDEX qualified_name index_partition_cmd
                               2262                 :                :                 {
 3212 alvherre@alvh.no-ip.     2263                 :CBC         290 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2264                 :                : 
                               2265                 :            290 :                     n->relation = $3;
                               2266                 :            290 :                     n->cmds = list_make1($4);
 2308 michael@paquier.xyz      2267                 :            290 :                     n->objtype = OBJECT_INDEX;
 3212 alvherre@alvh.no-ip.     2268                 :            290 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     2269                 :            290 :                     $$ = (Node *) n;
                               2270                 :                :                 }
                               2271                 :                :         |   ALTER INDEX ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
                               2272                 :                :                 {
                               2273                 :                :                     AlterTableMoveAllStmt *n =
 4459 sfrost@snowman.net       2274                 :              4 :                         makeNode(AlterTableMoveAllStmt);
                               2275                 :                : 
                               2276                 :              4 :                     n->orig_tablespacename = $6;
                               2277                 :              4 :                     n->objtype = OBJECT_INDEX;
                               2278                 :              4 :                     n->roles = NIL;
                               2279                 :              4 :                     n->new_tablespacename = $9;
                               2280                 :              4 :                     n->nowait = $10;
 1637 peter@eisentraut.org     2281                 :              4 :                     $$ = (Node *) n;
                               2282                 :                :                 }
                               2283                 :                :         |   ALTER INDEX ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
                               2284                 :                :                 {
                               2285                 :                :                     AlterTableMoveAllStmt *n =
 4459 sfrost@snowman.net       2286                 :UBC           0 :                         makeNode(AlterTableMoveAllStmt);
                               2287                 :                : 
                               2288                 :              0 :                     n->orig_tablespacename = $6;
                               2289                 :              0 :                     n->objtype = OBJECT_INDEX;
                               2290                 :              0 :                     n->roles = $9;
                               2291                 :              0 :                     n->new_tablespacename = $12;
                               2292                 :              0 :                     n->nowait = $13;
 1637 peter@eisentraut.org     2293                 :              0 :                     $$ = (Node *) n;
                               2294                 :                :                 }
                               2295                 :                :         |   ALTER SEQUENCE qualified_name alter_table_cmds
                               2296                 :                :                 {
 6717 tgl@sss.pgh.pa.us        2297                 :CBC          55 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2298                 :                : 
                               2299                 :             55 :                     n->relation = $3;
                               2300                 :             55 :                     n->cmds = $4;
 2308 michael@paquier.xyz      2301                 :             55 :                     n->objtype = OBJECT_SEQUENCE;
 5400 simon@2ndQuadrant.co     2302                 :             55 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     2303                 :             55 :                     $$ = (Node *) n;
                               2304                 :                :                 }
                               2305                 :                :         |   ALTER SEQUENCE IF_P EXISTS qualified_name alter_table_cmds
                               2306                 :                :                 {
 5400 simon@2ndQuadrant.co     2307                 :UBC           0 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2308                 :                : 
                               2309                 :              0 :                     n->relation = $5;
                               2310                 :              0 :                     n->cmds = $6;
 2308 michael@paquier.xyz      2311                 :              0 :                     n->objtype = OBJECT_SEQUENCE;
 5400 simon@2ndQuadrant.co     2312                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     2313                 :              0 :                     $$ = (Node *) n;
                               2314                 :                :                 }
                               2315                 :                :         |   ALTER VIEW qualified_name alter_table_cmds
                               2316                 :                :                 {
 6717 tgl@sss.pgh.pa.us        2317                 :CBC         150 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2318                 :                : 
                               2319                 :            150 :                     n->relation = $3;
                               2320                 :            150 :                     n->cmds = $4;
 2308 michael@paquier.xyz      2321                 :            150 :                     n->objtype = OBJECT_VIEW;
 5400 simon@2ndQuadrant.co     2322                 :            150 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     2323                 :            150 :                     $$ = (Node *) n;
                               2324                 :                :                 }
                               2325                 :                :         |   ALTER VIEW IF_P EXISTS qualified_name alter_table_cmds
                               2326                 :                :                 {
 5400 simon@2ndQuadrant.co     2327                 :UBC           0 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2328                 :                : 
                               2329                 :              0 :                     n->relation = $5;
                               2330                 :              0 :                     n->cmds = $6;
 2308 michael@paquier.xyz      2331                 :              0 :                     n->objtype = OBJECT_VIEW;
 5400 simon@2ndQuadrant.co     2332                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     2333                 :              0 :                     $$ = (Node *) n;
                               2334                 :                :                 }
                               2335                 :                :         |   ALTER MATERIALIZED VIEW qualified_name alter_table_cmds
                               2336                 :                :                 {
 4995 kgrittn@postgresql.o     2337                 :CBC          29 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2338                 :                : 
                               2339                 :             29 :                     n->relation = $4;
                               2340                 :             29 :                     n->cmds = $5;
 2308 michael@paquier.xyz      2341                 :             29 :                     n->objtype = OBJECT_MATVIEW;
 4995 kgrittn@postgresql.o     2342                 :             29 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     2343                 :             29 :                     $$ = (Node *) n;
                               2344                 :                :                 }
                               2345                 :                :         |   ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name alter_table_cmds
                               2346                 :                :                 {
 4995 kgrittn@postgresql.o     2347                 :UBC           0 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2348                 :                : 
                               2349                 :              0 :                     n->relation = $6;
                               2350                 :              0 :                     n->cmds = $7;
 2308 michael@paquier.xyz      2351                 :              0 :                     n->objtype = OBJECT_MATVIEW;
 4995 kgrittn@postgresql.o     2352                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     2353                 :              0 :                     $$ = (Node *) n;
                               2354                 :                :                 }
                               2355                 :                :         |   ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
                               2356                 :                :                 {
                               2357                 :                :                     AlterTableMoveAllStmt *n =
 4459 sfrost@snowman.net       2358                 :CBC           8 :                         makeNode(AlterTableMoveAllStmt);
                               2359                 :                : 
                               2360                 :              8 :                     n->orig_tablespacename = $7;
                               2361                 :              8 :                     n->objtype = OBJECT_MATVIEW;
                               2362                 :              8 :                     n->roles = NIL;
                               2363                 :              8 :                     n->new_tablespacename = $10;
                               2364                 :              8 :                     n->nowait = $11;
 1637 peter@eisentraut.org     2365                 :              8 :                     $$ = (Node *) n;
                               2366                 :                :                 }
                               2367                 :                :         |   ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
                               2368                 :                :                 {
                               2369                 :                :                     AlterTableMoveAllStmt *n =
 4459 sfrost@snowman.net       2370                 :UBC           0 :                         makeNode(AlterTableMoveAllStmt);
                               2371                 :                : 
                               2372                 :              0 :                     n->orig_tablespacename = $7;
                               2373                 :              0 :                     n->objtype = OBJECT_MATVIEW;
                               2374                 :              0 :                     n->roles = $10;
                               2375                 :              0 :                     n->new_tablespacename = $13;
                               2376                 :              0 :                     n->nowait = $14;
 1637 peter@eisentraut.org     2377                 :              0 :                     $$ = (Node *) n;
                               2378                 :                :                 }
                               2379                 :                :         |   ALTER FOREIGN TABLE relation_expr alter_table_cmds
                               2380                 :                :                 {
 2338 peter@eisentraut.org     2381                 :CBC         251 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2382                 :                : 
                               2383                 :            251 :                     n->relation = $4;
                               2384                 :            251 :                     n->cmds = $5;
 2308 michael@paquier.xyz      2385                 :            251 :                     n->objtype = OBJECT_FOREIGN_TABLE;
 2338 peter@eisentraut.org     2386                 :            251 :                     n->missing_ok = false;
 1637                          2387                 :            251 :                     $$ = (Node *) n;
                               2388                 :                :                 }
                               2389                 :                :         |   ALTER FOREIGN TABLE IF_P EXISTS relation_expr alter_table_cmds
                               2390                 :                :                 {
 2338                          2391                 :             88 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               2392                 :                : 
                               2393                 :             88 :                     n->relation = $6;
                               2394                 :             88 :                     n->cmds = $7;
 2308 michael@paquier.xyz      2395                 :             88 :                     n->objtype = OBJECT_FOREIGN_TABLE;
 2338 peter@eisentraut.org     2396                 :             88 :                     n->missing_ok = true;
 1637                          2397                 :             88 :                     $$ = (Node *) n;
                               2398                 :                :                 }
                               2399                 :                :         ;
                               2400                 :                : 
                               2401                 :                : alter_table_cmds:
 8194 neilc@samurai.com        2402                 :          17926 :             alter_table_cmd                         { $$ = list_make1($1); }
 8219 tgl@sss.pgh.pa.us        2403                 :            731 :             | alter_table_cmds ',' alter_table_cmd  { $$ = lappend($1, $3); }
                               2404                 :                :         ;
                               2405                 :                : 
                               2406                 :                : partition_cmd:
                               2407                 :                :             /* ALTER TABLE <name> ATTACH PARTITION <table_name> FOR VALUES */
                               2408                 :                :             ATTACH PARTITION qualified_name PartitionBoundSpec
                               2409                 :                :                 {
 3620 rhaas@postgresql.org     2410                 :           1561 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2411                 :           1561 :                     PartitionCmd *cmd = makeNode(PartitionCmd);
                               2412                 :                : 
                               2413                 :           1561 :                     n->subtype = AT_AttachPartition;
                               2414                 :           1561 :                     cmd->name = $3;
 3448 tgl@sss.pgh.pa.us        2415                 :           1561 :                     cmd->bound = $4;
 2051 alvherre@alvh.no-ip.     2416                 :           1561 :                     cmd->concurrent = false;
 3620 rhaas@postgresql.org     2417                 :           1561 :                     n->def = (Node *) cmd;
                               2418                 :                : 
                               2419                 :           1561 :                     $$ = (Node *) n;
                               2420                 :                :                 }
                               2421                 :                :             /* ALTER TABLE <name> DETACH PARTITION <partition_name> [CONCURRENTLY] */
                               2422                 :                :             | DETACH PARTITION qualified_name opt_concurrently
                               2423                 :                :                 {
                               2424                 :            378 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2425                 :            378 :                     PartitionCmd *cmd = makeNode(PartitionCmd);
                               2426                 :                : 
                               2427                 :            378 :                     n->subtype = AT_DetachPartition;
                               2428                 :            378 :                     cmd->name = $3;
 3448 tgl@sss.pgh.pa.us        2429                 :            378 :                     cmd->bound = NULL;
 2051 alvherre@alvh.no-ip.     2430                 :            378 :                     cmd->concurrent = $4;
 3620 rhaas@postgresql.org     2431                 :            378 :                     n->def = (Node *) cmd;
                               2432                 :                : 
 2051 alvherre@alvh.no-ip.     2433                 :            378 :                     $$ = (Node *) n;
                               2434                 :                :                 }
                               2435                 :                :             | DETACH PARTITION qualified_name FINALIZE
                               2436                 :                :                 {
                               2437                 :             11 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2438                 :             11 :                     PartitionCmd *cmd = makeNode(PartitionCmd);
                               2439                 :                : 
                               2440                 :             11 :                     n->subtype = AT_DetachPartitionFinalize;
                               2441                 :             11 :                     cmd->name = $3;
                               2442                 :             11 :                     cmd->bound = NULL;
                               2443                 :             11 :                     cmd->concurrent = false;
                               2444                 :             11 :                     n->def = (Node *) cmd;
 3620 rhaas@postgresql.org     2445                 :             11 :                     $$ = (Node *) n;
                               2446                 :                :                 }
                               2447                 :                :         ;
                               2448                 :                : 
                               2449                 :                : index_partition_cmd:
                               2450                 :                :             /* ALTER INDEX <name> ATTACH PARTITION <index_name> */
                               2451                 :                :             ATTACH PARTITION qualified_name
                               2452                 :                :                 {
 3212 alvherre@alvh.no-ip.     2453                 :            290 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2454                 :            290 :                     PartitionCmd *cmd = makeNode(PartitionCmd);
                               2455                 :                : 
                               2456                 :            290 :                     n->subtype = AT_AttachPartition;
                               2457                 :            290 :                     cmd->name = $3;
                               2458                 :            290 :                     cmd->bound = NULL;
 2051                          2459                 :            290 :                     cmd->concurrent = false;
 3212                          2460                 :            290 :                     n->def = (Node *) cmd;
                               2461                 :                : 
                               2462                 :            290 :                     $$ = (Node *) n;
                               2463                 :                :                 }
                               2464                 :                :         ;
                               2465                 :                : 
                               2466                 :                : alter_table_cmd:
                               2467                 :                :             /* ALTER TABLE <name> ADD <coldef> */
                               2468                 :                :             ADD_P columnDef
                               2469                 :                :                 {
 6177 tgl@sss.pgh.pa.us        2470                 :            138 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2471                 :                : 
                               2472                 :            138 :                     n->subtype = AT_AddColumn;
                               2473                 :            138 :                     n->def = $2;
 4117 andrew@dunslane.net      2474                 :            138 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     2475                 :            138 :                     $$ = (Node *) n;
                               2476                 :                :                 }
                               2477                 :                :             /* ALTER TABLE <name> ADD IF NOT EXISTS <coldef> */
                               2478                 :                :             | ADD_P IF_P NOT EXISTS columnDef
                               2479                 :                :                 {
 4117 andrew@dunslane.net      2480                 :              4 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2481                 :                : 
                               2482                 :              4 :                     n->subtype = AT_AddColumn;
                               2483                 :              4 :                     n->def = $5;
                               2484                 :              4 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     2485                 :              4 :                     $$ = (Node *) n;
                               2486                 :                :                 }
                               2487                 :                :             /* ALTER TABLE <name> ADD COLUMN <coldef> */
                               2488                 :                :             | ADD_P COLUMN columnDef
                               2489                 :                :                 {
 8219 tgl@sss.pgh.pa.us        2490                 :           1386 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2491                 :                : 
                               2492                 :           1386 :                     n->subtype = AT_AddColumn;
                               2493                 :           1386 :                     n->def = $3;
 4117 andrew@dunslane.net      2494                 :           1386 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     2495                 :           1386 :                     $$ = (Node *) n;
                               2496                 :                :                 }
                               2497                 :                :             /* ALTER TABLE <name> ADD COLUMN IF NOT EXISTS <coldef> */
                               2498                 :                :             | ADD_P COLUMN IF_P NOT EXISTS columnDef
                               2499                 :                :                 {
 4117 andrew@dunslane.net      2500                 :             48 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2501                 :                : 
                               2502                 :             48 :                     n->subtype = AT_AddColumn;
                               2503                 :             48 :                     n->def = $6;
                               2504                 :             48 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     2505                 :             48 :                     $$ = (Node *) n;
                               2506                 :                :                 }
                               2507                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> {SET DEFAULT <expr>|DROP DEFAULT} */
                               2508                 :                :             | ALTER opt_column ColId alter_column_default
                               2509                 :                :                 {
 8219 tgl@sss.pgh.pa.us        2510                 :            365 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2511                 :                : 
                               2512                 :            365 :                     n->subtype = AT_ColumnDefault;
                               2513                 :            365 :                     n->name = $3;
                               2514                 :            365 :                     n->def = $4;
 1637 peter@eisentraut.org     2515                 :            365 :                     $$ = (Node *) n;
                               2516                 :                :                 }
                               2517                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> DROP NOT NULL */
                               2518                 :                :             | ALTER opt_column ColId DROP NOT NULL_P
                               2519                 :                :                 {
 8219 tgl@sss.pgh.pa.us        2520                 :            214 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2521                 :                : 
                               2522                 :            214 :                     n->subtype = AT_DropNotNull;
                               2523                 :            214 :                     n->name = $3;
 1637 peter@eisentraut.org     2524                 :            214 :                     $$ = (Node *) n;
                               2525                 :                :                 }
                               2526                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET NOT NULL */
                               2527                 :                :             | ALTER opt_column ColId SET NOT NULL_P
                               2528                 :                :                 {
 8219 tgl@sss.pgh.pa.us        2529                 :            289 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2530                 :                : 
                               2531                 :            289 :                     n->subtype = AT_SetNotNull;
                               2532                 :            289 :                     n->name = $3;
 1637 peter@eisentraut.org     2533                 :            289 :                     $$ = (Node *) n;
                               2534                 :                :                 }
                               2535                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET EXPRESSION AS <expr> */
                               2536                 :                :             | ALTER opt_column ColId SET EXPRESSION AS '(' a_expr ')'
                               2537                 :                :                 {
 1036                          2538                 :            153 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2539                 :                : 
                               2540                 :            153 :                     n->subtype = AT_SetExpression;
                               2541                 :            153 :                     n->name = $3;
                               2542                 :            153 :                     n->def = $8;
                               2543                 :            153 :                     $$ = (Node *) n;
                               2544                 :                :                 }
                               2545                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> DROP EXPRESSION */
                               2546                 :                :             | ALTER opt_column ColId DROP EXPRESSION
                               2547                 :                :                 {
 2487                          2548                 :             57 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2549                 :                : 
                               2550                 :             57 :                     n->subtype = AT_DropExpression;
                               2551                 :             57 :                     n->name = $3;
 1637                          2552                 :             57 :                     $$ = (Node *) n;
                               2553                 :                :                 }
                               2554                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> DROP EXPRESSION IF EXISTS */
                               2555                 :                :             | ALTER opt_column ColId DROP EXPRESSION IF_P EXISTS
                               2556                 :                :                 {
 2487                          2557                 :              8 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2558                 :                : 
                               2559                 :              8 :                     n->subtype = AT_DropExpression;
                               2560                 :              8 :                     n->name = $3;
                               2561                 :              8 :                     n->missing_ok = true;
 1637                          2562                 :              8 :                     $$ = (Node *) n;
                               2563                 :                :                 }
                               2564                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET STATISTICS */
                               2565                 :                :             | ALTER opt_column ColId SET STATISTICS set_statistics_value
                               2566                 :                :                 {
 8219 tgl@sss.pgh.pa.us        2567                 :             44 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2568                 :                : 
                               2569                 :             44 :                     n->subtype = AT_SetStatistics;
                               2570                 :             44 :                     n->name = $3;
 1027 peter@eisentraut.org     2571                 :             44 :                     n->def = $6;
 1637                          2572                 :             44 :                     $$ = (Node *) n;
                               2573                 :                :                 }
                               2574                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colnum> SET STATISTICS */
                               2575                 :                :             | ALTER opt_column Iconst SET STATISTICS set_statistics_value
                               2576                 :                :                 {
 3347 simon@2ndQuadrant.co     2577                 :             48 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2578                 :                : 
                               2579   [ +  +  -  + ]:             48 :                     if ($3 <= 0 || $3 > PG_INT16_MAX)
                               2580         [ +  - ]:              4 :                         ereport(ERROR,
                               2581                 :                :                                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                               2582                 :                :                                  errmsg("column number must be in range from 1 to %d", PG_INT16_MAX),
                               2583                 :                :                                  parser_errposition(@3)));
                               2584                 :                : 
                               2585                 :             44 :                     n->subtype = AT_SetStatistics;
                               2586                 :             44 :                     n->num = (int16) $3;
 1027 peter@eisentraut.org     2587                 :             44 :                     n->def = $6;
 1637                          2588                 :             44 :                     $$ = (Node *) n;
                               2589                 :                :                 }
                               2590                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET ( column_parameter = value [, ... ] ) */
                               2591                 :                :             | ALTER opt_column ColId SET reloptions
                               2592                 :                :                 {
 6304 tgl@sss.pgh.pa.us        2593                 :             25 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2594                 :                : 
 6131 rhaas@postgresql.org     2595                 :             25 :                     n->subtype = AT_SetOptions;
 6304 tgl@sss.pgh.pa.us        2596                 :             25 :                     n->name = $3;
 6131 rhaas@postgresql.org     2597                 :             25 :                     n->def = (Node *) $5;
 1637 peter@eisentraut.org     2598                 :             25 :                     $$ = (Node *) n;
                               2599                 :                :                 }
                               2600                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> RESET ( column_parameter [, ... ] ) */
                               2601                 :                :             | ALTER opt_column ColId RESET reloptions
                               2602                 :                :                 {
 6131 rhaas@postgresql.org     2603                 :              4 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2604                 :                : 
                               2605                 :              4 :                     n->subtype = AT_ResetOptions;
                               2606                 :              4 :                     n->name = $3;
                               2607                 :              4 :                     n->def = (Node *) $5;
 1637 peter@eisentraut.org     2608                 :              4 :                     $$ = (Node *) n;
                               2609                 :                :                 }
                               2610                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET STORAGE <storagemode> */
                               2611                 :                :             | ALTER opt_column ColId SET column_storage
                               2612                 :                :                 {
 8219 tgl@sss.pgh.pa.us        2613                 :            221 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2614                 :                : 
                               2615                 :            221 :                     n->subtype = AT_SetStorage;
                               2616                 :            221 :                     n->name = $3;
 1576 peter@eisentraut.org     2617                 :            221 :                     n->def = (Node *) makeString($5);
 1637                          2618                 :            221 :                     $$ = (Node *) n;
                               2619                 :                :                 }
                               2620                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET COMPRESSION <cm> */
                               2621                 :                :             | ALTER opt_column ColId SET column_compression
                               2622                 :                :                 {
 1988 tgl@sss.pgh.pa.us        2623                 :             49 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2624                 :                : 
                               2625                 :             49 :                     n->subtype = AT_SetCompression;
                               2626                 :             49 :                     n->name = $3;
                               2627                 :             49 :                     n->def = (Node *) makeString($5);
 1637 peter@eisentraut.org     2628                 :             49 :                     $$ = (Node *) n;
                               2629                 :                :                 }
                               2630                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> ADD GENERATED ... AS IDENTITY ... */
                               2631                 :                :             | ALTER opt_column ColId ADD_P GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
                               2632                 :                :                 {
 3500 peter_e@gmx.net          2633                 :            107 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2634                 :            107 :                     Constraint *c = makeNode(Constraint);
                               2635                 :                : 
                               2636                 :            107 :                     c->contype = CONSTR_IDENTITY;
                               2637                 :            107 :                     c->generated_when = $6;
                               2638                 :            107 :                     c->options = $9;
                               2639                 :            107 :                     c->location = @5;
                               2640                 :                : 
                               2641                 :            107 :                     n->subtype = AT_AddIdentity;
                               2642                 :            107 :                     n->name = $3;
                               2643                 :            107 :                     n->def = (Node *) c;
                               2644                 :                : 
 1637 peter@eisentraut.org     2645                 :            107 :                     $$ = (Node *) n;
                               2646                 :                :                 }
                               2647                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET <sequence options>/RESET */
                               2648                 :                :             | ALTER opt_column ColId alter_identity_column_option_list
                               2649                 :                :                 {
 3500 peter_e@gmx.net          2650                 :             41 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2651                 :                : 
                               2652                 :             41 :                     n->subtype = AT_SetIdentity;
                               2653                 :             41 :                     n->name = $3;
                               2654                 :             41 :                     n->def = (Node *) $4;
 1637 peter@eisentraut.org     2655                 :             41 :                     $$ = (Node *) n;
                               2656                 :                :                 }
                               2657                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> DROP IDENTITY */
                               2658                 :                :             | ALTER opt_column ColId DROP IDENTITY_P
                               2659                 :                :                 {
 3500 peter_e@gmx.net          2660                 :             33 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2661                 :                : 
                               2662                 :             33 :                     n->subtype = AT_DropIdentity;
                               2663                 :             33 :                     n->name = $3;
                               2664                 :             33 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     2665                 :             33 :                     $$ = (Node *) n;
                               2666                 :                :                 }
                               2667                 :                :             /* ALTER TABLE <name> ALTER [COLUMN] <colname> DROP IDENTITY IF EXISTS */
                               2668                 :                :             | ALTER opt_column ColId DROP IDENTITY_P IF_P EXISTS
                               2669                 :                :                 {
 3500 peter_e@gmx.net          2670                 :              4 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2671                 :                : 
                               2672                 :              4 :                     n->subtype = AT_DropIdentity;
                               2673                 :              4 :                     n->name = $3;
                               2674                 :              4 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     2675                 :              4 :                     $$ = (Node *) n;
                               2676                 :                :                 }
                               2677                 :                :             /* ALTER TABLE <name> DROP [COLUMN] IF EXISTS <colname> [RESTRICT|CASCADE] */
                               2678                 :                :             | DROP opt_column IF_P EXISTS ColId opt_drop_behavior
                               2679                 :                :                 {
 6317 andrew@dunslane.net      2680                 :             16 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2681                 :                : 
                               2682                 :             16 :                     n->subtype = AT_DropColumn;
                               2683                 :             16 :                     n->name = $5;
                               2684                 :             16 :                     n->behavior = $6;
 3368 peter_e@gmx.net          2685                 :             16 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     2686                 :             16 :                     $$ = (Node *) n;
                               2687                 :                :                 }
                               2688                 :                :             /* ALTER TABLE <name> DROP [COLUMN] <colname> [RESTRICT|CASCADE] */
                               2689                 :                :             | DROP opt_column ColId opt_drop_behavior
                               2690                 :                :                 {
 8219 tgl@sss.pgh.pa.us        2691                 :           1056 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2692                 :                : 
                               2693                 :           1056 :                     n->subtype = AT_DropColumn;
                               2694                 :           1056 :                     n->name = $3;
                               2695                 :           1056 :                     n->behavior = $4;
 3368 peter_e@gmx.net          2696                 :           1056 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     2697                 :           1056 :                     $$ = (Node *) n;
                               2698                 :                :                 }
                               2699                 :                :             /*
                               2700                 :                :              * ALTER TABLE <name> ALTER [COLUMN] <colname> [SET DATA] TYPE <typename>
                               2701                 :                :              *      [ USING <expression> ]
                               2702                 :                :              */
                               2703                 :                :             | ALTER opt_column ColId opt_set_data TYPE_P Typename opt_collate_clause alter_using
                               2704                 :                :                 {
 8219 tgl@sss.pgh.pa.us        2705                 :            765 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
 5720                          2706                 :            765 :                     ColumnDef *def = makeNode(ColumnDef);
                               2707                 :                : 
 8219                          2708                 :            765 :                     n->subtype = AT_AlterColumnType;
                               2709                 :            765 :                     n->name = $3;
 5720                          2710                 :            765 :                     n->def = (Node *) def;
                               2711                 :                :                     /* We only use these fields of the ColumnDef node */
                               2712                 :            765 :                     def->typeName = $6;
                               2713                 :            765 :                     def->collClause = (CollateClause *) $7;
                               2714                 :            765 :                     def->raw_default = $8;
 4732                          2715                 :            765 :                     def->location = @3;
 1637 peter@eisentraut.org     2716                 :            765 :                     $$ = (Node *) n;
                               2717                 :                :                 }
                               2718                 :                :             /* ALTER FOREIGN TABLE <name> ALTER [COLUMN] <colname> OPTIONS */
                               2719                 :                :             | ALTER opt_column ColId alter_generic_options
                               2720                 :                :                 {
 5571 rhaas@postgresql.org     2721                 :             33 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2722                 :                : 
                               2723                 :             33 :                     n->subtype = AT_AlterColumnGenericOptions;
                               2724                 :             33 :                     n->name = $3;
                               2725                 :             33 :                     n->def = (Node *) $4;
 1637 peter@eisentraut.org     2726                 :             33 :                     $$ = (Node *) n;
                               2727                 :                :                 }
                               2728                 :                :             /* ALTER TABLE <name> ADD CONSTRAINT ... */
                               2729                 :                :             | ADD_P TableConstraint
                               2730                 :                :                 {
 8219 tgl@sss.pgh.pa.us        2731                 :           8997 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2732                 :                : 
                               2733                 :           8997 :                     n->subtype = AT_AddConstraint;
                               2734                 :           8997 :                     n->def = $2;
 1637 peter@eisentraut.org     2735                 :           8997 :                     $$ = (Node *) n;
                               2736                 :                :                 }
                               2737                 :                :             /* ALTER TABLE <name> ALTER CONSTRAINT ... */
                               2738                 :                :             | ALTER CONSTRAINT name ConstraintAttributeSpec
                               2739                 :                :                 {
 4877 simon@2ndQuadrant.co     2740                 :            312 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
  624 alvherre@alvh.no-ip.     2741                 :            312 :                     ATAlterConstraint *c = makeNode(ATAlterConstraint);
                               2742                 :                : 
 4877 simon@2ndQuadrant.co     2743                 :            312 :                     n->subtype = AT_AlterConstraint;
                               2744                 :            312 :                     n->def = (Node *) c;
                               2745                 :            312 :                     c->conname = $3;
  582 peter@eisentraut.org     2746         [ +  + ]:            312 :                     if ($4 & (CAS_NOT_ENFORCED | CAS_ENFORCED))
                               2747                 :            204 :                         c->alterEnforceability = true;
  588 alvherre@alvh.no-ip.     2748         [ +  + ]:            312 :                     if ($4 & (CAS_DEFERRABLE | CAS_NOT_DEFERRABLE |
                               2749                 :                :                               CAS_INITIALLY_DEFERRED | CAS_INITIALLY_IMMEDIATE))
                               2750                 :             80 :                         c->alterDeferrability = true;
                               2751         [ +  + ]:            312 :                     if ($4 & CAS_NO_INHERIT)
                               2752                 :             24 :                         c->alterInheritability = true;
                               2753                 :                :                     /* handle unsupported case with specific error message */
  491 alvherre@kurilemu.de     2754         [ +  + ]:            312 :                     if ($4 & CAS_NOT_VALID)
                               2755         [ +  - ]:              8 :                         ereport(ERROR,
                               2756                 :                :                                 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               2757                 :                :                                 errmsg("constraints cannot be altered to be NOT VALID"),
                               2758                 :                :                                 parser_errposition(@4));
  611 alvherre@alvh.no-ip.     2759                 :            304 :                     processCASbits($4, @4, "FOREIGN KEY",
                               2760                 :                :                                     &c->deferrable,
                               2761                 :                :                                     &c->initdeferred,
                               2762                 :                :                                     &c->is_enforced,
                               2763                 :                :                                     NULL,
                               2764                 :                :                                     &c->noinherit,
                               2765                 :                :                                     yyscanner);
 1637 peter@eisentraut.org     2766                 :            304 :                     $$ = (Node *) n;
                               2767                 :                :                 }
                               2768                 :                :             /* ALTER TABLE <name> ALTER CONSTRAINT INHERIT */
                               2769                 :                :             | ALTER CONSTRAINT name INHERIT
                               2770                 :                :                 {
  610 alvherre@alvh.no-ip.     2771                 :             44 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2772                 :             44 :                     ATAlterConstraint *c = makeNode(ATAlterConstraint);
                               2773                 :                : 
                               2774                 :             44 :                     n->subtype = AT_AlterConstraint;
                               2775                 :             44 :                     n->def = (Node *) c;
                               2776                 :             44 :                     c->conname = $3;
                               2777                 :             44 :                     c->alterInheritability = true;
                               2778                 :             44 :                     c->noinherit = false;
                               2779                 :                : 
                               2780                 :             44 :                     $$ = (Node *) n;
                               2781                 :                :                 }
                               2782                 :                :             /* ALTER TABLE <name> VALIDATE CONSTRAINT ... */
                               2783                 :                :             | VALIDATE CONSTRAINT name
                               2784                 :                :                 {
 5749 simon@2ndQuadrant.co     2785                 :            292 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2786                 :                : 
                               2787                 :            292 :                     n->subtype = AT_ValidateConstraint;
                               2788                 :            292 :                     n->name = $3;
 1637 peter@eisentraut.org     2789                 :            292 :                     $$ = (Node *) n;
                               2790                 :                :                 }
                               2791                 :                :             /* ALTER TABLE <name> DROP CONSTRAINT IF EXISTS <name> [RESTRICT|CASCADE] */
                               2792                 :                :             | DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
                               2793                 :                :                 {
 6317 andrew@dunslane.net      2794                 :             12 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2795                 :                : 
                               2796                 :             12 :                     n->subtype = AT_DropConstraint;
                               2797                 :             12 :                     n->name = $5;
                               2798                 :             12 :                     n->behavior = $6;
 3368 peter_e@gmx.net          2799                 :             12 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     2800                 :             12 :                     $$ = (Node *) n;
                               2801                 :                :                 }
                               2802                 :                :             /* ALTER TABLE <name> DROP CONSTRAINT <name> [RESTRICT|CASCADE] */
                               2803                 :                :             | DROP CONSTRAINT name opt_drop_behavior
                               2804                 :                :                 {
 8219 tgl@sss.pgh.pa.us        2805                 :            567 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2806                 :                : 
                               2807                 :            567 :                     n->subtype = AT_DropConstraint;
                               2808                 :            567 :                     n->name = $3;
                               2809                 :            567 :                     n->behavior = $4;
 3368 peter_e@gmx.net          2810                 :            567 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     2811                 :            567 :                     $$ = (Node *) n;
                               2812                 :                :                 }
                               2813                 :                :             /* ALTER TABLE <name> SET WITHOUT OIDS, for backward compat */
                               2814                 :                :             | SET WITHOUT OIDS
                               2815                 :                :                 {
 8219 tgl@sss.pgh.pa.us        2816                 :              4 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2817                 :                : 
                               2818                 :              4 :                     n->subtype = AT_DropOids;
 1637 peter@eisentraut.org     2819                 :              4 :                     $$ = (Node *) n;
                               2820                 :                :                 }
                               2821                 :                :             /* ALTER TABLE <name> CLUSTER ON <indexname> */
                               2822                 :                :             | CLUSTER ON name
                               2823                 :                :                 {
 8219 tgl@sss.pgh.pa.us        2824                 :             31 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2825                 :                : 
                               2826                 :             31 :                     n->subtype = AT_ClusterOn;
                               2827                 :             31 :                     n->name = $3;
 1637 peter@eisentraut.org     2828                 :             31 :                     $$ = (Node *) n;
                               2829                 :                :                 }
                               2830                 :                :             /* ALTER TABLE <name> SET WITHOUT CLUSTER */
                               2831                 :                :             | SET WITHOUT CLUSTER
                               2832                 :                :                 {
 8191 bruce@momjian.us         2833                 :             12 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2834                 :                : 
                               2835                 :             12 :                     n->subtype = AT_DropCluster;
                               2836                 :             12 :                     n->name = NULL;
 1637 peter@eisentraut.org     2837                 :             12 :                     $$ = (Node *) n;
                               2838                 :                :                 }
                               2839                 :                :             /* ALTER TABLE <name> SET LOGGED */
                               2840                 :                :             | SET LOGGED
                               2841                 :                :                 {
 4458 alvherre@alvh.no-ip.     2842                 :             34 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2843                 :                : 
                               2844                 :             34 :                     n->subtype = AT_SetLogged;
 1637 peter@eisentraut.org     2845                 :             34 :                     $$ = (Node *) n;
                               2846                 :                :                 }
                               2847                 :                :             /* ALTER TABLE <name> SET UNLOGGED */
                               2848                 :                :             | SET UNLOGGED
                               2849                 :                :                 {
 4458 alvherre@alvh.no-ip.     2850                 :             45 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2851                 :                : 
                               2852                 :             45 :                     n->subtype = AT_SetUnLogged;
 1637 peter@eisentraut.org     2853                 :             45 :                     $$ = (Node *) n;
                               2854                 :                :                 }
                               2855                 :                :             /* ALTER TABLE <name> ENABLE TRIGGER <trig> */
                               2856                 :                :             | ENABLE_P TRIGGER name
                               2857                 :                :                 {
 7744 tgl@sss.pgh.pa.us        2858                 :             65 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2859                 :                : 
                               2860                 :             65 :                     n->subtype = AT_EnableTrig;
                               2861                 :             65 :                     n->name = $3;
 1637 peter@eisentraut.org     2862                 :             65 :                     $$ = (Node *) n;
                               2863                 :                :                 }
                               2864                 :                :             /* ALTER TABLE <name> ENABLE ALWAYS TRIGGER <trig> */
                               2865                 :                :             | ENABLE_P ALWAYS TRIGGER name
                               2866                 :                :                 {
 7171 JanWieck@Yahoo.com       2867                 :             27 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2868                 :                : 
                               2869                 :             27 :                     n->subtype = AT_EnableAlwaysTrig;
                               2870                 :             27 :                     n->name = $4;
 1637 peter@eisentraut.org     2871                 :             27 :                     $$ = (Node *) n;
                               2872                 :                :                 }
                               2873                 :                :             /* ALTER TABLE <name> ENABLE REPLICA TRIGGER <trig> */
                               2874                 :                :             | ENABLE_P REPLICA TRIGGER name
                               2875                 :                :                 {
 7171 JanWieck@Yahoo.com       2876                 :              8 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2877                 :                : 
                               2878                 :              8 :                     n->subtype = AT_EnableReplicaTrig;
                               2879                 :              8 :                     n->name = $4;
 1637 peter@eisentraut.org     2880                 :              8 :                     $$ = (Node *) n;
                               2881                 :                :                 }
                               2882                 :                :             /* ALTER TABLE <name> ENABLE TRIGGER ALL */
                               2883                 :                :             | ENABLE_P TRIGGER ALL
                               2884                 :                :                 {
 7744 tgl@sss.pgh.pa.us        2885                 :UBC           0 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2886                 :                : 
                               2887                 :              0 :                     n->subtype = AT_EnableTrigAll;
 1637 peter@eisentraut.org     2888                 :              0 :                     $$ = (Node *) n;
                               2889                 :                :                 }
                               2890                 :                :             /* ALTER TABLE <name> ENABLE TRIGGER USER */
                               2891                 :                :             | ENABLE_P TRIGGER USER
                               2892                 :                :                 {
 7744 tgl@sss.pgh.pa.us        2893                 :              0 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2894                 :                : 
                               2895                 :              0 :                     n->subtype = AT_EnableTrigUser;
 1637 peter@eisentraut.org     2896                 :              0 :                     $$ = (Node *) n;
                               2897                 :                :                 }
                               2898                 :                :             /* ALTER TABLE <name> DISABLE TRIGGER <trig> */
                               2899                 :                :             | DISABLE_P TRIGGER name
                               2900                 :                :                 {
 7744 tgl@sss.pgh.pa.us        2901                 :CBC          75 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2902                 :                : 
                               2903                 :             75 :                     n->subtype = AT_DisableTrig;
                               2904                 :             75 :                     n->name = $3;
 1637 peter@eisentraut.org     2905                 :             75 :                     $$ = (Node *) n;
                               2906                 :                :                 }
                               2907                 :                :             /* ALTER TABLE <name> DISABLE TRIGGER ALL */
                               2908                 :                :             | DISABLE_P TRIGGER ALL
                               2909                 :                :                 {
 7744 tgl@sss.pgh.pa.us        2910                 :              8 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2911                 :                : 
                               2912                 :              8 :                     n->subtype = AT_DisableTrigAll;
 1637 peter@eisentraut.org     2913                 :              8 :                     $$ = (Node *) n;
                               2914                 :                :                 }
                               2915                 :                :             /* ALTER TABLE <name> DISABLE TRIGGER USER */
                               2916                 :                :             | DISABLE_P TRIGGER USER
                               2917                 :                :                 {
 7744 tgl@sss.pgh.pa.us        2918                 :              8 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2919                 :                : 
                               2920                 :              8 :                     n->subtype = AT_DisableTrigUser;
 1637 peter@eisentraut.org     2921                 :              8 :                     $$ = (Node *) n;
                               2922                 :                :                 }
                               2923                 :                :             /* ALTER TABLE <name> ENABLE RULE <rule> */
                               2924                 :                :             | ENABLE_P RULE name
                               2925                 :                :                 {
 7171 JanWieck@Yahoo.com       2926                 :              5 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2927                 :                : 
                               2928                 :              5 :                     n->subtype = AT_EnableRule;
                               2929                 :              5 :                     n->name = $3;
 1637 peter@eisentraut.org     2930                 :              5 :                     $$ = (Node *) n;
                               2931                 :                :                 }
                               2932                 :                :             /* ALTER TABLE <name> ENABLE ALWAYS RULE <rule> */
                               2933                 :                :             | ENABLE_P ALWAYS RULE name
                               2934                 :                :                 {
 7171 JanWieck@Yahoo.com       2935                 :UBC           0 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2936                 :                : 
                               2937                 :              0 :                     n->subtype = AT_EnableAlwaysRule;
                               2938                 :              0 :                     n->name = $4;
 1637 peter@eisentraut.org     2939                 :              0 :                     $$ = (Node *) n;
                               2940                 :                :                 }
                               2941                 :                :             /* ALTER TABLE <name> ENABLE REPLICA RULE <rule> */
                               2942                 :                :             | ENABLE_P REPLICA RULE name
                               2943                 :                :                 {
 7171 JanWieck@Yahoo.com       2944                 :CBC           4 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2945                 :                : 
                               2946                 :              4 :                     n->subtype = AT_EnableReplicaRule;
                               2947                 :              4 :                     n->name = $4;
 1637 peter@eisentraut.org     2948                 :              4 :                     $$ = (Node *) n;
                               2949                 :                :                 }
                               2950                 :                :             /* ALTER TABLE <name> DISABLE RULE <rule> */
                               2951                 :                :             | DISABLE_P RULE name
                               2952                 :                :                 {
 7171 JanWieck@Yahoo.com       2953                 :             20 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2954                 :                : 
                               2955                 :             20 :                     n->subtype = AT_DisableRule;
                               2956                 :             20 :                     n->name = $3;
 1637 peter@eisentraut.org     2957                 :             20 :                     $$ = (Node *) n;
                               2958                 :                :                 }
                               2959                 :                :             /* ALTER TABLE <name> INHERIT <parent> */
                               2960                 :                :             | INHERIT qualified_name
                               2961                 :                :                 {
 7431 bruce@momjian.us         2962                 :            305 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2963                 :                : 
 7328 tgl@sss.pgh.pa.us        2964                 :            305 :                     n->subtype = AT_AddInherit;
                               2965                 :            305 :                     n->def = (Node *) $2;
 1637 peter@eisentraut.org     2966                 :            305 :                     $$ = (Node *) n;
                               2967                 :                :                 }
                               2968                 :                :             /* ALTER TABLE <name> NO INHERIT <parent> */
                               2969                 :                :             | NO INHERIT qualified_name
                               2970                 :                :                 {
 7431 bruce@momjian.us         2971                 :             73 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2972                 :                : 
 7328 tgl@sss.pgh.pa.us        2973                 :             73 :                     n->subtype = AT_DropInherit;
                               2974                 :             73 :                     n->def = (Node *) $3;
 1637 peter@eisentraut.org     2975                 :             73 :                     $$ = (Node *) n;
                               2976                 :                :                 }
                               2977                 :                :             /* ALTER TABLE <name> OF <type_name> */
                               2978                 :                :             | OF any_name
                               2979                 :                :                 {
 5678 rhaas@postgresql.org     2980                 :             50 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
 1637 peter@eisentraut.org     2981                 :             50 :                     TypeName   *def = makeTypeNameFromNameList($2);
                               2982                 :                : 
 5678 rhaas@postgresql.org     2983                 :             50 :                     def->location = @2;
                               2984                 :             50 :                     n->subtype = AT_AddOf;
                               2985                 :             50 :                     n->def = (Node *) def;
 1637 peter@eisentraut.org     2986                 :             50 :                     $$ = (Node *) n;
                               2987                 :                :                 }
                               2988                 :                :             /* ALTER TABLE <name> NOT OF */
                               2989                 :                :             | NOT OF
                               2990                 :                :                 {
 5678 rhaas@postgresql.org     2991                 :              4 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               2992                 :                : 
                               2993                 :              4 :                     n->subtype = AT_DropOf;
 1637 peter@eisentraut.org     2994                 :              4 :                     $$ = (Node *) n;
                               2995                 :                :                 }
                               2996                 :                :             /* ALTER TABLE <name> OWNER TO RoleSpec */
                               2997                 :                :             | OWNER TO RoleSpec
                               2998                 :                :                 {
 8112 bruce@momjian.us         2999                 :           1153 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3000                 :                : 
                               3001                 :           1153 :                     n->subtype = AT_ChangeOwner;
 4259 alvherre@alvh.no-ip.     3002                 :           1153 :                     n->newowner = $3;
 1637 peter@eisentraut.org     3003                 :           1153 :                     $$ = (Node *) n;
                               3004                 :                :                 }
                               3005                 :                :             /* ALTER TABLE <name> SET ACCESS METHOD { <amname> | DEFAULT } */
                               3006                 :                :             | SET ACCESS METHOD set_access_method_name
                               3007                 :                :                 {
 1926 michael@paquier.xyz      3008                 :             85 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3009                 :                : 
                               3010                 :             85 :                     n->subtype = AT_SetAccessMethod;
                               3011                 :             85 :                     n->name = $4;
 1637 peter@eisentraut.org     3012                 :             85 :                     $$ = (Node *) n;
                               3013                 :                :                 }
                               3014                 :                :             /* ALTER TABLE <name> SET TABLESPACE <tablespacename> */
                               3015                 :                :             | SET TABLESPACE name
                               3016                 :                :                 {
 8152 tgl@sss.pgh.pa.us        3017                 :             79 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3018                 :                : 
                               3019                 :             79 :                     n->subtype = AT_SetTableSpace;
                               3020                 :             79 :                     n->name = $3;
 1637 peter@eisentraut.org     3021                 :             79 :                     $$ = (Node *) n;
                               3022                 :                :                 }
                               3023                 :                :             /* ALTER TABLE <name> SET (...) */
                               3024                 :                :             | SET reloptions
                               3025                 :                :                 {
 7431 bruce@momjian.us         3026                 :            418 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3027                 :                : 
 7430 tgl@sss.pgh.pa.us        3028                 :            418 :                     n->subtype = AT_SetRelOptions;
 1637 peter@eisentraut.org     3029                 :            418 :                     n->def = (Node *) $2;
                               3030                 :            418 :                     $$ = (Node *) n;
                               3031                 :                :                 }
                               3032                 :                :             /* ALTER TABLE <name> RESET (...) */
                               3033                 :                :             | RESET reloptions
                               3034                 :                :                 {
 7430 tgl@sss.pgh.pa.us        3035                 :            123 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3036                 :                : 
                               3037                 :            123 :                     n->subtype = AT_ResetRelOptions;
 1637 peter@eisentraut.org     3038                 :            123 :                     n->def = (Node *) $2;
                               3039                 :            123 :                     $$ = (Node *) n;
                               3040                 :                :                 }
                               3041                 :                :             /* ALTER TABLE <name> REPLICA IDENTITY */
                               3042                 :                :             | REPLICA IDENTITY_P replica_identity
                               3043                 :                :                 {
 4745 rhaas@postgresql.org     3044                 :            322 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3045                 :                : 
                               3046                 :            322 :                     n->subtype = AT_ReplicaIdentity;
                               3047                 :            322 :                     n->def = $3;
 1637 peter@eisentraut.org     3048                 :            322 :                     $$ = (Node *) n;
                               3049                 :                :                 }
                               3050                 :                :             /* ALTER TABLE <name> ENABLE ROW LEVEL SECURITY */
                               3051                 :                :             | ENABLE_P ROW LEVEL SECURITY
                               3052                 :                :                 {
 4430 sfrost@snowman.net       3053                 :            250 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3054                 :                : 
                               3055                 :            250 :                     n->subtype = AT_EnableRowSecurity;
 1637 peter@eisentraut.org     3056                 :            250 :                     $$ = (Node *) n;
                               3057                 :                :                 }
                               3058                 :                :             /* ALTER TABLE <name> DISABLE ROW LEVEL SECURITY */
                               3059                 :                :             | DISABLE_P ROW LEVEL SECURITY
                               3060                 :                :                 {
 4430 sfrost@snowman.net       3061                 :              6 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3062                 :                : 
                               3063                 :              6 :                     n->subtype = AT_DisableRowSecurity;
 1637 peter@eisentraut.org     3064                 :              6 :                     $$ = (Node *) n;
                               3065                 :                :                 }
                               3066                 :                :             /* ALTER TABLE <name> FORCE ROW LEVEL SECURITY */
                               3067                 :                :             | FORCE ROW LEVEL SECURITY
                               3068                 :                :                 {
 4050 sfrost@snowman.net       3069                 :             65 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3070                 :                : 
                               3071                 :             65 :                     n->subtype = AT_ForceRowSecurity;
 1637 peter@eisentraut.org     3072                 :             65 :                     $$ = (Node *) n;
                               3073                 :                :                 }
                               3074                 :                :             /* ALTER TABLE <name> NO FORCE ROW LEVEL SECURITY */
                               3075                 :                :             | NO FORCE ROW LEVEL SECURITY
                               3076                 :                :                 {
 4050 sfrost@snowman.net       3077                 :             20 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3078                 :                : 
                               3079                 :             20 :                     n->subtype = AT_NoForceRowSecurity;
 1637 peter@eisentraut.org     3080                 :             20 :                     $$ = (Node *) n;
                               3081                 :                :                 }
                               3082                 :                :             | alter_generic_options
                               3083                 :                :                 {
 5787 rhaas@postgresql.org     3084                 :             38 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3085                 :                : 
                               3086                 :             38 :                     n->subtype = AT_GenericOptions;
 1637 peter@eisentraut.org     3087                 :             38 :                     n->def = (Node *) $1;
 5787 rhaas@postgresql.org     3088                 :             38 :                     $$ = (Node *) n;
                               3089                 :                :                 }
                               3090                 :                :         ;
                               3091                 :                : 
                               3092                 :                : alter_column_default:
 6947 tgl@sss.pgh.pa.us        3093                 :            250 :             SET DEFAULT a_expr          { $$ = $3; }
 8219                          3094                 :            124 :             | DROP DEFAULT              { $$ = NULL; }
                               3095                 :                :         ;
                               3096                 :                : 
                               3097                 :                : opt_collate_clause:
                               3098                 :                :             COLLATE any_name
                               3099                 :                :                 {
 5720                          3100                 :             12 :                     CollateClause *n = makeNode(CollateClause);
                               3101                 :                : 
                               3102                 :             12 :                     n->arg = NULL;
 5718                          3103                 :             12 :                     n->collname = $2;
 5720                          3104                 :             12 :                     n->location = @1;
                               3105                 :             12 :                     $$ = (Node *) n;
                               3106                 :                :                 }
                               3107                 :           3135 :             | /* EMPTY */               { $$ = NULL; }
                               3108                 :                :         ;
                               3109                 :                : 
                               3110                 :                : alter_using:
 8219                          3111                 :            119 :             USING a_expr                { $$ = $2; }
                               3112                 :            646 :             | /* EMPTY */               { $$ = NULL; }
                               3113                 :                :         ;
                               3114                 :                : 
                               3115                 :                : replica_identity:
                               3116                 :                :             NOTHING
                               3117                 :                :                 {
 4745 rhaas@postgresql.org     3118                 :             30 :                     ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
                               3119                 :                : 
                               3120                 :             30 :                     n->identity_type = REPLICA_IDENTITY_NOTHING;
                               3121                 :             30 :                     n->name = NULL;
                               3122                 :             30 :                     $$ = (Node *) n;
                               3123                 :                :                 }
                               3124                 :                :             | FULL
                               3125                 :                :                 {
                               3126                 :            101 :                     ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
                               3127                 :                : 
                               3128                 :            101 :                     n->identity_type = REPLICA_IDENTITY_FULL;
                               3129                 :            101 :                     n->name = NULL;
                               3130                 :            101 :                     $$ = (Node *) n;
                               3131                 :                :                 }
                               3132                 :                :             | DEFAULT
                               3133                 :                :                 {
                               3134                 :              5 :                     ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
                               3135                 :                : 
                               3136                 :              5 :                     n->identity_type = REPLICA_IDENTITY_DEFAULT;
                               3137                 :              5 :                     n->name = NULL;
                               3138                 :              5 :                     $$ = (Node *) n;
                               3139                 :                :                 }
                               3140                 :                :             | USING INDEX name
                               3141                 :                :                 {
                               3142                 :            186 :                     ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
                               3143                 :                : 
                               3144                 :            186 :                     n->identity_type = REPLICA_IDENTITY_INDEX;
                               3145                 :            186 :                     n->name = $3;
                               3146                 :            186 :                     $$ = (Node *) n;
                               3147                 :                :                 }
                               3148                 :                : ;
                               3149                 :                : 
                               3150                 :                : reloptions:
 5483 peter_e@gmx.net          3151                 :           1981 :             '(' reloption_list ')'                  { $$ = $2; }
                               3152                 :                :         ;
                               3153                 :                : 
 6485 alvherre@alvh.no-ip.     3154                 :            613 : opt_reloptions:     WITH reloptions                 { $$ = $2; }
                               3155                 :          15233 :              |      /* EMPTY */                     { $$ = NIL; }
                               3156                 :                :         ;
                               3157                 :                : 
                               3158                 :                : reloption_list:
                               3159                 :           1981 :             reloption_elem                          { $$ = list_make1($1); }
                               3160                 :            183 :             | reloption_list ',' reloption_elem     { $$ = lappend($1, $3); }
                               3161                 :                :         ;
                               3162                 :                : 
                               3163                 :                : /* This should match def_elem and also allow qualified names */
                               3164                 :                : reloption_elem:
                               3165                 :                :             ColLabel '=' def_arg
                               3166                 :                :                 {
 3712 peter_e@gmx.net          3167                 :           1725 :                     $$ = makeDefElem($1, (Node *) $3, @1);
                               3168                 :                :                 }
                               3169                 :                :             | ColLabel
                               3170                 :                :                 {
                               3171                 :            383 :                     $$ = makeDefElem($1, NULL, @1);
                               3172                 :                :                 }
                               3173                 :                :             | ColLabel '.' ColLabel '=' def_arg
                               3174                 :                :                 {
 6424 tgl@sss.pgh.pa.us        3175                 :             52 :                     $$ = makeDefElemExtended($1, $3, (Node *) $5,
 3712 peter_e@gmx.net          3176                 :             52 :                                              DEFELEM_UNSPEC, @1);
                               3177                 :                :                 }
                               3178                 :                :             | ColLabel '.' ColLabel
                               3179                 :                :                 {
                               3180                 :              4 :                     $$ = makeDefElemExtended($1, $3, NULL, DEFELEM_UNSPEC, @1);
                               3181                 :                :                 }
                               3182                 :                :         ;
                               3183                 :                : 
                               3184                 :                : alter_identity_column_option_list:
                               3185                 :                :             alter_identity_column_option
 3500                          3186                 :             41 :                 { $$ = list_make1($1); }
                               3187                 :                :             | alter_identity_column_option_list alter_identity_column_option
                               3188                 :             40 :                 { $$ = lappend($1, $2); }
                               3189                 :                :         ;
                               3190                 :                : 
                               3191                 :                : alter_identity_column_option:
                               3192                 :                :             RESTART
                               3193                 :                :                 {
                               3194                 :             16 :                     $$ = makeDefElem("restart", NULL, @1);
                               3195                 :                :                 }
                               3196                 :                :             | RESTART opt_with NumericOnly
                               3197                 :                :                 {
 1637 peter@eisentraut.org     3198                 :UBC           0 :                     $$ = makeDefElem("restart", (Node *) $3, @1);
                               3199                 :                :                 }
                               3200                 :                :             | SET SeqOptElem
                               3201                 :                :                 {
 3500 peter_e@gmx.net          3202         [ +  - ]:CBC          36 :                     if (strcmp($2->defname, "as") == 0 ||
                               3203         [ +  - ]:             36 :                         strcmp($2->defname, "restart") == 0 ||
                               3204         [ -  + ]:             36 :                         strcmp($2->defname, "owned_by") == 0)
 3500 peter_e@gmx.net          3205         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               3206                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               3207                 :                :                                  errmsg("sequence option \"%s\" not supported here", $2->defname),
                               3208                 :                :                                  parser_errposition(@2)));
 3500 peter_e@gmx.net          3209                 :CBC          36 :                     $$ = $2;
                               3210                 :                :                 }
                               3211                 :                :             | SET GENERATED generated_when
                               3212                 :                :                 {
                               3213                 :             29 :                     $$ = makeDefElem("generated", (Node *) makeInteger($3), @1);
                               3214                 :                :                 }
                               3215                 :                :         ;
                               3216                 :                : 
                               3217                 :                : set_statistics_value:
 1027 peter@eisentraut.org     3218                 :            107 :             SignedIconst                    { $$ = (Node *) makeInteger($1); }
                               3219                 :              2 :             | DEFAULT                       { $$ = NULL; }
                               3220                 :                :         ;
                               3221                 :                : 
                               3222                 :                : set_access_method_name:
  972 michael@paquier.xyz      3223                 :             61 :             ColId                           { $$ = $1; }
                               3224                 :             24 :             | DEFAULT                       { $$ = NULL; }
                               3225                 :                :         ;
                               3226                 :                : 
                               3227                 :                : PartitionBoundSpec:
                               3228                 :                :             /* a HASH partition */
                               3229                 :                :             FOR VALUES WITH '(' hash_partbound ')'
                               3230                 :                :                 {
                               3231                 :                :                     ListCell   *lc;
 3283 rhaas@postgresql.org     3232                 :            472 :                     PartitionBoundSpec *n = makeNode(PartitionBoundSpec);
                               3233                 :                : 
                               3234                 :            472 :                     n->strategy = PARTITION_STRATEGY_HASH;
                               3235                 :            472 :                     n->modulus = n->remainder = -1;
                               3236                 :                : 
                               3237   [ +  -  +  +  :           1416 :                     foreach (lc, $5)
                                              +  + ]
                               3238                 :                :                     {
                               3239                 :            944 :                         DefElem    *opt = lfirst_node(DefElem, lc);
                               3240                 :                : 
                               3241         [ +  + ]:            944 :                         if (strcmp(opt->defname, "modulus") == 0)
                               3242                 :                :                         {
                               3243         [ -  + ]:            472 :                             if (n->modulus != -1)
 3283 rhaas@postgresql.org     3244         [ #  # ]:UBC           0 :                                 ereport(ERROR,
                               3245                 :                :                                         (errcode(ERRCODE_DUPLICATE_OBJECT),
                               3246                 :                :                                          errmsg("modulus for hash partition provided more than once"),
                               3247                 :                :                                          parser_errposition(opt->location)));
 3283 rhaas@postgresql.org     3248                 :CBC         472 :                             n->modulus = defGetInt32(opt);
                               3249                 :                :                         }
                               3250         [ +  - ]:            472 :                         else if (strcmp(opt->defname, "remainder") == 0)
                               3251                 :                :                         {
                               3252         [ -  + ]:            472 :                             if (n->remainder != -1)
 3283 rhaas@postgresql.org     3253         [ #  # ]:UBC           0 :                                 ereport(ERROR,
                               3254                 :                :                                         (errcode(ERRCODE_DUPLICATE_OBJECT),
                               3255                 :                :                                          errmsg("remainder for hash partition provided more than once"),
                               3256                 :                :                                          parser_errposition(opt->location)));
 3283 rhaas@postgresql.org     3257                 :CBC         472 :                             n->remainder = defGetInt32(opt);
                               3258                 :                :                         }
                               3259                 :                :                         else
 3283 rhaas@postgresql.org     3260         [ #  # ]:UBC           0 :                             ereport(ERROR,
                               3261                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                               3262                 :                :                                      errmsg("unrecognized hash partition bound specification \"%s\"",
                               3263                 :                :                                             opt->defname),
                               3264                 :                :                                      parser_errposition(opt->location)));
                               3265                 :                :                     }
                               3266                 :                : 
 3283 rhaas@postgresql.org     3267         [ -  + ]:CBC         472 :                     if (n->modulus == -1)
 3283 rhaas@postgresql.org     3268         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               3269                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               3270                 :                :                                  errmsg("modulus for hash partition must be specified"),
                               3271                 :                :                                  parser_errposition(@3)));
 3283 rhaas@postgresql.org     3272         [ -  + ]:CBC         472 :                     if (n->remainder == -1)
 3283 rhaas@postgresql.org     3273         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               3274                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               3275                 :                :                                  errmsg("remainder for hash partition must be specified"),
                               3276                 :                :                                  parser_errposition(@3)));
                               3277                 :                : 
 3283 rhaas@postgresql.org     3278                 :CBC         472 :                     n->location = @3;
                               3279                 :                : 
                               3280                 :            472 :                     $$ = n;
                               3281                 :                :                 }
                               3282                 :                : 
                               3283                 :                :             /* a LIST partition */
                               3284                 :                :             | FOR VALUES IN_P '(' expr_list ')'
                               3285                 :                :                 {
 3620                          3286                 :           3161 :                     PartitionBoundSpec *n = makeNode(PartitionBoundSpec);
                               3287                 :                : 
                               3288                 :           3161 :                     n->strategy = PARTITION_STRATEGY_LIST;
 3345                          3289                 :           3161 :                     n->is_default = false;
 3620                          3290                 :           3161 :                     n->listdatums = $5;
                               3291                 :           3161 :                     n->location = @3;
                               3292                 :                : 
 3448 tgl@sss.pgh.pa.us        3293                 :           3161 :                     $$ = n;
                               3294                 :                :                 }
                               3295                 :                : 
                               3296                 :                :             /* a RANGE partition */
                               3297                 :                :             | FOR VALUES FROM '(' expr_list ')' TO '(' expr_list ')'
                               3298                 :                :                 {
 3620 rhaas@postgresql.org     3299                 :           3546 :                     PartitionBoundSpec *n = makeNode(PartitionBoundSpec);
                               3300                 :                : 
                               3301                 :           3546 :                     n->strategy = PARTITION_STRATEGY_RANGE;
 3345                          3302                 :           3546 :                     n->is_default = false;
 3620                          3303                 :           3546 :                     n->lowerdatums = $5;
                               3304                 :           3546 :                     n->upperdatums = $9;
                               3305                 :           3546 :                     n->location = @3;
                               3306                 :                : 
 3345                          3307                 :           3546 :                     $$ = n;
                               3308                 :                :                 }
                               3309                 :                : 
                               3310                 :                :             /* a DEFAULT partition */
                               3311                 :                :             | DEFAULT
                               3312                 :                :                 {
                               3313                 :            426 :                     PartitionBoundSpec *n = makeNode(PartitionBoundSpec);
                               3314                 :                : 
                               3315                 :            426 :                     n->is_default = true;
                               3316                 :            426 :                     n->location = @1;
                               3317                 :                : 
 3448 tgl@sss.pgh.pa.us        3318                 :            426 :                     $$ = n;
                               3319                 :                :                 }
                               3320                 :                :         ;
                               3321                 :                : 
                               3322                 :                : hash_partbound_elem:
                               3323                 :                :         NonReservedWord Iconst
                               3324                 :                :             {
 1637 peter@eisentraut.org     3325                 :            944 :                 $$ = makeDefElem($1, (Node *) makeInteger($2), @1);
                               3326                 :                :             }
                               3327                 :                :         ;
                               3328                 :                : 
                               3329                 :                : hash_partbound:
                               3330                 :                :         hash_partbound_elem
                               3331                 :                :             {
 3283 rhaas@postgresql.org     3332                 :            472 :                 $$ = list_make1($1);
                               3333                 :                :             }
                               3334                 :                :         | hash_partbound ',' hash_partbound_elem
                               3335                 :                :             {
                               3336                 :            472 :                 $$ = lappend($1, $3);
                               3337                 :                :             }
                               3338                 :                :         ;
                               3339                 :                : 
                               3340                 :                : /*****************************************************************************
                               3341                 :                :  *
                               3342                 :                :  *  ALTER TYPE
                               3343                 :                :  *
                               3344                 :                :  * really variants of the ALTER TABLE subcommands with different spellings
                               3345                 :                :  *****************************************************************************/
                               3346                 :                : 
                               3347                 :                : AlterCompositeTypeStmt:
                               3348                 :                :             ALTER TYPE_P any_name alter_type_cmds
                               3349                 :                :                 {
 5884 peter_e@gmx.net          3350                 :            145 :                     AlterTableStmt *n = makeNode(AlterTableStmt);
                               3351                 :                : 
                               3352                 :                :                     /* can't use qualified_name, sigh */
                               3353                 :            145 :                     n->relation = makeRangeVarFromAnyName($3, @3, yyscanner);
                               3354                 :            145 :                     n->cmds = $4;
 2308 michael@paquier.xyz      3355                 :            145 :                     n->objtype = OBJECT_TYPE;
 1637 peter@eisentraut.org     3356                 :            145 :                     $$ = (Node *) n;
                               3357                 :                :                 }
                               3358                 :                :             ;
                               3359                 :                : 
                               3360                 :                : alter_type_cmds:
 5884 peter_e@gmx.net          3361                 :            145 :             alter_type_cmd                          { $$ = list_make1($1); }
                               3362                 :              8 :             | alter_type_cmds ',' alter_type_cmd    { $$ = lappend($1, $3); }
                               3363                 :                :         ;
                               3364                 :                : 
                               3365                 :                : alter_type_cmd:
                               3366                 :                :             /* ALTER TYPE <name> ADD ATTRIBUTE <coldef> [RESTRICT|CASCADE] */
                               3367                 :                :             ADD_P ATTRIBUTE TableFuncElement opt_drop_behavior
                               3368                 :                :                 {
                               3369                 :             46 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3370                 :                : 
                               3371                 :             46 :                     n->subtype = AT_AddColumn;
                               3372                 :             46 :                     n->def = $3;
 5826                          3373                 :             46 :                     n->behavior = $4;
 1637 peter@eisentraut.org     3374                 :             46 :                     $$ = (Node *) n;
                               3375                 :                :                 }
                               3376                 :                :             /* ALTER TYPE <name> DROP ATTRIBUTE IF EXISTS <attname> [RESTRICT|CASCADE] */
                               3377                 :                :             | DROP ATTRIBUTE IF_P EXISTS ColId opt_drop_behavior
                               3378                 :                :                 {
 5884 peter_e@gmx.net          3379                 :              4 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3380                 :                : 
                               3381                 :              4 :                     n->subtype = AT_DropColumn;
                               3382                 :              4 :                     n->name = $5;
 5826                          3383                 :              4 :                     n->behavior = $6;
 3368                          3384                 :              4 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     3385                 :              4 :                     $$ = (Node *) n;
                               3386                 :                :                 }
                               3387                 :                :             /* ALTER TYPE <name> DROP ATTRIBUTE <attname> [RESTRICT|CASCADE] */
                               3388                 :                :             | DROP ATTRIBUTE ColId opt_drop_behavior
                               3389                 :                :                 {
 5884 peter_e@gmx.net          3390                 :             50 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
                               3391                 :                : 
                               3392                 :             50 :                     n->subtype = AT_DropColumn;
                               3393                 :             50 :                     n->name = $3;
 5826                          3394                 :             50 :                     n->behavior = $4;
 3368                          3395                 :             50 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     3396                 :             50 :                     $$ = (Node *) n;
                               3397                 :                :                 }
                               3398                 :                :             /* ALTER TYPE <name> ALTER ATTRIBUTE <attname> [SET DATA] TYPE <typename> [RESTRICT|CASCADE] */
                               3399                 :                :             | ALTER ATTRIBUTE ColId opt_set_data TYPE_P Typename opt_collate_clause opt_drop_behavior
                               3400                 :                :                 {
 5884 peter_e@gmx.net          3401                 :             53 :                     AlterTableCmd *n = makeNode(AlterTableCmd);
 5720 tgl@sss.pgh.pa.us        3402                 :             53 :                     ColumnDef *def = makeNode(ColumnDef);
                               3403                 :                : 
 5884 peter_e@gmx.net          3404                 :             53 :                     n->subtype = AT_AlterColumnType;
                               3405                 :             53 :                     n->name = $3;
 5720 tgl@sss.pgh.pa.us        3406                 :             53 :                     n->def = (Node *) def;
                               3407                 :             53 :                     n->behavior = $8;
                               3408                 :                :                     /* We only use these fields of the ColumnDef node */
                               3409                 :             53 :                     def->typeName = $6;
                               3410                 :             53 :                     def->collClause = (CollateClause *) $7;
                               3411                 :             53 :                     def->raw_default = NULL;
 4732                          3412                 :             53 :                     def->location = @3;
 1637 peter@eisentraut.org     3413                 :             53 :                     $$ = (Node *) n;
                               3414                 :                :                 }
                               3415                 :                :         ;
                               3416                 :                : 
                               3417                 :                : 
                               3418                 :                : /*****************************************************************************
                               3419                 :                :  *
                               3420                 :                :  *      QUERY :
                               3421                 :                :  *              close <portalname>
                               3422                 :                :  *
                               3423                 :                :  *****************************************************************************/
                               3424                 :                : 
                               3425                 :                : ClosePortalStmt:
                               3426                 :                :             CLOSE cursor_name
                               3427                 :                :                 {
10650 bruce@momjian.us         3428                 :           1195 :                     ClosePortalStmt *n = makeNode(ClosePortalStmt);
                               3429                 :                : 
                               3430                 :           1195 :                     n->portalname = $2;
 1637 peter@eisentraut.org     3431                 :           1195 :                     $$ = (Node *) n;
                               3432                 :                :                 }
                               3433                 :                :             | CLOSE ALL
                               3434                 :                :                 {
 7147 neilc@samurai.com        3435                 :              8 :                     ClosePortalStmt *n = makeNode(ClosePortalStmt);
                               3436                 :                : 
                               3437                 :              8 :                     n->portalname = NULL;
 1637 peter@eisentraut.org     3438                 :              8 :                     $$ = (Node *) n;
                               3439                 :                :                 }
                               3440                 :                :         ;
                               3441                 :                : 
                               3442                 :                : 
                               3443                 :                : /*****************************************************************************
                               3444                 :                :  *
                               3445                 :                :  *      QUERY :
                               3446                 :                :  *              COPY relname [(columnList)] FROM/TO file [WITH] [(options)]
                               3447                 :                :  *              COPY ( query ) TO file  [WITH] [(options)]
                               3448                 :                :  *
                               3449                 :                :  *              where 'query' can be one of:
                               3450                 :                :  *              { SELECT | UPDATE | INSERT | DELETE | MERGE }
                               3451                 :                :  *
                               3452                 :                :  *              and 'file' can be one of:
                               3453                 :                :  *              { PROGRAM 'command' | STDIN | STDOUT | 'filename' }
                               3454                 :                :  *
                               3455                 :                :  *              In the preferred syntax the options are comma-separated
                               3456                 :                :  *              and use generic identifiers instead of keywords.  The pre-9.0
                               3457                 :                :  *              syntax had a hard-wired, space-separated set of options.
                               3458                 :                :  *
                               3459                 :                :  *              Really old syntax, from versions 7.2 and prior:
                               3460                 :                :  *              COPY [ BINARY ] table FROM/TO file
                               3461                 :                :  *                  [ [ USING ] DELIMITERS 'delimiter' ] ]
                               3462                 :                :  *                  [ WITH NULL AS 'null string' ]
                               3463                 :                :  *              This option placement is not supported with COPY (query...).
                               3464                 :                :  *
                               3465                 :                :  *****************************************************************************/
                               3466                 :                : 
                               3467                 :                : CopyStmt:   COPY opt_binary qualified_name opt_column_list
                               3468                 :                :             copy_from opt_program copy_file_name copy_delimiter opt_with
                               3469                 :                :             copy_options where_clause
                               3470                 :                :                 {
10650 bruce@momjian.us         3471                 :           6258 :                     CopyStmt *n = makeNode(CopyStmt);
                               3472                 :                : 
 8995 tgl@sss.pgh.pa.us        3473                 :           6258 :                     n->relation = $3;
 7372                          3474                 :           6258 :                     n->query = NULL;
 8876 bruce@momjian.us         3475                 :           6258 :                     n->attlist = $4;
 2907 andres@anarazel.de       3476                 :           6258 :                     n->is_from = $5;
                               3477                 :           6258 :                     n->is_program = $6;
                               3478                 :           6258 :                     n->filename = $7;
 2847 tomas.vondra@postgre     3479                 :           6258 :                     n->whereClause = $11;
                               3480                 :                : 
 4999 heikki.linnakangas@i     3481   [ +  +  -  + ]:           6258 :                     if (n->is_program && n->filename == NULL)
 4999 heikki.linnakangas@i     3482         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               3483                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               3484                 :                :                                  errmsg("STDIN/STDOUT not allowed with PROGRAM"),
                               3485                 :                :                                  parser_errposition(@8)));
                               3486                 :                : 
 2847 tomas.vondra@postgre     3487   [ +  +  +  + ]:CBC        6258 :                     if (!n->is_from && n->whereClause != NULL)
                               3488         [ +  - ]:              4 :                         ereport(ERROR,
                               3489                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               3490                 :                :                                  errmsg("WHERE clause not allowed with COPY TO"),
                               3491                 :                :                                  errhint("Try the COPY (SELECT ... WHERE ...) TO variant."),
                               3492                 :                :                                  parser_errposition(@11)));
                               3493                 :                : 
 8904 bruce@momjian.us         3494                 :           6254 :                     n->options = NIL;
                               3495                 :                :                     /* Concatenate user-supplied flags */
                               3496         [ +  + ]:           6254 :                     if ($2)
                               3497                 :              8 :                         n->options = lappend(n->options, $2);
 2907 andres@anarazel.de       3498         [ -  + ]:           6254 :                     if ($8)
 2907 andres@anarazel.de       3499                 :UBC           0 :                         n->options = lappend(n->options, $8);
 2907 andres@anarazel.de       3500         [ +  + ]:CBC        6254 :                     if ($10)
                               3501                 :            865 :                         n->options = list_concat(n->options, $10);
 1637 peter@eisentraut.org     3502                 :           6254 :                     $$ = (Node *) n;
                               3503                 :                :                 }
                               3504                 :                :             | COPY '(' PreparableStmt ')' TO opt_program copy_file_name opt_with copy_options
                               3505                 :                :                 {
 7372 tgl@sss.pgh.pa.us        3506                 :            377 :                     CopyStmt *n = makeNode(CopyStmt);
                               3507                 :                : 
                               3508                 :            377 :                     n->relation = NULL;
 3996 teodor@sigaev.ru         3509                 :            377 :                     n->query = $3;
 7372 tgl@sss.pgh.pa.us        3510                 :            377 :                     n->attlist = NIL;
                               3511                 :            377 :                     n->is_from = false;
 3996 teodor@sigaev.ru         3512                 :            377 :                     n->is_program = $6;
                               3513                 :            377 :                     n->filename = $7;
                               3514                 :            377 :                     n->options = $9;
                               3515                 :                : 
 4999 heikki.linnakangas@i     3516   [ -  +  -  - ]:            377 :                     if (n->is_program && n->filename == NULL)
 4999 heikki.linnakangas@i     3517         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               3518                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               3519                 :                :                                  errmsg("STDIN/STDOUT not allowed with PROGRAM"),
                               3520                 :                :                                  parser_errposition(@5)));
                               3521                 :                : 
 1637 peter@eisentraut.org     3522                 :CBC         377 :                     $$ = (Node *) n;
                               3523                 :                :                 }
                               3524                 :                :         ;
                               3525                 :                : 
                               3526                 :                : copy_from:
 3368 peter_e@gmx.net          3527                 :           1260 :             FROM                                    { $$ = true; }
                               3528                 :           4998 :             | TO                                    { $$ = false; }
                               3529                 :                :         ;
                               3530                 :                : 
                               3531                 :                : opt_program:
                               3532                 :              1 :             PROGRAM                                 { $$ = true; }
                               3533                 :           6634 :             | /* EMPTY */                           { $$ = false; }
                               3534                 :                :         ;
                               3535                 :                : 
                               3536                 :                : /*
                               3537                 :                :  * copy_file_name NULL indicates stdio is used. Whether stdin or stdout is
                               3538                 :                :  * used depends on the direction. (It really doesn't make sense to copy from
                               3539                 :                :  * stdout. We silently correct the "typo".)        - AY 9/94
                               3540                 :                :  */
                               3541                 :                : copy_file_name:
 8907 bruce@momjian.us         3542                 :            323 :             Sconst                                  { $$ = $1; }
                               3543                 :            995 :             | STDIN                                 { $$ = NULL; }
                               3544                 :           5317 :             | STDOUT                                { $$ = NULL; }
                               3545                 :                :         ;
                               3546                 :                : 
 6254 tgl@sss.pgh.pa.us        3547                 :           5906 : copy_options: copy_opt_list                         { $$ = $1; }
                               3548                 :            729 :             | '(' copy_generic_opt_list ')'         { $$ = $2; }
                               3549                 :                :         ;
                               3550                 :                : 
                               3551                 :                : /* old COPY option syntax */
                               3552                 :                : copy_opt_list:
 8904 bruce@momjian.us         3553                 :            348 :             copy_opt_list copy_opt_item             { $$ = lappend($1, $2); }
                               3554                 :           5906 :             | /* EMPTY */                           { $$ = NIL; }
                               3555                 :                :         ;
                               3556                 :                : 
                               3557                 :                : copy_opt_item:
                               3558                 :                :             BINARY
                               3559                 :                :                 {
 1637 peter@eisentraut.org     3560                 :UBC           0 :                     $$ = makeDefElem("format", (Node *) makeString("binary"), @1);
                               3561                 :                :                 }
                               3562                 :                :             | FREEZE
                               3563                 :                :                 {
 1637 peter@eisentraut.org     3564                 :CBC          32 :                     $$ = makeDefElem("freeze", (Node *) makeBoolean(true), @1);
                               3565                 :                :                 }
                               3566                 :                :             | DELIMITER opt_as Sconst
                               3567                 :                :                 {
                               3568                 :            120 :                     $$ = makeDefElem("delimiter", (Node *) makeString($3), @1);
                               3569                 :                :                 }
                               3570                 :                :             | NULL_P opt_as Sconst
                               3571                 :                :                 {
                               3572                 :             32 :                     $$ = makeDefElem("null", (Node *) makeString($3), @1);
                               3573                 :                :                 }
                               3574                 :                :             | CSV
                               3575                 :                :                 {
                               3576                 :            100 :                     $$ = makeDefElem("format", (Node *) makeString("csv"), @1);
                               3577                 :                :                 }
                               3578                 :                :             | JSON
                               3579                 :                :                 {
  234 andrew@dunslane.net      3580                 :              8 :                     $$ = makeDefElem("format", (Node *) makeString("json"), @1);
                               3581                 :                :                 }
                               3582                 :                :             | HEADER_P
                               3583                 :                :                 {
 1637 peter@eisentraut.org     3584                 :             12 :                     $$ = makeDefElem("header", (Node *) makeBoolean(true), @1);
                               3585                 :                :                 }
                               3586                 :                :             | QUOTE opt_as Sconst
                               3587                 :                :                 {
                               3588                 :             12 :                     $$ = makeDefElem("quote", (Node *) makeString($3), @1);
                               3589                 :                :                 }
                               3590                 :                :             | ESCAPE opt_as Sconst
                               3591                 :                :                 {
                               3592                 :             12 :                     $$ = makeDefElem("escape", (Node *) makeString($3), @1);
                               3593                 :                :                 }
                               3594                 :                :             | FORCE QUOTE columnList
                               3595                 :                :                 {
                               3596                 :              8 :                     $$ = makeDefElem("force_quote", (Node *) $3, @1);
                               3597                 :                :                 }
                               3598                 :                :             | FORCE QUOTE '*'
                               3599                 :                :                 {
                               3600                 :              4 :                     $$ = makeDefElem("force_quote", (Node *) makeNode(A_Star), @1);
                               3601                 :                :                 }
                               3602                 :                :             | FORCE NOT NULL_P columnList
                               3603                 :                :                 {
 1637 peter@eisentraut.org     3604                 :UBC           0 :                     $$ = makeDefElem("force_not_null", (Node *) $4, @1);
                               3605                 :                :                 }
                               3606                 :                :             | FORCE NOT NULL_P '*'
                               3607                 :                :                 {
 1132 andrew@dunslane.net      3608                 :              0 :                     $$ = makeDefElem("force_not_null", (Node *) makeNode(A_Star), @1);
                               3609                 :                :                 }
                               3610                 :                :             | FORCE NULL_P columnList
                               3611                 :                :                 {
 1637 peter@eisentraut.org     3612                 :              0 :                     $$ = makeDefElem("force_null", (Node *) $3, @1);
                               3613                 :                :                 }
                               3614                 :                :             | FORCE NULL_P '*'
                               3615                 :                :                 {
 1132 andrew@dunslane.net      3616                 :              0 :                     $$ = makeDefElem("force_null", (Node *) makeNode(A_Star), @1);
                               3617                 :                :                 }
                               3618                 :                :             | ENCODING Sconst
                               3619                 :                :                 {
 1637 peter@eisentraut.org     3620                 :CBC           8 :                     $$ = makeDefElem("encoding", (Node *) makeString($2), @1);
                               3621                 :                :                 }
                               3622                 :                :         ;
                               3623                 :                : 
                               3624                 :                : /* The following exist for backward compatibility with very old versions */
                               3625                 :                : 
                               3626                 :                : opt_binary:
                               3627                 :                :             BINARY
                               3628                 :                :                 {
                               3629                 :              8 :                     $$ = makeDefElem("format", (Node *) makeString("binary"), @1);
                               3630                 :                :                 }
 8904 bruce@momjian.us         3631                 :           6250 :             | /*EMPTY*/                             { $$ = NULL; }
                               3632                 :                :         ;
                               3633                 :                : 
                               3634                 :                : copy_delimiter:
                               3635                 :                :             opt_using DELIMITERS Sconst
                               3636                 :                :                 {
 1637 peter@eisentraut.org     3637                 :UBC           0 :                     $$ = makeDefElem("delimiter", (Node *) makeString($3), @2);
                               3638                 :                :                 }
 8904 bruce@momjian.us         3639                 :CBC        6258 :             | /*EMPTY*/                             { $$ = NULL; }
                               3640                 :                :         ;
                               3641                 :                : 
                               3642                 :                : opt_using:
                               3643                 :                :             USING
                               3644                 :                :             | /*EMPTY*/
                               3645                 :                :         ;
                               3646                 :                : 
                               3647                 :                : /* new COPY option syntax */
                               3648                 :                : copy_generic_opt_list:
                               3649                 :                :             copy_generic_opt_elem
                               3650                 :                :                 {
 6254 tgl@sss.pgh.pa.us        3651                 :            729 :                     $$ = list_make1($1);
                               3652                 :                :                 }
                               3653                 :                :             | copy_generic_opt_list ',' copy_generic_opt_elem
                               3654                 :                :                 {
                               3655                 :            439 :                     $$ = lappend($1, $3);
                               3656                 :                :                 }
                               3657                 :                :         ;
                               3658                 :                : 
                               3659                 :                : copy_generic_opt_elem:
                               3660                 :                :             ColLabel copy_generic_opt_arg
                               3661                 :                :                 {
 3712 peter_e@gmx.net          3662                 :           1008 :                     $$ = makeDefElem($1, $2, @1);
                               3663                 :                :                 }
                               3664                 :                :             | FORMAT_LA copy_generic_opt_arg
                               3665                 :                :                 {
  234 andrew@dunslane.net      3666                 :            160 :                     $$ = makeDefElem("format", $2, @1);
                               3667                 :                :                 }
                               3668                 :                :         ;
                               3669                 :                : 
                               3670                 :                : copy_generic_opt_arg:
 5858 heikki.linnakangas@i     3671                 :            892 :             opt_boolean_or_string           { $$ = (Node *) makeString($1); }
 6254 tgl@sss.pgh.pa.us        3672                 :             52 :             | NumericOnly                   { $$ = (Node *) $1; }
                               3673                 :             72 :             | '*'                           { $$ = (Node *) makeNode(A_Star); }
  948 msawada@postgresql.o     3674                 :              4 :             | DEFAULT                       { $$ = (Node *) makeString("default"); }
 6254 tgl@sss.pgh.pa.us        3675                 :            100 :             | '(' copy_generic_opt_arg_list ')'     { $$ = (Node *) $2; }
                               3676                 :             48 :             | /* EMPTY */                   { $$ = NULL; }
                               3677                 :                :         ;
                               3678                 :                : 
                               3679                 :                : copy_generic_opt_arg_list:
                               3680                 :                :               copy_generic_opt_arg_list_item
                               3681                 :                :                 {
                               3682                 :            100 :                     $$ = list_make1($1);
                               3683                 :                :                 }
                               3684                 :                :             | copy_generic_opt_arg_list ',' copy_generic_opt_arg_list_item
                               3685                 :                :                 {
                               3686                 :              8 :                     $$ = lappend($1, $3);
                               3687                 :                :                 }
                               3688                 :                :         ;
                               3689                 :                : 
                               3690                 :                : /* beware of emitting non-string list elements here; see commands/define.c */
                               3691                 :                : copy_generic_opt_arg_list_item:
 5858 heikki.linnakangas@i     3692                 :            108 :             opt_boolean_or_string   { $$ = (Node *) makeString($1); }
                               3693                 :                :         ;
                               3694                 :                : 
                               3695                 :                : 
                               3696                 :                : /*****************************************************************************
                               3697                 :                :  *
                               3698                 :                :  *      QUERY :
                               3699                 :                :  *              CREATE TABLE relname
                               3700                 :                :  *
                               3701                 :                :  *****************************************************************************/
                               3702                 :                : 
                               3703                 :                : CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
                               3704                 :                :             OptInherit OptPartitionSpec table_access_method_clause OptWith
                               3705                 :                :             OnCommitOption OptTableSpace
                               3706                 :                :                 {
10650 bruce@momjian.us         3707                 :          19701 :                     CreateStmt *n = makeNode(CreateStmt);
                               3708                 :                : 
 5806 rhaas@postgresql.org     3709                 :          19701 :                     $4->relpersistence = $2;
 8995 tgl@sss.pgh.pa.us        3710                 :          19701 :                     n->relation = $4;
 9435                          3711                 :          19701 :                     n->tableElts = $6;
 8995                          3712                 :          19701 :                     n->inhRelations = $8;
 3620 rhaas@postgresql.org     3713                 :          19701 :                     n->partspec = $9;
 4246 tgl@sss.pgh.pa.us        3714                 :          19701 :                     n->ofTypename = NULL;
10563 lockhart@fourpalms.o     3715                 :          19701 :                     n->constraints = NIL;
 2801 andres@anarazel.de       3716                 :          19701 :                     n->accessMethod = $10;
                               3717                 :          19701 :                     n->options = $11;
                               3718                 :          19701 :                     n->oncommit = $12;
                               3719                 :          19701 :                     n->tablespacename = $13;
 5947 rhaas@postgresql.org     3720                 :          19701 :                     n->if_not_exists = false;
 1637 peter@eisentraut.org     3721                 :          19701 :                     $$ = (Node *) n;
                               3722                 :                :                 }
                               3723                 :                :         | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name '('
                               3724                 :                :             OptTableElementList ')' OptInherit OptPartitionSpec table_access_method_clause
                               3725                 :                :             OptWith OnCommitOption OptTableSpace
                               3726                 :                :                 {
 5947 rhaas@postgresql.org     3727                 :             17 :                     CreateStmt *n = makeNode(CreateStmt);
                               3728                 :                : 
 5806                          3729                 :             17 :                     $7->relpersistence = $2;
 5947                          3730                 :             17 :                     n->relation = $7;
                               3731                 :             17 :                     n->tableElts = $9;
                               3732                 :             17 :                     n->inhRelations = $11;
 3620                          3733                 :             17 :                     n->partspec = $12;
 4246 tgl@sss.pgh.pa.us        3734                 :             17 :                     n->ofTypename = NULL;
 5947 rhaas@postgresql.org     3735                 :             17 :                     n->constraints = NIL;
 2801 andres@anarazel.de       3736                 :             17 :                     n->accessMethod = $13;
                               3737                 :             17 :                     n->options = $14;
                               3738                 :             17 :                     n->oncommit = $15;
                               3739                 :             17 :                     n->tablespacename = $16;
 5947 rhaas@postgresql.org     3740                 :             17 :                     n->if_not_exists = true;
 1637 peter@eisentraut.org     3741                 :             17 :                     $$ = (Node *) n;
                               3742                 :                :                 }
                               3743                 :                :         | CREATE OptTemp TABLE qualified_name OF any_name
                               3744                 :                :             OptTypedTableElementList OptPartitionSpec table_access_method_clause
                               3745                 :                :             OptWith OnCommitOption OptTableSpace
                               3746                 :                :                 {
 8859 lockhart@fourpalms.o     3747                 :             81 :                     CreateStmt *n = makeNode(CreateStmt);
                               3748                 :                : 
 5806 rhaas@postgresql.org     3749                 :             81 :                     $4->relpersistence = $2;
 8859 lockhart@fourpalms.o     3750                 :             81 :                     n->relation = $4;
 6125 peter_e@gmx.net          3751                 :             81 :                     n->tableElts = $7;
 4246 tgl@sss.pgh.pa.us        3752                 :             81 :                     n->inhRelations = NIL;
 3620 rhaas@postgresql.org     3753                 :             81 :                     n->partspec = $8;
 6125 peter_e@gmx.net          3754                 :             81 :                     n->ofTypename = makeTypeNameFromNameList($6);
                               3755                 :             81 :                     n->ofTypename->location = @6;
 8859 lockhart@fourpalms.o     3756                 :             81 :                     n->constraints = NIL;
 2801 andres@anarazel.de       3757                 :             81 :                     n->accessMethod = $9;
                               3758                 :             81 :                     n->options = $10;
                               3759                 :             81 :                     n->oncommit = $11;
                               3760                 :             81 :                     n->tablespacename = $12;
 5947 rhaas@postgresql.org     3761                 :             81 :                     n->if_not_exists = false;
 1637 peter@eisentraut.org     3762                 :             81 :                     $$ = (Node *) n;
                               3763                 :                :                 }
                               3764                 :                :         | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name OF any_name
                               3765                 :                :             OptTypedTableElementList OptPartitionSpec table_access_method_clause
                               3766                 :                :             OptWith OnCommitOption OptTableSpace
                               3767                 :                :                 {
 5947 rhaas@postgresql.org     3768                 :              4 :                     CreateStmt *n = makeNode(CreateStmt);
                               3769                 :                : 
 5806                          3770                 :              4 :                     $7->relpersistence = $2;
 5947                          3771                 :              4 :                     n->relation = $7;
                               3772                 :              4 :                     n->tableElts = $10;
 4246 tgl@sss.pgh.pa.us        3773                 :              4 :                     n->inhRelations = NIL;
 3620 rhaas@postgresql.org     3774                 :              4 :                     n->partspec = $11;
 5947                          3775                 :              4 :                     n->ofTypename = makeTypeNameFromNameList($9);
                               3776                 :              4 :                     n->ofTypename->location = @9;
                               3777                 :              4 :                     n->constraints = NIL;
 2801 andres@anarazel.de       3778                 :              4 :                     n->accessMethod = $12;
                               3779                 :              4 :                     n->options = $13;
                               3780                 :              4 :                     n->oncommit = $14;
                               3781                 :              4 :                     n->tablespacename = $15;
 3620 rhaas@postgresql.org     3782                 :              4 :                     n->if_not_exists = true;
 1637 peter@eisentraut.org     3783                 :              4 :                     $$ = (Node *) n;
                               3784                 :                :                 }
                               3785                 :                :         | CREATE OptTemp TABLE qualified_name PARTITION OF qualified_name
                               3786                 :                :             OptTypedTableElementList PartitionBoundSpec OptPartitionSpec
                               3787                 :                :             table_access_method_clause OptWith OnCommitOption OptTableSpace
                               3788                 :                :                 {
 3620 rhaas@postgresql.org     3789                 :           5978 :                     CreateStmt *n = makeNode(CreateStmt);
                               3790                 :                : 
                               3791                 :           5978 :                     $4->relpersistence = $2;
                               3792                 :           5978 :                     n->relation = $4;
                               3793                 :           5978 :                     n->tableElts = $8;
                               3794                 :           5978 :                     n->inhRelations = list_make1($7);
 3448 tgl@sss.pgh.pa.us        3795                 :           5978 :                     n->partbound = $9;
 3620 rhaas@postgresql.org     3796                 :           5978 :                     n->partspec = $10;
                               3797                 :           5978 :                     n->ofTypename = NULL;
                               3798                 :           5978 :                     n->constraints = NIL;
 2801 andres@anarazel.de       3799                 :           5978 :                     n->accessMethod = $11;
                               3800                 :           5978 :                     n->options = $12;
                               3801                 :           5978 :                     n->oncommit = $13;
                               3802                 :           5978 :                     n->tablespacename = $14;
 3620 rhaas@postgresql.org     3803                 :           5978 :                     n->if_not_exists = false;
 1637 peter@eisentraut.org     3804                 :           5978 :                     $$ = (Node *) n;
                               3805                 :                :                 }
                               3806                 :                :         | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name PARTITION OF
                               3807                 :                :             qualified_name OptTypedTableElementList PartitionBoundSpec OptPartitionSpec
                               3808                 :                :             table_access_method_clause OptWith OnCommitOption OptTableSpace
                               3809                 :                :                 {
 3620 rhaas@postgresql.org     3810                 :UBC           0 :                     CreateStmt *n = makeNode(CreateStmt);
                               3811                 :                : 
                               3812                 :              0 :                     $7->relpersistence = $2;
                               3813                 :              0 :                     n->relation = $7;
                               3814                 :              0 :                     n->tableElts = $11;
                               3815                 :              0 :                     n->inhRelations = list_make1($10);
 3448 tgl@sss.pgh.pa.us        3816                 :              0 :                     n->partbound = $12;
 3620 rhaas@postgresql.org     3817                 :              0 :                     n->partspec = $13;
                               3818                 :              0 :                     n->ofTypename = NULL;
                               3819                 :              0 :                     n->constraints = NIL;
 2801 andres@anarazel.de       3820                 :              0 :                     n->accessMethod = $14;
                               3821                 :              0 :                     n->options = $15;
                               3822                 :              0 :                     n->oncommit = $16;
                               3823                 :              0 :                     n->tablespacename = $17;
 5947 rhaas@postgresql.org     3824                 :              0 :                     n->if_not_exists = true;
 1637 peter@eisentraut.org     3825                 :              0 :                     $$ = (Node *) n;
                               3826                 :                :                 }
                               3827                 :                :         ;
                               3828                 :                : 
                               3829                 :                : /*
                               3830                 :                :  * Redundancy here is needed to avoid shift/reduce conflicts,
                               3831                 :                :  * since TEMP is not a reserved word.  See also OptTempTableName.
                               3832                 :                :  *
                               3833                 :                :  * NOTE: we accept both GLOBAL and LOCAL options.  They currently do nothing,
                               3834                 :                :  * but future versions might consider GLOBAL to request SQL-spec-compliant
                               3835                 :                :  * temp table behavior, so warn about that.  Since we have no modules the
                               3836                 :                :  * LOCAL keyword is really meaningless; furthermore, some other products
                               3837                 :                :  * implement LOCAL as meaning the same as our default temp table behavior,
                               3838                 :                :  * so we'll probably continue to treat LOCAL as a noise word.
                               3839                 :                :  */
 5806 rhaas@postgresql.org     3840                 :CBC         229 : OptTemp:    TEMPORARY                   { $$ = RELPERSISTENCE_TEMP; }
                               3841                 :           2066 :             | TEMP                      { $$ = RELPERSISTENCE_TEMP; }
 5261 simon@2ndQuadrant.co     3842                 :UBC           0 :             | LOCAL TEMPORARY           { $$ = RELPERSISTENCE_TEMP; }
                               3843                 :              0 :             | LOCAL TEMP                { $$ = RELPERSISTENCE_TEMP; }
                               3844                 :                :             | GLOBAL TEMPORARY
                               3845                 :                :                 {
 5258 tgl@sss.pgh.pa.us        3846         [ #  # ]:              0 :                     ereport(WARNING,
                               3847                 :                :                             (errmsg("GLOBAL is deprecated in temporary table creation"),
                               3848                 :                :                              parser_errposition(@1)));
                               3849                 :              0 :                     $$ = RELPERSISTENCE_TEMP;
                               3850                 :                :                 }
                               3851                 :                :             | GLOBAL TEMP
                               3852                 :                :                 {
                               3853         [ #  # ]:              0 :                     ereport(WARNING,
                               3854                 :                :                             (errmsg("GLOBAL is deprecated in temporary table creation"),
                               3855                 :                :                              parser_errposition(@1)));
                               3856                 :              0 :                     $$ = RELPERSISTENCE_TEMP;
                               3857                 :                :                 }
 5790 rhaas@postgresql.org     3858                 :CBC         107 :             | UNLOGGED                  { $$ = RELPERSISTENCE_UNLOGGED; }
 5806                          3859                 :          35575 :             | /*EMPTY*/                 { $$ = RELPERSISTENCE_PERMANENT; }
                               3860                 :                :         ;
                               3861                 :                : 
                               3862                 :                : OptTableElementList:
 8858 tgl@sss.pgh.pa.us        3863                 :          18924 :             TableElementList                    { $$ = $1; }
                               3864                 :           1073 :             | /*EMPTY*/                         { $$ = NIL; }
                               3865                 :                :         ;
                               3866                 :                : 
                               3867                 :                : OptTypedTableElementList:
 6125 peter_e@gmx.net          3868                 :            221 :             '(' TypedTableElementList ')'       { $$ = $2; }
                               3869                 :           5912 :             | /*EMPTY*/                         { $$ = NIL; }
                               3870                 :                :         ;
                               3871                 :                : 
                               3872                 :                : TableElementList:
                               3873                 :                :             TableElement
                               3874                 :                :                 {
 8194 neilc@samurai.com        3875                 :          18960 :                     $$ = list_make1($1);
                               3876                 :                :                 }
                               3877                 :                :             | TableElementList ',' TableElement
                               3878                 :                :                 {
 8834 tgl@sss.pgh.pa.us        3879                 :          26007 :                     $$ = lappend($1, $3);
                               3880                 :                :                 }
                               3881                 :                :         ;
                               3882                 :                : 
                               3883                 :                : TypedTableElementList:
                               3884                 :                :             TypedTableElement
                               3885                 :                :                 {
 6125 peter_e@gmx.net          3886                 :            221 :                     $$ = list_make1($1);
                               3887                 :                :                 }
                               3888                 :                :             | TypedTableElementList ',' TypedTableElement
                               3889                 :                :                 {
                               3890                 :             45 :                     $$ = lappend($1, $3);
                               3891                 :                :                 }
                               3892                 :                :         ;
                               3893                 :                : 
                               3894                 :                : TableElement:
 8907 bruce@momjian.us         3895                 :          42549 :             columnDef                           { $$ = $1; }
 8902 lockhart@fourpalms.o     3896                 :            542 :             | TableLikeClause                   { $$ = $1; }
10563                          3897                 :           1876 :             | TableConstraint                   { $$ = $1; }
                               3898                 :                :         ;
                               3899                 :                : 
                               3900                 :                : TypedTableElement:
 6125 peter_e@gmx.net          3901                 :            224 :             columnOptions                       { $$ = $1; }
                               3902                 :             42 :             | TableConstraint                   { $$ = $1; }
                               3903                 :                :         ;
                               3904                 :                : 
                               3905                 :                : columnDef:  ColId Typename opt_column_storage opt_column_compression create_generic_options ColQualList
                               3906                 :                :                 {
10563 lockhart@fourpalms.o     3907                 :          44125 :                     ColumnDef *n = makeNode(ColumnDef);
                               3908                 :                : 
                               3909                 :          44125 :                     n->colname = $1;
 6321 peter_e@gmx.net          3910                 :          44125 :                     n->typeName = $2;
 1576 peter@eisentraut.org     3911                 :          44125 :                     n->storage_name = $3;
                               3912                 :          44125 :                     n->compression = $4;
 5720 tgl@sss.pgh.pa.us        3913                 :          44125 :                     n->inhcount = 0;
 8810                          3914                 :          44125 :                     n->is_local = true;
 5720                          3915                 :          44125 :                     n->is_not_null = false;
                               3916                 :          44125 :                     n->is_from_type = false;
  989 peter@eisentraut.org     3917                 :          44125 :                     n->storage = 0;
 5720 tgl@sss.pgh.pa.us        3918                 :          44125 :                     n->raw_default = NULL;
                               3919                 :          44125 :                     n->cooked_default = NULL;
                               3920                 :          44125 :                     n->collOid = InvalidOid;
 1576 peter@eisentraut.org     3921                 :          44125 :                     n->fdwoptions = $5;
                               3922                 :          44125 :                     SplitColQualList($6, &n->constraints, &n->collClause,
                               3923                 :                :                                      yyscanner);
 4732 tgl@sss.pgh.pa.us        3924                 :          44125 :                     n->location = @1;
 1637 peter@eisentraut.org     3925                 :          44125 :                     $$ = (Node *) n;
                               3926                 :                :                 }
                               3927                 :                :         ;
                               3928                 :                : 
                               3929                 :                : columnOptions:  ColId ColQualList
                               3930                 :                :                 {
 3479 sfrost@snowman.net       3931                 :             95 :                     ColumnDef *n = makeNode(ColumnDef);
                               3932                 :                : 
                               3933                 :             95 :                     n->colname = $1;
                               3934                 :             95 :                     n->typeName = NULL;
                               3935                 :             95 :                     n->inhcount = 0;
                               3936                 :             95 :                     n->is_local = true;
                               3937                 :             95 :                     n->is_not_null = false;
                               3938                 :             95 :                     n->is_from_type = false;
  989 peter@eisentraut.org     3939                 :             95 :                     n->storage = 0;
 3479 sfrost@snowman.net       3940                 :             95 :                     n->raw_default = NULL;
                               3941                 :             95 :                     n->cooked_default = NULL;
                               3942                 :             95 :                     n->collOid = InvalidOid;
                               3943                 :             95 :                     SplitColQualList($2, &n->constraints, &n->collClause,
                               3944                 :                :                                      yyscanner);
                               3945                 :             95 :                     n->location = @1;
 1637 peter@eisentraut.org     3946                 :             95 :                     $$ = (Node *) n;
                               3947                 :                :                 }
                               3948                 :                :                 | ColId WITH OPTIONS ColQualList
                               3949                 :                :                 {
 6125 peter_e@gmx.net          3950                 :            129 :                     ColumnDef *n = makeNode(ColumnDef);
                               3951                 :                : 
                               3952                 :            129 :                     n->colname = $1;
 5720 tgl@sss.pgh.pa.us        3953                 :            129 :                     n->typeName = NULL;
                               3954                 :            129 :                     n->inhcount = 0;
 6125 peter_e@gmx.net          3955                 :            129 :                     n->is_local = true;
 5720 tgl@sss.pgh.pa.us        3956                 :            129 :                     n->is_not_null = false;
                               3957                 :            129 :                     n->is_from_type = false;
  989 peter@eisentraut.org     3958                 :            129 :                     n->storage = 0;
 5720 tgl@sss.pgh.pa.us        3959                 :            129 :                     n->raw_default = NULL;
                               3960                 :            129 :                     n->cooked_default = NULL;
                               3961                 :            129 :                     n->collOid = InvalidOid;
                               3962                 :            129 :                     SplitColQualList($4, &n->constraints, &n->collClause,
                               3963                 :                :                                      yyscanner);
 4732                          3964                 :            129 :                     n->location = @1;
 1637 peter@eisentraut.org     3965                 :            129 :                     $$ = (Node *) n;
                               3966                 :                :                 }
                               3967                 :                :         ;
                               3968                 :                : 
                               3969                 :                : column_compression:
 1988 tgl@sss.pgh.pa.us        3970                 :            109 :             COMPRESSION ColId                       { $$ = $2; }
                               3971                 :              6 :             | COMPRESSION DEFAULT                   { $$ = pstrdup("default"); }
                               3972                 :                :         ;
                               3973                 :                : 
                               3974                 :                : opt_column_compression:
                               3975                 :             66 :             column_compression                      { $$ = $1; }
                               3976                 :          44103 :             | /*EMPTY*/                             { $$ = NULL; }
                               3977                 :                :         ;
                               3978                 :                : 
                               3979                 :                : column_storage:
 1576 peter@eisentraut.org     3980                 :            243 :             STORAGE ColId                           { $$ = $2; }
 1456 tgl@sss.pgh.pa.us        3981                 :              4 :             | STORAGE DEFAULT                       { $$ = pstrdup("default"); }
                               3982                 :                :         ;
                               3983                 :                : 
                               3984                 :                : opt_column_storage:
 1576 peter@eisentraut.org     3985                 :             26 :             column_storage                          { $$ = $1; }
                               3986                 :          44143 :             | /*EMPTY*/                             { $$ = NULL; }
                               3987                 :                :         ;
                               3988                 :                : 
                               3989                 :                : ColQualList:
 8907 bruce@momjian.us         3990                 :          13174 :             ColQualList ColConstraint               { $$ = lappend($1, $2); }
                               3991                 :          45429 :             | /*EMPTY*/                             { $$ = NIL; }
                               3992                 :                :         ;
                               3993                 :                : 
                               3994                 :                : ColConstraint:
                               3995                 :                :             CONSTRAINT name ColConstraintElem
                               3996                 :                :                 {
 3544 peter_e@gmx.net          3997                 :            535 :                     Constraint *n = castNode(Constraint, $3);
                               3998                 :                : 
 6307 tgl@sss.pgh.pa.us        3999                 :            535 :                     n->conname = $2;
                               4000                 :            535 :                     n->location = @1;
                               4001                 :            535 :                     $$ = (Node *) n;
                               4002                 :                :                 }
 8907 bruce@momjian.us         4003                 :          11780 :             | ColConstraintElem                     { $$ = $1; }
                               4004                 :            319 :             | ConstraintAttr                        { $$ = $1; }
                               4005                 :                :             | COLLATE any_name
                               4006                 :                :                 {
                               4007                 :                :                     /*
                               4008                 :                :                      * Note: the CollateClause is momentarily included in
                               4009                 :                :                      * the list built by ColQualList, but we split it out
                               4010                 :                :                      * again in SplitColQualList.
                               4011                 :                :                      */
 5720 tgl@sss.pgh.pa.us        4012                 :            540 :                     CollateClause *n = makeNode(CollateClause);
                               4013                 :                : 
                               4014                 :            540 :                     n->arg = NULL;
 5718                          4015                 :            540 :                     n->collname = $2;
 5720                          4016                 :            540 :                     n->location = @1;
                               4017                 :            540 :                     $$ = (Node *) n;
                               4018                 :                :                 }
                               4019                 :                :         ;
                               4020                 :                : 
                               4021                 :                : /* DEFAULT NULL is already the default for Postgres.
                               4022                 :                :  * But define it here and carry it forward into the system
                               4023                 :                :  * to make it explicit.
                               4024                 :                :  * - thomas 1998-09-13
                               4025                 :                :  *
                               4026                 :                :  * WITH NULL and NULL are not SQL-standard syntax elements,
                               4027                 :                :  * so leave them out. Use DEFAULT NULL to explicitly indicate
                               4028                 :                :  * that a column may have that value. WITH NULL leads to
                               4029                 :                :  * shift/reduce conflicts with WITH TIME ZONE anyway.
                               4030                 :                :  * - thomas 1999-01-08
                               4031                 :                :  *
                               4032                 :                :  * DEFAULT expression must be b_expr not a_expr to prevent shift/reduce
                               4033                 :                :  * conflict on NOT (since NOT might start a subsequent NOT NULL constraint,
                               4034                 :                :  * or be part of a_expr NOT LIKE or similar constructs).
                               4035                 :                :  */
                               4036                 :                : ColConstraintElem:
                               4037                 :                :             NOT NULL_P opt_no_inherit
                               4038                 :                :                 {
 9745                          4039                 :           4106 :                     Constraint *n = makeNode(Constraint);
                               4040                 :                : 
                               4041                 :           4106 :                     n->contype = CONSTR_NOTNULL;
 6307                          4042                 :           4106 :                     n->location = @1;
  727 alvherre@alvh.no-ip.     4043                 :           4106 :                     n->is_no_inherit = $3;
  663 peter@eisentraut.org     4044                 :           4106 :                     n->is_enforced = true;
  727 alvherre@alvh.no-ip.     4045                 :           4106 :                     n->skip_validation = false;
                               4046                 :           4106 :                     n->initially_valid = true;
 1637 peter@eisentraut.org     4047                 :           4106 :                     $$ = (Node *) n;
                               4048                 :                :                 }
                               4049                 :                :             | NULL_P
                               4050                 :                :                 {
 9745 tgl@sss.pgh.pa.us        4051                 :             18 :                     Constraint *n = makeNode(Constraint);
                               4052                 :                : 
                               4053                 :             18 :                     n->contype = CONSTR_NULL;
 6307                          4054                 :             18 :                     n->location = @1;
 1637 peter@eisentraut.org     4055                 :             18 :                     $$ = (Node *) n;
                               4056                 :                :                 }
                               4057                 :                :             | UNIQUE opt_unique_null_treatment opt_definition OptConsTableSpace
                               4058                 :                :                 {
10277 lockhart@fourpalms.o     4059                 :            305 :                     Constraint *n = makeNode(Constraint);
                               4060                 :                : 
 9760                          4061                 :            305 :                     n->contype = CONSTR_UNIQUE;
 6307 tgl@sss.pgh.pa.us        4062                 :            305 :                     n->location = @1;
 1736 peter@eisentraut.org     4063                 :            305 :                     n->nulls_not_distinct = !$2;
10277 lockhart@fourpalms.o     4064                 :            305 :                     n->keys = NULL;
 1736 peter@eisentraut.org     4065                 :            305 :                     n->options = $3;
 5763 tgl@sss.pgh.pa.us        4066                 :            305 :                     n->indexname = NULL;
 1736 peter@eisentraut.org     4067                 :            305 :                     n->indexspace = $4;
 1637                          4068                 :            305 :                     $$ = (Node *) n;
                               4069                 :                :                 }
                               4070                 :                :             | PRIMARY KEY opt_definition OptConsTableSpace
                               4071                 :                :                 {
 9745 tgl@sss.pgh.pa.us        4072                 :           3679 :                     Constraint *n = makeNode(Constraint);
                               4073                 :                : 
                               4074                 :           3679 :                     n->contype = CONSTR_PRIMARY;
 6307                          4075                 :           3679 :                     n->location = @1;
 9745                          4076                 :           3679 :                     n->keys = NULL;
 7431 bruce@momjian.us         4077                 :           3679 :                     n->options = $3;
 5763 tgl@sss.pgh.pa.us        4078                 :           3679 :                     n->indexname = NULL;
 7431 bruce@momjian.us         4079                 :           3679 :                     n->indexspace = $4;
 1637 peter@eisentraut.org     4080                 :           3679 :                     $$ = (Node *) n;
                               4081                 :                :                 }
                               4082                 :                :             | CHECK '(' a_expr ')' opt_no_inherit
                               4083                 :                :                 {
10563 lockhart@fourpalms.o     4084                 :            801 :                     Constraint *n = makeNode(Constraint);
                               4085                 :                : 
 9760                          4086                 :            801 :                     n->contype = CONSTR_CHECK;
 6307 tgl@sss.pgh.pa.us        4087                 :            801 :                     n->location = @1;
 5217 alvherre@alvh.no-ip.     4088                 :            801 :                     n->is_no_inherit = $5;
                               4089                 :            801 :                     n->raw_expr = $3;
 9895 tgl@sss.pgh.pa.us        4090                 :            801 :                     n->cooked_expr = NULL;
  663 peter@eisentraut.org     4091                 :            801 :                     n->is_enforced = true;
 3977 rhaas@postgresql.org     4092                 :            801 :                     n->skip_validation = false;
                               4093                 :            801 :                     n->initially_valid = true;
 1637 peter@eisentraut.org     4094                 :            801 :                     $$ = (Node *) n;
                               4095                 :                :                 }
                               4096                 :                :             | DEFAULT b_expr
                               4097                 :                :                 {
 9745 tgl@sss.pgh.pa.us        4098                 :           1212 :                     Constraint *n = makeNode(Constraint);
                               4099                 :                : 
                               4100                 :           1212 :                     n->contype = CONSTR_DEFAULT;
 6307                          4101                 :           1212 :                     n->location = @1;
 6947                          4102                 :           1212 :                     n->raw_expr = $2;
 9745                          4103                 :           1212 :                     n->cooked_expr = NULL;
 1637 peter@eisentraut.org     4104                 :           1212 :                     $$ = (Node *) n;
                               4105                 :                :                 }
                               4106                 :                :             | GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
                               4107                 :                :                 {
 3500 peter_e@gmx.net          4108                 :            237 :                     Constraint *n = makeNode(Constraint);
                               4109                 :                : 
                               4110                 :            237 :                     n->contype = CONSTR_IDENTITY;
                               4111                 :            237 :                     n->generated_when = $2;
                               4112                 :            237 :                     n->options = $5;
                               4113                 :            237 :                     n->location = @1;
 1637 peter@eisentraut.org     4114                 :            237 :                     $$ = (Node *) n;
                               4115                 :                :                 }
                               4116                 :                :             | GENERATED generated_when AS '(' a_expr ')' opt_virtual_or_stored
                               4117                 :                :                 {
 2777                          4118                 :           1294 :                     Constraint *n = makeNode(Constraint);
                               4119                 :                : 
                               4120                 :           1294 :                     n->contype = CONSTR_GENERATED;
                               4121                 :           1294 :                     n->generated_when = $2;
                               4122                 :           1294 :                     n->raw_expr = $5;
                               4123                 :           1294 :                     n->cooked_expr = NULL;
  636                          4124                 :           1294 :                     n->generated_kind = $7;
 2777                          4125                 :           1294 :                     n->location = @1;
                               4126                 :                : 
                               4127                 :                :                     /*
                               4128                 :                :                      * Can't do this in the grammar because of shift/reduce
                               4129                 :                :                      * conflicts.  (IDENTITY allows both ALWAYS and BY
                               4130                 :                :                      * DEFAULT, but generated columns only allow ALWAYS.)  We
                               4131                 :                :                      * can also give a more useful error message and location.
                               4132                 :                :                      */
 2775                          4133         [ +  + ]:           1294 :                     if ($2 != ATTRIBUTE_IDENTITY_ALWAYS)
                               4134         [ +  - ]:              8 :                         ereport(ERROR,
                               4135                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               4136                 :                :                                  errmsg("for a generated column, GENERATED ALWAYS must be specified"),
                               4137                 :                :                                  parser_errposition(@2)));
                               4138                 :                : 
 1637                          4139                 :           1286 :                     $$ = (Node *) n;
                               4140                 :                :                 }
                               4141                 :                :             | REFERENCES qualified_name opt_column_list key_match key_actions
                               4142                 :                :                 {
 6307 tgl@sss.pgh.pa.us        4143                 :            671 :                     Constraint *n = makeNode(Constraint);
                               4144                 :                : 
                               4145                 :            671 :                     n->contype = CONSTR_FOREIGN;
                               4146                 :            671 :                     n->location = @1;
 1940 peter@eisentraut.org     4147                 :            671 :                     n->pktable = $2;
                               4148                 :            671 :                     n->fk_attrs = NIL;
                               4149                 :            671 :                     n->pk_attrs = $3;
                               4150                 :            671 :                     n->fk_matchtype = $4;
 1793                          4151                 :            671 :                     n->fk_upd_action = ($5)->updateAction->action;
                               4152                 :            671 :                     n->fk_del_action = ($5)->deleteAction->action;
                               4153                 :            671 :                     n->fk_del_set_cols = ($5)->deleteAction->cols;
  663                          4154                 :            671 :                     n->is_enforced = true;
 1940                          4155                 :            671 :                     n->skip_validation = false;
                               4156                 :            671 :                     n->initially_valid = true;
 1637                          4157                 :            671 :                     $$ = (Node *) n;
                               4158                 :                :                 }
                               4159                 :                :         ;
                               4160                 :                : 
                               4161                 :                : opt_unique_null_treatment:
 1736                          4162                 :              8 :             NULLS_P DISTINCT        { $$ = true; }
                               4163                 :             32 :             | NULLS_P NOT DISTINCT  { $$ = false; }
                               4164                 :           5358 :             | /*EMPTY*/             { $$ = true; }
                               4165                 :                :         ;
                               4166                 :                : 
                               4167                 :                : generated_when:
 3500 peter_e@gmx.net          4168                 :           1549 :             ALWAYS          { $$ = ATTRIBUTE_IDENTITY_ALWAYS; }
                               4169                 :            118 :             | BY DEFAULT    { $$ = ATTRIBUTE_IDENTITY_BY_DEFAULT; }
                               4170                 :                :         ;
                               4171                 :                : 
                               4172                 :                : opt_virtual_or_stored:
  636 peter@eisentraut.org     4173                 :            675 :             STORED          { $$ = ATTRIBUTE_GENERATED_STORED; }
                               4174                 :            468 :             | VIRTUAL       { $$ = ATTRIBUTE_GENERATED_VIRTUAL; }
                               4175                 :            151 :             | /*EMPTY*/     { $$ = ATTRIBUTE_GENERATED_VIRTUAL; }
                               4176                 :                :         ;
                               4177                 :                : 
                               4178                 :                : /*
                               4179                 :                :  * ConstraintAttr represents constraint attributes, which we parse as if
                               4180                 :                :  * they were independent constraint clauses, in order to avoid shift/reduce
                               4181                 :                :  * conflicts (since NOT might start either an independent NOT NULL clause
                               4182                 :                :  * or an attribute).  parse_utilcmd.c is responsible for attaching the
                               4183                 :                :  * attribute information to the preceding "real" constraint node, and for
                               4184                 :                :  * complaining if attribute clauses appear in the wrong place or wrong
                               4185                 :                :  * combinations.
                               4186                 :                :  *
                               4187                 :                :  * See also ConstraintAttributeSpec, which can be used in places where
                               4188                 :                :  * there is no parsing conflict.  (Note: currently, NOT VALID and NO INHERIT
                               4189                 :                :  * are allowed clauses in ConstraintAttributeSpec, but not here.  Someday we
                               4190                 :                :  * might need to allow them here too, but for the moment it doesn't seem
                               4191                 :                :  * useful in the statements that use ConstraintAttr.)
                               4192                 :                :  */
                               4193                 :                : ConstraintAttr:
                               4194                 :                :             DEFERRABLE
                               4195                 :                :                 {
 9756 lockhart@fourpalms.o     4196                 :            108 :                     Constraint *n = makeNode(Constraint);
                               4197                 :                : 
 9745 tgl@sss.pgh.pa.us        4198                 :            108 :                     n->contype = CONSTR_ATTR_DEFERRABLE;
 6307                          4199                 :            108 :                     n->location = @1;
 1637 peter@eisentraut.org     4200                 :            108 :                     $$ = (Node *) n;
                               4201                 :                :                 }
                               4202                 :                :             | NOT DEFERRABLE
                               4203                 :                :                 {
 9756 lockhart@fourpalms.o     4204                 :              4 :                     Constraint *n = makeNode(Constraint);
                               4205                 :                : 
 9745 tgl@sss.pgh.pa.us        4206                 :              4 :                     n->contype = CONSTR_ATTR_NOT_DEFERRABLE;
 6307                          4207                 :              4 :                     n->location = @1;
 1637 peter@eisentraut.org     4208                 :              4 :                     $$ = (Node *) n;
                               4209                 :                :                 }
                               4210                 :                :             | INITIALLY DEFERRED
                               4211                 :                :                 {
 9745 tgl@sss.pgh.pa.us        4212                 :             86 :                     Constraint *n = makeNode(Constraint);
                               4213                 :                : 
                               4214                 :             86 :                     n->contype = CONSTR_ATTR_DEFERRED;
 6307                          4215                 :             86 :                     n->location = @1;
 1637 peter@eisentraut.org     4216                 :             86 :                     $$ = (Node *) n;
                               4217                 :                :                 }
                               4218                 :                :             | INITIALLY IMMEDIATE
                               4219                 :                :                 {
 9745 tgl@sss.pgh.pa.us        4220                 :              8 :                     Constraint *n = makeNode(Constraint);
                               4221                 :                : 
                               4222                 :              8 :                     n->contype = CONSTR_ATTR_IMMEDIATE;
 6307                          4223                 :              8 :                     n->location = @1;
 1637 peter@eisentraut.org     4224                 :              8 :                     $$ = (Node *) n;
                               4225                 :                :                 }
                               4226                 :                :             | ENFORCED
                               4227                 :                :                 {
  663                          4228                 :             52 :                     Constraint *n = makeNode(Constraint);
                               4229                 :                : 
                               4230                 :             52 :                     n->contype = CONSTR_ATTR_ENFORCED;
                               4231                 :             52 :                     n->location = @1;
                               4232                 :             52 :                     $$ = (Node *) n;
                               4233                 :                :                 }
                               4234                 :                :             | NOT ENFORCED
                               4235                 :                :                 {
                               4236                 :             61 :                     Constraint *n = makeNode(Constraint);
                               4237                 :                : 
                               4238                 :             61 :                     n->contype = CONSTR_ATTR_NOT_ENFORCED;
                               4239                 :             61 :                     n->location = @1;
                               4240                 :             61 :                     $$ = (Node *) n;
                               4241                 :                :                 }
                               4242                 :                :         ;
                               4243                 :                : 
                               4244                 :                : 
                               4245                 :                : TableLikeClause:
                               4246                 :                :             LIKE qualified_name TableLikeOptionList
                               4247                 :                :                 {
 5416 peter_e@gmx.net          4248                 :            542 :                     TableLikeClause *n = makeNode(TableLikeClause);
                               4249                 :                : 
 8534 bruce@momjian.us         4250                 :            542 :                     n->relation = $2;
 7436                          4251                 :            542 :                     n->options = $3;
 2165 tgl@sss.pgh.pa.us        4252                 :            542 :                     n->relationOid = InvalidOid;
 1637 peter@eisentraut.org     4253                 :            542 :                     $$ = (Node *) n;
                               4254                 :                :                 }
                               4255                 :                :         ;
                               4256                 :                : 
                               4257                 :                : TableLikeOptionList:
 6233 andrew@dunslane.net      4258                 :            215 :                 TableLikeOptionList INCLUDING TableLikeOption   { $$ = $1 | $3; }
                               4259                 :              5 :                 | TableLikeOptionList EXCLUDING TableLikeOption { $$ = $1 & ~$3; }
                               4260                 :            542 :                 | /* EMPTY */                       { $$ = 0; }
                               4261                 :                :         ;
                               4262                 :                : 
                               4263                 :                : TableLikeOption:
 3167 alvherre@alvh.no-ip.     4264                 :             20 :                 COMMENTS            { $$ = CREATE_TABLE_LIKE_COMMENTS; }
 2022 fujii@postgresql.org     4265                 :              4 :                 | COMPRESSION       { $$ = CREATE_TABLE_LIKE_COMPRESSION; }
 6233 andrew@dunslane.net      4266                 :             40 :                 | CONSTRAINTS       { $$ = CREATE_TABLE_LIKE_CONSTRAINTS; }
 3167 alvherre@alvh.no-ip.     4267                 :             17 :                 | DEFAULTS          { $$ = CREATE_TABLE_LIKE_DEFAULTS; }
 3500 peter_e@gmx.net          4268                 :              8 :                 | IDENTITY_P        { $$ = CREATE_TABLE_LIKE_IDENTITY; }
 2777 peter@eisentraut.org     4269                 :             20 :                 | GENERATED         { $$ = CREATE_TABLE_LIKE_GENERATED; }
 6233 andrew@dunslane.net      4270                 :             33 :                 | INDEXES           { $$ = CREATE_TABLE_LIKE_INDEXES; }
 3167 alvherre@alvh.no-ip.     4271                 :              8 :                 | STATISTICS        { $$ = CREATE_TABLE_LIKE_STATISTICS; }
 6233 andrew@dunslane.net      4272                 :             17 :                 | STORAGE           { $$ = CREATE_TABLE_LIKE_STORAGE; }
                               4273                 :             53 :                 | ALL               { $$ = CREATE_TABLE_LIKE_ALL; }
                               4274                 :                :         ;
                               4275                 :                : 
                               4276                 :                : 
                               4277                 :                : /* ConstraintElem specifies constraint syntax which is not embedded into
                               4278                 :                :  *  a column definition. ColConstraintElem specifies the embedded form.
                               4279                 :                :  * - thomas 1997-12-03
                               4280                 :                :  */
                               4281                 :                : TableConstraint:
                               4282                 :                :             CONSTRAINT name ConstraintElem
                               4283                 :                :                 {
 3544 peter_e@gmx.net          4284                 :           2792 :                     Constraint *n = castNode(Constraint, $3);
                               4285                 :                : 
 6307 tgl@sss.pgh.pa.us        4286                 :           2792 :                     n->conname = $2;
                               4287                 :           2792 :                     n->location = @1;
                               4288                 :           2792 :                     $$ = (Node *) n;
                               4289                 :                :                 }
 8907 bruce@momjian.us         4290                 :           8123 :             | ConstraintElem                        { $$ = $1; }
                               4291                 :                :         ;
                               4292                 :                : 
                               4293                 :                : ConstraintElem:
                               4294                 :                :             CHECK '(' a_expr ')' ConstraintAttributeSpec
                               4295                 :                :                 {
10563 lockhart@fourpalms.o     4296                 :            901 :                     Constraint *n = makeNode(Constraint);
                               4297                 :                : 
                               4298                 :            901 :                     n->contype = CONSTR_CHECK;
 6307 tgl@sss.pgh.pa.us        4299                 :            901 :                     n->location = @1;
 5217 alvherre@alvh.no-ip.     4300                 :            901 :                     n->raw_expr = $3;
 9895 tgl@sss.pgh.pa.us        4301                 :            901 :                     n->cooked_expr = NULL;
 5217 alvherre@alvh.no-ip.     4302                 :            901 :                     processCASbits($5, @5, "CHECK",
                               4303                 :                :                                    NULL, NULL, &n->is_enforced, &n->skip_validation,
                               4304                 :                :                                    &n->is_no_inherit, yyscanner);
 5636                          4305                 :            901 :                     n->initially_valid = !n->skip_validation;
 1637 peter@eisentraut.org     4306                 :            901 :                     $$ = (Node *) n;
                               4307                 :                :                 }
                               4308                 :                :             | NOT NULL_P ColId ConstraintAttributeSpec
                               4309                 :                :                 {
  727 alvherre@alvh.no-ip.     4310                 :            445 :                     Constraint *n = makeNode(Constraint);
                               4311                 :                : 
                               4312                 :            445 :                     n->contype = CONSTR_NOTNULL;
                               4313                 :            445 :                     n->location = @1;
                               4314                 :            445 :                     n->keys = list_make1(makeString($3));
                               4315                 :            445 :                     processCASbits($4, @4, "NOT NULL",
                               4316                 :                :                                    NULL, NULL, NULL, &n->skip_validation,
                               4317                 :                :                                    &n->is_no_inherit, yyscanner);
  577                          4318                 :            445 :                     n->initially_valid = !n->skip_validation;
  727                          4319                 :            445 :                     $$ = (Node *) n;
                               4320                 :                :                 }
                               4321                 :                :             | UNIQUE opt_unique_null_treatment '(' columnList opt_without_overlaps ')' opt_c_include opt_definition OptConsTableSpace
                               4322                 :                :                 ConstraintAttributeSpec
                               4323                 :                :                 {
10563 lockhart@fourpalms.o     4324                 :            439 :                     Constraint *n = makeNode(Constraint);
                               4325                 :                : 
                               4326                 :            439 :                     n->contype = CONSTR_UNIQUE;
 6307 tgl@sss.pgh.pa.us        4327                 :            439 :                     n->location = @1;
 1736 peter@eisentraut.org     4328                 :            439 :                     n->nulls_not_distinct = !$2;
                               4329                 :            439 :                     n->keys = $4;
  779                          4330                 :            439 :                     n->without_overlaps = $5;
                               4331                 :            439 :                     n->including = $7;
                               4332                 :            439 :                     n->options = $8;
 5763 tgl@sss.pgh.pa.us        4333                 :            439 :                     n->indexname = NULL;
  779 peter@eisentraut.org     4334                 :            439 :                     n->indexspace = $9;
                               4335                 :            439 :                     processCASbits($10, @10, "UNIQUE",
                               4336                 :                :                                    &n->deferrable, &n->initdeferred, NULL,
                               4337                 :                :                                    NULL, NULL, yyscanner);
 1637                          4338                 :            439 :                     $$ = (Node *) n;
                               4339                 :                :                 }
                               4340                 :                :             | UNIQUE ExistingIndex ConstraintAttributeSpec
                               4341                 :                :                 {
 5763 tgl@sss.pgh.pa.us        4342                 :           2762 :                     Constraint *n = makeNode(Constraint);
                               4343                 :                : 
                               4344                 :           2762 :                     n->contype = CONSTR_UNIQUE;
                               4345                 :           2762 :                     n->location = @1;
                               4346                 :           2762 :                     n->keys = NIL;
 3134 teodor@sigaev.ru         4347                 :           2762 :                     n->including = NIL;
 5763 tgl@sss.pgh.pa.us        4348                 :           2762 :                     n->options = NIL;
                               4349                 :           2762 :                     n->indexname = $2;
                               4350                 :           2762 :                     n->indexspace = NULL;
 5622                          4351                 :           2762 :                     processCASbits($3, @3, "UNIQUE",
                               4352                 :                :                                    &n->deferrable, &n->initdeferred, NULL,
                               4353                 :                :                                    NULL, NULL, yyscanner);
 1637 peter@eisentraut.org     4354                 :           2762 :                     $$ = (Node *) n;
                               4355                 :                :                 }
                               4356                 :                :             | PRIMARY KEY '(' columnList opt_without_overlaps ')' opt_c_include opt_definition OptConsTableSpace
                               4357                 :                :                 ConstraintAttributeSpec
                               4358                 :                :                 {
 9745 tgl@sss.pgh.pa.us        4359                 :           1403 :                     Constraint *n = makeNode(Constraint);
                               4360                 :                : 
                               4361                 :           1403 :                     n->contype = CONSTR_PRIMARY;
 6307                          4362                 :           1403 :                     n->location = @1;
 9745                          4363                 :           1403 :                     n->keys = $4;
  779 peter@eisentraut.org     4364                 :           1403 :                     n->without_overlaps = $5;
                               4365                 :           1403 :                     n->including = $7;
                               4366                 :           1403 :                     n->options = $8;
 5763 tgl@sss.pgh.pa.us        4367                 :           1403 :                     n->indexname = NULL;
  779 peter@eisentraut.org     4368                 :           1403 :                     n->indexspace = $9;
                               4369                 :           1403 :                     processCASbits($10, @10, "PRIMARY KEY",
                               4370                 :                :                                    &n->deferrable, &n->initdeferred, NULL,
                               4371                 :                :                                    NULL, NULL, yyscanner);
 1637                          4372                 :           1403 :                     $$ = (Node *) n;
                               4373                 :                :                 }
                               4374                 :                :             | PRIMARY KEY ExistingIndex ConstraintAttributeSpec
                               4375                 :                :                 {
 5763 tgl@sss.pgh.pa.us        4376                 :           3578 :                     Constraint *n = makeNode(Constraint);
                               4377                 :                : 
                               4378                 :           3578 :                     n->contype = CONSTR_PRIMARY;
                               4379                 :           3578 :                     n->location = @1;
                               4380                 :           3578 :                     n->keys = NIL;
 3134 teodor@sigaev.ru         4381                 :           3578 :                     n->including = NIL;
 5763 tgl@sss.pgh.pa.us        4382                 :           3578 :                     n->options = NIL;
                               4383                 :           3578 :                     n->indexname = $3;
                               4384                 :           3578 :                     n->indexspace = NULL;
 5622                          4385                 :           3578 :                     processCASbits($4, @4, "PRIMARY KEY",
                               4386                 :                :                                    &n->deferrable, &n->initdeferred, NULL,
                               4387                 :                :                                    NULL, NULL, yyscanner);
 1637 peter@eisentraut.org     4388                 :           3578 :                     $$ = (Node *) n;
                               4389                 :                :                 }
                               4390                 :                :             | EXCLUDE access_method_clause '(' ExclusionConstraintList ')'
                               4391                 :                :                 opt_c_include opt_definition OptConsTableSpace OptWhereClause
                               4392                 :                :                 ConstraintAttributeSpec
                               4393                 :                :                 {
 6177 tgl@sss.pgh.pa.us        4394                 :            170 :                     Constraint *n = makeNode(Constraint);
                               4395                 :                : 
                               4396                 :            170 :                     n->contype = CONSTR_EXCLUSION;
                               4397                 :            170 :                     n->location = @1;
 1940 peter@eisentraut.org     4398                 :            170 :                     n->access_method = $2;
                               4399                 :            170 :                     n->exclusions = $4;
                               4400                 :            170 :                     n->including = $6;
                               4401                 :            170 :                     n->options = $7;
                               4402                 :            170 :                     n->indexname = NULL;
                               4403                 :            170 :                     n->indexspace = $8;
                               4404                 :            170 :                     n->where_clause = $9;
 3134 teodor@sigaev.ru         4405                 :            170 :                     processCASbits($10, @10, "EXCLUDE",
                               4406                 :                :                                    &n->deferrable, &n->initdeferred, NULL,
                               4407                 :                :                                    NULL, NULL, yyscanner);
 1637 peter@eisentraut.org     4408                 :            170 :                     $$ = (Node *) n;
                               4409                 :                :                 }
                               4410                 :                :             | FOREIGN KEY '(' columnList optionalPeriodName ')' REFERENCES qualified_name
                               4411                 :                :                 opt_column_and_period_list key_match key_actions ConstraintAttributeSpec
                               4412                 :                :                 {
 6307 tgl@sss.pgh.pa.us        4413                 :           1217 :                     Constraint *n = makeNode(Constraint);
                               4414                 :                : 
                               4415                 :           1217 :                     n->contype = CONSTR_FOREIGN;
                               4416                 :           1217 :                     n->location = @1;
  779 peter@eisentraut.org     4417                 :           1217 :                     n->pktable = $8;
 1940                          4418                 :           1217 :                     n->fk_attrs = $4;
  779                          4419         [ +  + ]:           1217 :                     if ($5)
                               4420                 :                :                     {
                               4421                 :            210 :                         n->fk_attrs = lappend(n->fk_attrs, $5);
                               4422                 :            210 :                         n->fk_with_period = true;
                               4423                 :                :                     }
                               4424                 :           1217 :                     n->pk_attrs = linitial($9);
                               4425         [ +  + ]:           1217 :                     if (lsecond($9))
                               4426                 :                :                     {
                               4427                 :            112 :                         n->pk_attrs = lappend(n->pk_attrs, lsecond($9));
                               4428                 :            112 :                         n->pk_with_period = true;
                               4429                 :                :                     }
                               4430                 :           1217 :                     n->fk_matchtype = $10;
                               4431                 :           1217 :                     n->fk_upd_action = ($11)->updateAction->action;
                               4432                 :           1217 :                     n->fk_del_action = ($11)->deleteAction->action;
                               4433                 :           1217 :                     n->fk_del_set_cols = ($11)->deleteAction->cols;
                               4434                 :           1217 :                     processCASbits($12, @12, "FOREIGN KEY",
                               4435                 :                :                                    &n->deferrable, &n->initdeferred,
                               4436                 :                :                                    &n->is_enforced, &n->skip_validation, NULL,
                               4437                 :                :                                    yyscanner);
 5622 tgl@sss.pgh.pa.us        4438                 :           1217 :                     n->initially_valid = !n->skip_validation;
 1637 peter@eisentraut.org     4439                 :           1217 :                     $$ = (Node *) n;
                               4440                 :                :                 }
                               4441                 :                :         ;
                               4442                 :                : 
                               4443                 :                : /*
                               4444                 :                :  * DomainConstraint is separate from TableConstraint because the syntax for
                               4445                 :                :  * NOT NULL constraints is different.  For table constraints, we need to
                               4446                 :                :  * accept a column name, but for domain constraints, we don't.  (We could
                               4447                 :                :  * accept something like NOT NULL VALUE, but that seems weird.)  CREATE DOMAIN
                               4448                 :                :  * (which uses ColQualList) has for a long time accepted NOT NULL without a
                               4449                 :                :  * column name, so it makes sense that ALTER DOMAIN (which uses
                               4450                 :                :  * DomainConstraint) does as well.  None of these syntaxes are per SQL
                               4451                 :                :  * standard; we are just living with the bits of inconsistency that have built
                               4452                 :                :  * up over time.
                               4453                 :                :  */
                               4454                 :                : DomainConstraint:
                               4455                 :                :             CONSTRAINT name DomainConstraintElem
                               4456                 :                :                 {
  934                          4457                 :            113 :                     Constraint *n = castNode(Constraint, $3);
                               4458                 :                : 
                               4459                 :            113 :                     n->conname = $2;
                               4460                 :            113 :                     n->location = @1;
                               4461                 :            113 :                     $$ = (Node *) n;
                               4462                 :                :                 }
                               4463                 :             12 :             | DomainConstraintElem                  { $$ = $1; }
                               4464                 :                :         ;
                               4465                 :                : 
                               4466                 :                : DomainConstraintElem:
                               4467                 :                :             CHECK '(' a_expr ')' ConstraintAttributeSpec
                               4468                 :                :                 {
                               4469                 :            113 :                     Constraint *n = makeNode(Constraint);
                               4470                 :                : 
                               4471                 :            113 :                     n->contype = CONSTR_CHECK;
                               4472                 :            113 :                     n->location = @1;
                               4473                 :            113 :                     n->raw_expr = $3;
                               4474                 :            113 :                     n->cooked_expr = NULL;
                               4475                 :            113 :                     processCASbits($5, @5, "CHECK",
                               4476                 :                :                                    NULL, NULL, NULL, &n->skip_validation,
                               4477                 :                :                                    &n->is_no_inherit, yyscanner);
  663                          4478                 :            105 :                     n->is_enforced = true;
  934                          4479                 :            105 :                     n->initially_valid = !n->skip_validation;
                               4480                 :            105 :                     $$ = (Node *) n;
                               4481                 :                :                 }
                               4482                 :                :             | NOT NULL_P ConstraintAttributeSpec
                               4483                 :                :                 {
                               4484                 :             20 :                     Constraint *n = makeNode(Constraint);
                               4485                 :                : 
                               4486                 :             20 :                     n->contype = CONSTR_NOTNULL;
                               4487                 :             20 :                     n->location = @1;
                               4488                 :             20 :                     n->keys = list_make1(makeString("value"));
                               4489                 :                :                     /* no NOT VALID, NO INHERIT support */
                               4490                 :             20 :                     processCASbits($3, @3, "NOT NULL",
                               4491                 :                :                                    NULL, NULL, NULL,
                               4492                 :                :                                    NULL, NULL, yyscanner);
                               4493                 :             20 :                     n->initially_valid = true;
                               4494                 :             20 :                     $$ = (Node *) n;
                               4495                 :                :                 }
                               4496                 :                :         ;
                               4497                 :                : 
 3368 peter_e@gmx.net          4498                 :             97 : opt_no_inherit: NO INHERIT                          {  $$ = true; }
                               4499                 :           4810 :             | /* EMPTY */                           {  $$ = false; }
                               4500                 :                :         ;
                               4501                 :                : 
                               4502                 :                : opt_without_overlaps:
  779 peter@eisentraut.org     4503                 :            391 :             WITHOUT OVERLAPS                        { $$ = true; }
                               4504                 :           1451 :             | /*EMPTY*/                             { $$ = false; }
                               4505                 :                :     ;
                               4506                 :                : 
                               4507                 :                : opt_column_list:
 8907 bruce@momjian.us         4508                 :           5888 :             '(' columnList ')'                      { $$ = $2; }
                               4509                 :          22215 :             | /*EMPTY*/                             { $$ = NIL; }
                               4510                 :                :         ;
                               4511                 :                : 
                               4512                 :                : columnList:
 8194 neilc@samurai.com        4513                 :          10030 :             columnElem                              { $$ = list_make1($1); }
 8906 bruce@momjian.us         4514                 :          15771 :             | columnList ',' columnElem             { $$ = lappend($1, $3); }
                               4515                 :                :         ;
                               4516                 :                : 
                               4517                 :                : optionalPeriodName:
  779 peter@eisentraut.org     4518                 :            322 :             ',' PERIOD columnElem { $$ = $3; }
                               4519                 :           1616 :             | /*EMPTY*/               { $$ = NULL; }
                               4520                 :                :     ;
                               4521                 :                : 
                               4522                 :                : opt_column_and_period_list:
                               4523                 :            717 :             '(' columnList optionalPeriodName ')'           { $$ = list_make2($2, $3); }
                               4524                 :            504 :             | /*EMPTY*/                             { $$ = list_make2(NIL, NULL); }
                               4525                 :                :         ;
                               4526                 :                : 
                               4527                 :                : columnElem: ColId
                               4528                 :                :                 {
 8844 tgl@sss.pgh.pa.us        4529                 :          26123 :                     $$ = (Node *) makeString($1);
                               4530                 :                :                 }
                               4531                 :                :         ;
                               4532                 :                : 
 3134 teodor@sigaev.ru         4533                 :            100 : opt_c_include:  INCLUDE '(' columnList ')'          { $$ = $3; }
                               4534                 :           1912 :              |      /* EMPTY */                     { $$ = NIL; }
                               4535                 :                :         ;
                               4536                 :                : 
                               4537                 :                : key_match:  MATCH FULL
                               4538                 :                :             {
 8882 tgl@sss.pgh.pa.us        4539                 :             65 :                 $$ = FKCONSTR_MATCH_FULL;
                               4540                 :                :             }
                               4541                 :                :         | MATCH PARTIAL
                               4542                 :                :             {
 8510 tgl@sss.pgh.pa.us        4543         [ #  # ]:UBC           0 :                 ereport(ERROR,
                               4544                 :                :                         (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               4545                 :                :                          errmsg("MATCH PARTIAL not yet implemented"),
                               4546                 :                :                          parser_errposition(@1)));
                               4547                 :                :                 $$ = FKCONSTR_MATCH_PARTIAL;
                               4548                 :                :             }
                               4549                 :                :         | MATCH SIMPLE
                               4550                 :                :             {
 5254 tgl@sss.pgh.pa.us        4551                 :CBC           4 :                 $$ = FKCONSTR_MATCH_SIMPLE;
                               4552                 :                :             }
                               4553                 :                :         | /*EMPTY*/
                               4554                 :                :             {
                               4555                 :           1823 :                 $$ = FKCONSTR_MATCH_SIMPLE;
                               4556                 :                :             }
                               4557                 :                :         ;
                               4558                 :                : 
                               4559                 :                : ExclusionConstraintList:
 6177                          4560                 :            170 :             ExclusionConstraintElem                 { $$ = list_make1($1); }
                               4561                 :                :             | ExclusionConstraintList ',' ExclusionConstraintElem
                               4562                 :             85 :                                                     { $$ = lappend($1, $3); }
                               4563                 :                :         ;
                               4564                 :                : 
                               4565                 :                : ExclusionConstraintElem: index_elem WITH any_operator
                               4566                 :                :             {
                               4567                 :            255 :                 $$ = list_make2($1, $3);
                               4568                 :                :             }
                               4569                 :                :             /* allow OPERATOR() decoration for the benefit of ruleutils.c */
                               4570                 :                :             | index_elem WITH OPERATOR '(' any_operator ')'
                               4571                 :                :             {
 6177 tgl@sss.pgh.pa.us        4572                 :UBC           0 :                 $$ = list_make2($1, $5);
                               4573                 :                :             }
                               4574                 :                :         ;
                               4575                 :                : 
                               4576                 :                : OptWhereClause:
 6177 tgl@sss.pgh.pa.us        4577                 :CBC         308 :             WHERE '(' a_expr ')'                    { $$ = $3; }
                               4578                 :            849 :             | /*EMPTY*/                             { $$ = NULL; }
                               4579                 :                :         ;
                               4580                 :                : 
                               4581                 :                : key_actions:
                               4582                 :                :             key_update
                               4583                 :                :                 {
  330 michael@paquier.xyz      4584                 :             49 :                     KeyActions *n = palloc_object(KeyActions);
                               4585                 :                : 
 1793 peter@eisentraut.org     4586                 :             49 :                     n->updateAction = $1;
  330 michael@paquier.xyz      4587                 :             49 :                     n->deleteAction = palloc_object(KeyAction);
 1793 peter@eisentraut.org     4588                 :             49 :                     n->deleteAction->action = FKCONSTR_ACTION_NOACTION;
                               4589                 :             49 :                     n->deleteAction->cols = NIL;
                               4590                 :             49 :                     $$ = n;
                               4591                 :                :                 }
                               4592                 :                :             | key_delete
                               4593                 :                :                 {
  330 michael@paquier.xyz      4594                 :             97 :                     KeyActions *n = palloc_object(KeyActions);
                               4595                 :                : 
                               4596                 :             97 :                     n->updateAction = palloc_object(KeyAction);
 1793 peter@eisentraut.org     4597                 :             97 :                     n->updateAction->action = FKCONSTR_ACTION_NOACTION;
                               4598                 :             97 :                     n->updateAction->cols = NIL;
                               4599                 :             97 :                     n->deleteAction = $1;
                               4600                 :             97 :                     $$ = n;
                               4601                 :                :                 }
                               4602                 :                :             | key_update key_delete
                               4603                 :                :                 {
  330 michael@paquier.xyz      4604                 :            111 :                     KeyActions *n = palloc_object(KeyActions);
                               4605                 :                : 
 1793 peter@eisentraut.org     4606                 :            111 :                     n->updateAction = $1;
                               4607                 :            111 :                     n->deleteAction = $2;
                               4608                 :            111 :                     $$ = n;
                               4609                 :                :                 }
                               4610                 :                :             | key_delete key_update
                               4611                 :                :                 {
  330 michael@paquier.xyz      4612                 :            100 :                     KeyActions *n = palloc_object(KeyActions);
                               4613                 :                : 
 1793 peter@eisentraut.org     4614                 :            100 :                     n->updateAction = $2;
                               4615                 :            100 :                     n->deleteAction = $1;
                               4616                 :            100 :                     $$ = n;
                               4617                 :                :                 }
                               4618                 :                :             | /*EMPTY*/
                               4619                 :                :                 {
  330 michael@paquier.xyz      4620                 :           1531 :                     KeyActions *n = palloc_object(KeyActions);
                               4621                 :                : 
                               4622                 :           1531 :                     n->updateAction = palloc_object(KeyAction);
 1793 peter@eisentraut.org     4623                 :           1531 :                     n->updateAction->action = FKCONSTR_ACTION_NOACTION;
                               4624                 :           1531 :                     n->updateAction->cols = NIL;
  330 michael@paquier.xyz      4625                 :           1531 :                     n->deleteAction = palloc_object(KeyAction);
 1793 peter@eisentraut.org     4626                 :           1531 :                     n->deleteAction->action = FKCONSTR_ACTION_NOACTION;
                               4627                 :           1531 :                     n->deleteAction->cols = NIL;
                               4628                 :           1531 :                     $$ = n;
                               4629                 :                :                 }
                               4630                 :                :         ;
                               4631                 :                : 
                               4632                 :                : key_update: ON UPDATE key_action
                               4633                 :                :                 {
                               4634         [ +  + ]:            264 :                     if (($3)->cols)
                               4635   [ +  -  +  - ]:              4 :                         ereport(ERROR,
                               4636                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               4637                 :                :                                  errmsg("a column list with %s is only supported for ON DELETE actions",
                               4638                 :                :                                         ($3)->action == FKCONSTR_ACTION_SETNULL ? "SET NULL" : "SET DEFAULT"),
                               4639                 :                :                                  parser_errposition(@1)));
                               4640                 :            260 :                     $$ = $3;
                               4641                 :                :                 }
                               4642                 :                :         ;
                               4643                 :                : 
                               4644                 :                : key_delete: ON DELETE_P key_action
                               4645                 :                :                 {
                               4646                 :            308 :                     $$ = $3;
                               4647                 :                :                 }
                               4648                 :                :         ;
                               4649                 :                : 
                               4650                 :                : key_action:
                               4651                 :                :             NO ACTION
                               4652                 :                :                 {
  330 michael@paquier.xyz      4653                 :             51 :                     KeyAction *n = palloc_object(KeyAction);
                               4654                 :                : 
 1793 peter@eisentraut.org     4655                 :             51 :                     n->action = FKCONSTR_ACTION_NOACTION;
                               4656                 :             51 :                     n->cols = NIL;
                               4657                 :             51 :                     $$ = n;
                               4658                 :                :                 }
                               4659                 :                :             | RESTRICT
                               4660                 :                :                 {
  330 michael@paquier.xyz      4661                 :             32 :                     KeyAction *n = palloc_object(KeyAction);
                               4662                 :                : 
 1793 peter@eisentraut.org     4663                 :             32 :                     n->action = FKCONSTR_ACTION_RESTRICT;
                               4664                 :             32 :                     n->cols = NIL;
                               4665                 :             32 :                     $$ = n;
                               4666                 :                :                 }
                               4667                 :                :             | CASCADE
                               4668                 :                :                 {
  330 michael@paquier.xyz      4669                 :            297 :                     KeyAction *n = palloc_object(KeyAction);
                               4670                 :                : 
 1793 peter@eisentraut.org     4671                 :            297 :                     n->action = FKCONSTR_ACTION_CASCADE;
                               4672                 :            297 :                     n->cols = NIL;
                               4673                 :            297 :                     $$ = n;
                               4674                 :                :                 }
                               4675                 :                :             | SET NULL_P opt_column_list
                               4676                 :                :                 {
  330 michael@paquier.xyz      4677                 :            124 :                     KeyAction *n = palloc_object(KeyAction);
                               4678                 :                : 
 1793 peter@eisentraut.org     4679                 :            124 :                     n->action = FKCONSTR_ACTION_SETNULL;
                               4680                 :            124 :                     n->cols = $3;
                               4681                 :            124 :                     $$ = n;
                               4682                 :                :                 }
                               4683                 :                :             | SET DEFAULT opt_column_list
                               4684                 :                :                 {
  330 michael@paquier.xyz      4685                 :             68 :                     KeyAction *n = palloc_object(KeyAction);
                               4686                 :                : 
 1793 peter@eisentraut.org     4687                 :             68 :                     n->action = FKCONSTR_ACTION_SETDEFAULT;
                               4688                 :             68 :                     n->cols = $3;
                               4689                 :             68 :                     $$ = n;
                               4690                 :                :                 }
                               4691                 :                :         ;
                               4692                 :                : 
 8907 bruce@momjian.us         4693                 :           1408 : OptInherit: INHERITS '(' qualified_name_list ')'    { $$ = $3; }
                               4694                 :          18577 :             | /*EMPTY*/                             { $$ = NIL; }
                               4695                 :                :         ;
                               4696                 :                : 
                               4697                 :                : /* Optional partition key specification */
 3620 rhaas@postgresql.org     4698                 :           3455 : OptPartitionSpec: PartitionSpec { $$ = $1; }
                               4699                 :          22334 :             | /*EMPTY*/         { $$ = NULL; }
                               4700                 :                :         ;
                               4701                 :                : 
                               4702                 :                : PartitionSpec: PARTITION BY ColId '(' part_params ')'
                               4703                 :                :                 {
                               4704                 :           3459 :                     PartitionSpec *n = makeNode(PartitionSpec);
                               4705                 :                : 
  735 tgl@sss.pgh.pa.us        4706                 :           3459 :                     n->strategy = parsePartitionStrategy($3, @3, yyscanner);
 3620 rhaas@postgresql.org     4707                 :           3455 :                     n->partParams = $5;
                               4708                 :           3455 :                     n->location = @1;
                               4709                 :                : 
                               4710                 :           3455 :                     $$ = n;
                               4711                 :                :                 }
                               4712                 :                :         ;
                               4713                 :                : 
                               4714                 :           3459 : part_params:    part_elem                       { $$ = list_make1($1); }
                               4715                 :            322 :             | part_params ',' part_elem         { $$ = lappend($1, $3); }
                               4716                 :                :         ;
                               4717                 :                : 
                               4718                 :                : part_elem: ColId opt_collate opt_qualified_name
                               4719                 :                :                 {
                               4720                 :           3549 :                     PartitionElem *n = makeNode(PartitionElem);
                               4721                 :                : 
                               4722                 :           3549 :                     n->name = $1;
                               4723                 :           3549 :                     n->expr = NULL;
                               4724                 :           3549 :                     n->collation = $2;
                               4725                 :           3549 :                     n->opclass = $3;
                               4726                 :           3549 :                     n->location = @1;
                               4727                 :           3549 :                     $$ = n;
                               4728                 :                :                 }
                               4729                 :                :             | func_expr_windowless opt_collate opt_qualified_name
                               4730                 :                :                 {
                               4731                 :             86 :                     PartitionElem *n = makeNode(PartitionElem);
                               4732                 :                : 
                               4733                 :             86 :                     n->name = NULL;
                               4734                 :             86 :                     n->expr = $1;
                               4735                 :             86 :                     n->collation = $2;
                               4736                 :             86 :                     n->opclass = $3;
                               4737                 :             86 :                     n->location = @1;
                               4738                 :             86 :                     $$ = n;
                               4739                 :                :                 }
                               4740                 :                :             | '(' a_expr ')' opt_collate opt_qualified_name
                               4741                 :                :                 {
                               4742                 :            146 :                     PartitionElem *n = makeNode(PartitionElem);
                               4743                 :                : 
                               4744                 :            146 :                     n->name = NULL;
                               4745                 :            146 :                     n->expr = $2;
                               4746                 :            146 :                     n->collation = $4;
                               4747                 :            146 :                     n->opclass = $5;
                               4748                 :            146 :                     n->location = @1;
                               4749                 :            146 :                     $$ = n;
                               4750                 :                :                 }
                               4751                 :                :         ;
                               4752                 :                : 
                               4753                 :                : table_access_method_clause:
 2339 peter@eisentraut.org     4754                 :             79 :             USING name                          { $$ = $2; }
 2801 andres@anarazel.de       4755                 :          26994 :             | /*EMPTY*/                         { $$ = NULL; }
                               4756                 :                :         ;
                               4757                 :                : 
                               4758                 :                : /* WITHOUT OIDS is legacy only */
                               4759                 :                : OptWith:
 6485 alvherre@alvh.no-ip.     4760                 :            688 :             WITH reloptions             { $$ = $2; }
 2907 andres@anarazel.de       4761                 :             16 :             | WITHOUT OIDS              { $$ = NIL; }
 7430 tgl@sss.pgh.pa.us        4762                 :          25995 :             | /*EMPTY*/                 { $$ = NIL; }
                               4763                 :                :         ;
                               4764                 :                : 
 8760                          4765                 :             39 : OnCommitOption:  ON COMMIT DROP             { $$ = ONCOMMIT_DROP; }
                               4766                 :             69 :             | ON COMMIT DELETE_P ROWS       { $$ = ONCOMMIT_DELETE_ROWS; }
                               4767                 :             16 :             | ON COMMIT PRESERVE ROWS       { $$ = ONCOMMIT_PRESERVE_ROWS; }
                               4768                 :          26575 :             | /*EMPTY*/                     { $$ = ONCOMMIT_NOOP; }
                               4769                 :                :         ;
                               4770                 :                : 
 8175                          4771                 :            143 : OptTableSpace:   TABLESPACE name                    { $$ = $2; }
                               4772                 :          31580 :             | /*EMPTY*/                             { $$ = NULL; }
                               4773                 :                :         ;
                               4774                 :                : 
 8130                          4775                 :             42 : OptConsTableSpace:   USING INDEX TABLESPACE name    { $$ = $4; }
                               4776                 :           5954 :             | /*EMPTY*/                             { $$ = NULL; }
                               4777                 :                :         ;
                               4778                 :                : 
 2339 peter@eisentraut.org     4779                 :           6340 : ExistingIndex:   USING INDEX name                   { $$ = $3; }
                               4780                 :                :         ;
                               4781                 :                : 
                               4782                 :                : /*****************************************************************************
                               4783                 :                :  *
                               4784                 :                :  *      QUERY :
                               4785                 :                :  *              CREATE STATISTICS [[IF NOT EXISTS] stats_name] [(stat types)]
                               4786                 :                :  *                  ON expression-list FROM from_list
                               4787                 :                :  *
                               4788                 :                :  * Note: the expectation here is that the clauses after ON are a subset of
                               4789                 :                :  * SELECT syntax, allowing for expressions and joined tables, and probably
                               4790                 :                :  * someday a WHERE clause.  Much less than that is currently implemented,
                               4791                 :                :  * but the grammar accepts it and then we'll throw FEATURE_NOT_SUPPORTED
                               4792                 :                :  * errors as necessary at execution.
                               4793                 :                :  *
                               4794                 :                :  * Statistics name is optional unless IF NOT EXISTS is specified.
                               4795                 :                :  *
                               4796                 :                :  *****************************************************************************/
                               4797                 :                : 
                               4798                 :                : CreateStatsStmt:
                               4799                 :                :             CREATE STATISTICS opt_qualified_name
                               4800                 :                :             opt_name_list ON stats_params FROM from_list
                               4801                 :                :                 {
 3464 alvherre@alvh.no-ip.     4802                 :            659 :                     CreateStatsStmt *n = makeNode(CreateStatsStmt);
                               4803                 :                : 
 3423                          4804                 :            659 :                     n->defnames = $3;
                               4805                 :            659 :                     n->stat_types = $4;
                               4806                 :            659 :                     n->exprs = $6;
                               4807                 :            659 :                     n->relations = $8;
 3167                          4808                 :            659 :                     n->stxcomment = NULL;
 3423                          4809                 :            659 :                     n->if_not_exists = false;
 1637 peter@eisentraut.org     4810                 :            659 :                     $$ = (Node *) n;
                               4811                 :                :                 }
                               4812                 :                :             | CREATE STATISTICS IF_P NOT EXISTS any_name
                               4813                 :                :             opt_name_list ON stats_params FROM from_list
                               4814                 :                :                 {
 3423 alvherre@alvh.no-ip.     4815                 :              8 :                     CreateStatsStmt *n = makeNode(CreateStatsStmt);
                               4816                 :                : 
                               4817                 :              8 :                     n->defnames = $6;
                               4818                 :              8 :                     n->stat_types = $7;
                               4819                 :              8 :                     n->exprs = $9;
                               4820                 :              8 :                     n->relations = $11;
 3167                          4821                 :              8 :                     n->stxcomment = NULL;
 3423                          4822                 :              8 :                     n->if_not_exists = true;
 1637 peter@eisentraut.org     4823                 :              8 :                     $$ = (Node *) n;
                               4824                 :                :                 }
                               4825                 :                :             ;
                               4826                 :                : 
                               4827                 :                : /*
                               4828                 :                :  * Statistics attributes can be either simple column references, or arbitrary
                               4829                 :                :  * expressions in parens.  For compatibility with index attributes permitted
                               4830                 :                :  * in CREATE INDEX, we allow an expression that's just a function call to be
                               4831                 :                :  * written without parens.
                               4832                 :                :  */
                               4833                 :                : 
 2050 tomas.vondra@postgre     4834                 :            675 : stats_params:   stats_param                         { $$ = list_make1($1); }
                               4835                 :            923 :             | stats_params ',' stats_param          { $$ = lappend($1, $3); }
                               4836                 :                :         ;
                               4837                 :                : 
                               4838                 :                : stats_param:    ColId
                               4839                 :                :                 {
                               4840                 :           1159 :                     $$ = makeNode(StatsElem);
                               4841                 :           1159 :                     $$->name = $1;
                               4842                 :           1159 :                     $$->expr = NULL;
                               4843                 :                :                 }
                               4844                 :                :             | func_expr_windowless
                               4845                 :                :                 {
                               4846                 :             69 :                     $$ = makeNode(StatsElem);
                               4847                 :             69 :                     $$->name = NULL;
                               4848                 :             69 :                     $$->expr = $1;
                               4849                 :                :                 }
                               4850                 :                :             | '(' a_expr ')'
                               4851                 :                :                 {
                               4852                 :            370 :                     $$ = makeNode(StatsElem);
                               4853                 :            370 :                     $$->name = NULL;
                               4854                 :            370 :                     $$->expr = $2;
                               4855                 :                :                 }
                               4856                 :                :         ;
                               4857                 :                : 
                               4858                 :                : /*****************************************************************************
                               4859                 :                :  *
                               4860                 :                :  *      QUERY :
                               4861                 :                :  *              ALTER STATISTICS [IF EXISTS] stats_name
                               4862                 :                :  *                  SET STATISTICS  <SignedIconst>
                               4863                 :                :  *
                               4864                 :                :  *****************************************************************************/
                               4865                 :                : 
                               4866                 :                : AlterStatsStmt:
                               4867                 :                :             ALTER STATISTICS any_name SET STATISTICS set_statistics_value
                               4868                 :                :                 {
 2613                          4869                 :             13 :                     AlterStatsStmt *n = makeNode(AlterStatsStmt);
                               4870                 :                : 
                               4871                 :             13 :                     n->defnames = $3;
                               4872                 :             13 :                     n->missing_ok = false;
                               4873                 :             13 :                     n->stxstattarget = $6;
 1637 peter@eisentraut.org     4874                 :             13 :                     $$ = (Node *) n;
                               4875                 :                :                 }
                               4876                 :                :             | ALTER STATISTICS IF_P EXISTS any_name SET STATISTICS set_statistics_value
                               4877                 :                :                 {
 2613 tomas.vondra@postgre     4878                 :              4 :                     AlterStatsStmt *n = makeNode(AlterStatsStmt);
                               4879                 :                : 
                               4880                 :              4 :                     n->defnames = $5;
                               4881                 :              4 :                     n->missing_ok = true;
                               4882                 :              4 :                     n->stxstattarget = $8;
 1637 peter@eisentraut.org     4883                 :              4 :                     $$ = (Node *) n;
                               4884                 :                :                 }
                               4885                 :                :             ;
                               4886                 :                : 
                               4887                 :                : /*****************************************************************************
                               4888                 :                :  *
                               4889                 :                :  *      QUERY :
                               4890                 :                :  *              CREATE TABLE relname AS SelectStmt [ WITH [NO] DATA ]
                               4891                 :                :  *
                               4892                 :                :  *
                               4893                 :                :  * Note: SELECT ... INTO is a now-deprecated alternative for this.
                               4894                 :                :  *
                               4895                 :                :  *****************************************************************************/
                               4896                 :                : 
                               4897                 :                : CreateAsStmt:
                               4898                 :                :         CREATE OptTemp TABLE create_as_target AS SelectStmt opt_with_data
                               4899                 :                :                 {
 5344 tgl@sss.pgh.pa.us        4900                 :            830 :                     CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
                               4901                 :                : 
                               4902                 :            830 :                     ctas->query = $6;
                               4903                 :            830 :                     ctas->into = $4;
 2308 michael@paquier.xyz      4904                 :            830 :                     ctas->objtype = OBJECT_TABLE;
 5344 tgl@sss.pgh.pa.us        4905                 :            830 :                     ctas->is_select_into = false;
 4345 andrew@dunslane.net      4906                 :            830 :                     ctas->if_not_exists = false;
                               4907                 :                :                     /* cram additional flags into the IntoClause */
 5460 tgl@sss.pgh.pa.us        4908                 :            830 :                     $4->rel->relpersistence = $2;
                               4909                 :            830 :                     $4->skipData = !($7);
 5344                          4910                 :            830 :                     $$ = (Node *) ctas;
                               4911                 :                :                 }
                               4912                 :                :         | CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS SelectStmt opt_with_data
                               4913                 :                :                 {
 4345 andrew@dunslane.net      4914                 :             30 :                     CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
                               4915                 :                : 
                               4916                 :             30 :                     ctas->query = $9;
                               4917                 :             30 :                     ctas->into = $7;
 2308 michael@paquier.xyz      4918                 :             30 :                     ctas->objtype = OBJECT_TABLE;
 4345 andrew@dunslane.net      4919                 :             30 :                     ctas->is_select_into = false;
                               4920                 :             30 :                     ctas->if_not_exists = true;
                               4921                 :                :                     /* cram additional flags into the IntoClause */
                               4922                 :             30 :                     $7->rel->relpersistence = $2;
                               4923                 :             30 :                     $7->skipData = !($10);
                               4924                 :             30 :                     $$ = (Node *) ctas;
                               4925                 :                :                 }
                               4926                 :                :         ;
                               4927                 :                : 
                               4928                 :                : create_as_target:
                               4929                 :                :             qualified_name opt_column_list table_access_method_clause
                               4930                 :                :             OptWith OnCommitOption OptTableSpace
                               4931                 :                :                 {
 7198 tgl@sss.pgh.pa.us        4932                 :            918 :                     $$ = makeNode(IntoClause);
                               4933                 :            918 :                     $$->rel = $1;
                               4934                 :            918 :                     $$->colNames = $2;
 2801 andres@anarazel.de       4935                 :            918 :                     $$->accessMethod = $3;
                               4936                 :            918 :                     $$->options = $4;
                               4937                 :            918 :                     $$->onCommit = $5;
                               4938                 :            918 :                     $$->tableSpaceName = $6;
 4955 tgl@sss.pgh.pa.us        4939                 :            918 :                     $$->viewQuery = NULL;
 5460                          4940                 :            918 :                     $$->skipData = false;        /* might get changed later */
                               4941                 :                :                 }
                               4942                 :                :         ;
                               4943                 :                : 
                               4944                 :                : opt_with_data:
 3368 peter_e@gmx.net          4945                 :             24 :             WITH DATA_P                             { $$ = true; }
                               4946                 :            144 :             | WITH NO DATA_P                        { $$ = false; }
                               4947                 :           1294 :             | /*EMPTY*/                             { $$ = true; }
                               4948                 :                :         ;
                               4949                 :                : 
                               4950                 :                : 
                               4951                 :                : /*****************************************************************************
                               4952                 :                :  *
                               4953                 :                :  *      QUERY :
                               4954                 :                :  *              CREATE MATERIALIZED VIEW relname AS SelectStmt
                               4955                 :                :  *
                               4956                 :                :  *****************************************************************************/
                               4957                 :                : 
                               4958                 :                : CreateMatViewStmt:
                               4959                 :                :         CREATE OptNoLog MATERIALIZED VIEW create_mv_target AS SelectStmt opt_with_data
                               4960                 :                :                 {
 4995 kgrittn@postgresql.o     4961                 :            341 :                     CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
                               4962                 :                : 
                               4963                 :            341 :                     ctas->query = $7;
                               4964                 :            341 :                     ctas->into = $5;
 2308 michael@paquier.xyz      4965                 :            341 :                     ctas->objtype = OBJECT_MATVIEW;
 4995 kgrittn@postgresql.o     4966                 :            341 :                     ctas->is_select_into = false;
 4345 andrew@dunslane.net      4967                 :            341 :                     ctas->if_not_exists = false;
                               4968                 :                :                     /* cram additional flags into the IntoClause */
 4995 kgrittn@postgresql.o     4969                 :            341 :                     $5->rel->relpersistence = $2;
                               4970                 :            341 :                     $5->skipData = !($8);
                               4971                 :            341 :                     $$ = (Node *) ctas;
                               4972                 :                :                 }
                               4973                 :                :         | CREATE OptNoLog MATERIALIZED VIEW IF_P NOT EXISTS create_mv_target AS SelectStmt opt_with_data
                               4974                 :                :                 {
 4345 andrew@dunslane.net      4975                 :             29 :                     CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
                               4976                 :                : 
                               4977                 :             29 :                     ctas->query = $10;
                               4978                 :             29 :                     ctas->into = $8;
 2308 michael@paquier.xyz      4979                 :             29 :                     ctas->objtype = OBJECT_MATVIEW;
 4345 andrew@dunslane.net      4980                 :             29 :                     ctas->is_select_into = false;
                               4981                 :             29 :                     ctas->if_not_exists = true;
                               4982                 :                :                     /* cram additional flags into the IntoClause */
                               4983                 :             29 :                     $8->rel->relpersistence = $2;
                               4984                 :             29 :                     $8->skipData = !($11);
                               4985                 :             29 :                     $$ = (Node *) ctas;
                               4986                 :                :                 }
                               4987                 :                :         ;
                               4988                 :                : 
                               4989                 :                : create_mv_target:
                               4990                 :                :             qualified_name opt_column_list table_access_method_clause opt_reloptions OptTableSpace
                               4991                 :                :                 {
 4995 kgrittn@postgresql.o     4992                 :            370 :                     $$ = makeNode(IntoClause);
                               4993                 :            370 :                     $$->rel = $1;
                               4994                 :            370 :                     $$->colNames = $2;
 2801 andres@anarazel.de       4995                 :            370 :                     $$->accessMethod = $3;
                               4996                 :            370 :                     $$->options = $4;
 4995 kgrittn@postgresql.o     4997                 :            370 :                     $$->onCommit = ONCOMMIT_NOOP;
 2801 andres@anarazel.de       4998                 :            370 :                     $$->tableSpaceName = $5;
 4955 tgl@sss.pgh.pa.us        4999                 :            370 :                     $$->viewQuery = NULL;        /* filled at analysis time */
 4995 kgrittn@postgresql.o     5000                 :            370 :                     $$->skipData = false;        /* might get changed later */
                               5001                 :                :                 }
                               5002                 :                :         ;
                               5003                 :                : 
 4995 kgrittn@postgresql.o     5004                 :UBC           0 : OptNoLog:   UNLOGGED                    { $$ = RELPERSISTENCE_UNLOGGED; }
 4995 kgrittn@postgresql.o     5005                 :CBC         370 :             | /*EMPTY*/                 { $$ = RELPERSISTENCE_PERMANENT; }
                               5006                 :                :         ;
                               5007                 :                : 
                               5008                 :                : 
                               5009                 :                : /*****************************************************************************
                               5010                 :                :  *
                               5011                 :                :  *      QUERY :
                               5012                 :                :  *              REFRESH MATERIALIZED VIEW qualified_name
                               5013                 :                :  *
                               5014                 :                :  *****************************************************************************/
                               5015                 :                : 
                               5016                 :                : RefreshMatViewStmt:
                               5017                 :                :             REFRESH MATERIALIZED VIEW opt_concurrently qualified_name opt_with_data
                               5018                 :                :                 {
                               5019                 :            174 :                     RefreshMatViewStmt *n = makeNode(RefreshMatViewStmt);
                               5020                 :                : 
 4860                          5021                 :            174 :                     n->concurrent = $4;
                               5022                 :            174 :                     n->relation = $5;
                               5023                 :            174 :                     n->skipData = !($6);
 4995                          5024                 :            174 :                     $$ = (Node *) n;
                               5025                 :                :                 }
                               5026                 :                :         ;
                               5027                 :                : 
                               5028                 :                : 
                               5029                 :                : /*****************************************************************************
                               5030                 :                :  *
                               5031                 :                :  *      QUERY :
                               5032                 :                :  *              CREATE SEQUENCE seqname
                               5033                 :                :  *              ALTER SEQUENCE seqname
                               5034                 :                :  *
                               5035                 :                :  *****************************************************************************/
                               5036                 :                : 
                               5037                 :                : CreateSeqStmt:
                               5038                 :                :             CREATE OptTemp SEQUENCE qualified_name OptSeqOptList
                               5039                 :                :                 {
10650 bruce@momjian.us         5040                 :            442 :                     CreateSeqStmt *n = makeNode(CreateSeqStmt);
                               5041                 :                : 
 5806 rhaas@postgresql.org     5042                 :            442 :                     $4->relpersistence = $2;
 8995 tgl@sss.pgh.pa.us        5043                 :            442 :                     n->sequence = $4;
 9266 bruce@momjian.us         5044                 :            442 :                     n->options = $5;
 5923 tgl@sss.pgh.pa.us        5045                 :            442 :                     n->ownerId = InvalidOid;
 4454 heikki.linnakangas@i     5046                 :            442 :                     n->if_not_exists = false;
 1637 peter@eisentraut.org     5047                 :            442 :                     $$ = (Node *) n;
                               5048                 :                :                 }
                               5049                 :                :             | CREATE OptTemp SEQUENCE IF_P NOT EXISTS qualified_name OptSeqOptList
                               5050                 :                :                 {
 4454 heikki.linnakangas@i     5051                 :             13 :                     CreateSeqStmt *n = makeNode(CreateSeqStmt);
                               5052                 :                : 
                               5053                 :             13 :                     $7->relpersistence = $2;
                               5054                 :             13 :                     n->sequence = $7;
                               5055                 :             13 :                     n->options = $8;
                               5056                 :             13 :                     n->ownerId = InvalidOid;
                               5057                 :             13 :                     n->if_not_exists = true;
 1637 peter@eisentraut.org     5058                 :             13 :                     $$ = (Node *) n;
                               5059                 :                :                 }
                               5060                 :                :         ;
                               5061                 :                : 
                               5062                 :                : AlterSeqStmt:
                               5063                 :                :             ALTER SEQUENCE qualified_name SeqOptList
                               5064                 :                :                 {
 8631 bruce@momjian.us         5065                 :            125 :                     AlterSeqStmt *n = makeNode(AlterSeqStmt);
                               5066                 :                : 
                               5067                 :            125 :                     n->sequence = $3;
                               5068                 :            125 :                     n->options = $4;
 5400 simon@2ndQuadrant.co     5069                 :            125 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     5070                 :            125 :                     $$ = (Node *) n;
                               5071                 :                :                 }
                               5072                 :                :             | ALTER SEQUENCE IF_P EXISTS qualified_name SeqOptList
                               5073                 :                :                 {
 5400 simon@2ndQuadrant.co     5074                 :              8 :                     AlterSeqStmt *n = makeNode(AlterSeqStmt);
                               5075                 :                : 
                               5076                 :              8 :                     n->sequence = $5;
                               5077                 :              8 :                     n->options = $6;
                               5078                 :              8 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     5079                 :              8 :                     $$ = (Node *) n;
                               5080                 :                :                 }
                               5081                 :                : 
                               5082                 :                :         ;
                               5083                 :                : 
 6717 tgl@sss.pgh.pa.us        5084                 :            164 : OptSeqOptList: SeqOptList                           { $$ = $1; }
 8858                          5085                 :            291 :             | /*EMPTY*/                             { $$ = NIL; }
                               5086                 :                :         ;
                               5087                 :                : 
 3500 peter_e@gmx.net          5088                 :             42 : OptParenthesizedSeqOptList: '(' SeqOptList ')'      { $$ = $2; }
                               5089                 :            302 :             | /*EMPTY*/                             { $$ = NIL; }
                               5090                 :                :         ;
                               5091                 :                : 
 6717 tgl@sss.pgh.pa.us        5092                 :            339 : SeqOptList: SeqOptElem                              { $$ = list_make1($1); }
                               5093                 :            441 :             | SeqOptList SeqOptElem                 { $$ = lappend($1, $2); }
                               5094                 :                :         ;
                               5095                 :                : 
                               5096                 :                : SeqOptElem: AS SimpleTypename
                               5097                 :                :                 {
 1637 peter@eisentraut.org     5098                 :            119 :                     $$ = makeDefElem("as", (Node *) $2, @1);
                               5099                 :                :                 }
                               5100                 :                :             | CACHE NumericOnly
                               5101                 :                :                 {
                               5102                 :             67 :                     $$ = makeDefElem("cache", (Node *) $2, @1);
                               5103                 :                :                 }
                               5104                 :                :             | CYCLE
                               5105                 :                :                 {
                               5106                 :             22 :                     $$ = makeDefElem("cycle", (Node *) makeBoolean(true), @1);
                               5107                 :                :                 }
                               5108                 :                :             | NO CYCLE
                               5109                 :                :                 {
                               5110                 :              9 :                     $$ = makeDefElem("cycle", (Node *) makeBoolean(false), @1);
                               5111                 :                :                 }
                               5112                 :                :             | INCREMENT opt_by NumericOnly
                               5113                 :                :                 {
                               5114                 :            150 :                     $$ = makeDefElem("increment", (Node *) $3, @1);
                               5115                 :                :                 }
                               5116                 :                :             | LOGGED
                               5117                 :                :                 {
  779 tgl@sss.pgh.pa.us        5118                 :              1 :                     $$ = makeDefElem("logged", NULL, @1);
                               5119                 :                :                 }
                               5120                 :                :             | MAXVALUE NumericOnly
                               5121                 :                :                 {
 1637 peter@eisentraut.org     5122                 :             43 :                     $$ = makeDefElem("maxvalue", (Node *) $2, @1);
                               5123                 :                :                 }
                               5124                 :                :             | MINVALUE NumericOnly
                               5125                 :                :                 {
                               5126                 :             43 :                     $$ = makeDefElem("minvalue", (Node *) $2, @1);
                               5127                 :                :                 }
                               5128                 :                :             | NO MAXVALUE
                               5129                 :                :                 {
 3712 peter_e@gmx.net          5130                 :             54 :                     $$ = makeDefElem("maxvalue", NULL, @1);
                               5131                 :                :                 }
                               5132                 :                :             | NO MINVALUE
                               5133                 :                :                 {
                               5134                 :             54 :                     $$ = makeDefElem("minvalue", NULL, @1);
                               5135                 :                :                 }
                               5136                 :                :             | OWNED BY any_name
                               5137                 :                :                 {
 1637 peter@eisentraut.org     5138                 :             43 :                     $$ = makeDefElem("owned_by", (Node *) $3, @1);
                               5139                 :                :                 }
                               5140                 :                :             | SEQUENCE NAME_P any_name
                               5141                 :                :                 {
                               5142                 :             22 :                     $$ = makeDefElem("sequence_name", (Node *) $3, @1);
                               5143                 :                :                 }
                               5144                 :                :             | START opt_with NumericOnly
                               5145                 :                :                 {
                               5146                 :            137 :                     $$ = makeDefElem("start", (Node *) $3, @1);
                               5147                 :                :                 }
                               5148                 :                :             | RESTART
                               5149                 :                :                 {
 3712 peter_e@gmx.net          5150                 :              4 :                     $$ = makeDefElem("restart", NULL, @1);
                               5151                 :                :                 }
                               5152                 :                :             | RESTART opt_with NumericOnly
                               5153                 :                :                 {
 1637 peter@eisentraut.org     5154                 :             47 :                     $$ = makeDefElem("restart", (Node *) $3, @1);
                               5155                 :                :                 }
                               5156                 :                :             | UNLOGGED
                               5157                 :                :                 {
  779 tgl@sss.pgh.pa.us        5158                 :              1 :                     $$ = makeDefElem("unlogged", NULL, @1);
                               5159                 :                :                 }
                               5160                 :                :         ;
                               5161                 :                : 
                               5162                 :                : opt_by:     BY
                               5163                 :                :             | /* EMPTY */
                               5164                 :                :       ;
                               5165                 :                : 
                               5166                 :                : NumericOnly:
 1883 peter@eisentraut.org     5167                 :            211 :             FCONST                              { $$ = (Node *) makeFloat($1); }
 1883 peter@eisentraut.org     5168                 :UBC           0 :             | '+' FCONST                        { $$ = (Node *) makeFloat($2); }
                               5169                 :                :             | '-' FCONST
                               5170                 :                :                 {
 1637 peter@eisentraut.org     5171                 :CBC          13 :                     Float      *f = makeFloat($2);
                               5172                 :                : 
 1883                          5173                 :             13 :                     doNegateFloat(f);
                               5174                 :             13 :                     $$ = (Node *) f;
                               5175                 :                :                 }
                               5176                 :           7227 :             | SignedIconst                      { $$ = (Node *) makeInteger($1); }
                               5177                 :                :         ;
                               5178                 :                : 
 5989 rhaas@postgresql.org     5179                 :             62 : NumericOnly_list:   NumericOnly                     { $$ = list_make1($1); }
                               5180                 :              4 :                 | NumericOnly_list ',' NumericOnly  { $$ = lappend($1, $3); }
                               5181                 :                :         ;
                               5182                 :                : 
                               5183                 :                : /*****************************************************************************
                               5184                 :                :  *
                               5185                 :                :  *      QUERIES :
                               5186                 :                :  *              CREATE [OR REPLACE] [TRUSTED] [PROCEDURAL] LANGUAGE ...
                               5187                 :                :  *              DROP [PROCEDURAL] LANGUAGE ...
                               5188                 :                :  *
                               5189                 :                :  *****************************************************************************/
                               5190                 :                : 
                               5191                 :                : CreatePLangStmt:
                               5192                 :                :             CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE name
                               5193                 :                :             {
                               5194                 :                :                 /*
                               5195                 :                :                  * We now interpret parameterless CREATE LANGUAGE as
                               5196                 :                :                  * CREATE EXTENSION.  "OR REPLACE" is silently translated
                               5197                 :                :                  * to "IF NOT EXISTS", which isn't quite the same, but
                               5198                 :                :                  * seems more useful than throwing an error.  We just
                               5199                 :                :                  * ignore TRUSTED, as the previous code would have too.
                               5200                 :                :                  */
 2472 tgl@sss.pgh.pa.us        5201                 :UBC           0 :                 CreateExtensionStmt *n = makeNode(CreateExtensionStmt);
                               5202                 :                : 
                               5203                 :              0 :                 n->if_not_exists = $2;
                               5204                 :              0 :                 n->extname = $6;
                               5205                 :              0 :                 n->options = NIL;
 1637 peter@eisentraut.org     5206                 :              0 :                 $$ = (Node *) n;
                               5207                 :                :             }
                               5208                 :                :             | CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE name
                               5209                 :                :               HANDLER handler_name opt_inline_handler opt_validator
                               5210                 :                :             {
10600 vadim4o@yahoo.com        5211                 :CBC          82 :                 CreatePLangStmt *n = makeNode(CreatePLangStmt);
                               5212                 :                : 
 6099 tgl@sss.pgh.pa.us        5213                 :             82 :                 n->replace = $2;
                               5214                 :             82 :                 n->plname = $6;
                               5215                 :             82 :                 n->plhandler = $8;
                               5216                 :             82 :                 n->plinline = $9;
                               5217                 :             82 :                 n->plvalidator = $10;
                               5218                 :             82 :                 n->pltrusted = $3;
 1637 peter@eisentraut.org     5219                 :             82 :                 $$ = (Node *) n;
                               5220                 :                :             }
                               5221                 :                :         ;
                               5222                 :                : 
                               5223                 :                : opt_trusted:
 3368 peter_e@gmx.net          5224                 :             65 :             TRUSTED                                 { $$ = true; }
                               5225                 :             22 :             | /*EMPTY*/                             { $$ = false; }
                               5226                 :                :         ;
                               5227                 :                : 
                               5228                 :                : /* This ought to be just func_name, but that causes reduce/reduce conflicts
                               5229                 :                :  * (CREATE LANGUAGE is the only place where func_name isn't followed by '(').
                               5230                 :                :  * Work around by using simple names, instead.
                               5231                 :                :  */
                               5232                 :                : handler_name:
 8184 tgl@sss.pgh.pa.us        5233                 :            353 :             name                        { $$ = list_make1(makeString($1)); }
                               5234                 :              1 :             | name attrs                { $$ = lcons(makeString($1), $2); }
                               5235                 :                :         ;
                               5236                 :                : 
                               5237                 :                : opt_inline_handler:
 6253                          5238                 :             71 :             INLINE_P handler_name                   { $$ = $2; }
                               5239                 :             11 :             | /*EMPTY*/                             { $$ = NIL; }
                               5240                 :                :         ;
                               5241                 :                : 
                               5242                 :                : validator_clause:
 7731                          5243                 :             71 :             VALIDATOR handler_name                  { $$ = $2; }
 6463 peter_e@gmx.net          5244                 :UBC           0 :             | NO VALIDATOR                          { $$ = NIL; }
                               5245                 :                :         ;
                               5246                 :                : 
                               5247                 :                : opt_validator:
 6463 peter_e@gmx.net          5248                 :CBC          71 :             validator_clause                        { $$ = $1; }
 7731 tgl@sss.pgh.pa.us        5249                 :             11 :             | /*EMPTY*/                             { $$ = NIL; }
                               5250                 :                :         ;
                               5251                 :                : 
                               5252                 :                : opt_procedural:
                               5253                 :                :             PROCEDURAL
                               5254                 :                :             | /*EMPTY*/
                               5255                 :                :         ;
                               5256                 :                : 
                               5257                 :                : /*****************************************************************************
                               5258                 :                :  *
                               5259                 :                :  *      QUERY:
                               5260                 :                :  *             CREATE TABLESPACE tablespace LOCATION '/path/to/tablespace/'
                               5261                 :                :  *
                               5262                 :                :  *****************************************************************************/
                               5263                 :                : 
                               5264                 :                : CreateTableSpaceStmt: CREATE TABLESPACE name OptTableSpaceOwner LOCATION Sconst opt_reloptions
                               5265                 :                :                 {
 8175                          5266                 :             83 :                     CreateTableSpaceStmt *n = makeNode(CreateTableSpaceStmt);
                               5267                 :                : 
                               5268                 :             83 :                     n->tablespacename = $3;
                               5269                 :             83 :                     n->owner = $4;
                               5270                 :             83 :                     n->location = $6;
 4674 sfrost@snowman.net       5271                 :             83 :                     n->options = $7;
 8175 tgl@sss.pgh.pa.us        5272                 :             83 :                     $$ = (Node *) n;
                               5273                 :                :                 }
                               5274                 :                :         ;
                               5275                 :                : 
 4259 alvherre@alvh.no-ip.     5276                 :             12 : OptTableSpaceOwner: OWNER RoleSpec      { $$ = $2; }
 8175 tgl@sss.pgh.pa.us        5277                 :             71 :             | /*EMPTY */                { $$ = NULL; }
                               5278                 :                :         ;
                               5279                 :                : 
                               5280                 :                : /*****************************************************************************
                               5281                 :                :  *
                               5282                 :                :  *      QUERY :
                               5283                 :                :  *              DROP TABLESPACE <tablespace>
                               5284                 :                :  *
                               5285                 :                :  *      No need for drop behaviour as we cannot implement dependencies for
                               5286                 :                :  *      objects in other databases; we can only support RESTRICT.
                               5287                 :                :  *
                               5288                 :                :  ****************************************************************************/
                               5289                 :                : 
                               5290                 :                : DropTableSpaceStmt: DROP TABLESPACE name
                               5291                 :                :                 {
                               5292                 :             44 :                     DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt);
                               5293                 :                : 
                               5294                 :             44 :                     n->tablespacename = $3;
 7447 andrew@dunslane.net      5295                 :             44 :                     n->missing_ok = false;
                               5296                 :             44 :                     $$ = (Node *) n;
                               5297                 :                :                 }
                               5298                 :                :                 |  DROP TABLESPACE IF_P EXISTS name
                               5299                 :                :                 {
                               5300                 :              6 :                     DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt);
                               5301                 :                : 
                               5302                 :              6 :                     n->tablespacename = $5;
                               5303                 :              6 :                     n->missing_ok = true;
 8175 tgl@sss.pgh.pa.us        5304                 :              6 :                     $$ = (Node *) n;
                               5305                 :                :                 }
                               5306                 :                :         ;
                               5307                 :                : 
                               5308                 :                : /*****************************************************************************
                               5309                 :                :  *
                               5310                 :                :  *      QUERY:
                               5311                 :                :  *             CREATE EXTENSION extension
                               5312                 :                :  *             [ WITH ] [ SCHEMA schema ] [ VERSION version ]
                               5313                 :                :  *
                               5314                 :                :  *****************************************************************************/
                               5315                 :                : 
                               5316                 :                : CreateExtensionStmt: CREATE EXTENSION name opt_with create_extension_opt_list
                               5317                 :                :                 {
 5749                          5318                 :            342 :                     CreateExtensionStmt *n = makeNode(CreateExtensionStmt);
                               5319                 :                : 
                               5320                 :            342 :                     n->extname = $3;
 5725                          5321                 :            342 :                     n->if_not_exists = false;
 5749                          5322                 :            342 :                     n->options = $5;
                               5323                 :            342 :                     $$ = (Node *) n;
                               5324                 :                :                 }
                               5325                 :                :                 | CREATE EXTENSION IF_P NOT EXISTS name opt_with create_extension_opt_list
                               5326                 :                :                 {
 5725                          5327                 :             19 :                     CreateExtensionStmt *n = makeNode(CreateExtensionStmt);
                               5328                 :                : 
                               5329                 :             19 :                     n->extname = $6;
                               5330                 :             19 :                     n->if_not_exists = true;
                               5331                 :             19 :                     n->options = $8;
                               5332                 :             19 :                     $$ = (Node *) n;
                               5333                 :                :                 }
                               5334                 :                :         ;
                               5335                 :                : 
                               5336                 :                : create_extension_opt_list:
                               5337                 :                :             create_extension_opt_list create_extension_opt_item
 5749                          5338                 :             49 :                 { $$ = lappend($1, $2); }
                               5339                 :                :             | /* EMPTY */
                               5340                 :            361 :                 { $$ = NIL; }
                               5341                 :                :         ;
                               5342                 :                : 
                               5343                 :                : create_extension_opt_item:
                               5344                 :                :             SCHEMA name
                               5345                 :                :                 {
 1637 peter@eisentraut.org     5346                 :             23 :                     $$ = makeDefElem("schema", (Node *) makeString($2), @1);
                               5347                 :                :                 }
                               5348                 :                :             | VERSION_P NonReservedWord_or_Sconst
                               5349                 :                :                 {
                               5350                 :              6 :                     $$ = makeDefElem("new_version", (Node *) makeString($2), @1);
                               5351                 :                :                 }
                               5352                 :                :             | FROM NonReservedWord_or_Sconst
                               5353                 :                :                 {
 2451 tgl@sss.pgh.pa.us        5354         [ #  # ]:UBC           0 :                     ereport(ERROR,
                               5355                 :                :                             (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               5356                 :                :                              errmsg("CREATE EXTENSION ... FROM is no longer supported"),
                               5357                 :                :                              parser_errposition(@1)));
                               5358                 :                :                 }
                               5359                 :                :             | CASCADE
                               5360                 :                :                 {
 1637 peter@eisentraut.org     5361                 :CBC          20 :                     $$ = makeDefElem("cascade", (Node *) makeBoolean(true), @1);
                               5362                 :                :                 }
                               5363                 :                :         ;
                               5364                 :                : 
                               5365                 :                : /*****************************************************************************
                               5366                 :                :  *
                               5367                 :                :  * ALTER EXTENSION name UPDATE [ TO version ]
                               5368                 :                :  *
                               5369                 :                :  *****************************************************************************/
                               5370                 :                : 
                               5371                 :                : AlterExtensionStmt: ALTER EXTENSION name UPDATE alter_extension_opt_list
                               5372                 :                :                 {
 5746 tgl@sss.pgh.pa.us        5373                 :             20 :                     AlterExtensionStmt *n = makeNode(AlterExtensionStmt);
                               5374                 :                : 
                               5375                 :             20 :                     n->extname = $3;
                               5376                 :             20 :                     n->options = $5;
                               5377                 :             20 :                     $$ = (Node *) n;
                               5378                 :                :                 }
                               5379                 :                :         ;
                               5380                 :                : 
                               5381                 :                : alter_extension_opt_list:
                               5382                 :                :             alter_extension_opt_list alter_extension_opt_item
                               5383                 :             20 :                 { $$ = lappend($1, $2); }
                               5384                 :                :             | /* EMPTY */
                               5385                 :             20 :                 { $$ = NIL; }
                               5386                 :                :         ;
                               5387                 :                : 
                               5388                 :                : alter_extension_opt_item:
                               5389                 :                :             TO NonReservedWord_or_Sconst
                               5390                 :                :                 {
 1637 peter@eisentraut.org     5391                 :             20 :                     $$ = makeDefElem("new_version", (Node *) makeString($2), @1);
                               5392                 :                :                 }
                               5393                 :                :         ;
                               5394                 :                : 
                               5395                 :                : /*****************************************************************************
                               5396                 :                :  *
                               5397                 :                :  * ALTER EXTENSION name ADD/DROP object-identifier
                               5398                 :                :  *
                               5399                 :                :  *****************************************************************************/
                               5400                 :                : 
                               5401                 :                : AlterExtensionContentsStmt:
                               5402                 :                :             ALTER EXTENSION name add_drop object_type_name name
                               5403                 :                :                 {
 3686 tgl@sss.pgh.pa.us        5404                 :              9 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5405                 :                : 
                               5406                 :              9 :                     n->extname = $3;
                               5407                 :              9 :                     n->action = $4;
 2336 peter@eisentraut.org     5408                 :              9 :                     n->objtype = $5;
                               5409                 :              9 :                     n->object = (Node *) makeString($6);
 1637                          5410                 :              9 :                     $$ = (Node *) n;
                               5411                 :                :                 }
                               5412                 :                :             | ALTER EXTENSION name add_drop object_type_any_name any_name
                               5413                 :                :                 {
 5747 tgl@sss.pgh.pa.us        5414                 :             44 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5415                 :                : 
 5748                          5416                 :             44 :                     n->extname = $3;
 5747                          5417                 :             44 :                     n->action = $4;
 2336 peter@eisentraut.org     5418                 :             44 :                     n->objtype = $5;
 3645 peter_e@gmx.net          5419                 :             44 :                     n->object = (Node *) $6;
 1637 peter@eisentraut.org     5420                 :             44 :                     $$ = (Node *) n;
                               5421                 :                :                 }
                               5422                 :                :             | ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes
                               5423                 :                :                 {
 5745 peter_e@gmx.net          5424                 :              4 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5425                 :                : 
                               5426                 :              4 :                     n->extname = $3;
                               5427                 :              4 :                     n->action = $4;
 2336 peter@eisentraut.org     5428                 :              4 :                     n->objtype = OBJECT_AGGREGATE;
 3645 peter_e@gmx.net          5429                 :              4 :                     n->object = (Node *) $6;
 1637 peter@eisentraut.org     5430                 :              4 :                     $$ = (Node *) n;
                               5431                 :                :                 }
                               5432                 :                :             | ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
                               5433                 :                :                 {
 5747 tgl@sss.pgh.pa.us        5434                 :              2 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5435                 :                : 
 5748                          5436                 :              2 :                     n->extname = $3;
 5747                          5437                 :              2 :                     n->action = $4;
 2336 peter@eisentraut.org     5438                 :              2 :                     n->objtype = OBJECT_CAST;
                               5439                 :              2 :                     n->object = (Node *) list_make2($7, $9);
                               5440                 :              2 :                     $$ = (Node *) n;
                               5441                 :                :                 }
                               5442                 :                :             | ALTER EXTENSION name add_drop DOMAIN_P Typename
                               5443                 :                :                 {
 5747 tgl@sss.pgh.pa.us        5444                 :UBC           0 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5445                 :                : 
 5748                          5446                 :              0 :                     n->extname = $3;
 5747                          5447                 :              0 :                     n->action = $4;
 5748                          5448                 :              0 :                     n->objtype = OBJECT_DOMAIN;
 3645 peter_e@gmx.net          5449                 :              0 :                     n->object = (Node *) $6;
 1637 peter@eisentraut.org     5450                 :              0 :                     $$ = (Node *) n;
                               5451                 :                :                 }
                               5452                 :                :             | ALTER EXTENSION name add_drop FUNCTION function_with_argtypes
                               5453                 :                :                 {
 5747 tgl@sss.pgh.pa.us        5454                 :CBC          68 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5455                 :                : 
 5748                          5456                 :             68 :                     n->extname = $3;
 5747                          5457                 :             68 :                     n->action = $4;
 5748                          5458                 :             68 :                     n->objtype = OBJECT_FUNCTION;
 3645 peter_e@gmx.net          5459                 :             68 :                     n->object = (Node *) $6;
 1637 peter@eisentraut.org     5460                 :             68 :                     $$ = (Node *) n;
                               5461                 :                :                 }
                               5462                 :                :             | ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes
                               5463                 :                :                 {
 5747 tgl@sss.pgh.pa.us        5464                 :              9 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5465                 :                : 
 5748                          5466                 :              9 :                     n->extname = $3;
 5747                          5467                 :              9 :                     n->action = $4;
 5748                          5468                 :              9 :                     n->objtype = OBJECT_OPERATOR;
 3645 peter_e@gmx.net          5469                 :              9 :                     n->object = (Node *) $6;
 1637 peter@eisentraut.org     5470                 :              9 :                     $$ = (Node *) n;
                               5471                 :                :                 }
                               5472                 :                :             | ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING name
                               5473                 :                :                 {
 5747 tgl@sss.pgh.pa.us        5474                 :              2 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5475                 :                : 
 5748                          5476                 :              2 :                     n->extname = $3;
 5747                          5477                 :              2 :                     n->action = $4;
 5748                          5478                 :              2 :                     n->objtype = OBJECT_OPCLASS;
 3645 peter_e@gmx.net          5479                 :              2 :                     n->object = (Node *) lcons(makeString($9), $7);
 1637 peter@eisentraut.org     5480                 :              2 :                     $$ = (Node *) n;
                               5481                 :                :                 }
                               5482                 :                :             | ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING name
                               5483                 :                :                 {
 5747 tgl@sss.pgh.pa.us        5484                 :              2 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5485                 :                : 
 5748                          5486                 :              2 :                     n->extname = $3;
 5747                          5487                 :              2 :                     n->action = $4;
 5748                          5488                 :              2 :                     n->objtype = OBJECT_OPFAMILY;
 3645 peter_e@gmx.net          5489                 :              2 :                     n->object = (Node *) lcons(makeString($9), $7);
 1637 peter@eisentraut.org     5490                 :              2 :                     $$ = (Node *) n;
                               5491                 :                :                 }
                               5492                 :                :             | ALTER EXTENSION name add_drop PROCEDURE function_with_argtypes
                               5493                 :                :                 {
 3262 peter_e@gmx.net          5494                 :UBC           0 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5495                 :                : 
                               5496                 :              0 :                     n->extname = $3;
                               5497                 :              0 :                     n->action = $4;
                               5498                 :              0 :                     n->objtype = OBJECT_PROCEDURE;
                               5499                 :              0 :                     n->object = (Node *) $6;
 1637 peter@eisentraut.org     5500                 :              0 :                     $$ = (Node *) n;
                               5501                 :                :                 }
                               5502                 :                :             | ALTER EXTENSION name add_drop ROUTINE function_with_argtypes
                               5503                 :                :                 {
 3262 peter_e@gmx.net          5504                 :              0 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5505                 :                : 
                               5506                 :              0 :                     n->extname = $3;
                               5507                 :              0 :                     n->action = $4;
                               5508                 :              0 :                     n->objtype = OBJECT_ROUTINE;
                               5509                 :              0 :                     n->object = (Node *) $6;
 1637 peter@eisentraut.org     5510                 :              0 :                     $$ = (Node *) n;
                               5511                 :                :                 }
                               5512                 :                :             | ALTER EXTENSION name add_drop TRANSFORM FOR Typename LANGUAGE name
                               5513                 :                :                 {
 4211 peter_e@gmx.net          5514                 :CBC           2 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5515                 :                : 
                               5516                 :              2 :                     n->extname = $3;
                               5517                 :              2 :                     n->action = $4;
                               5518                 :              2 :                     n->objtype = OBJECT_TRANSFORM;
 3645                          5519                 :              2 :                     n->object = (Node *) list_make2($7, makeString($9));
 1637 peter@eisentraut.org     5520                 :              2 :                     $$ = (Node *) n;
                               5521                 :                :                 }
                               5522                 :                :             | ALTER EXTENSION name add_drop TYPE_P Typename
                               5523                 :                :                 {
 5747 tgl@sss.pgh.pa.us        5524                 :              4 :                     AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
                               5525                 :                : 
 5748                          5526                 :              4 :                     n->extname = $3;
 5747                          5527                 :              4 :                     n->action = $4;
 5748                          5528                 :              4 :                     n->objtype = OBJECT_TYPE;
 3645 peter_e@gmx.net          5529                 :              4 :                     n->object = (Node *) $6;
 1637 peter@eisentraut.org     5530                 :              4 :                     $$ = (Node *) n;
                               5531                 :                :                 }
                               5532                 :                :         ;
                               5533                 :                : 
                               5534                 :                : /*****************************************************************************
                               5535                 :                :  *
                               5536                 :                :  *      QUERY:
                               5537                 :                :  *             CREATE FOREIGN DATA WRAPPER name options
                               5538                 :                :  *
                               5539                 :                :  *****************************************************************************/
                               5540                 :                : 
                               5541                 :                : CreateFdwStmt: CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic_options
                               5542                 :                :                 {
 6530 peter_e@gmx.net          5543                 :            158 :                     CreateFdwStmt *n = makeNode(CreateFdwStmt);
                               5544                 :                : 
                               5545                 :            158 :                     n->fdwname = $5;
 5738 tgl@sss.pgh.pa.us        5546                 :            158 :                     n->func_options = $6;
 6463 peter_e@gmx.net          5547                 :            158 :                     n->options = $7;
 6530                          5548                 :            158 :                     $$ = (Node *) n;
                               5549                 :                :                 }
                               5550                 :                :         ;
                               5551                 :                : 
                               5552                 :                : fdw_option:
 1637 peter@eisentraut.org     5553                 :             40 :             HANDLER handler_name                { $$ = makeDefElem("handler", (Node *) $2, @1); }
 3712 peter_e@gmx.net          5554                 :UBC           0 :             | NO HANDLER                        { $$ = makeDefElem("handler", NULL, @1); }
 1637 peter@eisentraut.org     5555                 :CBC          38 :             | VALIDATOR handler_name            { $$ = makeDefElem("validator", (Node *) $2, @1); }
 3712 peter_e@gmx.net          5556                 :              4 :             | NO VALIDATOR                      { $$ = makeDefElem("validator", NULL, @1); }
  244 jdavis@postgresql.or     5557                 :             14 :             | CONNECTION handler_name           { $$ = makeDefElem("connection", (Node *) $2, @1); }
                               5558                 :              4 :             | NO CONNECTION                     { $$ = makeDefElem("connection", NULL, @1); }
                               5559                 :                :         ;
                               5560                 :                : 
                               5561                 :                : fdw_options:
 5738 tgl@sss.pgh.pa.us        5562                 :             84 :             fdw_option                          { $$ = list_make1($1); }
                               5563                 :             16 :             | fdw_options fdw_option            { $$ = lappend($1, $2); }
                               5564                 :                :         ;
                               5565                 :                : 
                               5566                 :                : opt_fdw_options:
                               5567                 :             38 :             fdw_options                         { $$ = $1; }
                               5568                 :            181 :             | /*EMPTY*/                         { $$ = NIL; }
                               5569                 :                :         ;
                               5570                 :                : 
                               5571                 :                : /*****************************************************************************
                               5572                 :                :  *
                               5573                 :                :  *      QUERY :
                               5574                 :                :  *              ALTER FOREIGN DATA WRAPPER name options
                               5575                 :                :  *
                               5576                 :                :  ****************************************************************************/
                               5577                 :                : 
                               5578                 :                : AlterFdwStmt: ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_options
                               5579                 :                :                 {
 6530 peter_e@gmx.net          5580                 :             57 :                     AlterFdwStmt *n = makeNode(AlterFdwStmt);
                               5581                 :                : 
                               5582                 :             57 :                     n->fdwname = $5;
 5738 tgl@sss.pgh.pa.us        5583                 :             57 :                     n->func_options = $6;
 6463 peter_e@gmx.net          5584                 :             57 :                     n->options = $7;
 6530                          5585                 :             57 :                     $$ = (Node *) n;
                               5586                 :                :                 }
                               5587                 :                :             | ALTER FOREIGN DATA_P WRAPPER name fdw_options
                               5588                 :                :                 {
                               5589                 :             46 :                     AlterFdwStmt *n = makeNode(AlterFdwStmt);
                               5590                 :                : 
                               5591                 :             46 :                     n->fdwname = $5;
 5738 tgl@sss.pgh.pa.us        5592                 :             46 :                     n->func_options = $6;
                               5593                 :             46 :                     n->options = NIL;
 6530 peter_e@gmx.net          5594                 :             46 :                     $$ = (Node *) n;
                               5595                 :                :                 }
                               5596                 :                :         ;
                               5597                 :                : 
                               5598                 :                : /* Options definition for CREATE FDW, SERVER and USER MAPPING */
                               5599                 :                : create_generic_options:
 6424 tgl@sss.pgh.pa.us        5600                 :            457 :             OPTIONS '(' generic_option_list ')'         { $$ = $3; }
                               5601                 :          44582 :             | /*EMPTY*/                                 { $$ = NIL; }
                               5602                 :                :         ;
                               5603                 :                : 
                               5604                 :                : generic_option_list:
                               5605                 :                :             generic_option_elem
                               5606                 :                :                 {
                               5607                 :            457 :                     $$ = list_make1($1);
                               5608                 :                :                 }
                               5609                 :                :             | generic_option_list ',' generic_option_elem
                               5610                 :                :                 {
                               5611                 :            306 :                     $$ = lappend($1, $3);
                               5612                 :                :                 }
                               5613                 :                :         ;
                               5614                 :                : 
                               5615                 :                : /* Options definition for ALTER FDW, SERVER and USER MAPPING */
                               5616                 :                : alter_generic_options:
                               5617                 :            302 :             OPTIONS '(' alter_generic_option_list ')'       { $$ = $3; }
                               5618                 :                :         ;
                               5619                 :                : 
                               5620                 :                : alter_generic_option_list:
                               5621                 :                :             alter_generic_option_elem
                               5622                 :                :                 {
                               5623                 :            302 :                     $$ = list_make1($1);
                               5624                 :                :                 }
                               5625                 :                :             | alter_generic_option_list ',' alter_generic_option_elem
                               5626                 :                :                 {
                               5627                 :            103 :                     $$ = lappend($1, $3);
                               5628                 :                :                 }
                               5629                 :                :         ;
                               5630                 :                : 
                               5631                 :                : alter_generic_option_elem:
                               5632                 :                :             generic_option_elem
                               5633                 :                :                 {
                               5634                 :            119 :                     $$ = $1;
                               5635                 :                :                 }
                               5636                 :                :             | SET generic_option_elem
                               5637                 :                :                 {
                               5638                 :             73 :                     $$ = $2;
                               5639                 :             73 :                     $$->defaction = DEFELEM_SET;
                               5640                 :                :                 }
                               5641                 :                :             | ADD_P generic_option_elem
                               5642                 :                :                 {
                               5643                 :            136 :                     $$ = $2;
                               5644                 :            136 :                     $$->defaction = DEFELEM_ADD;
                               5645                 :                :                 }
                               5646                 :                :             | DROP generic_option_name
                               5647                 :                :                 {
 3712 peter_e@gmx.net          5648                 :             77 :                     $$ = makeDefElemExtended(NULL, $2, NULL, DEFELEM_DROP, @2);
                               5649                 :                :                 }
                               5650                 :                :         ;
                               5651                 :                : 
                               5652                 :                : generic_option_elem:
                               5653                 :                :             generic_option_name generic_option_arg
                               5654                 :                :                 {
                               5655                 :           1091 :                     $$ = makeDefElem($1, $2, @1);
                               5656                 :                :                 }
                               5657                 :                :         ;
                               5658                 :                : 
                               5659                 :                : generic_option_name:
 6424 tgl@sss.pgh.pa.us        5660                 :           1168 :                 ColLabel            { $$ = $1; }
                               5661                 :                :         ;
                               5662                 :                : 
                               5663                 :                : /* We could use def_arg here, but the spec only requires string literals */
                               5664                 :                : generic_option_arg:
                               5665                 :           1091 :                 Sconst              { $$ = (Node *) makeString($1); }
                               5666                 :                :         ;
                               5667                 :                : 
                               5668                 :                : /*****************************************************************************
                               5669                 :                :  *
                               5670                 :                :  *      QUERY:
                               5671                 :                :  *             CREATE SERVER name [TYPE] [VERSION] [OPTIONS]
                               5672                 :                :  *
                               5673                 :                :  *****************************************************************************/
                               5674                 :                : 
                               5675                 :                : CreateForeignServerStmt: CREATE SERVER name opt_type opt_foreign_server_version
                               5676                 :                :                          FOREIGN DATA_P WRAPPER name create_generic_options
                               5677                 :                :                 {
 6530 peter_e@gmx.net          5678                 :            187 :                     CreateForeignServerStmt *n = makeNode(CreateForeignServerStmt);
                               5679                 :                : 
                               5680                 :            187 :                     n->servername = $3;
                               5681                 :            187 :                     n->servertype = $4;
                               5682                 :            187 :                     n->version = $5;
                               5683                 :            187 :                     n->fdwname = $9;
                               5684                 :            187 :                     n->options = $10;
 3517 andrew@dunslane.net      5685                 :            187 :                     n->if_not_exists = false;
                               5686                 :            187 :                     $$ = (Node *) n;
                               5687                 :                :                 }
                               5688                 :                :                 | CREATE SERVER IF_P NOT EXISTS name opt_type opt_foreign_server_version
                               5689                 :                :                          FOREIGN DATA_P WRAPPER name create_generic_options
                               5690                 :                :                 {
                               5691                 :             13 :                     CreateForeignServerStmt *n = makeNode(CreateForeignServerStmt);
                               5692                 :                : 
                               5693                 :             13 :                     n->servername = $6;
                               5694                 :             13 :                     n->servertype = $7;
                               5695                 :             13 :                     n->version = $8;
                               5696                 :             13 :                     n->fdwname = $12;
                               5697                 :             13 :                     n->options = $13;
                               5698                 :             13 :                     n->if_not_exists = true;
 6530 peter_e@gmx.net          5699                 :             13 :                     $$ = (Node *) n;
                               5700                 :                :                 }
                               5701                 :                :         ;
                               5702                 :                : 
                               5703                 :                : opt_type:
                               5704                 :             12 :             TYPE_P Sconst           { $$ = $2; }
                               5705                 :            188 :             | /*EMPTY*/             { $$ = NULL; }
                               5706                 :                :         ;
                               5707                 :                : 
                               5708                 :                : 
                               5709                 :                : foreign_server_version:
                               5710                 :             44 :             VERSION_P Sconst        { $$ = $2; }
 6530 peter_e@gmx.net          5711                 :UBC           0 :         |   VERSION_P NULL_P        { $$ = NULL; }
                               5712                 :                :         ;
                               5713                 :                : 
                               5714                 :                : opt_foreign_server_version:
 5483 peter_e@gmx.net          5715                 :CBC          12 :             foreign_server_version  { $$ = $1; }
 6530                          5716                 :            188 :             | /*EMPTY*/             { $$ = NULL; }
                               5717                 :                :         ;
                               5718                 :                : 
                               5719                 :                : /*****************************************************************************
                               5720                 :                :  *
                               5721                 :                :  *      QUERY :
                               5722                 :                :  *              ALTER SERVER name [VERSION] [OPTIONS]
                               5723                 :                :  *
                               5724                 :                :  ****************************************************************************/
                               5725                 :                : 
                               5726                 :                : AlterForeignServerStmt: ALTER SERVER name foreign_server_version alter_generic_options
                               5727                 :                :                 {
                               5728                 :              4 :                     AlterForeignServerStmt *n = makeNode(AlterForeignServerStmt);
                               5729                 :                : 
                               5730                 :              4 :                     n->servername = $3;
                               5731                 :              4 :                     n->version = $4;
                               5732                 :              4 :                     n->options = $5;
                               5733                 :              4 :                     n->has_version = true;
                               5734                 :              4 :                     $$ = (Node *) n;
                               5735                 :                :                 }
                               5736                 :                :             | ALTER SERVER name foreign_server_version
                               5737                 :                :                 {
                               5738                 :             28 :                     AlterForeignServerStmt *n = makeNode(AlterForeignServerStmt);
                               5739                 :                : 
                               5740                 :             28 :                     n->servername = $3;
                               5741                 :             28 :                     n->version = $4;
                               5742                 :             28 :                     n->has_version = true;
                               5743                 :             28 :                     $$ = (Node *) n;
                               5744                 :                :                 }
                               5745                 :                :             | ALTER SERVER name alter_generic_options
                               5746                 :                :                 {
                               5747                 :             97 :                     AlterForeignServerStmt *n = makeNode(AlterForeignServerStmt);
                               5748                 :                : 
                               5749                 :             97 :                     n->servername = $3;
                               5750                 :             97 :                     n->options = $4;
                               5751                 :             97 :                     $$ = (Node *) n;
                               5752                 :                :                 }
                               5753                 :                :         ;
                               5754                 :                : 
                               5755                 :                : /*****************************************************************************
                               5756                 :                :  *
                               5757                 :                :  *      QUERY:
                               5758                 :                :  *             CREATE FOREIGN TABLE relname (...) SERVER name (...)
                               5759                 :                :  *
                               5760                 :                :  *****************************************************************************/
                               5761                 :                : 
                               5762                 :                : CreateForeignTableStmt:
                               5763                 :                :         CREATE FOREIGN TABLE qualified_name
                               5764                 :                :             '(' OptTableElementList ')'
                               5765                 :                :             OptInherit SERVER name create_generic_options
                               5766                 :                :                 {
 5787 rhaas@postgresql.org     5767                 :            251 :                     CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
                               5768                 :                : 
                               5769                 :            251 :                     $4->relpersistence = RELPERSISTENCE_PERMANENT;
                               5770                 :            251 :                     n->base.relation = $4;
 4986 tgl@sss.pgh.pa.us        5771                 :            251 :                     n->base.tableElts = $6;
 4246                          5772                 :            251 :                     n->base.inhRelations = $8;
                               5773                 :            251 :                     n->base.ofTypename = NULL;
                               5774                 :            251 :                     n->base.constraints = NIL;
                               5775                 :            251 :                     n->base.options = NIL;
                               5776                 :            251 :                     n->base.oncommit = ONCOMMIT_NOOP;
                               5777                 :            251 :                     n->base.tablespacename = NULL;
 5787 rhaas@postgresql.org     5778                 :            251 :                     n->base.if_not_exists = false;
                               5779                 :                :                     /* FDW-specific data */
 4246 tgl@sss.pgh.pa.us        5780                 :            251 :                     n->servername = $10;
                               5781                 :            251 :                     n->options = $11;
 5787 rhaas@postgresql.org     5782                 :            251 :                     $$ = (Node *) n;
                               5783                 :                :                 }
                               5784                 :                :         | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name
                               5785                 :                :             '(' OptTableElementList ')'
                               5786                 :                :             OptInherit SERVER name create_generic_options
                               5787                 :                :                 {
 5787 rhaas@postgresql.org     5788                 :UBC           0 :                     CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
                               5789                 :                : 
                               5790                 :              0 :                     $7->relpersistence = RELPERSISTENCE_PERMANENT;
                               5791                 :              0 :                     n->base.relation = $7;
 4986 tgl@sss.pgh.pa.us        5792                 :              0 :                     n->base.tableElts = $9;
 4246                          5793                 :              0 :                     n->base.inhRelations = $11;
                               5794                 :              0 :                     n->base.ofTypename = NULL;
                               5795                 :              0 :                     n->base.constraints = NIL;
                               5796                 :              0 :                     n->base.options = NIL;
                               5797                 :              0 :                     n->base.oncommit = ONCOMMIT_NOOP;
                               5798                 :              0 :                     n->base.tablespacename = NULL;
 5787 rhaas@postgresql.org     5799                 :              0 :                     n->base.if_not_exists = true;
                               5800                 :                :                     /* FDW-specific data */
 4246 tgl@sss.pgh.pa.us        5801                 :              0 :                     n->servername = $13;
                               5802                 :              0 :                     n->options = $14;
 5787 rhaas@postgresql.org     5803                 :              0 :                     $$ = (Node *) n;
                               5804                 :                :                 }
                               5805                 :                :         | CREATE FOREIGN TABLE qualified_name
                               5806                 :                :             PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec
                               5807                 :                :             SERVER name create_generic_options
                               5808                 :                :                 {
 3620 rhaas@postgresql.org     5809                 :CBC          66 :                     CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
                               5810                 :                : 
                               5811                 :             66 :                     $4->relpersistence = RELPERSISTENCE_PERMANENT;
                               5812                 :             66 :                     n->base.relation = $4;
                               5813                 :             66 :                     n->base.inhRelations = list_make1($7);
                               5814                 :             66 :                     n->base.tableElts = $8;
 3448 tgl@sss.pgh.pa.us        5815                 :             66 :                     n->base.partbound = $9;
 3620 rhaas@postgresql.org     5816                 :             66 :                     n->base.ofTypename = NULL;
                               5817                 :             66 :                     n->base.constraints = NIL;
                               5818                 :             66 :                     n->base.options = NIL;
                               5819                 :             66 :                     n->base.oncommit = ONCOMMIT_NOOP;
                               5820                 :             66 :                     n->base.tablespacename = NULL;
                               5821                 :             66 :                     n->base.if_not_exists = false;
                               5822                 :                :                     /* FDW-specific data */
                               5823                 :             66 :                     n->servername = $11;
                               5824                 :             66 :                     n->options = $12;
                               5825                 :             66 :                     $$ = (Node *) n;
                               5826                 :                :                 }
                               5827                 :                :         | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name
                               5828                 :                :             PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec
                               5829                 :                :             SERVER name create_generic_options
                               5830                 :                :                 {
 3620 rhaas@postgresql.org     5831                 :UBC           0 :                     CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
                               5832                 :                : 
                               5833                 :              0 :                     $7->relpersistence = RELPERSISTENCE_PERMANENT;
                               5834                 :              0 :                     n->base.relation = $7;
                               5835                 :              0 :                     n->base.inhRelations = list_make1($10);
                               5836                 :              0 :                     n->base.tableElts = $11;
 3448 tgl@sss.pgh.pa.us        5837                 :              0 :                     n->base.partbound = $12;
 3620 rhaas@postgresql.org     5838                 :              0 :                     n->base.ofTypename = NULL;
                               5839                 :              0 :                     n->base.constraints = NIL;
                               5840                 :              0 :                     n->base.options = NIL;
                               5841                 :              0 :                     n->base.oncommit = ONCOMMIT_NOOP;
                               5842                 :              0 :                     n->base.tablespacename = NULL;
                               5843                 :              0 :                     n->base.if_not_exists = true;
                               5844                 :                :                     /* FDW-specific data */
                               5845                 :              0 :                     n->servername = $14;
                               5846                 :              0 :                     n->options = $15;
                               5847                 :              0 :                     $$ = (Node *) n;
                               5848                 :                :                 }
                               5849                 :                :         ;
                               5850                 :                : 
                               5851                 :                : /*****************************************************************************
                               5852                 :                :  *
                               5853                 :                :  *      QUERY:
                               5854                 :                :  *              IMPORT FOREIGN SCHEMA remote_schema
                               5855                 :                :  *              [ { LIMIT TO | EXCEPT } ( table_list ) ]
                               5856                 :                :  *              FROM SERVER server_name INTO local_schema [ OPTIONS (...) ]
                               5857                 :                :  *
                               5858                 :                :  ****************************************************************************/
                               5859                 :                : 
                               5860                 :                : ImportForeignSchemaStmt:
                               5861                 :                :         IMPORT_P FOREIGN SCHEMA name import_qualification
                               5862                 :                :           FROM SERVER name INTO name create_generic_options
                               5863                 :                :             {
 4501 tgl@sss.pgh.pa.us        5864                 :CBC          28 :                 ImportForeignSchemaStmt *n = makeNode(ImportForeignSchemaStmt);
                               5865                 :                : 
                               5866                 :             28 :                 n->server_name = $8;
                               5867                 :             28 :                 n->remote_schema = $4;
                               5868                 :             28 :                 n->local_schema = $10;
                               5869                 :             28 :                 n->list_type = $5->type;
                               5870                 :             28 :                 n->table_list = $5->table_names;
                               5871                 :             28 :                 n->options = $11;
                               5872                 :             28 :                 $$ = (Node *) n;
                               5873                 :                :             }
                               5874                 :                :         ;
                               5875                 :                : 
                               5876                 :                : import_qualification_type:
 2185 peter@eisentraut.org     5877                 :              8 :         LIMIT TO                { $$ = FDW_IMPORT_SCHEMA_LIMIT_TO; }
                               5878                 :              9 :         | EXCEPT                { $$ = FDW_IMPORT_SCHEMA_EXCEPT; }
                               5879                 :                :         ;
                               5880                 :                : 
                               5881                 :                : import_qualification:
                               5882                 :                :         import_qualification_type '(' relation_expr_list ')'
                               5883                 :                :             {
  330 michael@paquier.xyz      5884                 :             17 :                 ImportQual *n = palloc_object(ImportQual);
                               5885                 :                : 
 4501 tgl@sss.pgh.pa.us        5886                 :             17 :                 n->type = $1;
                               5887                 :             17 :                 n->table_names = $3;
                               5888                 :             17 :                 $$ = n;
                               5889                 :                :             }
                               5890                 :                :         | /*EMPTY*/
                               5891                 :                :             {
  330 michael@paquier.xyz      5892                 :             11 :                 ImportQual *n = palloc_object(ImportQual);
 4501 tgl@sss.pgh.pa.us        5893                 :             11 :                 n->type = FDW_IMPORT_SCHEMA_ALL;
                               5894                 :             11 :                 n->table_names = NIL;
                               5895                 :             11 :                 $$ = n;
                               5896                 :                :             }
                               5897                 :                :         ;
                               5898                 :                : 
                               5899                 :                : /*****************************************************************************
                               5900                 :                :  *
                               5901                 :                :  *      QUERY:
                               5902                 :                :  *             CREATE USER MAPPING FOR auth_ident SERVER name [OPTIONS]
                               5903                 :                :  *
                               5904                 :                :  *****************************************************************************/
                               5905                 :                : 
                               5906                 :                : CreateUserMappingStmt: CREATE USER MAPPING FOR auth_ident SERVER name create_generic_options
                               5907                 :                :                 {
 6530 peter_e@gmx.net          5908                 :            163 :                     CreateUserMappingStmt *n = makeNode(CreateUserMappingStmt);
                               5909                 :                : 
 4259 alvherre@alvh.no-ip.     5910                 :            163 :                     n->user = $5;
 6530 peter_e@gmx.net          5911                 :            163 :                     n->servername = $7;
                               5912                 :            163 :                     n->options = $8;
 3517 andrew@dunslane.net      5913                 :            163 :                     n->if_not_exists = false;
                               5914                 :            163 :                     $$ = (Node *) n;
                               5915                 :                :                 }
                               5916                 :                :                 | CREATE USER MAPPING IF_P NOT EXISTS FOR auth_ident SERVER name create_generic_options
                               5917                 :                :                 {
                               5918                 :              4 :                     CreateUserMappingStmt *n = makeNode(CreateUserMappingStmt);
                               5919                 :                : 
                               5920                 :              4 :                     n->user = $8;
                               5921                 :              4 :                     n->servername = $10;
                               5922                 :              4 :                     n->options = $11;
                               5923                 :              4 :                     n->if_not_exists = true;
 6530 peter_e@gmx.net          5924                 :              4 :                     $$ = (Node *) n;
                               5925                 :                :                 }
                               5926                 :                :         ;
                               5927                 :                : 
                               5928                 :                : /* User mapping authorization identifier */
 4259 alvherre@alvh.no-ip.     5929                 :            290 : auth_ident: RoleSpec            { $$ = $1; }
                               5930                 :             29 :             | USER              { $$ = makeRoleSpec(ROLESPEC_CURRENT_USER, @1); }
                               5931                 :                :         ;
                               5932                 :                : 
                               5933                 :                : /*****************************************************************************
                               5934                 :                :  *
                               5935                 :                :  *      QUERY :
                               5936                 :                :  *              DROP USER MAPPING FOR auth_ident SERVER name
                               5937                 :                :  *
                               5938                 :                :  * XXX you'd think this should have a CASCADE/RESTRICT option, even if it's
                               5939                 :                :  * only pro forma; but the SQL standard doesn't show one.
                               5940                 :                :  ****************************************************************************/
                               5941                 :                : 
                               5942                 :                : DropUserMappingStmt: DROP USER MAPPING FOR auth_ident SERVER name
                               5943                 :                :                 {
 6530 peter_e@gmx.net          5944                 :             57 :                     DropUserMappingStmt *n = makeNode(DropUserMappingStmt);
                               5945                 :                : 
 4259 alvherre@alvh.no-ip.     5946                 :             57 :                     n->user = $5;
 6530 peter_e@gmx.net          5947                 :             57 :                     n->servername = $7;
                               5948                 :             57 :                     n->missing_ok = false;
                               5949                 :             57 :                     $$ = (Node *) n;
                               5950                 :                :                 }
                               5951                 :                :                 |  DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name
                               5952                 :                :                 {
                               5953                 :             22 :                     DropUserMappingStmt *n = makeNode(DropUserMappingStmt);
                               5954                 :                : 
 4259 alvherre@alvh.no-ip.     5955                 :             22 :                     n->user = $7;
 6530 peter_e@gmx.net          5956                 :             22 :                     n->servername = $9;
                               5957                 :             22 :                     n->missing_ok = true;
                               5958                 :             22 :                     $$ = (Node *) n;
                               5959                 :                :                 }
                               5960                 :                :         ;
                               5961                 :                : 
                               5962                 :                : /*****************************************************************************
                               5963                 :                :  *
                               5964                 :                :  *      QUERY :
                               5965                 :                :  *              ALTER USER MAPPING FOR auth_ident SERVER name OPTIONS
                               5966                 :                :  *
                               5967                 :                :  ****************************************************************************/
                               5968                 :                : 
                               5969                 :                : AlterUserMappingStmt: ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options
                               5970                 :                :                 {
                               5971                 :             73 :                     AlterUserMappingStmt *n = makeNode(AlterUserMappingStmt);
                               5972                 :                : 
 4259 alvherre@alvh.no-ip.     5973                 :             73 :                     n->user = $5;
 6530 peter_e@gmx.net          5974                 :             73 :                     n->servername = $7;
                               5975                 :             73 :                     n->options = $8;
                               5976                 :             73 :                     $$ = (Node *) n;
                               5977                 :                :                 }
                               5978                 :                :         ;
                               5979                 :                : 
                               5980                 :                : /*****************************************************************************
                               5981                 :                :  *
                               5982                 :                :  *      QUERIES:
                               5983                 :                :  *              CREATE POLICY name ON table
                               5984                 :                :  *                  [AS { PERMISSIVE | RESTRICTIVE } ]
                               5985                 :                :  *                  [FOR { SELECT | INSERT | UPDATE | DELETE } ]
                               5986                 :                :  *                  [TO role, ...]
                               5987                 :                :  *                  [USING (qual)] [WITH CHECK (with check qual)]
                               5988                 :                :  *              ALTER POLICY name ON table [TO role, ...]
                               5989                 :                :  *                  [USING (qual)] [WITH CHECK (with check qual)]
                               5990                 :                :  *
                               5991                 :                :  *****************************************************************************/
                               5992                 :                : 
                               5993                 :                : CreatePolicyStmt:
                               5994                 :                :             CREATE POLICY name ON qualified_name RowSecurityDefaultPermissive
                               5995                 :                :                 RowSecurityDefaultForCmd RowSecurityDefaultToRole
                               5996                 :                :                 RowSecurityOptionalExpr RowSecurityOptionalWithCheck
                               5997                 :                :                 {
 4430 sfrost@snowman.net       5998                 :            543 :                     CreatePolicyStmt *n = makeNode(CreatePolicyStmt);
                               5999                 :                : 
                               6000                 :            543 :                     n->policy_name = $3;
                               6001                 :            543 :                     n->table = $5;
 3622                          6002                 :            543 :                     n->permissive = $6;
                               6003                 :            543 :                     n->cmd_name = $7;
                               6004                 :            543 :                     n->roles = $8;
                               6005                 :            543 :                     n->qual = $9;
                               6006                 :            543 :                     n->with_check = $10;
 4430                          6007                 :            543 :                     $$ = (Node *) n;
                               6008                 :                :                 }
                               6009                 :                :         ;
                               6010                 :                : 
                               6011                 :                : AlterPolicyStmt:
                               6012                 :                :             ALTER POLICY name ON qualified_name RowSecurityOptionalToRole
                               6013                 :                :                 RowSecurityOptionalExpr RowSecurityOptionalWithCheck
                               6014                 :                :                 {
                               6015                 :             56 :                     AlterPolicyStmt *n = makeNode(AlterPolicyStmt);
                               6016                 :                : 
                               6017                 :             56 :                     n->policy_name = $3;
                               6018                 :             56 :                     n->table = $5;
                               6019                 :             56 :                     n->roles = $6;
                               6020                 :             56 :                     n->qual = $7;
                               6021                 :             56 :                     n->with_check = $8;
                               6022                 :             56 :                     $$ = (Node *) n;
                               6023                 :                :                 }
                               6024                 :                :         ;
                               6025                 :                : 
                               6026                 :                : RowSecurityOptionalExpr:
                               6027                 :            553 :             USING '(' a_expr ')'    { $$ = $3; }
                               6028                 :             46 :             | /* EMPTY */           { $$ = NULL; }
                               6029                 :                :         ;
                               6030                 :                : 
                               6031                 :                : RowSecurityOptionalWithCheck:
                               6032                 :            107 :             WITH CHECK '(' a_expr ')'       { $$ = $4; }
                               6033                 :            492 :             | /* EMPTY */                   { $$ = NULL; }
                               6034                 :                :         ;
                               6035                 :                : 
                               6036                 :                : RowSecurityDefaultToRole:
                               6037                 :             89 :             TO role_list            { $$ = $2; }
 4259 alvherre@alvh.no-ip.     6038                 :            454 :             | /* EMPTY */           { $$ = list_make1(makeRoleSpec(ROLESPEC_PUBLIC, -1)); }
                               6039                 :                :         ;
                               6040                 :                : 
                               6041                 :                : RowSecurityOptionalToRole:
 4430 sfrost@snowman.net       6042                 :              8 :             TO role_list            { $$ = $2; }
                               6043                 :             48 :             | /* EMPTY */           { $$ = NULL; }
                               6044                 :                :         ;
                               6045                 :                : 
                               6046                 :                : RowSecurityDefaultPermissive:
                               6047                 :                :             AS IDENT
                               6048                 :                :                 {
 3622                          6049         [ +  + ]:             65 :                     if (strcmp($2, "permissive") == 0)
                               6050                 :             16 :                         $$ = true;
                               6051         [ +  + ]:             49 :                     else if (strcmp($2, "restrictive") == 0)
                               6052                 :             45 :                         $$ = false;
                               6053                 :                :                     else
                               6054         [ +  - ]:              4 :                         ereport(ERROR,
                               6055                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               6056                 :                :                                  errmsg("unrecognized row security option \"%s\"", $2),
                               6057                 :                :                                  errhint("Only PERMISSIVE or RESTRICTIVE policies are supported currently."),
                               6058                 :                :                                  parser_errposition(@2)));
                               6059                 :                : 
                               6060                 :                :                 }
                               6061                 :            482 :             | /* EMPTY */           { $$ = true; }
                               6062                 :                :         ;
                               6063                 :                : 
                               6064                 :                : RowSecurityDefaultForCmd:
 4430                          6065                 :            253 :             FOR row_security_cmd    { $$ = $2; }
                               6066                 :            290 :             | /* EMPTY */           { $$ = "all"; }
                               6067                 :                :         ;
                               6068                 :                : 
                               6069                 :                : row_security_cmd:
                               6070                 :             37 :             ALL             { $$ = "all"; }
                               6071                 :             85 :         |   SELECT          { $$ = "select"; }
                               6072                 :             37 :         |   INSERT          { $$ = "insert"; }
                               6073                 :             63 :         |   UPDATE          { $$ = "update"; }
                               6074                 :             31 :         |   DELETE_P        { $$ = "delete"; }
                               6075                 :                :         ;
                               6076                 :                : 
                               6077                 :                : /*****************************************************************************
                               6078                 :                :  *
                               6079                 :                :  *      QUERY:
                               6080                 :                :  *             CREATE ACCESS METHOD name HANDLER handler_name
                               6081                 :                :  *
                               6082                 :                :  *****************************************************************************/
                               6083                 :                : 
                               6084                 :                : CreateAmStmt: CREATE ACCESS METHOD name TYPE_P am_type HANDLER handler_name
                               6085                 :                :                 {
 3879 alvherre@alvh.no-ip.     6086                 :             38 :                     CreateAmStmt *n = makeNode(CreateAmStmt);
                               6087                 :                : 
                               6088                 :             38 :                     n->amname = $4;
                               6089                 :             38 :                     n->handler_name = $8;
 2801 andres@anarazel.de       6090                 :             38 :                     n->amtype = $6;
 3879 alvherre@alvh.no-ip.     6091                 :             38 :                     $$ = (Node *) n;
                               6092                 :                :                 }
                               6093                 :                :         ;
                               6094                 :                : 
                               6095                 :                : am_type:
 2801 andres@anarazel.de       6096                 :             20 :             INDEX           { $$ = AMTYPE_INDEX; }
                               6097                 :             18 :         |   TABLE           { $$ = AMTYPE_TABLE; }
                               6098                 :                :         ;
                               6099                 :                : 
                               6100                 :                : /*****************************************************************************
                               6101                 :                :  *
                               6102                 :                :  *      QUERIES :
                               6103                 :                :  *              CREATE TRIGGER ...
                               6104                 :                :  *
                               6105                 :                :  *****************************************************************************/
                               6106                 :                : 
                               6107                 :                : CreateTrigStmt:
                               6108                 :                :             CREATE opt_or_replace TRIGGER name TriggerActionTime TriggerEvents ON
                               6109                 :                :             qualified_name TriggerReferencing TriggerForSpec TriggerWhen
                               6110                 :                :             EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')'
                               6111                 :                :                 {
10650 bruce@momjian.us         6112                 :           1986 :                     CreateTrigStmt *n = makeNode(CreateTrigStmt);
                               6113                 :                : 
 2182 tgl@sss.pgh.pa.us        6114                 :           1986 :                     n->replace = $2;
                               6115                 :           1986 :                     n->isconstraint = false;
                               6116                 :           1986 :                     n->trigname = $4;
                               6117                 :           1986 :                     n->relation = $8;
                               6118                 :           1986 :                     n->funcname = $14;
                               6119                 :           1986 :                     n->args = $16;
                               6120                 :           1986 :                     n->row = $10;
                               6121                 :           1986 :                     n->timing = $5;
                               6122                 :           1986 :                     n->events = intVal(linitial($6));
                               6123                 :           1986 :                     n->columns = (List *) lsecond($6);
                               6124                 :           1986 :                     n->whenClause = $11;
                               6125                 :           1986 :                     n->transitionRels = $9;
 2051 peter@eisentraut.org     6126                 :           1986 :                     n->deferrable = false;
                               6127                 :           1986 :                     n->initdeferred = false;
 8995 tgl@sss.pgh.pa.us        6128                 :           1986 :                     n->constrrel = NULL;
 1637 peter@eisentraut.org     6129                 :           1986 :                     $$ = (Node *) n;
                               6130                 :                :                 }
                               6131                 :                :           | CREATE opt_or_replace CONSTRAINT TRIGGER name AFTER TriggerEvents ON
                               6132                 :                :             qualified_name OptConstrFromTable ConstraintAttributeSpec
                               6133                 :                :             FOR EACH ROW TriggerWhen
                               6134                 :                :             EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')'
                               6135                 :                :                 {
 9899 JanWieck@Yahoo.com       6136                 :             58 :                     CreateTrigStmt *n = makeNode(CreateTrigStmt);
                               6137                 :                :                     bool        dummy;
                               6138                 :                : 
  490 alvherre@kurilemu.de     6139         [ +  + ]:             58 :                     if (($11 & CAS_NOT_VALID) != 0)
                               6140         [ +  - ]:              4 :                         ereport(ERROR,
                               6141                 :                :                                 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               6142                 :                :                                 errmsg("constraint triggers cannot be marked %s",
                               6143                 :                :                                        "NOT VALID"),
                               6144                 :                :                                 parser_errposition(@11));
                               6145         [ +  + ]:             54 :                     if (($11 & CAS_NO_INHERIT) != 0)
                               6146         [ +  - ]:              4 :                         ereport(ERROR,
                               6147                 :                :                                 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               6148                 :                :                                 errmsg("constraint triggers cannot be marked %s",
                               6149                 :                :                                        "NO INHERIT"),
                               6150                 :                :                                 parser_errposition(@11));
                               6151         [ +  + ]:             50 :                     if (($11 & CAS_NOT_ENFORCED) != 0)
                               6152         [ +  - ]:              4 :                         ereport(ERROR,
                               6153                 :                :                                 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               6154                 :                :                                 errmsg("constraint triggers cannot be marked %s",
                               6155                 :                :                                        "NOT ENFORCED"),
                               6156                 :                :                                 parser_errposition(@11));
                               6157                 :                : 
 2182 tgl@sss.pgh.pa.us        6158                 :             46 :                     n->replace = $2;
                               6159         [ -  + ]:             46 :                     if (n->replace) /* not supported, see CreateTrigger */
 2182 tgl@sss.pgh.pa.us        6160         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               6161                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               6162                 :                :                                  errmsg("CREATE OR REPLACE CONSTRAINT TRIGGER is not supported"),
                               6163                 :                :                                  parser_errposition(@1)));
 2182 tgl@sss.pgh.pa.us        6164                 :CBC          46 :                     n->isconstraint = true;
                               6165                 :             46 :                     n->trigname = $5;
                               6166                 :             46 :                     n->relation = $9;
                               6167                 :             46 :                     n->funcname = $18;
                               6168                 :             46 :                     n->args = $20;
 3368 peter_e@gmx.net          6169                 :             46 :                     n->row = true;
 5870 tgl@sss.pgh.pa.us        6170                 :             46 :                     n->timing = TRIGGER_TYPE_AFTER;
 2182                          6171                 :             46 :                     n->events = intVal(linitial($7));
                               6172                 :             46 :                     n->columns = (List *) lsecond($7);
                               6173                 :             46 :                     n->whenClause = $15;
 3653 kgrittn@postgresql.o     6174                 :             46 :                     n->transitionRels = NIL;
 2182 tgl@sss.pgh.pa.us        6175                 :             46 :                     processCASbits($11, @11, "TRIGGER",
                               6176                 :                :                                    &n->deferrable, &n->initdeferred, &dummy,
                               6177                 :                :                                    NULL, NULL, yyscanner);
                               6178                 :             46 :                     n->constrrel = $10;
 1637 peter@eisentraut.org     6179                 :             46 :                     $$ = (Node *) n;
                               6180                 :                :                 }
                               6181                 :                :         ;
                               6182                 :                : 
                               6183                 :                : TriggerActionTime:
 5870 tgl@sss.pgh.pa.us        6184                 :            895 :             BEFORE                              { $$ = TRIGGER_TYPE_BEFORE; }
                               6185                 :           1004 :             | AFTER                             { $$ = TRIGGER_TYPE_AFTER; }
                               6186                 :             95 :             | INSTEAD OF                        { $$ = TRIGGER_TYPE_INSTEAD; }
                               6187                 :                :         ;
                               6188                 :                : 
                               6189                 :                : TriggerEvents:
                               6190                 :                :             TriggerOneEvent
 6349                          6191                 :           2052 :                 { $$ = $1; }
                               6192                 :                :             | TriggerEvents OR TriggerOneEvent
                               6193                 :                :                 {
 1637 peter@eisentraut.org     6194                 :            708 :                     int         events1 = intVal(linitial($1));
                               6195                 :            708 :                     int         events2 = intVal(linitial($3));
                               6196                 :            708 :                     List       *columns1 = (List *) lsecond($1);
                               6197                 :            708 :                     List       *columns2 = (List *) lsecond($3);
                               6198                 :                : 
 6231 tgl@sss.pgh.pa.us        6199         [ +  + ]:            708 :                     if (events1 & events2)
 6324                          6200                 :              4 :                         parser_yyerror("duplicate trigger events specified");
                               6201                 :                :                     /*
                               6202                 :                :                      * concat'ing the columns lists loses information about
                               6203                 :                :                      * which columns went with which event, but so long as
                               6204                 :                :                      * only UPDATE carries columns and we disallow multiple
                               6205                 :                :                      * UPDATE items, it doesn't matter.  Command execution
                               6206                 :                :                      * should just ignore the columns for non-UPDATE events.
                               6207                 :                :                      */
 6231                          6208                 :            704 :                     $$ = list_make2(makeInteger(events1 | events2),
                               6209                 :                :                                     list_concat(columns1, columns2));
                               6210                 :                :                 }
                               6211                 :                :         ;
                               6212                 :                : 
                               6213                 :                : TriggerOneEvent:
                               6214                 :                :             INSERT
                               6215                 :           1079 :                 { $$ = list_make2(makeInteger(TRIGGER_TYPE_INSERT), NIL); }
                               6216                 :                :             | DELETE_P
                               6217                 :            548 :                 { $$ = list_make2(makeInteger(TRIGGER_TYPE_DELETE), NIL); }
                               6218                 :                :             | UPDATE
                               6219                 :           1042 :                 { $$ = list_make2(makeInteger(TRIGGER_TYPE_UPDATE), NIL); }
                               6220                 :                :             | UPDATE OF columnList
                               6221                 :             65 :                 { $$ = list_make2(makeInteger(TRIGGER_TYPE_UPDATE), $3); }
                               6222                 :                :             | TRUNCATE
                               6223                 :             26 :                 { $$ = list_make2(makeInteger(TRIGGER_TYPE_TRUNCATE), NIL); }
                               6224                 :                :         ;
                               6225                 :                : 
                               6226                 :                : TriggerReferencing:
 3653 kgrittn@postgresql.o     6227                 :            304 :             REFERENCING TriggerTransitions          { $$ = $2; }
                               6228                 :           1682 :             | /*EMPTY*/                             { $$ = NIL; }
                               6229                 :                :         ;
                               6230                 :                : 
                               6231                 :                : TriggerTransitions:
                               6232                 :            304 :             TriggerTransition                       { $$ = list_make1($1); }
                               6233                 :             92 :             | TriggerTransitions TriggerTransition  { $$ = lappend($1, $2); }
                               6234                 :                :         ;
                               6235                 :                : 
                               6236                 :                : TriggerTransition:
                               6237                 :                :             TransitionOldOrNew TransitionRowOrTable opt_as TransitionRelName
                               6238                 :                :                 {
                               6239                 :            396 :                     TriggerTransition *n = makeNode(TriggerTransition);
                               6240                 :                : 
                               6241                 :            396 :                     n->name = $4;
                               6242                 :            396 :                     n->isNew = $1;
                               6243                 :            396 :                     n->isTable = $2;
 1637 peter@eisentraut.org     6244                 :            396 :                     $$ = (Node *) n;
                               6245                 :                :                 }
                               6246                 :                :         ;
                               6247                 :                : 
                               6248                 :                : TransitionOldOrNew:
 3368 peter_e@gmx.net          6249                 :            216 :             NEW                                     { $$ = true; }
                               6250                 :            180 :             | OLD                                   { $$ = false; }
                               6251                 :                :         ;
                               6252                 :                : 
                               6253                 :                : TransitionRowOrTable:
                               6254                 :            396 :             TABLE                                   { $$ = true; }
                               6255                 :                :             /*
                               6256                 :                :              * According to the standard, lack of a keyword here implies ROW.
                               6257                 :                :              * Support for that would require prohibiting ROW entirely here,
                               6258                 :                :              * reserving the keyword ROW, and/or requiring AS (instead of
                               6259                 :                :              * allowing it to be optional, as the standard specifies) as the
                               6260                 :                :              * next token.  Requiring ROW seems cleanest and easiest to
                               6261                 :                :              * explain.
                               6262                 :                :              */
 3368 peter_e@gmx.net          6263                 :UBC           0 :             | ROW                                   { $$ = false; }
                               6264                 :                :         ;
                               6265                 :                : 
                               6266                 :                : TransitionRelName:
 3653 kgrittn@postgresql.o     6267                 :CBC         396 :             ColId                                   { $$ = $1; }
                               6268                 :                :         ;
                               6269                 :                : 
                               6270                 :                : TriggerForSpec:
                               6271                 :                :             FOR TriggerForOptEach TriggerForType
                               6272                 :                :                 {
10494 lockhart@fourpalms.o     6273                 :           1852 :                     $$ = $3;
                               6274                 :                :                 }
                               6275                 :                :             | /* EMPTY */
                               6276                 :                :                 {
                               6277                 :                :                     /*
                               6278                 :                :                      * If ROW/STATEMENT not specified, default to
                               6279                 :                :                      * STATEMENT, per SQL
                               6280                 :                :                      */
 3368 peter_e@gmx.net          6281                 :            134 :                     $$ = false;
                               6282                 :                :                 }
                               6283                 :                :         ;
                               6284                 :                : 
                               6285                 :                : TriggerForOptEach:
                               6286                 :                :             EACH
                               6287                 :                :             | /*EMPTY*/
                               6288                 :                :         ;
                               6289                 :                : 
                               6290                 :                : TriggerForType:
                               6291                 :           1314 :             ROW                                     { $$ = true; }
                               6292                 :            538 :             | STATEMENT                             { $$ = false; }
                               6293                 :                :         ;
                               6294                 :                : 
                               6295                 :                : TriggerWhen:
 6194 tgl@sss.pgh.pa.us        6296                 :            124 :             WHEN '(' a_expr ')'                     { $$ = $3; }
                               6297                 :           1920 :             | /*EMPTY*/                             { $$ = NULL; }
                               6298                 :                :         ;
                               6299                 :                : 
                               6300                 :                : FUNCTION_or_PROCEDURE:
                               6301                 :                :             FUNCTION
                               6302                 :                :         |   PROCEDURE
                               6303                 :                :         ;
                               6304                 :                : 
                               6305                 :                : TriggerFuncArgs:
 8194 neilc@samurai.com        6306                 :            336 :             TriggerFuncArg                          { $$ = list_make1($1); }
 8906 bruce@momjian.us         6307                 :             63 :             | TriggerFuncArgs ',' TriggerFuncArg    { $$ = lappend($1, $3); }
 8907                          6308                 :           1708 :             | /*EMPTY*/                             { $$ = NIL; }
                               6309                 :                :         ;
                               6310                 :                : 
                               6311                 :                : TriggerFuncArg:
                               6312                 :                :             Iconst
                               6313                 :                :                 {
 1883 peter@eisentraut.org     6314                 :             49 :                     $$ = (Node *) makeString(psprintf("%d", $1));
                               6315                 :                :                 }
 1883 peter@eisentraut.org     6316                 :UBC           0 :             | FCONST                                { $$ = (Node *) makeString($1); }
 1883 peter@eisentraut.org     6317                 :CBC         337 :             | Sconst                                { $$ = (Node *) makeString($1); }
                               6318                 :             13 :             | ColLabel                              { $$ = (Node *) makeString($1); }
                               6319                 :                :         ;
                               6320                 :                : 
                               6321                 :                : OptConstrFromTable:
 8907 bruce@momjian.us         6322                 :              8 :             FROM qualified_name                     { $$ = $2; }
                               6323                 :             50 :             | /*EMPTY*/                             { $$ = NULL; }
                               6324                 :                :         ;
                               6325                 :                : 
                               6326                 :                : ConstraintAttributeSpec:
                               6327                 :                :             /*EMPTY*/
 5622 tgl@sss.pgh.pa.us        6328                 :          11426 :                 { $$ = 0; }
                               6329                 :                :             | ConstraintAttributeSpec ConstraintAttributeElem
                               6330                 :                :                 {
                               6331                 :                :                     /*
                               6332                 :                :                      * We must complain about conflicting options.
                               6333                 :                :                      * We could, but choose not to, complain about redundant
                               6334                 :                :                      * options (ie, where $2's bit is already set in $1).
                               6335                 :                :                      */
                               6336                 :           1288 :                     int     newspec = $1 | $2;
                               6337                 :                : 
                               6338                 :                :                     /* special message for this case */
                               6339         [ +  + ]:           1288 :                     if ((newspec & (CAS_NOT_DEFERRABLE | CAS_INITIALLY_DEFERRED)) == (CAS_NOT_DEFERRABLE | CAS_INITIALLY_DEFERRED))
 8510                          6340         [ +  - ]:              4 :                         ereport(ERROR,
                               6341                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               6342                 :                :                                  errmsg("constraint declared INITIALLY DEFERRED must be DEFERRABLE"),
                               6343                 :                :                                  parser_errposition(@2)));
                               6344                 :                :                     /* generic message for other conflicts */
 5622                          6345         [ +  - ]:           1284 :                     if ((newspec & (CAS_NOT_DEFERRABLE | CAS_DEFERRABLE)) == (CAS_NOT_DEFERRABLE | CAS_DEFERRABLE) ||
  663 peter@eisentraut.org     6346         [ +  - ]:           1284 :                         (newspec & (CAS_INITIALLY_IMMEDIATE | CAS_INITIALLY_DEFERRED)) == (CAS_INITIALLY_IMMEDIATE | CAS_INITIALLY_DEFERRED) ||
                               6347         [ +  + ]:           1284 :                         (newspec & (CAS_NOT_ENFORCED | CAS_ENFORCED)) == (CAS_NOT_ENFORCED | CAS_ENFORCED))
 8510 tgl@sss.pgh.pa.us        6348         [ +  - ]:              4 :                         ereport(ERROR,
                               6349                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                               6350                 :                :                                  errmsg("conflicting constraint properties"),
                               6351                 :                :                                  parser_errposition(@2)));
 5622                          6352                 :           1280 :                     $$ = newspec;
                               6353                 :                :                 }
                               6354                 :                :         ;
                               6355                 :                : 
                               6356                 :                : ConstraintAttributeElem:
                               6357                 :             32 :             NOT DEFERRABLE                  { $$ = CAS_NOT_DEFERRABLE; }
                               6358                 :            156 :             | DEFERRABLE                    { $$ = CAS_DEFERRABLE; }
                               6359                 :             20 :             | INITIALLY IMMEDIATE           { $$ = CAS_INITIALLY_IMMEDIATE; }
                               6360                 :            110 :             | INITIALLY DEFERRED            { $$ = CAS_INITIALLY_DEFERRED; }
                               6361                 :            444 :             | NOT VALID                     { $$ = CAS_NOT_VALID; }
 5217 alvherre@alvh.no-ip.     6362                 :            171 :             | NO INHERIT                    { $$ = CAS_NO_INHERIT; }
  663 peter@eisentraut.org     6363                 :            203 :             | NOT ENFORCED                  { $$ = CAS_NOT_ENFORCED; }
                               6364                 :            152 :             | ENFORCED                      { $$ = CAS_ENFORCED; }
                               6365                 :                :         ;
                               6366                 :                : 
                               6367                 :                : 
                               6368                 :                : /*****************************************************************************
                               6369                 :                :  *
                               6370                 :                :  *      QUERIES :
                               6371                 :                :  *              CREATE EVENT TRIGGER ...
                               6372                 :                :  *              ALTER EVENT TRIGGER ...
                               6373                 :                :  *
                               6374                 :                :  *****************************************************************************/
                               6375                 :                : 
                               6376                 :                : CreateEventTrigStmt:
                               6377                 :                :             CREATE EVENT TRIGGER name ON ColLabel
                               6378                 :                :             EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')'
                               6379                 :                :                 {
 5223 rhaas@postgresql.org     6380                 :             64 :                     CreateEventTrigStmt *n = makeNode(CreateEventTrigStmt);
                               6381                 :                : 
                               6382                 :             64 :                     n->trigname = $4;
                               6383                 :             64 :                     n->eventname = $6;
                               6384                 :             64 :                     n->whenclause = NULL;
                               6385                 :             64 :                     n->funcname = $9;
 1637 peter@eisentraut.org     6386                 :             64 :                     $$ = (Node *) n;
                               6387                 :                :                 }
                               6388                 :                :           | CREATE EVENT TRIGGER name ON ColLabel
                               6389                 :                :             WHEN event_trigger_when_list
                               6390                 :                :             EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')'
                               6391                 :                :                 {
 5223 rhaas@postgresql.org     6392                 :             65 :                     CreateEventTrigStmt *n = makeNode(CreateEventTrigStmt);
                               6393                 :                : 
                               6394                 :             65 :                     n->trigname = $4;
                               6395                 :             65 :                     n->eventname = $6;
                               6396                 :             65 :                     n->whenclause = $8;
                               6397                 :             65 :                     n->funcname = $11;
 1637 peter@eisentraut.org     6398                 :             65 :                     $$ = (Node *) n;
                               6399                 :                :                 }
                               6400                 :                :         ;
                               6401                 :                : 
                               6402                 :                : event_trigger_when_list:
                               6403                 :                :           event_trigger_when_item
 5223 rhaas@postgresql.org     6404                 :             65 :             { $$ = list_make1($1); }
                               6405                 :                :         | event_trigger_when_list AND event_trigger_when_item
                               6406                 :              4 :             { $$ = lappend($1, $3); }
                               6407                 :                :         ;
                               6408                 :                : 
                               6409                 :                : event_trigger_when_item:
                               6410                 :                :         ColId IN_P '(' event_trigger_value_list ')'
 3712 peter_e@gmx.net          6411                 :             69 :             { $$ = makeDefElem($1, (Node *) $4, @1); }
                               6412                 :                :         ;
                               6413                 :                : 
                               6414                 :                : event_trigger_value_list:
                               6415                 :                :           SCONST
 5223 rhaas@postgresql.org     6416                 :             69 :             { $$ = list_make1(makeString($1)); }
                               6417                 :                :         | event_trigger_value_list ',' SCONST
                               6418                 :             44 :             { $$ = lappend($1, makeString($3)); }
                               6419                 :                :         ;
                               6420                 :                : 
                               6421                 :                : AlterEventTrigStmt:
                               6422                 :                :             ALTER EVENT TRIGGER name enable_trigger
                               6423                 :                :                 {
                               6424                 :             32 :                     AlterEventTrigStmt *n = makeNode(AlterEventTrigStmt);
                               6425                 :                : 
                               6426                 :             32 :                     n->trigname = $4;
                               6427                 :             32 :                     n->tgenabled = $5;
                               6428                 :             32 :                     $$ = (Node *) n;
                               6429                 :                :                 }
                               6430                 :                :         ;
                               6431                 :                : 
                               6432                 :                : enable_trigger:
                               6433                 :              4 :             ENABLE_P                    { $$ = TRIGGER_FIRES_ON_ORIGIN; }
                               6434                 :              4 :             | ENABLE_P REPLICA          { $$ = TRIGGER_FIRES_ON_REPLICA; }
                               6435                 :             11 :             | ENABLE_P ALWAYS           { $$ = TRIGGER_FIRES_ALWAYS; }
                               6436                 :             13 :             | DISABLE_P                 { $$ = TRIGGER_DISABLED; }
                               6437                 :                :         ;
                               6438                 :                : 
                               6439                 :                : /*****************************************************************************
                               6440                 :                :  *
                               6441                 :                :  *      QUERY :
                               6442                 :                :  *              CREATE ASSERTION ...
                               6443                 :                :  *
                               6444                 :                :  *****************************************************************************/
                               6445                 :                : 
                               6446                 :                : CreateAssertionStmt:
                               6447                 :                :             CREATE ASSERTION any_name CHECK '(' a_expr ')' ConstraintAttributeSpec
                               6448                 :                :                 {
 8510 tgl@sss.pgh.pa.us        6449         [ #  # ]:UBC           0 :                     ereport(ERROR,
                               6450                 :                :                             (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               6451                 :                :                              errmsg("CREATE ASSERTION is not yet implemented"),
                               6452                 :                :                              parser_errposition(@1)));
                               6453                 :                : 
                               6454                 :                :                     $$ = NULL;
                               6455                 :                :                 }
                               6456                 :                :         ;
                               6457                 :                : 
                               6458                 :                : 
                               6459                 :                : /*****************************************************************************
                               6460                 :                :  *
                               6461                 :                :  *      QUERY :
                               6462                 :                :  *              define (aggregate,operator,type)
                               6463                 :                :  *
                               6464                 :                :  *****************************************************************************/
                               6465                 :                : 
                               6466                 :                : DefineStmt:
                               6467                 :                :             CREATE opt_or_replace AGGREGATE func_name aggr_args definition
                               6468                 :                :                 {
 9708 lockhart@fourpalms.o     6469                 :CBC         341 :                     DefineStmt *n = makeNode(DefineStmt);
                               6470                 :                : 
 8532 peter_e@gmx.net          6471                 :            341 :                     n->kind = OBJECT_AGGREGATE;
 7509 tgl@sss.pgh.pa.us        6472                 :            341 :                     n->oldstyle = false;
 2788 rhodiumtoad@postgres     6473                 :            341 :                     n->replace = $2;
                               6474                 :            341 :                     n->defnames = $4;
                               6475                 :            341 :                     n->args = $5;
                               6476                 :            341 :                     n->definition = $6;
 1637 peter@eisentraut.org     6477                 :            341 :                     $$ = (Node *) n;
                               6478                 :                :                 }
                               6479                 :                :             | CREATE opt_or_replace AGGREGATE func_name old_aggr_definition
                               6480                 :                :                 {
                               6481                 :                :                     /* old-style (pre-8.2) syntax for CREATE AGGREGATE */
 7509 tgl@sss.pgh.pa.us        6482                 :            240 :                     DefineStmt *n = makeNode(DefineStmt);
                               6483                 :                : 
                               6484                 :            240 :                     n->kind = OBJECT_AGGREGATE;
                               6485                 :            240 :                     n->oldstyle = true;
 2788 rhodiumtoad@postgres     6486                 :            240 :                     n->replace = $2;
                               6487                 :            240 :                     n->defnames = $4;
 7509 tgl@sss.pgh.pa.us        6488                 :            240 :                     n->args = NIL;
 2788 rhodiumtoad@postgres     6489                 :            240 :                     n->definition = $5;
 1637 peter@eisentraut.org     6490                 :            240 :                     $$ = (Node *) n;
                               6491                 :                :                 }
                               6492                 :                :             | CREATE OPERATOR any_operator definition
                               6493                 :                :                 {
 9449 tgl@sss.pgh.pa.us        6494                 :            933 :                     DefineStmt *n = makeNode(DefineStmt);
                               6495                 :                : 
 8532 peter_e@gmx.net          6496                 :            933 :                     n->kind = OBJECT_OPERATOR;
 7509 tgl@sss.pgh.pa.us        6497                 :            933 :                     n->oldstyle = false;
 8969                          6498                 :            933 :                     n->defnames = $3;
 7509                          6499                 :            933 :                     n->args = NIL;
 9449                          6500                 :            933 :                     n->definition = $4;
 1637 peter@eisentraut.org     6501                 :            933 :                     $$ = (Node *) n;
                               6502                 :                :                 }
                               6503                 :                :             | CREATE TYPE_P any_name definition
                               6504                 :                :                 {
 9449 tgl@sss.pgh.pa.us        6505                 :            149 :                     DefineStmt *n = makeNode(DefineStmt);
                               6506                 :                : 
 8532 peter_e@gmx.net          6507                 :            149 :                     n->kind = OBJECT_TYPE;
 7509 tgl@sss.pgh.pa.us        6508                 :            149 :                     n->oldstyle = false;
 8987                          6509                 :            149 :                     n->defnames = $3;
 7509                          6510                 :            149 :                     n->args = NIL;
 9708 lockhart@fourpalms.o     6511                 :            149 :                     n->definition = $4;
 1637 peter@eisentraut.org     6512                 :            149 :                     $$ = (Node *) n;
                               6513                 :                :                 }
                               6514                 :                :             | CREATE TYPE_P any_name
                               6515                 :                :                 {
                               6516                 :                :                     /* Shell type (identified by lack of definition) */
 7555 tgl@sss.pgh.pa.us        6517                 :            101 :                     DefineStmt *n = makeNode(DefineStmt);
                               6518                 :                : 
                               6519                 :            101 :                     n->kind = OBJECT_TYPE;
 7509                          6520                 :            101 :                     n->oldstyle = false;
 7555                          6521                 :            101 :                     n->defnames = $3;
 7509                          6522                 :            101 :                     n->args = NIL;
 7555                          6523                 :            101 :                     n->definition = NIL;
 1637 peter@eisentraut.org     6524                 :            101 :                     $$ = (Node *) n;
                               6525                 :                :                 }
                               6526                 :                :             | CREATE TYPE_P any_name AS '(' OptTableFuncElementList ')'
                               6527                 :                :                 {
 8848 bruce@momjian.us         6528                 :           2387 :                     CompositeTypeStmt *n = makeNode(CompositeTypeStmt);
                               6529                 :                : 
                               6530                 :                :                     /* can't use qualified_name, sigh */
 5884 peter_e@gmx.net          6531                 :           2387 :                     n->typevar = makeRangeVarFromAnyName($3, @3, yyscanner);
 8834 tgl@sss.pgh.pa.us        6532                 :           2387 :                     n->coldeflist = $6;
 1637 peter@eisentraut.org     6533                 :           2387 :                     $$ = (Node *) n;
                               6534                 :                :                 }
                               6535                 :                :             | CREATE TYPE_P any_name AS ENUM_P '(' opt_enum_val_list ')'
                               6536                 :                :                 {
 7157 tgl@sss.pgh.pa.us        6537                 :            170 :                     CreateEnumStmt *n = makeNode(CreateEnumStmt);
                               6538                 :                : 
 6321 peter_e@gmx.net          6539                 :            170 :                     n->typeName = $3;
 7157 tgl@sss.pgh.pa.us        6540                 :            170 :                     n->vals = $7;
 1637 peter@eisentraut.org     6541                 :            170 :                     $$ = (Node *) n;
                               6542                 :                :                 }
                               6543                 :                :             | CREATE TYPE_P any_name AS RANGE definition
                               6544                 :                :                 {
 5481 heikki.linnakangas@i     6545                 :            148 :                     CreateRangeStmt *n = makeNode(CreateRangeStmt);
                               6546                 :                : 
                               6547                 :            148 :                     n->typeName = $3;
 1940 peter@eisentraut.org     6548                 :            148 :                     n->params = $6;
 1637                          6549                 :            148 :                     $$ = (Node *) n;
                               6550                 :                :                 }
                               6551                 :                :             | CREATE TEXT_P SEARCH PARSER any_name definition
                               6552                 :                :                 {
 7016 tgl@sss.pgh.pa.us        6553                 :             26 :                     DefineStmt *n = makeNode(DefineStmt);
                               6554                 :                : 
                               6555                 :             26 :                     n->kind = OBJECT_TSPARSER;
                               6556                 :             26 :                     n->args = NIL;
                               6557                 :             26 :                     n->defnames = $5;
                               6558                 :             26 :                     n->definition = $6;
 1637 peter@eisentraut.org     6559                 :             26 :                     $$ = (Node *) n;
                               6560                 :                :                 }
                               6561                 :                :             | CREATE TEXT_P SEARCH DICTIONARY any_name definition
                               6562                 :                :                 {
 7016 tgl@sss.pgh.pa.us        6563                 :           1860 :                     DefineStmt *n = makeNode(DefineStmt);
                               6564                 :                : 
                               6565                 :           1860 :                     n->kind = OBJECT_TSDICTIONARY;
                               6566                 :           1860 :                     n->args = NIL;
                               6567                 :           1860 :                     n->defnames = $5;
                               6568                 :           1860 :                     n->definition = $6;
 1637 peter@eisentraut.org     6569                 :           1860 :                     $$ = (Node *) n;
                               6570                 :                :                 }
                               6571                 :                :             | CREATE TEXT_P SEARCH TEMPLATE any_name definition
                               6572                 :                :                 {
 7016 tgl@sss.pgh.pa.us        6573                 :             85 :                     DefineStmt *n = makeNode(DefineStmt);
                               6574                 :                : 
                               6575                 :             85 :                     n->kind = OBJECT_TSTEMPLATE;
                               6576                 :             85 :                     n->args = NIL;
                               6577                 :             85 :                     n->defnames = $5;
                               6578                 :             85 :                     n->definition = $6;
 1637 peter@eisentraut.org     6579                 :             85 :                     $$ = (Node *) n;
                               6580                 :                :                 }
                               6581                 :                :             | CREATE TEXT_P SEARCH CONFIGURATION any_name definition
                               6582                 :                :                 {
 7016 tgl@sss.pgh.pa.us        6583                 :           1824 :                     DefineStmt *n = makeNode(DefineStmt);
                               6584                 :                : 
                               6585                 :           1824 :                     n->kind = OBJECT_TSCONFIGURATION;
                               6586                 :           1824 :                     n->args = NIL;
                               6587                 :           1824 :                     n->defnames = $5;
                               6588                 :           1824 :                     n->definition = $6;
 1637 peter@eisentraut.org     6589                 :           1824 :                     $$ = (Node *) n;
                               6590                 :                :                 }
                               6591                 :                :             | CREATE COLLATION any_name definition
                               6592                 :                :                 {
 5745 peter_e@gmx.net          6593                 :            196 :                     DefineStmt *n = makeNode(DefineStmt);
                               6594                 :                : 
                               6595                 :            196 :                     n->kind = OBJECT_COLLATION;
                               6596                 :            196 :                     n->args = NIL;
                               6597                 :            196 :                     n->defnames = $3;
                               6598                 :            196 :                     n->definition = $4;
 1637 peter@eisentraut.org     6599                 :            196 :                     $$ = (Node *) n;
                               6600                 :                :                 }
                               6601                 :                :             | CREATE COLLATION IF_P NOT EXISTS any_name definition
                               6602                 :                :                 {
 3557 peter_e@gmx.net          6603                 :              9 :                     DefineStmt *n = makeNode(DefineStmt);
                               6604                 :                : 
                               6605                 :              9 :                     n->kind = OBJECT_COLLATION;
                               6606                 :              9 :                     n->args = NIL;
                               6607                 :              9 :                     n->defnames = $6;
                               6608                 :              9 :                     n->definition = $7;
                               6609                 :              9 :                     n->if_not_exists = true;
 1637 peter@eisentraut.org     6610                 :              9 :                     $$ = (Node *) n;
                               6611                 :                :                 }
                               6612                 :                :             | CREATE COLLATION any_name FROM any_name
                               6613                 :                :                 {
 5745 peter_e@gmx.net          6614                 :             35 :                     DefineStmt *n = makeNode(DefineStmt);
                               6615                 :                : 
                               6616                 :             35 :                     n->kind = OBJECT_COLLATION;
                               6617                 :             35 :                     n->args = NIL;
                               6618                 :             35 :                     n->defnames = $3;
 3712                          6619                 :             35 :                     n->definition = list_make1(makeDefElem("from", (Node *) $5, @5));
 1637 peter@eisentraut.org     6620                 :             35 :                     $$ = (Node *) n;
                               6621                 :                :                 }
                               6622                 :                :             | CREATE COLLATION IF_P NOT EXISTS any_name FROM any_name
                               6623                 :                :                 {
 3557 peter_e@gmx.net          6624                 :UBC           0 :                     DefineStmt *n = makeNode(DefineStmt);
                               6625                 :                : 
                               6626                 :              0 :                     n->kind = OBJECT_COLLATION;
                               6627                 :              0 :                     n->args = NIL;
                               6628                 :              0 :                     n->defnames = $6;
                               6629                 :              0 :                     n->definition = list_make1(makeDefElem("from", (Node *) $8, @8));
                               6630                 :              0 :                     n->if_not_exists = true;
 1637 peter@eisentraut.org     6631                 :              0 :                     $$ = (Node *) n;
                               6632                 :                :                 }
                               6633                 :                :         ;
                               6634                 :                : 
 8907 bruce@momjian.us         6635                 :CBC        6410 : definition: '(' def_list ')'                        { $$ = $2; }
                               6636                 :                :         ;
                               6637                 :                : 
 5483 peter_e@gmx.net          6638                 :           6410 : def_list:   def_elem                                { $$ = list_make1($1); }
 8907 bruce@momjian.us         6639                 :           8726 :             | def_list ',' def_elem                 { $$ = lappend($1, $3); }
                               6640                 :                :         ;
                               6641                 :                : 
                               6642                 :                : def_elem:   ColLabel '=' def_arg
                               6643                 :                :                 {
 3712 peter_e@gmx.net          6644                 :          14941 :                     $$ = makeDefElem($1, (Node *) $3, @1);
                               6645                 :                :                 }
                               6646                 :                :             | ColLabel
                               6647                 :                :                 {
                               6648                 :            195 :                     $$ = makeDefElem($1, NULL, @1);
                               6649                 :                :                 }
                               6650                 :                :         ;
                               6651                 :                : 
                               6652                 :                : /* Note: any simple identifier will be returned as a type name! */
 1637 peter@eisentraut.org     6653                 :          12006 : def_arg:    func_type                       { $$ = (Node *) $1; }
                               6654                 :           2843 :             | reserved_keyword              { $$ = (Node *) makeString(pstrdup($1)); }
                               6655                 :            630 :             | qual_all_Op                   { $$ = (Node *) $1; }
                               6656                 :            923 :             | NumericOnly                   { $$ = (Node *) $1; }
                               6657                 :           1259 :             | Sconst                        { $$ = (Node *) makeString($1); }
                               6658                 :            153 :             | NONE                          { $$ = (Node *) makeString(pstrdup($1)); }
                               6659                 :                :         ;
                               6660                 :                : 
 7509 tgl@sss.pgh.pa.us        6661                 :            240 : old_aggr_definition: '(' old_aggr_list ')'          { $$ = $2; }
                               6662                 :                :         ;
                               6663                 :                : 
                               6664                 :            240 : old_aggr_list: old_aggr_elem                        { $$ = list_make1($1); }
                               6665                 :            856 :             | old_aggr_list ',' old_aggr_elem       { $$ = lappend($1, $3); }
                               6666                 :                :         ;
                               6667                 :                : 
                               6668                 :                : /*
                               6669                 :                :  * Must use IDENT here to avoid reduce/reduce conflicts; fortunately none of
                               6670                 :                :  * the item names needed in old aggregate definitions are likely to become
                               6671                 :                :  * SQL keywords.
                               6672                 :                :  */
                               6673                 :                : old_aggr_elem:  IDENT '=' def_arg
                               6674                 :                :                 {
 1637 peter@eisentraut.org     6675                 :           1096 :                     $$ = makeDefElem($1, (Node *) $3, @1);
                               6676                 :                :                 }
                               6677                 :                :         ;
                               6678                 :                : 
                               6679                 :                : opt_enum_val_list:
 6158 bruce@momjian.us         6680                 :            166 :         enum_val_list                           { $$ = $1; }
                               6681                 :              4 :         | /*EMPTY*/                             { $$ = NIL; }
                               6682                 :                :         ;
                               6683                 :                : 
                               6684                 :                : enum_val_list:  Sconst
 7157 tgl@sss.pgh.pa.us        6685                 :            166 :                 { $$ = list_make1(makeString($1)); }
                               6686                 :                :             | enum_val_list ',' Sconst
                               6687                 :           5296 :                 { $$ = lappend($1, makeString($3)); }
                               6688                 :                :         ;
                               6689                 :                : 
                               6690                 :                : /*****************************************************************************
                               6691                 :                :  *
                               6692                 :                :  *  ALTER TYPE enumtype ADD ...
                               6693                 :                :  *
                               6694                 :                :  *****************************************************************************/
                               6695                 :                : 
                               6696                 :                : AlterEnumStmt:
                               6697                 :                :         ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists Sconst
                               6698                 :                :             {
 5483 peter_e@gmx.net          6699                 :             86 :                 AlterEnumStmt *n = makeNode(AlterEnumStmt);
                               6700                 :                : 
                               6701                 :             86 :                 n->typeName = $3;
 3711 tgl@sss.pgh.pa.us        6702                 :             86 :                 n->oldVal = NULL;
 5157 andrew@dunslane.net      6703                 :             86 :                 n->newVal = $7;
 5483 peter_e@gmx.net          6704                 :             86 :                 n->newValNeighbor = NULL;
                               6705                 :             86 :                 n->newValIsAfter = true;
 3711 tgl@sss.pgh.pa.us        6706                 :             86 :                 n->skipIfNewValExists = $6;
 5483 peter_e@gmx.net          6707                 :             86 :                 $$ = (Node *) n;
                               6708                 :                :             }
                               6709                 :                :          | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists Sconst BEFORE Sconst
                               6710                 :                :             {
                               6711                 :            130 :                 AlterEnumStmt *n = makeNode(AlterEnumStmt);
                               6712                 :                : 
                               6713                 :            130 :                 n->typeName = $3;
 3711 tgl@sss.pgh.pa.us        6714                 :            130 :                 n->oldVal = NULL;
 5157 andrew@dunslane.net      6715                 :            130 :                 n->newVal = $7;
                               6716                 :            130 :                 n->newValNeighbor = $9;
 5483 peter_e@gmx.net          6717                 :            130 :                 n->newValIsAfter = false;
 3711 tgl@sss.pgh.pa.us        6718                 :            130 :                 n->skipIfNewValExists = $6;
 5483 peter_e@gmx.net          6719                 :            130 :                 $$ = (Node *) n;
                               6720                 :                :             }
                               6721                 :                :          | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists Sconst AFTER Sconst
                               6722                 :                :             {
                               6723                 :             14 :                 AlterEnumStmt *n = makeNode(AlterEnumStmt);
                               6724                 :                : 
                               6725                 :             14 :                 n->typeName = $3;
 3711 tgl@sss.pgh.pa.us        6726                 :             14 :                 n->oldVal = NULL;
 5157 andrew@dunslane.net      6727                 :             14 :                 n->newVal = $7;
                               6728                 :             14 :                 n->newValNeighbor = $9;
 5483 peter_e@gmx.net          6729                 :             14 :                 n->newValIsAfter = true;
 3711 tgl@sss.pgh.pa.us        6730                 :             14 :                 n->skipIfNewValExists = $6;
                               6731                 :             14 :                 $$ = (Node *) n;
                               6732                 :                :             }
                               6733                 :                :          | ALTER TYPE_P any_name RENAME VALUE_P Sconst TO Sconst
                               6734                 :                :             {
                               6735                 :             16 :                 AlterEnumStmt *n = makeNode(AlterEnumStmt);
                               6736                 :                : 
                               6737                 :             16 :                 n->typeName = $3;
                               6738                 :             16 :                 n->oldVal = $6;
                               6739                 :             16 :                 n->newVal = $8;
                               6740                 :             16 :                 n->newValNeighbor = NULL;
                               6741                 :             16 :                 n->newValIsAfter = false;
                               6742                 :             16 :                 n->skipIfNewValExists = false;
 5483 peter_e@gmx.net          6743                 :             16 :                 $$ = (Node *) n;
                               6744                 :                :             }
                               6745                 :                :          | ALTER TYPE_P any_name DROP VALUE_P Sconst
                               6746                 :                :             {
                               6747                 :                :                 /*
                               6748                 :                :                  * The following problems must be solved before this can be
                               6749                 :                :                  * implemented:
                               6750                 :                :                  *
                               6751                 :                :                  * - There must be no instance of the target value in
                               6752                 :                :                  *   any table.
                               6753                 :                :                  *
                               6754                 :                :                  * - The value must not appear in any catalog metadata,
                               6755                 :                :                  *   such as stored view expressions or column defaults.
                               6756                 :                :                  *
                               6757                 :                :                  * - The value must not appear in any non-leaf page of a
                               6758                 :                :                  *   btree (and similar issues with other index types).
                               6759                 :                :                  *   This is problematic because a value could persist
                               6760                 :                :                  *   there long after it's gone from user-visible data.
                               6761                 :                :                  *
                               6762                 :                :                  * - Concurrent sessions must not be able to insert the
                               6763                 :                :                  *   value while the preceding conditions are being checked.
                               6764                 :                :                  *
                               6765                 :                :                  * - Possibly more...
                               6766                 :                :                  */
 1129 tgl@sss.pgh.pa.us        6767         [ #  # ]:UBC           0 :                 ereport(ERROR,
                               6768                 :                :                         (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               6769                 :                :                          errmsg("dropping an enum value is not implemented"),
                               6770                 :                :                          parser_errposition(@4)));
                               6771                 :                :             }
                               6772                 :                :          ;
                               6773                 :                : 
 5157 andrew@dunslane.net      6774                 :CBC           8 : opt_if_not_exists: IF_P NOT EXISTS              { $$ = true; }
 2180 peter@eisentraut.org     6775                 :            222 :         | /* EMPTY */                          { $$ = false; }
                               6776                 :                :         ;
                               6777                 :                : 
                               6778                 :                : 
                               6779                 :                : /*****************************************************************************
                               6780                 :                :  *
                               6781                 :                :  *      QUERIES :
                               6782                 :                :  *              CREATE OPERATOR CLASS ...
                               6783                 :                :  *              CREATE OPERATOR FAMILY ...
                               6784                 :                :  *              ALTER OPERATOR FAMILY ...
                               6785                 :                :  *              DROP OPERATOR CLASS ...
                               6786                 :                :  *              DROP OPERATOR FAMILY ...
                               6787                 :                :  *
                               6788                 :                :  *****************************************************************************/
                               6789                 :                : 
                               6790                 :                : CreateOpClassStmt:
                               6791                 :                :             CREATE OPERATOR CLASS any_name opt_default FOR TYPE_P Typename
                               6792                 :                :             USING name opt_opfamily AS opclass_item_list
                               6793                 :                :                 {
 8865 tgl@sss.pgh.pa.us        6794                 :            319 :                     CreateOpClassStmt *n = makeNode(CreateOpClassStmt);
                               6795                 :                : 
                               6796                 :            319 :                     n->opclassname = $4;
                               6797                 :            319 :                     n->isDefault = $5;
                               6798                 :            319 :                     n->datatype = $8;
                               6799                 :            319 :                     n->amname = $10;
 7226                          6800                 :            319 :                     n->opfamilyname = $11;
                               6801                 :            319 :                     n->items = $13;
 8865                          6802                 :            319 :                     $$ = (Node *) n;
                               6803                 :                :                 }
                               6804                 :                :         ;
                               6805                 :                : 
                               6806                 :                : opclass_item_list:
 8194 neilc@samurai.com        6807                 :            565 :             opclass_item                            { $$ = list_make1($1); }
 8865 tgl@sss.pgh.pa.us        6808                 :           3182 :             | opclass_item_list ',' opclass_item    { $$ = lappend($1, $3); }
                               6809                 :                :         ;
                               6810                 :                : 
                               6811                 :                : opclass_item:
                               6812                 :                :             OPERATOR Iconst any_operator opclass_purpose
                               6813                 :                :                 {
                               6814                 :           1163 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
 3599 peter_e@gmx.net          6815                 :           1163 :                     ObjectWithArgs *owa = makeNode(ObjectWithArgs);
                               6816                 :                : 
                               6817                 :           1163 :                     owa->objname = $3;
                               6818                 :           1163 :                     owa->objargs = NIL;
 8865 tgl@sss.pgh.pa.us        6819                 :           1163 :                     n->itemtype = OPCLASS_ITEM_OPERATOR;
 3599 peter_e@gmx.net          6820                 :           1163 :                     n->name = owa;
 8865 tgl@sss.pgh.pa.us        6821                 :           1163 :                     n->number = $2;
 5825                          6822                 :           1163 :                     n->order_family = $4;
 8865                          6823                 :           1163 :                     $$ = (Node *) n;
                               6824                 :                :                 }
                               6825                 :                :             | OPERATOR Iconst operator_with_argtypes opclass_purpose
                               6826                 :                :                 {
                               6827                 :            823 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
                               6828                 :                : 
                               6829                 :            823 :                     n->itemtype = OPCLASS_ITEM_OPERATOR;
 3599 peter_e@gmx.net          6830                 :            823 :                     n->name = $3;
 8865 tgl@sss.pgh.pa.us        6831                 :            823 :                     n->number = $2;
 3599 peter_e@gmx.net          6832                 :            823 :                     n->order_family = $4;
 8865 tgl@sss.pgh.pa.us        6833                 :            823 :                     $$ = (Node *) n;
                               6834                 :                :                 }
                               6835                 :                :             | FUNCTION Iconst function_with_argtypes
                               6836                 :                :                 {
                               6837                 :           1443 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
                               6838                 :                : 
                               6839                 :           1443 :                     n->itemtype = OPCLASS_ITEM_FUNCTION;
 3599 peter_e@gmx.net          6840                 :           1443 :                     n->name = $3;
 8865 tgl@sss.pgh.pa.us        6841                 :           1443 :                     n->number = $2;
                               6842                 :           1443 :                     $$ = (Node *) n;
                               6843                 :                :                 }
                               6844                 :                :             | FUNCTION Iconst '(' type_list ')' function_with_argtypes
                               6845                 :                :                 {
 7226                          6846                 :            132 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
                               6847                 :                : 
                               6848                 :            132 :                     n->itemtype = OPCLASS_ITEM_FUNCTION;
 3599 peter_e@gmx.net          6849                 :            132 :                     n->name = $6;
 7226 tgl@sss.pgh.pa.us        6850                 :            132 :                     n->number = $2;
                               6851                 :            132 :                     n->class_args = $4;
                               6852                 :            132 :                     $$ = (Node *) n;
                               6853                 :                :                 }
                               6854                 :                :             | STORAGE Typename
                               6855                 :                :                 {
 8865                          6856                 :            186 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
                               6857                 :                : 
                               6858                 :            186 :                     n->itemtype = OPCLASS_ITEM_STORAGETYPE;
                               6859                 :            186 :                     n->storedtype = $2;
                               6860                 :            186 :                     $$ = (Node *) n;
                               6861                 :                :                 }
                               6862                 :                :         ;
                               6863                 :                : 
 3368 peter_e@gmx.net          6864                 :            226 : opt_default:    DEFAULT                     { $$ = true; }
                               6865                 :            135 :             | /*EMPTY*/                     { $$ = false; }
                               6866                 :                :         ;
                               6867                 :                : 
 7226 tgl@sss.pgh.pa.us        6868                 :             26 : opt_opfamily:   FAMILY any_name             { $$ = $2; }
                               6869                 :            293 :             | /*EMPTY*/                     { $$ = NIL; }
                               6870                 :                :         ;
                               6871                 :                : 
 5825 tgl@sss.pgh.pa.us        6872                 :UBC           0 : opclass_purpose: FOR SEARCH                 { $$ = NIL; }
 5825 tgl@sss.pgh.pa.us        6873                 :CBC          63 :             | FOR ORDER BY any_name         { $$ = $4; }
                               6874                 :           1923 :             | /*EMPTY*/                     { $$ = NIL; }
                               6875                 :                :         ;
                               6876                 :                : 
                               6877                 :                : 
                               6878                 :                : CreateOpFamilyStmt:
                               6879                 :                :             CREATE OPERATOR FAMILY any_name USING name
                               6880                 :                :                 {
 7226                          6881                 :             99 :                     CreateOpFamilyStmt *n = makeNode(CreateOpFamilyStmt);
                               6882                 :                : 
                               6883                 :             99 :                     n->opfamilyname = $4;
                               6884                 :             99 :                     n->amname = $6;
                               6885                 :             99 :                     $$ = (Node *) n;
                               6886                 :                :                 }
                               6887                 :                :         ;
                               6888                 :                : 
                               6889                 :                : AlterOpFamilyStmt:
                               6890                 :                :             ALTER OPERATOR FAMILY any_name USING name ADD_P opclass_item_list
                               6891                 :                :                 {
                               6892                 :            246 :                     AlterOpFamilyStmt *n = makeNode(AlterOpFamilyStmt);
                               6893                 :                : 
                               6894                 :            246 :                     n->opfamilyname = $4;
                               6895                 :            246 :                     n->amname = $6;
                               6896                 :            246 :                     n->isDrop = false;
                               6897                 :            246 :                     n->items = $8;
                               6898                 :            246 :                     $$ = (Node *) n;
                               6899                 :                :                 }
                               6900                 :                :             | ALTER OPERATOR FAMILY any_name USING name DROP opclass_drop_list
                               6901                 :                :                 {
                               6902                 :             42 :                     AlterOpFamilyStmt *n = makeNode(AlterOpFamilyStmt);
                               6903                 :                : 
                               6904                 :             42 :                     n->opfamilyname = $4;
                               6905                 :             42 :                     n->amname = $6;
                               6906                 :             42 :                     n->isDrop = true;
                               6907                 :             42 :                     n->items = $8;
                               6908                 :             42 :                     $$ = (Node *) n;
                               6909                 :                :                 }
                               6910                 :                :         ;
                               6911                 :                : 
                               6912                 :                : opclass_drop_list:
                               6913                 :             42 :             opclass_drop                            { $$ = list_make1($1); }
                               6914                 :             20 :             | opclass_drop_list ',' opclass_drop    { $$ = lappend($1, $3); }
                               6915                 :                :         ;
                               6916                 :                : 
                               6917                 :                : opclass_drop:
                               6918                 :                :             OPERATOR Iconst '(' type_list ')'
                               6919                 :                :                 {
                               6920                 :             40 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
                               6921                 :                : 
                               6922                 :             40 :                     n->itemtype = OPCLASS_ITEM_OPERATOR;
                               6923                 :             40 :                     n->number = $2;
 3599 peter_e@gmx.net          6924                 :             40 :                     n->class_args = $4;
 7226 tgl@sss.pgh.pa.us        6925                 :             40 :                     $$ = (Node *) n;
                               6926                 :                :                 }
                               6927                 :                :             | FUNCTION Iconst '(' type_list ')'
                               6928                 :                :                 {
                               6929                 :             22 :                     CreateOpClassItem *n = makeNode(CreateOpClassItem);
                               6930                 :                : 
                               6931                 :             22 :                     n->itemtype = OPCLASS_ITEM_FUNCTION;
                               6932                 :             22 :                     n->number = $2;
 3599 peter_e@gmx.net          6933                 :             22 :                     n->class_args = $4;
 7226 tgl@sss.pgh.pa.us        6934                 :             22 :                     $$ = (Node *) n;
                               6935                 :                :                 }
                               6936                 :                :         ;
                               6937                 :                : 
                               6938                 :                : 
                               6939                 :                : DropOpClassStmt:
                               6940                 :                :             DROP OPERATOR CLASS any_name USING name opt_drop_behavior
                               6941                 :                :                 {
 5467 rhaas@postgresql.org     6942                 :             25 :                     DropStmt *n = makeNode(DropStmt);
                               6943                 :                : 
 4252 alvherre@alvh.no-ip.     6944                 :             25 :                     n->objects = list_make1(lcons(makeString($6), $4));
 5467 rhaas@postgresql.org     6945                 :             25 :                     n->removeType = OBJECT_OPCLASS;
 8865 tgl@sss.pgh.pa.us        6946                 :             25 :                     n->behavior = $7;
 7447 andrew@dunslane.net      6947                 :             25 :                     n->missing_ok = false;
 5326 simon@2ndQuadrant.co     6948                 :             25 :                     n->concurrent = false;
 7447 andrew@dunslane.net      6949                 :             25 :                     $$ = (Node *) n;
                               6950                 :                :                 }
                               6951                 :                :             | DROP OPERATOR CLASS IF_P EXISTS any_name USING name opt_drop_behavior
                               6952                 :                :                 {
 5467 rhaas@postgresql.org     6953                 :             12 :                     DropStmt *n = makeNode(DropStmt);
                               6954                 :                : 
 4252 alvherre@alvh.no-ip.     6955                 :             12 :                     n->objects = list_make1(lcons(makeString($8), $6));
 5467 rhaas@postgresql.org     6956                 :             12 :                     n->removeType = OBJECT_OPCLASS;
 7447 andrew@dunslane.net      6957                 :             12 :                     n->behavior = $9;
                               6958                 :             12 :                     n->missing_ok = true;
 5326 simon@2ndQuadrant.co     6959                 :             12 :                     n->concurrent = false;
 8865 tgl@sss.pgh.pa.us        6960                 :             12 :                     $$ = (Node *) n;
                               6961                 :                :                 }
                               6962                 :                :         ;
                               6963                 :                : 
                               6964                 :                : DropOpFamilyStmt:
                               6965                 :                :             DROP OPERATOR FAMILY any_name USING name opt_drop_behavior
                               6966                 :                :                 {
 5467 rhaas@postgresql.org     6967                 :             73 :                     DropStmt *n = makeNode(DropStmt);
                               6968                 :                : 
 4252 alvherre@alvh.no-ip.     6969                 :             73 :                     n->objects = list_make1(lcons(makeString($6), $4));
 5467 rhaas@postgresql.org     6970                 :             73 :                     n->removeType = OBJECT_OPFAMILY;
 7226 tgl@sss.pgh.pa.us        6971                 :             73 :                     n->behavior = $7;
                               6972                 :             73 :                     n->missing_ok = false;
 5326 simon@2ndQuadrant.co     6973                 :             73 :                     n->concurrent = false;
 7226 tgl@sss.pgh.pa.us        6974                 :             73 :                     $$ = (Node *) n;
                               6975                 :                :                 }
                               6976                 :                :             | DROP OPERATOR FAMILY IF_P EXISTS any_name USING name opt_drop_behavior
                               6977                 :                :                 {
 5467 rhaas@postgresql.org     6978                 :             12 :                     DropStmt *n = makeNode(DropStmt);
                               6979                 :                : 
 4252 alvherre@alvh.no-ip.     6980                 :             12 :                     n->objects = list_make1(lcons(makeString($8), $6));
 5467 rhaas@postgresql.org     6981                 :             12 :                     n->removeType = OBJECT_OPFAMILY;
 7226 tgl@sss.pgh.pa.us        6982                 :             12 :                     n->behavior = $9;
                               6983                 :             12 :                     n->missing_ok = true;
 5326 simon@2ndQuadrant.co     6984                 :             12 :                     n->concurrent = false;
 7226 tgl@sss.pgh.pa.us        6985                 :             12 :                     $$ = (Node *) n;
                               6986                 :                :                 }
                               6987                 :                :         ;
                               6988                 :                : 
                               6989                 :                : 
                               6990                 :                : /*****************************************************************************
                               6991                 :                :  *
                               6992                 :                :  *      QUERY:
                               6993                 :                :  *
                               6994                 :                :  *      DROP OWNED BY username [, username ...] [ RESTRICT | CASCADE ]
                               6995                 :                :  *      REASSIGN OWNED BY username [, username ...] TO username
                               6996                 :                :  *
                               6997                 :                :  *****************************************************************************/
                               6998                 :                : DropOwnedStmt:
                               6999                 :                :             DROP OWNED BY role_list opt_drop_behavior
                               7000                 :                :                 {
 7654 alvherre@alvh.no-ip.     7001                 :            103 :                     DropOwnedStmt *n = makeNode(DropOwnedStmt);
                               7002                 :                : 
                               7003                 :            103 :                     n->roles = $4;
                               7004                 :            103 :                     n->behavior = $5;
 1637 peter@eisentraut.org     7005                 :            103 :                     $$ = (Node *) n;
                               7006                 :                :                 }
                               7007                 :                :         ;
                               7008                 :                : 
                               7009                 :                : ReassignOwnedStmt:
                               7010                 :                :             REASSIGN OWNED BY role_list TO RoleSpec
                               7011                 :                :                 {
 7654 alvherre@alvh.no-ip.     7012                 :             39 :                     ReassignOwnedStmt *n = makeNode(ReassignOwnedStmt);
                               7013                 :                : 
                               7014                 :             39 :                     n->roles = $4;
                               7015                 :             39 :                     n->newrole = $6;
 1637 peter@eisentraut.org     7016                 :             39 :                     $$ = (Node *) n;
                               7017                 :                :                 }
                               7018                 :                :         ;
                               7019                 :                : 
                               7020                 :                : /*****************************************************************************
                               7021                 :                :  *
                               7022                 :                :  *      QUERY:
                               7023                 :                :  *
                               7024                 :                :  *      DROP itemtype [ IF EXISTS ] itemname [, itemname ...]
                               7025                 :                :  *           [ RESTRICT | CASCADE ]
                               7026                 :                :  *
                               7027                 :                :  *****************************************************************************/
                               7028                 :                : 
                               7029                 :                : DropStmt:   DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
                               7030                 :                :                 {
 9514 bruce@momjian.us         7031                 :            758 :                     DropStmt *n = makeNode(DropStmt);
                               7032                 :                : 
 9510 tgl@sss.pgh.pa.us        7033                 :            758 :                     n->removeType = $2;
 3368 peter_e@gmx.net          7034                 :            758 :                     n->missing_ok = true;
 7656 andrew@dunslane.net      7035                 :            758 :                     n->objects = $5;
                               7036                 :            758 :                     n->behavior = $6;
 5326 simon@2ndQuadrant.co     7037                 :            758 :                     n->concurrent = false;
 1637 peter@eisentraut.org     7038                 :            758 :                     $$ = (Node *) n;
                               7039                 :                :                 }
                               7040                 :                :             | DROP object_type_any_name any_name_list opt_drop_behavior
                               7041                 :                :                 {
 3645 peter_e@gmx.net          7042                 :          10925 :                     DropStmt *n = makeNode(DropStmt);
                               7043                 :                : 
                               7044                 :          10925 :                     n->removeType = $2;
 3368                          7045                 :          10925 :                     n->missing_ok = false;
 3645                          7046                 :          10925 :                     n->objects = $3;
                               7047                 :          10925 :                     n->behavior = $4;
                               7048                 :          10925 :                     n->concurrent = false;
 1637 peter@eisentraut.org     7049                 :          10925 :                     $$ = (Node *) n;
                               7050                 :                :                 }
                               7051                 :                :             | DROP drop_type_name IF_P EXISTS name_list opt_drop_behavior
                               7052                 :                :                 {
 3645 peter_e@gmx.net          7053                 :            124 :                     DropStmt *n = makeNode(DropStmt);
                               7054                 :                : 
                               7055                 :            124 :                     n->removeType = $2;
 3368                          7056                 :            124 :                     n->missing_ok = true;
 3645                          7057                 :            124 :                     n->objects = $5;
                               7058                 :            124 :                     n->behavior = $6;
                               7059                 :            124 :                     n->concurrent = false;
 1637 peter@eisentraut.org     7060                 :            124 :                     $$ = (Node *) n;
                               7061                 :                :                 }
                               7062                 :                :             | DROP drop_type_name name_list opt_drop_behavior
                               7063                 :                :                 {
 7656 andrew@dunslane.net      7064                 :           1074 :                     DropStmt *n = makeNode(DropStmt);
                               7065                 :                : 
                               7066                 :           1074 :                     n->removeType = $2;
 3368 peter_e@gmx.net          7067                 :           1074 :                     n->missing_ok = false;
 8995 tgl@sss.pgh.pa.us        7068                 :           1074 :                     n->objects = $3;
 8997 bruce@momjian.us         7069                 :           1074 :                     n->behavior = $4;
 5326 simon@2ndQuadrant.co     7070                 :           1074 :                     n->concurrent = false;
 1637 peter@eisentraut.org     7071                 :           1074 :                     $$ = (Node *) n;
                               7072                 :                :                 }
                               7073                 :                :             | DROP object_type_name_on_any_name name ON any_name opt_drop_behavior
                               7074                 :                :                 {
 3544 peter_e@gmx.net          7075                 :            755 :                     DropStmt *n = makeNode(DropStmt);
                               7076                 :                : 
                               7077                 :            755 :                     n->removeType = $2;
                               7078                 :            755 :                     n->objects = list_make1(lappend($5, makeString($3)));
                               7079                 :            755 :                     n->behavior = $6;
                               7080                 :            755 :                     n->missing_ok = false;
                               7081                 :            755 :                     n->concurrent = false;
                               7082                 :            755 :                     $$ = (Node *) n;
                               7083                 :                :                 }
                               7084                 :                :             | DROP object_type_name_on_any_name IF_P EXISTS name ON any_name opt_drop_behavior
                               7085                 :                :                 {
                               7086                 :             32 :                     DropStmt *n = makeNode(DropStmt);
                               7087                 :                : 
                               7088                 :             32 :                     n->removeType = $2;
                               7089                 :             32 :                     n->objects = list_make1(lappend($7, makeString($5)));
                               7090                 :             32 :                     n->behavior = $8;
                               7091                 :             32 :                     n->missing_ok = true;
                               7092                 :             32 :                     n->concurrent = false;
                               7093                 :             32 :                     $$ = (Node *) n;
                               7094                 :                :                 }
                               7095                 :                :             | DROP TYPE_P type_name_list opt_drop_behavior
                               7096                 :                :                 {
 4328 alvherre@alvh.no-ip.     7097                 :            424 :                     DropStmt *n = makeNode(DropStmt);
                               7098                 :                : 
                               7099                 :            424 :                     n->removeType = OBJECT_TYPE;
 3368 peter_e@gmx.net          7100                 :            424 :                     n->missing_ok = false;
 4328 alvherre@alvh.no-ip.     7101                 :            424 :                     n->objects = $3;
                               7102                 :            424 :                     n->behavior = $4;
                               7103                 :            424 :                     n->concurrent = false;
                               7104                 :            424 :                     $$ = (Node *) n;
                               7105                 :                :                 }
                               7106                 :                :             | DROP TYPE_P IF_P EXISTS type_name_list opt_drop_behavior
                               7107                 :                :                 {
                               7108                 :             50 :                     DropStmt *n = makeNode(DropStmt);
                               7109                 :                : 
                               7110                 :             50 :                     n->removeType = OBJECT_TYPE;
 3368 peter_e@gmx.net          7111                 :             50 :                     n->missing_ok = true;
 4328 alvherre@alvh.no-ip.     7112                 :             50 :                     n->objects = $5;
                               7113                 :             50 :                     n->behavior = $6;
                               7114                 :             50 :                     n->concurrent = false;
                               7115                 :             50 :                     $$ = (Node *) n;
                               7116                 :                :                 }
                               7117                 :                :             | DROP DOMAIN_P type_name_list opt_drop_behavior
                               7118                 :                :                 {
                               7119                 :            358 :                     DropStmt *n = makeNode(DropStmt);
                               7120                 :                : 
                               7121                 :            358 :                     n->removeType = OBJECT_DOMAIN;
 3368 peter_e@gmx.net          7122                 :            358 :                     n->missing_ok = false;
 4328 alvherre@alvh.no-ip.     7123                 :            358 :                     n->objects = $3;
                               7124                 :            358 :                     n->behavior = $4;
                               7125                 :            358 :                     n->concurrent = false;
                               7126                 :            358 :                     $$ = (Node *) n;
                               7127                 :                :                 }
                               7128                 :                :             | DROP DOMAIN_P IF_P EXISTS type_name_list opt_drop_behavior
                               7129                 :                :                 {
                               7130                 :             46 :                     DropStmt *n = makeNode(DropStmt);
                               7131                 :                : 
                               7132                 :             46 :                     n->removeType = OBJECT_DOMAIN;
 3368 peter_e@gmx.net          7133                 :             46 :                     n->missing_ok = true;
 4328 alvherre@alvh.no-ip.     7134                 :             46 :                     n->objects = $5;
                               7135                 :             46 :                     n->behavior = $6;
                               7136                 :             46 :                     n->concurrent = false;
                               7137                 :             46 :                     $$ = (Node *) n;
                               7138                 :                :                 }
                               7139                 :                :             | DROP INDEX CONCURRENTLY any_name_list opt_drop_behavior
                               7140                 :                :                 {
 5326 simon@2ndQuadrant.co     7141                 :             96 :                     DropStmt *n = makeNode(DropStmt);
                               7142                 :                : 
                               7143                 :             96 :                     n->removeType = OBJECT_INDEX;
 3368 peter_e@gmx.net          7144                 :             96 :                     n->missing_ok = false;
 5326 simon@2ndQuadrant.co     7145                 :             96 :                     n->objects = $4;
                               7146                 :             96 :                     n->behavior = $5;
                               7147                 :             96 :                     n->concurrent = true;
 1637 peter@eisentraut.org     7148                 :             96 :                     $$ = (Node *) n;
                               7149                 :                :                 }
                               7150                 :                :             | DROP INDEX CONCURRENTLY IF_P EXISTS any_name_list opt_drop_behavior
                               7151                 :                :                 {
 5326 simon@2ndQuadrant.co     7152                 :              8 :                     DropStmt *n = makeNode(DropStmt);
                               7153                 :                : 
                               7154                 :              8 :                     n->removeType = OBJECT_INDEX;
 3368 peter_e@gmx.net          7155                 :              8 :                     n->missing_ok = true;
 5326 simon@2ndQuadrant.co     7156                 :              8 :                     n->objects = $6;
                               7157                 :              8 :                     n->behavior = $7;
                               7158                 :              8 :                     n->concurrent = true;
 1637 peter@eisentraut.org     7159                 :              8 :                     $$ = (Node *) n;
                               7160                 :                :                 }
                               7161                 :                :         ;
                               7162                 :                : 
                               7163                 :                : /* object types taking any_name/any_name_list */
                               7164                 :                : object_type_any_name:
 3645 peter_e@gmx.net          7165                 :          10009 :             TABLE                                   { $$ = OBJECT_TABLE; }
 8532                          7166                 :            137 :             | SEQUENCE                              { $$ = OBJECT_SEQUENCE; }
                               7167                 :            722 :             | VIEW                                  { $$ = OBJECT_VIEW; }
 4995 kgrittn@postgresql.o     7168                 :             86 :             | MATERIALIZED VIEW                     { $$ = OBJECT_MATVIEW; }
 8532 peter_e@gmx.net          7169                 :            518 :             | INDEX                                 { $$ = OBJECT_INDEX; }
 5787 rhaas@postgresql.org     7170                 :            128 :             | FOREIGN TABLE                         { $$ = OBJECT_FOREIGN_TABLE; }
 5745 peter_e@gmx.net          7171                 :             63 :             | COLLATION                             { $$ = OBJECT_COLLATION; }
 8532                          7172                 :             37 :             | CONVERSION_P                          { $$ = OBJECT_CONVERSION; }
 3513 alvherre@alvh.no-ip.     7173                 :            159 :             | STATISTICS                            { $$ = OBJECT_STATISTIC_EXT; }
 7016 tgl@sss.pgh.pa.us        7174                 :             13 :             | TEXT_P SEARCH PARSER                  { $$ = OBJECT_TSPARSER; }
                               7175                 :           1786 :             | TEXT_P SEARCH DICTIONARY              { $$ = OBJECT_TSDICTIONARY; }
                               7176                 :             70 :             | TEXT_P SEARCH TEMPLATE                { $$ = OBJECT_TSTEMPLATE; }
                               7177                 :           1789 :             | TEXT_P SEARCH CONFIGURATION           { $$ = OBJECT_TSCONFIGURATION; }
                               7178                 :                :         ;
                               7179                 :                : 
                               7180                 :                : /*
                               7181                 :                :  * object types taking name/name_list
                               7182                 :                :  *
                               7183                 :                :  * DROP handles some of them separately
                               7184                 :                :  */
                               7185                 :                : 
                               7186                 :                : object_type_name:
 2336 peter@eisentraut.org     7187                 :            143 :             drop_type_name                          { $$ = $1; }
                               7188                 :            143 :             | DATABASE                              { $$ = OBJECT_DATABASE; }
                               7189                 :             44 :             | ROLE                                  { $$ = OBJECT_ROLE; }
                               7190                 :              6 :             | SUBSCRIPTION                          { $$ = OBJECT_SUBSCRIPTION; }
 2336 peter@eisentraut.org     7191                 :UBC           0 :             | TABLESPACE                            { $$ = OBJECT_TABLESPACE; }
                               7192                 :                :         ;
                               7193                 :                : 
                               7194                 :                : drop_type_name:
 3645 peter_e@gmx.net          7195                 :CBC          29 :             ACCESS METHOD                           { $$ = OBJECT_ACCESS_METHOD; }
                               7196                 :             85 :             | EVENT TRIGGER                         { $$ = OBJECT_EVENT_TRIGGER; }
                               7197                 :            136 :             | EXTENSION                             { $$ = OBJECT_EXTENSION; }
 3544                          7198                 :            128 :             | FOREIGN DATA_P WRAPPER                { $$ = OBJECT_FDW; }
 2338 peter@eisentraut.org     7199                 :             90 :             | opt_procedural LANGUAGE               { $$ = OBJECT_LANGUAGE; }
 3577 peter_e@gmx.net          7200                 :            321 :             | PUBLICATION                           { $$ = OBJECT_PUBLICATION; }
 3645                          7201                 :            435 :             | SCHEMA                                { $$ = OBJECT_SCHEMA; }
 3544                          7202                 :            117 :             | SERVER                                { $$ = OBJECT_FOREIGN_SERVER; }
                               7203                 :                :         ;
                               7204                 :                : 
                               7205                 :                : /* object types attached to a table */
                               7206                 :                : object_type_name_on_any_name:
                               7207                 :            122 :             POLICY                                  { $$ = OBJECT_POLICY; }
                               7208                 :            197 :             | RULE                                  { $$ = OBJECT_RULE; }
                               7209                 :            503 :             | TRIGGER                               { $$ = OBJECT_TRIGGER; }
                               7210                 :                :         ;
                               7211                 :                : 
                               7212                 :                : any_name_list:
 8194 neilc@samurai.com        7213                 :          17291 :             any_name                                { $$ = list_make1($1); }
 8907 bruce@momjian.us         7214                 :           2661 :             | any_name_list ',' any_name            { $$ = lappend($1, $3); }
                               7215                 :                :         ;
                               7216                 :                : 
 8194 neilc@samurai.com        7217                 :          43660 : any_name:   ColId                       { $$ = list_make1(makeString($1)); }
 8184 tgl@sss.pgh.pa.us        7218                 :           6065 :             | ColId attrs               { $$ = lcons(makeString($1), $2); }
                               7219                 :                :         ;
                               7220                 :                : 
                               7221                 :                : attrs:      '.' attr_name
                               7222                 :          75516 :                     { $$ = list_make1(makeString($2)); }
                               7223                 :                :             | attrs '.' attr_name
 8032                          7224                 :             36 :                     { $$ = lappend($1, makeString($3)); }
                               7225                 :                :         ;
                               7226                 :                : 
                               7227                 :                : type_name_list:
 3645 peter_e@gmx.net          7228                 :            878 :             Typename                                { $$ = list_make1($1); }
                               7229                 :             84 :             | type_name_list ',' Typename           { $$ = lappend($1, $3); }
                               7230                 :                :         ;
                               7231                 :                : 
                               7232                 :                : /*****************************************************************************
                               7233                 :                :  *
                               7234                 :                :  *      QUERY:
                               7235                 :                :  *              truncate table relname1, relname2, ...
                               7236                 :                :  *
                               7237                 :                :  *****************************************************************************/
                               7238                 :                : 
                               7239                 :                : TruncateStmt:
                               7240                 :                :             TRUNCATE opt_table relation_expr_list opt_restart_seqs opt_drop_behavior
                               7241                 :                :                 {
 9905 bruce@momjian.us         7242                 :           1171 :                     TruncateStmt *n = makeNode(TruncateStmt);
                               7243                 :                : 
 7952 tgl@sss.pgh.pa.us        7244                 :           1170 :                     n->relations = $3;
 6747                          7245                 :           1170 :                     n->restart_seqs = $4;
                               7246                 :           1170 :                     n->behavior = $5;
 1637 peter@eisentraut.org     7247                 :           1170 :                     $$ = (Node *) n;
                               7248                 :                :                 }
                               7249                 :                :         ;
                               7250                 :                : 
                               7251                 :                : opt_restart_seqs:
 6747 tgl@sss.pgh.pa.us        7252                 :             12 :             CONTINUE_P IDENTITY_P       { $$ = false; }
                               7253                 :             15 :             | RESTART IDENTITY_P        { $$ = true; }
                               7254                 :           1144 :             | /* EMPTY */               { $$ = false; }
                               7255                 :                :         ;
                               7256                 :                : 
                               7257                 :                : /*****************************************************************************
                               7258                 :                :  *
                               7259                 :                :  * COMMENT ON <object> IS <text>
                               7260                 :                :  *
                               7261                 :                :  *****************************************************************************/
                               7262                 :                : 
                               7263                 :                : CommentStmt:
                               7264                 :                :             COMMENT ON object_type_any_name any_name IS comment_text
                               7265                 :                :                 {
 8907 bruce@momjian.us         7266                 :           3750 :                     CommentStmt *n = makeNode(CommentStmt);
                               7267                 :                : 
                               7268                 :           3750 :                     n->objtype = $3;
 3645 peter_e@gmx.net          7269                 :           3750 :                     n->object = (Node *) $4;
                               7270                 :           3750 :                     n->comment = $6;
                               7271                 :           3750 :                     $$ = (Node *) n;
                               7272                 :                :                 }
                               7273                 :                :             | COMMENT ON COLUMN any_name IS comment_text
                               7274                 :                :                 {
 2336 peter@eisentraut.org     7275                 :             74 :                     CommentStmt *n = makeNode(CommentStmt);
                               7276                 :                : 
                               7277                 :             74 :                     n->objtype = OBJECT_COLUMN;
                               7278                 :             74 :                     n->object = (Node *) $4;
                               7279                 :             74 :                     n->comment = $6;
                               7280                 :             74 :                     $$ = (Node *) n;
                               7281                 :                :                 }
                               7282                 :                :             | COMMENT ON object_type_name name IS comment_text
                               7283                 :                :                 {
 3645 peter_e@gmx.net          7284                 :            301 :                     CommentStmt *n = makeNode(CommentStmt);
                               7285                 :                : 
                               7286                 :            301 :                     n->objtype = $3;
                               7287                 :            301 :                     n->object = (Node *) makeString($4);
 8907 bruce@momjian.us         7288                 :            301 :                     n->comment = $6;
                               7289                 :            301 :                     $$ = (Node *) n;
                               7290                 :                :                 }
                               7291                 :                :             | COMMENT ON TYPE_P Typename IS comment_text
                               7292                 :                :                 {
 4328 alvherre@alvh.no-ip.     7293                 :             31 :                     CommentStmt *n = makeNode(CommentStmt);
                               7294                 :                : 
                               7295                 :             31 :                     n->objtype = OBJECT_TYPE;
 3645 peter_e@gmx.net          7296                 :             31 :                     n->object = (Node *) $4;
 4328 alvherre@alvh.no-ip.     7297                 :             31 :                     n->comment = $6;
                               7298                 :             31 :                     $$ = (Node *) n;
                               7299                 :                :                 }
                               7300                 :                :             | COMMENT ON DOMAIN_P Typename IS comment_text
                               7301                 :                :                 {
                               7302                 :              5 :                     CommentStmt *n = makeNode(CommentStmt);
                               7303                 :                : 
                               7304                 :              5 :                     n->objtype = OBJECT_DOMAIN;
 3645 peter_e@gmx.net          7305                 :              5 :                     n->object = (Node *) $4;
 4328 alvherre@alvh.no-ip.     7306                 :              5 :                     n->comment = $6;
                               7307                 :              5 :                     $$ = (Node *) n;
                               7308                 :                :                 }
                               7309                 :                :             | COMMENT ON AGGREGATE aggregate_with_argtypes IS comment_text
                               7310                 :                :                 {
 8907 bruce@momjian.us         7311                 :             26 :                     CommentStmt *n = makeNode(CommentStmt);
                               7312                 :                : 
 8532 peter_e@gmx.net          7313                 :             26 :                     n->objtype = OBJECT_AGGREGATE;
 3645                          7314                 :             26 :                     n->object = (Node *) $4;
 3703                          7315                 :             26 :                     n->comment = $6;
 8907 bruce@momjian.us         7316                 :             26 :                     $$ = (Node *) n;
                               7317                 :                :                 }
                               7318                 :                :             | COMMENT ON FUNCTION function_with_argtypes IS comment_text
                               7319                 :                :                 {
                               7320                 :             91 :                     CommentStmt *n = makeNode(CommentStmt);
                               7321                 :                : 
 8532 peter_e@gmx.net          7322                 :             91 :                     n->objtype = OBJECT_FUNCTION;
 3645                          7323                 :             91 :                     n->object = (Node *) $4;
 3703                          7324                 :             91 :                     n->comment = $6;
 8907 bruce@momjian.us         7325                 :             91 :                     $$ = (Node *) n;
                               7326                 :                :                 }
                               7327                 :                :             | COMMENT ON OPERATOR operator_with_argtypes IS comment_text
                               7328                 :                :                 {
                               7329                 :             12 :                     CommentStmt *n = makeNode(CommentStmt);
                               7330                 :                : 
 8532 peter_e@gmx.net          7331                 :             12 :                     n->objtype = OBJECT_OPERATOR;
 3645                          7332                 :             12 :                     n->object = (Node *) $4;
 3599                          7333                 :             12 :                     n->comment = $6;
 8907 bruce@momjian.us         7334                 :             12 :                     $$ = (Node *) n;
                               7335                 :                :                 }
                               7336                 :                :             | COMMENT ON CONSTRAINT name ON any_name IS comment_text
                               7337                 :                :                 {
                               7338                 :             97 :                     CommentStmt *n = makeNode(CommentStmt);
                               7339                 :                : 
 4335 alvherre@alvh.no-ip.     7340                 :             97 :                     n->objtype = OBJECT_TABCONSTRAINT;
 3645 peter_e@gmx.net          7341                 :             97 :                     n->object = (Node *) lappend($6, makeString($4));
 8907 bruce@momjian.us         7342                 :             97 :                     n->comment = $8;
                               7343                 :             97 :                     $$ = (Node *) n;
                               7344                 :                :                 }
                               7345                 :                :             | COMMENT ON CONSTRAINT name ON DOMAIN_P any_name IS comment_text
                               7346                 :                :                 {
 4335 alvherre@alvh.no-ip.     7347                 :             31 :                     CommentStmt *n = makeNode(CommentStmt);
                               7348                 :                : 
                               7349                 :             31 :                     n->objtype = OBJECT_DOMCONSTRAINT;
                               7350                 :                :                     /*
                               7351                 :                :                      * should use Typename not any_name in the production, but
                               7352                 :                :                      * there's a shift/reduce conflict if we do that, so fix it
                               7353                 :                :                      * up here.
                               7354                 :                :                      */
 3645 peter_e@gmx.net          7355                 :             31 :                     n->object = (Node *) list_make2(makeTypeNameFromNameList($7), makeString($4));
 4335 alvherre@alvh.no-ip.     7356                 :             31 :                     n->comment = $9;
                               7357                 :             31 :                     $$ = (Node *) n;
                               7358                 :                :                 }
                               7359                 :                :             | COMMENT ON object_type_name_on_any_name name ON any_name IS comment_text
                               7360                 :                :                 {
 4361 sfrost@snowman.net       7361                 :             27 :                     CommentStmt *n = makeNode(CommentStmt);
                               7362                 :                : 
 2336 peter@eisentraut.org     7363                 :             27 :                     n->objtype = $3;
 3645 peter_e@gmx.net          7364                 :             27 :                     n->object = (Node *) lappend($6, makeString($4));
 4361 sfrost@snowman.net       7365                 :             27 :                     n->comment = $8;
                               7366                 :             27 :                     $$ = (Node *) n;
                               7367                 :                :                 }
                               7368                 :                :             | COMMENT ON PROCEDURE function_with_argtypes IS comment_text
                               7369                 :                :                 {
 3262 peter_e@gmx.net          7370                 :UBC           0 :                     CommentStmt *n = makeNode(CommentStmt);
                               7371                 :                : 
                               7372                 :              0 :                     n->objtype = OBJECT_PROCEDURE;
                               7373                 :              0 :                     n->object = (Node *) $4;
                               7374                 :              0 :                     n->comment = $6;
                               7375                 :              0 :                     $$ = (Node *) n;
                               7376                 :                :                 }
                               7377                 :                :             | COMMENT ON ROUTINE function_with_argtypes IS comment_text
                               7378                 :                :                 {
                               7379                 :              0 :                     CommentStmt *n = makeNode(CommentStmt);
                               7380                 :                : 
                               7381                 :              0 :                     n->objtype = OBJECT_ROUTINE;
                               7382                 :              0 :                     n->object = (Node *) $4;
                               7383                 :              0 :                     n->comment = $6;
                               7384                 :              0 :                     $$ = (Node *) n;
                               7385                 :                :                 }
                               7386                 :                :             | COMMENT ON TRANSFORM FOR Typename LANGUAGE name IS comment_text
                               7387                 :                :                 {
 4211 peter_e@gmx.net          7388                 :CBC           7 :                     CommentStmt *n = makeNode(CommentStmt);
                               7389                 :                : 
                               7390                 :              7 :                     n->objtype = OBJECT_TRANSFORM;
 3645                          7391                 :              7 :                     n->object = (Node *) list_make2($5, makeString($7));
 4211                          7392                 :              7 :                     n->comment = $9;
                               7393                 :              7 :                     $$ = (Node *) n;
                               7394                 :                :                 }
                               7395                 :                :             | COMMENT ON OPERATOR CLASS any_name USING name IS comment_text
                               7396                 :                :                 {
 8385 tgl@sss.pgh.pa.us        7397                 :UBC           0 :                     CommentStmt *n = makeNode(CommentStmt);
                               7398                 :                : 
                               7399                 :              0 :                     n->objtype = OBJECT_OPCLASS;
 3645 peter_e@gmx.net          7400                 :              0 :                     n->object = (Node *) lcons(makeString($7), $5);
 8385 tgl@sss.pgh.pa.us        7401                 :              0 :                     n->comment = $9;
                               7402                 :              0 :                     $$ = (Node *) n;
                               7403                 :                :                 }
                               7404                 :                :             | COMMENT ON OPERATOR FAMILY any_name USING name IS comment_text
                               7405                 :                :                 {
 7226                          7406                 :              0 :                     CommentStmt *n = makeNode(CommentStmt);
                               7407                 :                : 
                               7408                 :              0 :                     n->objtype = OBJECT_OPFAMILY;
 3645 peter_e@gmx.net          7409                 :              0 :                     n->object = (Node *) lcons(makeString($7), $5);
 7226 tgl@sss.pgh.pa.us        7410                 :              0 :                     n->comment = $9;
                               7411                 :              0 :                     $$ = (Node *) n;
                               7412                 :                :                 }
                               7413                 :                :             | COMMENT ON LARGE_P OBJECT_P NumericOnly IS comment_text
                               7414                 :                :                 {
 8385 tgl@sss.pgh.pa.us        7415                 :CBC          24 :                     CommentStmt *n = makeNode(CommentStmt);
                               7416                 :                : 
                               7417                 :             24 :                     n->objtype = OBJECT_LARGEOBJECT;
 3645 peter_e@gmx.net          7418                 :             24 :                     n->object = (Node *) $5;
 8385 tgl@sss.pgh.pa.us        7419                 :             24 :                     n->comment = $7;
                               7420                 :             24 :                     $$ = (Node *) n;
                               7421                 :                :                 }
                               7422                 :                :             | COMMENT ON CAST '(' Typename AS Typename ')' IS comment_text
                               7423                 :                :                 {
 8385 tgl@sss.pgh.pa.us        7424                 :UBC           0 :                     CommentStmt *n = makeNode(CommentStmt);
                               7425                 :                : 
                               7426                 :              0 :                     n->objtype = OBJECT_CAST;
 3645 peter_e@gmx.net          7427                 :              0 :                     n->object = (Node *) list_make2($5, $7);
 8385 tgl@sss.pgh.pa.us        7428                 :              0 :                     n->comment = $10;
                               7429                 :              0 :                     $$ = (Node *) n;
                               7430                 :                :                 }
                               7431                 :                :         ;
                               7432                 :                : 
                               7433                 :                : comment_text:
 8880 tgl@sss.pgh.pa.us        7434                 :CBC        4403 :             Sconst                              { $$ = $1; }
                               7435                 :             73 :             | NULL_P                            { $$ = NULL; }
                               7436                 :                :         ;
                               7437                 :                : 
                               7438                 :                : 
                               7439                 :                : /*****************************************************************************
                               7440                 :                :  *
                               7441                 :                :  *  SECURITY LABEL [FOR <provider>] ON <object> IS <label>
                               7442                 :                :  *
                               7443                 :                :  *  As with COMMENT ON, <object> can refer to various types of database
                               7444                 :                :  *  objects (e.g. TABLE, COLUMN, etc.).
                               7445                 :                :  *
                               7446                 :                :  *****************************************************************************/
                               7447                 :                : 
                               7448                 :                : SecLabelStmt:
                               7449                 :                :             SECURITY LABEL opt_provider ON object_type_any_name any_name
                               7450                 :                :             IS security_label
                               7451                 :                :                 {
 5883 rhaas@postgresql.org     7452                 :             28 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7453                 :                : 
                               7454                 :             28 :                     n->provider = $3;
                               7455                 :             28 :                     n->objtype = $5;
 3645 peter_e@gmx.net          7456                 :             28 :                     n->object = (Node *) $6;
                               7457                 :             28 :                     n->label = $8;
                               7458                 :             28 :                     $$ = (Node *) n;
                               7459                 :                :                 }
                               7460                 :                :             | SECURITY LABEL opt_provider ON COLUMN any_name
                               7461                 :                :               IS security_label
                               7462                 :                :                 {
 2336 peter@eisentraut.org     7463                 :              2 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7464                 :                : 
                               7465                 :              2 :                     n->provider = $3;
                               7466                 :              2 :                     n->objtype = OBJECT_COLUMN;
                               7467                 :              2 :                     n->object = (Node *) $6;
                               7468                 :              2 :                     n->label = $8;
                               7469                 :              2 :                     $$ = (Node *) n;
                               7470                 :                :                 }
                               7471                 :                :             | SECURITY LABEL opt_provider ON object_type_name name
                               7472                 :                :               IS security_label
                               7473                 :                :                 {
 3645 peter_e@gmx.net          7474                 :             26 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7475                 :                : 
                               7476                 :             26 :                     n->provider = $3;
                               7477                 :             26 :                     n->objtype = $5;
                               7478                 :             26 :                     n->object = (Node *) makeString($6);
 5883 rhaas@postgresql.org     7479                 :             26 :                     n->label = $8;
                               7480                 :             26 :                     $$ = (Node *) n;
                               7481                 :                :                 }
                               7482                 :                :             | SECURITY LABEL opt_provider ON TYPE_P Typename
                               7483                 :                :               IS security_label
                               7484                 :                :                 {
 4328 alvherre@alvh.no-ip.     7485                 :UBC           0 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7486                 :                : 
                               7487                 :              0 :                     n->provider = $3;
                               7488                 :              0 :                     n->objtype = OBJECT_TYPE;
 3645 peter_e@gmx.net          7489                 :              0 :                     n->object = (Node *) $6;
 4328 alvherre@alvh.no-ip.     7490                 :              0 :                     n->label = $8;
                               7491                 :              0 :                     $$ = (Node *) n;
                               7492                 :                :                 }
                               7493                 :                :             | SECURITY LABEL opt_provider ON DOMAIN_P Typename
                               7494                 :                :               IS security_label
                               7495                 :                :                 {
 4328 alvherre@alvh.no-ip.     7496                 :CBC           1 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7497                 :                : 
                               7498                 :              1 :                     n->provider = $3;
 3382 peter_e@gmx.net          7499                 :              1 :                     n->objtype = OBJECT_DOMAIN;
 3645                          7500                 :              1 :                     n->object = (Node *) $6;
 4328 alvherre@alvh.no-ip.     7501                 :              1 :                     n->label = $8;
                               7502                 :              1 :                     $$ = (Node *) n;
                               7503                 :                :                 }
                               7504                 :                :             | SECURITY LABEL opt_provider ON AGGREGATE aggregate_with_argtypes
                               7505                 :                :               IS security_label
                               7506                 :                :                 {
 5883 rhaas@postgresql.org     7507                 :UBC           0 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7508                 :                : 
                               7509                 :              0 :                     n->provider = $3;
                               7510                 :              0 :                     n->objtype = OBJECT_AGGREGATE;
 3645 peter_e@gmx.net          7511                 :              0 :                     n->object = (Node *) $6;
 3703                          7512                 :              0 :                     n->label = $8;
 5883 rhaas@postgresql.org     7513                 :              0 :                     $$ = (Node *) n;
                               7514                 :                :                 }
                               7515                 :                :             | SECURITY LABEL opt_provider ON FUNCTION function_with_argtypes
                               7516                 :                :               IS security_label
                               7517                 :                :                 {
 5883 rhaas@postgresql.org     7518                 :CBC           1 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7519                 :                : 
                               7520                 :              1 :                     n->provider = $3;
                               7521                 :              1 :                     n->objtype = OBJECT_FUNCTION;
 3645 peter_e@gmx.net          7522                 :              1 :                     n->object = (Node *) $6;
 3703                          7523                 :              1 :                     n->label = $8;
 5883 rhaas@postgresql.org     7524                 :              1 :                     $$ = (Node *) n;
                               7525                 :                :                 }
                               7526                 :                :             | SECURITY LABEL opt_provider ON LARGE_P OBJECT_P NumericOnly
                               7527                 :                :               IS security_label
                               7528                 :                :                 {
                               7529                 :              9 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7530                 :                : 
                               7531                 :              9 :                     n->provider = $3;
                               7532                 :              9 :                     n->objtype = OBJECT_LARGEOBJECT;
 3645 peter_e@gmx.net          7533                 :              9 :                     n->object = (Node *) $7;
 5883 rhaas@postgresql.org     7534                 :              9 :                     n->label = $9;
                               7535                 :              9 :                     $$ = (Node *) n;
                               7536                 :                :                 }
                               7537                 :                :             | SECURITY LABEL opt_provider ON PROCEDURE function_with_argtypes
                               7538                 :                :               IS security_label
                               7539                 :                :                 {
 3262 peter_e@gmx.net          7540                 :UBC           0 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7541                 :                : 
                               7542                 :              0 :                     n->provider = $3;
                               7543                 :              0 :                     n->objtype = OBJECT_PROCEDURE;
                               7544                 :              0 :                     n->object = (Node *) $6;
                               7545                 :              0 :                     n->label = $8;
                               7546                 :              0 :                     $$ = (Node *) n;
                               7547                 :                :                 }
                               7548                 :                :             | SECURITY LABEL opt_provider ON ROUTINE function_with_argtypes
                               7549                 :                :               IS security_label
                               7550                 :                :                 {
                               7551                 :              0 :                     SecLabelStmt *n = makeNode(SecLabelStmt);
                               7552                 :                : 
                               7553                 :              0 :                     n->provider = $3;
                               7554                 :              0 :                     n->objtype = OBJECT_ROUTINE;
                               7555                 :              0 :                     n->object = (Node *) $6;
                               7556                 :              0 :                     n->label = $8;
                               7557                 :              0 :                     $$ = (Node *) n;
                               7558                 :                :                 }
                               7559                 :                :         ;
                               7560                 :                : 
 4904 tgl@sss.pgh.pa.us        7561                 :CBC          16 : opt_provider:   FOR NonReservedWord_or_Sconst   { $$ = $2; }
 2180 peter@eisentraut.org     7562                 :             51 :                 | /* EMPTY */                   { $$ = NULL; }
                               7563                 :                :         ;
                               7564                 :                : 
 5883 rhaas@postgresql.org     7565                 :             67 : security_label: Sconst              { $$ = $1; }
 5883 rhaas@postgresql.org     7566                 :UBC           0 :                 | NULL_P            { $$ = NULL; }
                               7567                 :                :         ;
                               7568                 :                : 
                               7569                 :                : /*****************************************************************************
                               7570                 :                :  *
                               7571                 :                :  *      QUERY:
                               7572                 :                :  *          fetch/move
                               7573                 :                :  *
                               7574                 :                :  *****************************************************************************/
                               7575                 :                : 
                               7576                 :                : FetchStmt:  FETCH fetch_args
                               7577                 :                :                 {
 8640 tgl@sss.pgh.pa.us        7578                 :CBC        4326 :                     FetchStmt *n = (FetchStmt *) $2;
                               7579                 :                : 
 3368 peter_e@gmx.net          7580                 :           4326 :                     n->ismove = false;
 1637 peter@eisentraut.org     7581                 :           4326 :                     $$ = (Node *) n;
                               7582                 :                :                 }
                               7583                 :                :             | MOVE fetch_args
                               7584                 :                :                 {
 8640 tgl@sss.pgh.pa.us        7585                 :             54 :                     FetchStmt *n = (FetchStmt *) $2;
                               7586                 :                : 
 3368 peter_e@gmx.net          7587                 :             54 :                     n->ismove = true;
 1637 peter@eisentraut.org     7588                 :             54 :                     $$ = (Node *) n;
                               7589                 :                :                 }
                               7590                 :                :         ;
                               7591                 :                : 
                               7592                 :                : fetch_args: cursor_name
                               7593                 :                :                 {
 9788 bruce@momjian.us         7594                 :             91 :                     FetchStmt *n = makeNode(FetchStmt);
                               7595                 :                : 
 6203 alvherre@alvh.no-ip.     7596                 :             91 :                     n->portalname = $1;
 8669 tgl@sss.pgh.pa.us        7597                 :             91 :                     n->direction = FETCH_FORWARD;
 9788 bruce@momjian.us         7598                 :             91 :                     n->howMany = 1;
  491 michael@paquier.xyz      7599                 :             91 :                     n->location = -1;
                               7600                 :             91 :                     n->direction_keyword = FETCH_KEYWORD_NONE;
 1637 peter@eisentraut.org     7601                 :             91 :                     $$ = (Node *) n;
                               7602                 :                :                 }
                               7603                 :                :             | from_in cursor_name
                               7604                 :                :                 {
 9788 bruce@momjian.us         7605                 :             97 :                     FetchStmt *n = makeNode(FetchStmt);
                               7606                 :                : 
 6203 alvherre@alvh.no-ip.     7607                 :             97 :                     n->portalname = $2;
 8669 tgl@sss.pgh.pa.us        7608                 :             97 :                     n->direction = FETCH_FORWARD;
 9788 bruce@momjian.us         7609                 :             97 :                     n->howMany = 1;
  491 michael@paquier.xyz      7610                 :             97 :                     n->location = -1;
                               7611                 :             97 :                     n->direction_keyword = FETCH_KEYWORD_NONE;
                               7612                 :             97 :                     $$ = (Node *) n;
                               7613                 :                :                 }
                               7614                 :                :             | SignedIconst opt_from_in cursor_name
                               7615                 :                :                 {
                               7616                 :           2260 :                     FetchStmt *n = makeNode(FetchStmt);
                               7617                 :                : 
                               7618                 :           2260 :                     n->portalname = $3;
                               7619                 :           2260 :                     n->direction = FETCH_FORWARD;
                               7620                 :           2260 :                     n->howMany = $1;
                               7621                 :           2260 :                     n->location = @1;
                               7622                 :           2260 :                     n->direction_keyword = FETCH_KEYWORD_NONE;
 1637 peter@eisentraut.org     7623                 :           2260 :                     $$ = (Node *) n;
                               7624                 :                :                 }
                               7625                 :                :             | NEXT opt_from_in cursor_name
                               7626                 :                :                 {
10629 vadim4o@yahoo.com        7627                 :           1309 :                     FetchStmt *n = makeNode(FetchStmt);
                               7628                 :                : 
 6203 alvherre@alvh.no-ip.     7629                 :           1309 :                     n->portalname = $3;
 8640 tgl@sss.pgh.pa.us        7630                 :           1309 :                     n->direction = FETCH_FORWARD;
                               7631                 :           1309 :                     n->howMany = 1;
  491 michael@paquier.xyz      7632                 :           1309 :                     n->location = -1;
                               7633                 :           1309 :                     n->direction_keyword = FETCH_KEYWORD_NEXT;
 1637 peter@eisentraut.org     7634                 :           1309 :                     $$ = (Node *) n;
                               7635                 :                :                 }
                               7636                 :                :             | PRIOR opt_from_in cursor_name
                               7637                 :                :                 {
 9788 bruce@momjian.us         7638                 :             21 :                     FetchStmt *n = makeNode(FetchStmt);
                               7639                 :                : 
 6203 alvherre@alvh.no-ip.     7640                 :             21 :                     n->portalname = $3;
 8640 tgl@sss.pgh.pa.us        7641                 :             21 :                     n->direction = FETCH_BACKWARD;
                               7642                 :             21 :                     n->howMany = 1;
  491 michael@paquier.xyz      7643                 :             21 :                     n->location = -1;
                               7644                 :             21 :                     n->direction_keyword = FETCH_KEYWORD_PRIOR;
 1637 peter@eisentraut.org     7645                 :             21 :                     $$ = (Node *) n;
                               7646                 :                :                 }
                               7647                 :                :             | FIRST_P opt_from_in cursor_name
                               7648                 :                :                 {
 9788 bruce@momjian.us         7649                 :             17 :                     FetchStmt *n = makeNode(FetchStmt);
                               7650                 :                : 
 6203 alvherre@alvh.no-ip.     7651                 :             17 :                     n->portalname = $3;
 8640 tgl@sss.pgh.pa.us        7652                 :             17 :                     n->direction = FETCH_ABSOLUTE;
 9788 bruce@momjian.us         7653                 :             17 :                     n->howMany = 1;
  491 michael@paquier.xyz      7654                 :             17 :                     n->location = -1;
                               7655                 :             17 :                     n->direction_keyword = FETCH_KEYWORD_FIRST;
 1637 peter@eisentraut.org     7656                 :             17 :                     $$ = (Node *) n;
                               7657                 :                :                 }
                               7658                 :                :             | LAST_P opt_from_in cursor_name
                               7659                 :                :                 {
 8640 tgl@sss.pgh.pa.us        7660                 :             13 :                     FetchStmt *n = makeNode(FetchStmt);
                               7661                 :                : 
 6203 alvherre@alvh.no-ip.     7662                 :             13 :                     n->portalname = $3;
 8640 tgl@sss.pgh.pa.us        7663                 :             13 :                     n->direction = FETCH_ABSOLUTE;
                               7664                 :             13 :                     n->howMany = -1;
  491 michael@paquier.xyz      7665                 :             13 :                     n->location = -1;
                               7666                 :             13 :                     n->direction_keyword = FETCH_KEYWORD_LAST;
 1637 peter@eisentraut.org     7667                 :             13 :                     $$ = (Node *) n;
                               7668                 :                :                 }
                               7669                 :                :             | ABSOLUTE_P SignedIconst opt_from_in cursor_name
                               7670                 :                :                 {
 8640 tgl@sss.pgh.pa.us        7671                 :             55 :                     FetchStmt *n = makeNode(FetchStmt);
                               7672                 :                : 
 6203 alvherre@alvh.no-ip.     7673                 :             55 :                     n->portalname = $4;
 8640 tgl@sss.pgh.pa.us        7674                 :             55 :                     n->direction = FETCH_ABSOLUTE;
                               7675                 :             55 :                     n->howMany = $2;
  491 michael@paquier.xyz      7676                 :             55 :                     n->location = @2;
                               7677                 :             55 :                     n->direction_keyword = FETCH_KEYWORD_ABSOLUTE;
 1637 peter@eisentraut.org     7678                 :             55 :                     $$ = (Node *) n;
                               7679                 :                :                 }
                               7680                 :                :             | RELATIVE_P SignedIconst opt_from_in cursor_name
                               7681                 :                :                 {
 8640 tgl@sss.pgh.pa.us        7682                 :             23 :                     FetchStmt *n = makeNode(FetchStmt);
                               7683                 :                : 
 6203 alvherre@alvh.no-ip.     7684                 :             23 :                     n->portalname = $4;
 8640 tgl@sss.pgh.pa.us        7685                 :             23 :                     n->direction = FETCH_RELATIVE;
                               7686                 :             23 :                     n->howMany = $2;
  491 michael@paquier.xyz      7687                 :             23 :                     n->location = @2;
                               7688                 :             23 :                     n->direction_keyword = FETCH_KEYWORD_RELATIVE;
 1637 peter@eisentraut.org     7689                 :             23 :                     $$ = (Node *) n;
                               7690                 :                :                 }
                               7691                 :                :             | ALL opt_from_in cursor_name
                               7692                 :                :                 {
 8640 tgl@sss.pgh.pa.us        7693                 :            175 :                     FetchStmt *n = makeNode(FetchStmt);
                               7694                 :                : 
 6203 alvherre@alvh.no-ip.     7695                 :            175 :                     n->portalname = $3;
 8640 tgl@sss.pgh.pa.us        7696                 :            175 :                     n->direction = FETCH_FORWARD;
                               7697                 :            175 :                     n->howMany = FETCH_ALL;
  491 michael@paquier.xyz      7698                 :            175 :                     n->location = -1;
                               7699                 :            175 :                     n->direction_keyword = FETCH_KEYWORD_ALL;
 1637 peter@eisentraut.org     7700                 :            175 :                     $$ = (Node *) n;
                               7701                 :                :                 }
                               7702                 :                :             | FORWARD opt_from_in cursor_name
                               7703                 :                :                 {
 9788 bruce@momjian.us         7704                 :             10 :                     FetchStmt *n = makeNode(FetchStmt);
                               7705                 :                : 
 6203 alvherre@alvh.no-ip.     7706                 :             10 :                     n->portalname = $3;
 8669 tgl@sss.pgh.pa.us        7707                 :             10 :                     n->direction = FETCH_FORWARD;
 9788 bruce@momjian.us         7708                 :             10 :                     n->howMany = 1;
  491 michael@paquier.xyz      7709                 :             10 :                     n->location = -1;
                               7710                 :             10 :                     n->direction_keyword = FETCH_KEYWORD_FORWARD;
 1637 peter@eisentraut.org     7711                 :             10 :                     $$ = (Node *) n;
                               7712                 :                :                 }
                               7713                 :                :             | FORWARD SignedIconst opt_from_in cursor_name
                               7714                 :                :                 {
 9788 bruce@momjian.us         7715                 :             15 :                     FetchStmt *n = makeNode(FetchStmt);
                               7716                 :                : 
 6203 alvherre@alvh.no-ip.     7717                 :             15 :                     n->portalname = $4;
 8669 tgl@sss.pgh.pa.us        7718                 :             15 :                     n->direction = FETCH_FORWARD;
 8640                          7719                 :             15 :                     n->howMany = $2;
  491 michael@paquier.xyz      7720                 :             15 :                     n->location = @2;
                               7721                 :             15 :                     n->direction_keyword = FETCH_KEYWORD_FORWARD;
 1637 peter@eisentraut.org     7722                 :             15 :                     $$ = (Node *) n;
                               7723                 :                :                 }
                               7724                 :                :             | FORWARD ALL opt_from_in cursor_name
                               7725                 :                :                 {
 8640 tgl@sss.pgh.pa.us        7726                 :             15 :                     FetchStmt *n = makeNode(FetchStmt);
                               7727                 :                : 
 6203 alvherre@alvh.no-ip.     7728                 :             15 :                     n->portalname = $4;
 8640 tgl@sss.pgh.pa.us        7729                 :             15 :                     n->direction = FETCH_FORWARD;
                               7730                 :             15 :                     n->howMany = FETCH_ALL;
  491 michael@paquier.xyz      7731                 :             15 :                     n->location = -1;
                               7732                 :             15 :                     n->direction_keyword = FETCH_KEYWORD_FORWARD_ALL;
 1637 peter@eisentraut.org     7733                 :             15 :                     $$ = (Node *) n;
                               7734                 :                :                 }
                               7735                 :                :             | BACKWARD opt_from_in cursor_name
                               7736                 :                :                 {
 8640 tgl@sss.pgh.pa.us        7737                 :             53 :                     FetchStmt *n = makeNode(FetchStmt);
                               7738                 :                : 
 6203 alvherre@alvh.no-ip.     7739                 :             53 :                     n->portalname = $3;
 8640 tgl@sss.pgh.pa.us        7740                 :             53 :                     n->direction = FETCH_BACKWARD;
 9788 bruce@momjian.us         7741                 :             53 :                     n->howMany = 1;
  491 michael@paquier.xyz      7742                 :             53 :                     n->location = -1;
                               7743                 :             53 :                     n->direction_keyword = FETCH_KEYWORD_BACKWARD;
 1637 peter@eisentraut.org     7744                 :             53 :                     $$ = (Node *) n;
                               7745                 :                :                 }
                               7746                 :                :             | BACKWARD SignedIconst opt_from_in cursor_name
                               7747                 :                :                 {
 8640 tgl@sss.pgh.pa.us        7748                 :            160 :                     FetchStmt *n = makeNode(FetchStmt);
                               7749                 :                : 
 6203 alvherre@alvh.no-ip.     7750                 :            160 :                     n->portalname = $4;
 8640 tgl@sss.pgh.pa.us        7751                 :            160 :                     n->direction = FETCH_BACKWARD;
                               7752                 :            160 :                     n->howMany = $2;
  491 michael@paquier.xyz      7753                 :            160 :                     n->location = @2;
                               7754                 :            160 :                     n->direction_keyword = FETCH_KEYWORD_BACKWARD;
 1637 peter@eisentraut.org     7755                 :            160 :                     $$ = (Node *) n;
                               7756                 :                :                 }
                               7757                 :                :             | BACKWARD ALL opt_from_in cursor_name
                               7758                 :                :                 {
 8640 tgl@sss.pgh.pa.us        7759                 :             66 :                     FetchStmt *n = makeNode(FetchStmt);
                               7760                 :                : 
 6203 alvherre@alvh.no-ip.     7761                 :             66 :                     n->portalname = $4;
 8640 tgl@sss.pgh.pa.us        7762                 :             66 :                     n->direction = FETCH_BACKWARD;
                               7763                 :             66 :                     n->howMany = FETCH_ALL;
  491 michael@paquier.xyz      7764                 :             66 :                     n->location = -1;
                               7765                 :             66 :                     n->direction_keyword = FETCH_KEYWORD_BACKWARD_ALL;
 1637 peter@eisentraut.org     7766                 :             66 :                     $$ = (Node *) n;
                               7767                 :                :                 }
                               7768                 :                :         ;
                               7769                 :                : 
                               7770                 :                : from_in:    FROM
                               7771                 :                :             | IN_P
                               7772                 :                :         ;
                               7773                 :                : 
                               7774                 :                : opt_from_in:    from_in
                               7775                 :                :             | /* EMPTY */
                               7776                 :                :         ;
                               7777                 :                : 
                               7778                 :                : 
                               7779                 :                : /*****************************************************************************
                               7780                 :                :  *
                               7781                 :                :  * GRANT and REVOKE statements
                               7782                 :                :  *
                               7783                 :                :  *****************************************************************************/
                               7784                 :                : 
                               7785                 :                : GrantStmt:  GRANT privileges ON privilege_target TO grantee_list
                               7786                 :                :             opt_grant_grant_option opt_granted_by
                               7787                 :                :                 {
 9280 peter_e@gmx.net          7788                 :           6309 :                     GrantStmt *n = makeNode(GrantStmt);
                               7789                 :                : 
                               7790                 :           6309 :                     n->is_grant = true;
                               7791                 :           6309 :                     n->privileges = $2;
 6233 tgl@sss.pgh.pa.us        7792                 :           6309 :                     n->targtype = ($4)->targtype;
 9026 peter_e@gmx.net          7793                 :           6309 :                     n->objtype = ($4)->objtype;
                               7794                 :           6309 :                     n->objects = ($4)->objs;
                               7795                 :           6309 :                     n->grantees = $6;
 8687                          7796                 :           6309 :                     n->grant_option = $7;
 2105 peter@eisentraut.org     7797                 :           6309 :                     n->grantor = $8;
 1637                          7798                 :           6309 :                     $$ = (Node *) n;
                               7799                 :                :                 }
                               7800                 :                :         ;
                               7801                 :                : 
                               7802                 :                : RevokeStmt:
                               7803                 :                :             REVOKE privileges ON privilege_target
                               7804                 :                :             FROM grantee_list opt_granted_by opt_drop_behavior
                               7805                 :                :                 {
 9026 peter_e@gmx.net          7806                 :           2441 :                     GrantStmt *n = makeNode(GrantStmt);
                               7807                 :                : 
                               7808                 :           2441 :                     n->is_grant = false;
 7800 tgl@sss.pgh.pa.us        7809                 :           2441 :                     n->grant_option = false;
                               7810                 :           2441 :                     n->privileges = $2;
 6233                          7811                 :           2441 :                     n->targtype = ($4)->targtype;
 7800                          7812                 :           2441 :                     n->objtype = ($4)->objtype;
                               7813                 :           2441 :                     n->objects = ($4)->objs;
                               7814                 :           2441 :                     n->grantees = $6;
 2105 peter@eisentraut.org     7815                 :           2441 :                     n->grantor = $7;
                               7816                 :           2441 :                     n->behavior = $8;
 1637                          7817                 :           2441 :                     $$ = (Node *) n;
                               7818                 :                :                 }
                               7819                 :                :             | REVOKE GRANT OPTION FOR privileges ON privilege_target
                               7820                 :                :             FROM grantee_list opt_granted_by opt_drop_behavior
                               7821                 :                :                 {
 7800 tgl@sss.pgh.pa.us        7822                 :              9 :                     GrantStmt *n = makeNode(GrantStmt);
                               7823                 :                : 
                               7824                 :              9 :                     n->is_grant = false;
                               7825                 :              9 :                     n->grant_option = true;
                               7826                 :              9 :                     n->privileges = $5;
 6233                          7827                 :              9 :                     n->targtype = ($7)->targtype;
 7800                          7828                 :              9 :                     n->objtype = ($7)->objtype;
                               7829                 :              9 :                     n->objects = ($7)->objs;
                               7830                 :              9 :                     n->grantees = $9;
 2105 peter@eisentraut.org     7831                 :              9 :                     n->grantor = $10;
                               7832                 :              9 :                     n->behavior = $11;
 1637                          7833                 :              9 :                     $$ = (Node *) n;
                               7834                 :                :                 }
                               7835                 :                :         ;
                               7836                 :                : 
                               7837                 :                : 
                               7838                 :                : /*
                               7839                 :                :  * Privilege names are represented as strings; the validity of the privilege
                               7840                 :                :  * names gets checked at execution.  This is a bit annoying but we have little
                               7841                 :                :  * choice because of the syntactic conflict with lists of role names in
                               7842                 :                :  * GRANT/REVOKE.  What's more, we have to call out in the "privilege"
                               7843                 :                :  * production any reserved keywords that need to be usable as privilege names.
                               7844                 :                :  */
                               7845                 :                : 
                               7846                 :                : /* either ALL [PRIVILEGES] or a list of individual privileges */
                               7847                 :                : privileges: privilege_list
 7800 tgl@sss.pgh.pa.us        7848                 :           7157 :                 { $$ = $1; }
                               7849                 :                :             | ALL
                               7850                 :           1663 :                 { $$ = NIL; }
                               7851                 :                :             | ALL PRIVILEGES
                               7852                 :             68 :                 { $$ = NIL; }
                               7853                 :                :             | ALL '(' columnList ')'
                               7854                 :                :                 {
 6496                          7855                 :             12 :                     AccessPriv *n = makeNode(AccessPriv);
                               7856                 :                : 
                               7857                 :             12 :                     n->priv_name = NULL;
                               7858                 :             12 :                     n->cols = $3;
                               7859                 :             12 :                     $$ = list_make1(n);
                               7860                 :                :                 }
                               7861                 :                :             | ALL PRIVILEGES '(' columnList ')'
                               7862                 :                :                 {
 6496 tgl@sss.pgh.pa.us        7863                 :UBC           0 :                     AccessPriv *n = makeNode(AccessPriv);
                               7864                 :                : 
                               7865                 :              0 :                     n->priv_name = NULL;
                               7866                 :              0 :                     n->cols = $4;
                               7867                 :              0 :                     $$ = list_make1(n);
                               7868                 :                :                 }
                               7869                 :                :         ;
                               7870                 :                : 
 6496 tgl@sss.pgh.pa.us        7871                 :CBC        7593 : privilege_list: privilege                           { $$ = list_make1($1); }
                               7872                 :            396 :             | privilege_list ',' privilege          { $$ = lappend($1, $3); }
                               7873                 :                :         ;
                               7874                 :                : 
                               7875                 :                : privilege:  SELECT opt_column_list
                               7876                 :                :             {
                               7877                 :           5671 :                 AccessPriv *n = makeNode(AccessPriv);
                               7878                 :                : 
                               7879                 :           5671 :                 n->priv_name = pstrdup($1);
                               7880                 :           5671 :                 n->cols = $2;
                               7881                 :           5671 :                 $$ = n;
                               7882                 :                :             }
                               7883                 :                :         | REFERENCES opt_column_list
                               7884                 :                :             {
                               7885                 :             25 :                 AccessPriv *n = makeNode(AccessPriv);
                               7886                 :                : 
                               7887                 :             25 :                 n->priv_name = pstrdup($1);
                               7888                 :             25 :                 n->cols = $2;
                               7889                 :             25 :                 $$ = n;
                               7890                 :                :             }
                               7891                 :                :         | CREATE opt_column_list
                               7892                 :                :             {
                               7893                 :            215 :                 AccessPriv *n = makeNode(AccessPriv);
                               7894                 :                : 
                               7895                 :            215 :                 n->priv_name = pstrdup($1);
                               7896                 :            215 :                 n->cols = $2;
                               7897                 :            215 :                 $$ = n;
                               7898                 :                :             }
                               7899                 :                :         | ALTER SYSTEM_P
                               7900                 :                :             {
 1674                          7901                 :             12 :                 AccessPriv *n = makeNode(AccessPriv);
                               7902                 :             12 :                 n->priv_name = pstrdup("alter system");
                               7903                 :             12 :                 n->cols = NIL;
                               7904                 :             12 :                 $$ = n;
                               7905                 :                :             }
                               7906                 :                :         | ColId opt_column_list
                               7907                 :                :             {
 6496                          7908                 :           2066 :                 AccessPriv *n = makeNode(AccessPriv);
                               7909                 :                : 
                               7910                 :           2066 :                 n->priv_name = $1;
                               7911                 :           2066 :                 n->cols = $2;
                               7912                 :           2066 :                 $$ = n;
                               7913                 :                :             }
                               7914                 :                :         ;
                               7915                 :                : 
                               7916                 :                : parameter_name_list:
                               7917                 :                :         parameter_name
                               7918                 :                :             {
 1674                          7919                 :             38 :                 $$ = list_make1(makeString($1));
                               7920                 :                :             }
                               7921                 :                :         | parameter_name_list ',' parameter_name
                               7922                 :                :             {
                               7923                 :             25 :                 $$ = lappend($1, makeString($3));
                               7924                 :                :             }
                               7925                 :                :         ;
                               7926                 :                : 
                               7927                 :                : parameter_name:
                               7928                 :                :         ColId
                               7929                 :                :             {
                               7930                 :             63 :                 $$ = $1;
                               7931                 :                :             }
                               7932                 :                :         | parameter_name '.' ColId
                               7933                 :                :             {
                               7934                 :             16 :                 $$ = psprintf("%s.%s", $1, $3);
                               7935                 :                :             }
                               7936                 :                :         ;
                               7937                 :                : 
                               7938                 :                : 
                               7939                 :                : /* Don't bother trying to fold the first two rules into one using
                               7940                 :                :  * opt_table.  You're going to get conflicts.
                               7941                 :                :  */
                               7942                 :                : privilege_target:
                               7943                 :                :             qualified_name_list
                               7944                 :                :                 {
  330 michael@paquier.xyz      7945                 :           6981 :                     PrivTarget *n = palloc_object(PrivTarget);
                               7946                 :                : 
 6233 tgl@sss.pgh.pa.us        7947                 :           6981 :                     n->targtype = ACL_TARGET_OBJECT;
 3312 peter_e@gmx.net          7948                 :           6981 :                     n->objtype = OBJECT_TABLE;
 9026                          7949                 :           6981 :                     n->objs = $1;
                               7950                 :           6981 :                     $$ = n;
                               7951                 :                :                 }
                               7952                 :                :             | TABLE qualified_name_list
                               7953                 :                :                 {
  330 michael@paquier.xyz      7954                 :            232 :                     PrivTarget *n = palloc_object(PrivTarget);
                               7955                 :                : 
 6233 tgl@sss.pgh.pa.us        7956                 :            232 :                     n->targtype = ACL_TARGET_OBJECT;
 3312 peter_e@gmx.net          7957                 :            232 :                     n->objtype = OBJECT_TABLE;
 9026                          7958                 :            232 :                     n->objs = $2;
                               7959                 :            232 :                     $$ = n;
                               7960                 :                :                 }
                               7961                 :                :             | SEQUENCE qualified_name_list
                               7962                 :                :                 {
  330 michael@paquier.xyz      7963                 :             12 :                     PrivTarget *n = palloc_object(PrivTarget);
                               7964                 :                : 
 6233 tgl@sss.pgh.pa.us        7965                 :             12 :                     n->targtype = ACL_TARGET_OBJECT;
 3312 peter_e@gmx.net          7966                 :             12 :                     n->objtype = OBJECT_SEQUENCE;
 7593 bruce@momjian.us         7967                 :             12 :                     n->objs = $2;
                               7968                 :             12 :                     $$ = n;
                               7969                 :                :                 }
                               7970                 :                :             | FOREIGN DATA_P WRAPPER name_list
                               7971                 :                :                 {
  330 michael@paquier.xyz      7972                 :             60 :                     PrivTarget *n = palloc_object(PrivTarget);
                               7973                 :                : 
 6233 tgl@sss.pgh.pa.us        7974                 :             60 :                     n->targtype = ACL_TARGET_OBJECT;
 3312 peter_e@gmx.net          7975                 :             60 :                     n->objtype = OBJECT_FDW;
 6530                          7976                 :             60 :                     n->objs = $4;
                               7977                 :             60 :                     $$ = n;
                               7978                 :                :                 }
                               7979                 :                :             | FOREIGN SERVER name_list
                               7980                 :                :                 {
  330 michael@paquier.xyz      7981                 :             70 :                     PrivTarget *n = palloc_object(PrivTarget);
                               7982                 :                : 
 6233 tgl@sss.pgh.pa.us        7983                 :             70 :                     n->targtype = ACL_TARGET_OBJECT;
 3312 peter_e@gmx.net          7984                 :             70 :                     n->objtype = OBJECT_FOREIGN_SERVER;
 6530                          7985                 :             70 :                     n->objs = $3;
                               7986                 :             70 :                     $$ = n;
                               7987                 :                :                 }
                               7988                 :                :             | FUNCTION function_with_argtypes_list
                               7989                 :                :                 {
  330 michael@paquier.xyz      7990                 :            577 :                     PrivTarget *n = palloc_object(PrivTarget);
                               7991                 :                : 
 6233 tgl@sss.pgh.pa.us        7992                 :            577 :                     n->targtype = ACL_TARGET_OBJECT;
 3312 peter_e@gmx.net          7993                 :            577 :                     n->objtype = OBJECT_FUNCTION;
 8964 tgl@sss.pgh.pa.us        7994                 :            577 :                     n->objs = $2;
                               7995                 :            577 :                     $$ = n;
                               7996                 :                :                 }
                               7997                 :                :             | PROCEDURE function_with_argtypes_list
                               7998                 :                :                 {
  330 michael@paquier.xyz      7999                 :             28 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8000                 :                : 
 3262 peter_e@gmx.net          8001                 :             28 :                     n->targtype = ACL_TARGET_OBJECT;
 3312                          8002                 :             28 :                     n->objtype = OBJECT_PROCEDURE;
 3262                          8003                 :             28 :                     n->objs = $2;
                               8004                 :             28 :                     $$ = n;
                               8005                 :                :                 }
                               8006                 :                :             | ROUTINE function_with_argtypes_list
                               8007                 :                :                 {
  330 michael@paquier.xyz      8008                 :UBC           0 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8009                 :                : 
 3262 peter_e@gmx.net          8010                 :              0 :                     n->targtype = ACL_TARGET_OBJECT;
 3312                          8011                 :              0 :                     n->objtype = OBJECT_ROUTINE;
 3262                          8012                 :              0 :                     n->objs = $2;
                               8013                 :              0 :                     $$ = n;
                               8014                 :                :                 }
                               8015                 :                :             | DATABASE name_list
                               8016                 :                :                 {
  330 michael@paquier.xyz      8017                 :CBC         214 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8018                 :                : 
 6233 tgl@sss.pgh.pa.us        8019                 :            214 :                     n->targtype = ACL_TARGET_OBJECT;
 3312 peter_e@gmx.net          8020                 :            214 :                     n->objtype = OBJECT_DATABASE;
 9026                          8021                 :            214 :                     n->objs = $2;
                               8022                 :            214 :                     $$ = n;
                               8023                 :                :                 }
                               8024                 :                :             | DOMAIN_P any_name_list
                               8025                 :                :                 {
  330 michael@paquier.xyz      8026                 :             17 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8027                 :                : 
 5434 peter_e@gmx.net          8028                 :             17 :                     n->targtype = ACL_TARGET_OBJECT;
 3312                          8029                 :             17 :                     n->objtype = OBJECT_DOMAIN;
 5434                          8030                 :             17 :                     n->objs = $2;
                               8031                 :             17 :                     $$ = n;
                               8032                 :                :                 }
                               8033                 :                :             | LANGUAGE name_list
                               8034                 :                :                 {
  330 michael@paquier.xyz      8035                 :             27 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8036                 :                : 
 6233 tgl@sss.pgh.pa.us        8037                 :             27 :                     n->targtype = ACL_TARGET_OBJECT;
 3312 peter_e@gmx.net          8038                 :             27 :                     n->objtype = OBJECT_LANGUAGE;
 8964 tgl@sss.pgh.pa.us        8039                 :             27 :                     n->objs = $2;
                               8040                 :             27 :                     $$ = n;
                               8041                 :                :                 }
                               8042                 :                :             | LARGE_P OBJECT_P NumericOnly_list
                               8043                 :                :                 {
  330 michael@paquier.xyz      8044                 :             62 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8045                 :                : 
 6173 itagaki.takahiro@gma     8046                 :             62 :                     n->targtype = ACL_TARGET_OBJECT;
 3312 peter_e@gmx.net          8047                 :             62 :                     n->objtype = OBJECT_LARGEOBJECT;
 6173 itagaki.takahiro@gma     8048                 :             62 :                     n->objs = $3;
                               8049                 :             62 :                     $$ = n;
                               8050                 :                :                 }
                               8051                 :                :             | PARAMETER parameter_name_list
                               8052                 :                :                 {
  330 michael@paquier.xyz      8053                 :             38 :                     PrivTarget *n = palloc_object(PrivTarget);
 1674 tgl@sss.pgh.pa.us        8054                 :             38 :                     n->targtype = ACL_TARGET_OBJECT;
                               8055                 :             38 :                     n->objtype = OBJECT_PARAMETER_ACL;
                               8056                 :             38 :                     n->objs = $2;
                               8057                 :             38 :                     $$ = n;
                               8058                 :                :                 }
                               8059                 :                :             | SCHEMA name_list
                               8060                 :                :                 {
  330 michael@paquier.xyz      8061                 :            332 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8062                 :                : 
 6233 tgl@sss.pgh.pa.us        8063                 :            332 :                     n->targtype = ACL_TARGET_OBJECT;
 3312 peter_e@gmx.net          8064                 :            332 :                     n->objtype = OBJECT_SCHEMA;
 9026                          8065                 :            332 :                     n->objs = $2;
                               8066                 :            332 :                     $$ = n;
                               8067                 :                :                 }
                               8068                 :                :             | TABLESPACE name_list
                               8069                 :                :                 {
  330 michael@paquier.xyz      8070                 :             10 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8071                 :                : 
 6233 tgl@sss.pgh.pa.us        8072                 :             10 :                     n->targtype = ACL_TARGET_OBJECT;
 3312 peter_e@gmx.net          8073                 :             10 :                     n->objtype = OBJECT_TABLESPACE;
 8175 tgl@sss.pgh.pa.us        8074                 :             10 :                     n->objs = $2;
                               8075                 :             10 :                     $$ = n;
                               8076                 :                :                 }
                               8077                 :                :             | TYPE_P any_name_list
                               8078                 :                :                 {
  330 michael@paquier.xyz      8079                 :             84 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8080                 :                : 
 5434 peter_e@gmx.net          8081                 :             84 :                     n->targtype = ACL_TARGET_OBJECT;
 3312                          8082                 :             84 :                     n->objtype = OBJECT_TYPE;
 5434                          8083                 :             84 :                     n->objs = $2;
                               8084                 :             84 :                     $$ = n;
                               8085                 :                :                 }
                               8086                 :                :             | ALL TABLES IN_P SCHEMA name_list
                               8087                 :                :                 {
  330 michael@paquier.xyz      8088                 :              8 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8089                 :                : 
 6233 tgl@sss.pgh.pa.us        8090                 :              8 :                     n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
 3312 peter_e@gmx.net          8091                 :              8 :                     n->objtype = OBJECT_TABLE;
 6233 tgl@sss.pgh.pa.us        8092                 :              8 :                     n->objs = $5;
                               8093                 :              8 :                     $$ = n;
                               8094                 :                :                 }
                               8095                 :                :             | ALL SEQUENCES IN_P SCHEMA name_list
                               8096                 :                :                 {
  330 michael@paquier.xyz      8097                 :              1 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8098                 :                : 
 6233 tgl@sss.pgh.pa.us        8099                 :              1 :                     n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
 3312 peter_e@gmx.net          8100                 :              1 :                     n->objtype = OBJECT_SEQUENCE;
 6233 tgl@sss.pgh.pa.us        8101                 :              1 :                     n->objs = $5;
                               8102                 :              1 :                     $$ = n;
                               8103                 :                :                 }
                               8104                 :                :             | ALL FUNCTIONS IN_P SCHEMA name_list
                               8105                 :                :                 {
  330 michael@paquier.xyz      8106                 :              4 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8107                 :                : 
 6233 tgl@sss.pgh.pa.us        8108                 :              4 :                     n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
 3312 peter_e@gmx.net          8109                 :              4 :                     n->objtype = OBJECT_FUNCTION;
 6233 tgl@sss.pgh.pa.us        8110                 :              4 :                     n->objs = $5;
                               8111                 :              4 :                     $$ = n;
                               8112                 :                :                 }
                               8113                 :                :             | ALL PROCEDURES IN_P SCHEMA name_list
                               8114                 :                :                 {
  330 michael@paquier.xyz      8115                 :              4 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8116                 :                : 
 3262 peter_e@gmx.net          8117                 :              4 :                     n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
 3312                          8118                 :              4 :                     n->objtype = OBJECT_PROCEDURE;
 3262                          8119                 :              4 :                     n->objs = $5;
                               8120                 :              4 :                     $$ = n;
                               8121                 :                :                 }
                               8122                 :                :             | ALL ROUTINES IN_P SCHEMA name_list
                               8123                 :                :                 {
  330 michael@paquier.xyz      8124                 :              4 :                     PrivTarget *n = palloc_object(PrivTarget);
                               8125                 :                : 
 3262 peter_e@gmx.net          8126                 :              4 :                     n->targtype = ACL_TARGET_ALL_IN_SCHEMA;
 3312                          8127                 :              4 :                     n->objtype = OBJECT_ROUTINE;
 3262                          8128                 :              4 :                     n->objs = $5;
                               8129                 :              4 :                     $$ = n;
                               8130                 :                :                 }
                               8131                 :                :         ;
                               8132                 :                : 
                               8133                 :                : 
                               8134                 :                : grantee_list:
 8194 neilc@samurai.com        8135                 :           8894 :             grantee                                 { $$ = list_make1($1); }
 8907 bruce@momjian.us         8136                 :             71 :             | grantee_list ',' grantee              { $$ = lappend($1, $3); }
                               8137                 :                :         ;
                               8138                 :                : 
                               8139                 :                : grantee:
 4259 alvherre@alvh.no-ip.     8140                 :           8949 :             RoleSpec                                { $$ = $1; }
                               8141                 :             16 :             | GROUP_P RoleSpec                      { $$ = $2; }
                               8142                 :                :         ;
                               8143                 :                : 
                               8144                 :                : 
                               8145                 :                : opt_grant_grant_option:
 3368 peter_e@gmx.net          8146                 :             77 :             WITH GRANT OPTION { $$ = true; }
                               8147                 :           6314 :             | /*EMPTY*/ { $$ = false; }
                               8148                 :                :         ;
                               8149                 :                : 
                               8150                 :                : /*****************************************************************************
                               8151                 :                :  *
                               8152                 :                :  * GRANT and REVOKE ROLE statements
                               8153                 :                :  *
                               8154                 :                :  *****************************************************************************/
                               8155                 :                : 
                               8156                 :                : GrantRoleStmt:
                               8157                 :                :             GRANT privilege_list TO role_list opt_granted_by
                               8158                 :                :                 {
 7800 tgl@sss.pgh.pa.us        8159                 :            207 :                     GrantRoleStmt *n = makeNode(GrantRoleStmt);
                               8160                 :                : 
                               8161                 :            207 :                     n->is_grant = true;
                               8162                 :            207 :                     n->granted_roles = $2;
                               8163                 :            207 :                     n->grantee_roles = $4;
 1533 rhaas@postgresql.org     8164                 :            207 :                     n->opt = NIL;
                               8165                 :            207 :                     n->grantor = $5;
                               8166                 :            207 :                     $$ = (Node *) n;
                               8167                 :                :                 }
                               8168                 :                :           | GRANT privilege_list TO role_list WITH grant_role_opt_list opt_granted_by
                               8169                 :                :                 {
                               8170                 :            122 :                     GrantRoleStmt *n = makeNode(GrantRoleStmt);
                               8171                 :                : 
                               8172                 :            122 :                     n->is_grant = true;
                               8173                 :            122 :                     n->granted_roles = $2;
                               8174                 :            122 :                     n->grantee_roles = $4;
                               8175                 :            122 :                     n->opt = $6;
                               8176                 :            122 :                     n->grantor = $7;
 1637 peter@eisentraut.org     8177                 :            122 :                     $$ = (Node *) n;
                               8178                 :                :                 }
                               8179                 :                :         ;
                               8180                 :                : 
                               8181                 :                : RevokeRoleStmt:
                               8182                 :                :             REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior
                               8183                 :                :                 {
 7800 tgl@sss.pgh.pa.us        8184                 :             59 :                     GrantRoleStmt *n = makeNode(GrantRoleStmt);
                               8185                 :                : 
                               8186                 :             59 :                     n->is_grant = false;
 1533 rhaas@postgresql.org     8187                 :             59 :                     n->opt = NIL;
 7800 tgl@sss.pgh.pa.us        8188                 :             59 :                     n->granted_roles = $2;
                               8189                 :             59 :                     n->grantee_roles = $4;
 1536 rhaas@postgresql.org     8190                 :             59 :                     n->grantor = $5;
 7800 tgl@sss.pgh.pa.us        8191                 :             59 :                     n->behavior = $6;
 1637 peter@eisentraut.org     8192                 :             59 :                     $$ = (Node *) n;
                               8193                 :                :                 }
                               8194                 :                :             | REVOKE ColId OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior
                               8195                 :                :                 {
 7800 tgl@sss.pgh.pa.us        8196                 :             48 :                     GrantRoleStmt *n = makeNode(GrantRoleStmt);
                               8197                 :                :                     DefElem *opt;
                               8198                 :                : 
 1533 rhaas@postgresql.org     8199                 :             48 :                     opt = makeDefElem(pstrdup($2),
                               8200                 :             48 :                                       (Node *) makeBoolean(false), @2);
 7800 tgl@sss.pgh.pa.us        8201                 :             48 :                     n->is_grant = false;
 1533 rhaas@postgresql.org     8202                 :             48 :                     n->opt = list_make1(opt);
 7800 tgl@sss.pgh.pa.us        8203                 :             48 :                     n->granted_roles = $5;
                               8204                 :             48 :                     n->grantee_roles = $7;
 1536 rhaas@postgresql.org     8205                 :             48 :                     n->grantor = $8;
 7800 tgl@sss.pgh.pa.us        8206                 :             48 :                     n->behavior = $9;
 1637 peter@eisentraut.org     8207                 :             48 :                     $$ = (Node *) n;
                               8208                 :                :                 }
                               8209                 :                :         ;
                               8210                 :                : 
                               8211                 :                : grant_role_opt_list:
 1533 rhaas@postgresql.org     8212                 :             79 :             grant_role_opt_list ',' grant_role_opt  { $$ = lappend($1, $3); }
                               8213                 :            122 :             | grant_role_opt                        { $$ = list_make1($1); }
                               8214                 :                :         ;
                               8215                 :                : 
                               8216                 :                : grant_role_opt:
                               8217                 :                :         ColLabel grant_role_opt_value
                               8218                 :                :             {
                               8219                 :            201 :                 $$ = makeDefElem(pstrdup($1), $2, @1);
                               8220                 :                :             }
                               8221                 :                :         ;
                               8222                 :                : 
                               8223                 :                : grant_role_opt_value:
                               8224                 :             49 :         OPTION          { $$ = (Node *) makeBoolean(true); }
                               8225                 :             77 :         | TRUE_P        { $$ = (Node *) makeBoolean(true); }
                               8226                 :             75 :         | FALSE_P       { $$ = (Node *) makeBoolean(false); }
                               8227                 :                :         ;
                               8228                 :                : 
 4259 alvherre@alvh.no-ip.     8229                 :            108 : opt_granted_by: GRANTED BY RoleSpec                     { $$ = $3; }
 7800 tgl@sss.pgh.pa.us        8230                 :           9087 :             | /*EMPTY*/                                 { $$ = NULL; }
                               8231                 :                :         ;
                               8232                 :                : 
                               8233                 :                : /*****************************************************************************
                               8234                 :                :  *
                               8235                 :                :  * ALTER DEFAULT PRIVILEGES statement
                               8236                 :                :  *
                               8237                 :                :  *****************************************************************************/
                               8238                 :                : 
                               8239                 :                : AlterDefaultPrivilegesStmt:
                               8240                 :                :             ALTER DEFAULT PRIVILEGES DefACLOptionList DefACLAction
                               8241                 :                :                 {
 6240                          8242                 :            135 :                     AlterDefaultPrivilegesStmt *n = makeNode(AlterDefaultPrivilegesStmt);
                               8243                 :                : 
                               8244                 :            135 :                     n->options = $4;
                               8245                 :            135 :                     n->action = (GrantStmt *) $5;
 1637 peter@eisentraut.org     8246                 :            135 :                     $$ = (Node *) n;
                               8247                 :                :                 }
                               8248                 :                :         ;
                               8249                 :                : 
                               8250                 :                : DefACLOptionList:
 6240 tgl@sss.pgh.pa.us        8251                 :             93 :             DefACLOptionList DefACLOption           { $$ = lappend($1, $2); }
                               8252                 :            135 :             | /* EMPTY */                           { $$ = NIL; }
                               8253                 :                :         ;
                               8254                 :                : 
                               8255                 :                : DefACLOption:
                               8256                 :                :             IN_P SCHEMA name_list
                               8257                 :                :                 {
 1637 peter@eisentraut.org     8258                 :             39 :                     $$ = makeDefElem("schemas", (Node *) $3, @1);
                               8259                 :                :                 }
                               8260                 :                :             | FOR ROLE role_list
                               8261                 :                :                 {
                               8262                 :             54 :                     $$ = makeDefElem("roles", (Node *) $3, @1);
                               8263                 :                :                 }
                               8264                 :                :             | FOR USER role_list
                               8265                 :                :                 {
 1637 peter@eisentraut.org     8266                 :UBC           0 :                     $$ = makeDefElem("roles", (Node *) $3, @1);
                               8267                 :                :                 }
                               8268                 :                :         ;
                               8269                 :                : 
                               8270                 :                : /*
                               8271                 :                :  * This should match GRANT/REVOKE, except that individual target objects
                               8272                 :                :  * are not mentioned and we only allow a subset of object types.
                               8273                 :                :  */
                               8274                 :                : DefACLAction:
                               8275                 :                :             GRANT privileges ON defacl_privilege_target TO grantee_list
                               8276                 :                :             opt_grant_grant_option
                               8277                 :                :                 {
 6240 tgl@sss.pgh.pa.us        8278                 :CBC          82 :                     GrantStmt *n = makeNode(GrantStmt);
                               8279                 :                : 
                               8280                 :             82 :                     n->is_grant = true;
                               8281                 :             82 :                     n->privileges = $2;
 6233                          8282                 :             82 :                     n->targtype = ACL_TARGET_DEFAULTS;
 6240                          8283                 :             82 :                     n->objtype = $4;
                               8284                 :             82 :                     n->objects = NIL;
                               8285                 :             82 :                     n->grantees = $6;
                               8286                 :             82 :                     n->grant_option = $7;
 1637 peter@eisentraut.org     8287                 :             82 :                     $$ = (Node *) n;
                               8288                 :                :                 }
                               8289                 :                :             | REVOKE privileges ON defacl_privilege_target
                               8290                 :                :             FROM grantee_list opt_drop_behavior
                               8291                 :                :                 {
 6240 tgl@sss.pgh.pa.us        8292                 :             53 :                     GrantStmt *n = makeNode(GrantStmt);
                               8293                 :                : 
                               8294                 :             53 :                     n->is_grant = false;
                               8295                 :             53 :                     n->grant_option = false;
                               8296                 :             53 :                     n->privileges = $2;
 6233                          8297                 :             53 :                     n->targtype = ACL_TARGET_DEFAULTS;
 6240                          8298                 :             53 :                     n->objtype = $4;
                               8299                 :             53 :                     n->objects = NIL;
                               8300                 :             53 :                     n->grantees = $6;
                               8301                 :             53 :                     n->behavior = $7;
 1637 peter@eisentraut.org     8302                 :             53 :                     $$ = (Node *) n;
                               8303                 :                :                 }
                               8304                 :                :             | REVOKE GRANT OPTION FOR privileges ON defacl_privilege_target
                               8305                 :                :             FROM grantee_list opt_drop_behavior
                               8306                 :                :                 {
 6240 tgl@sss.pgh.pa.us        8307                 :UBC           0 :                     GrantStmt *n = makeNode(GrantStmt);
                               8308                 :                : 
                               8309                 :              0 :                     n->is_grant = false;
                               8310                 :              0 :                     n->grant_option = true;
                               8311                 :              0 :                     n->privileges = $5;
 6233                          8312                 :              0 :                     n->targtype = ACL_TARGET_DEFAULTS;
 6240                          8313                 :              0 :                     n->objtype = $7;
                               8314                 :              0 :                     n->objects = NIL;
                               8315                 :              0 :                     n->grantees = $9;
                               8316                 :              0 :                     n->behavior = $10;
 1637 peter@eisentraut.org     8317                 :              0 :                     $$ = (Node *) n;
                               8318                 :                :                 }
                               8319                 :                :         ;
                               8320                 :                : 
                               8321                 :                : defacl_privilege_target:
 3312 peter_e@gmx.net          8322                 :CBC          51 :             TABLES          { $$ = OBJECT_TABLE; }
                               8323                 :             10 :             | FUNCTIONS     { $$ = OBJECT_FUNCTION; }
                               8324                 :              4 :             | ROUTINES      { $$ = OBJECT_FUNCTION; }
                               8325                 :              4 :             | SEQUENCES     { $$ = OBJECT_SEQUENCE; }
                               8326                 :             22 :             | TYPES_P       { $$ = OBJECT_TYPE; }
                               8327                 :             24 :             | SCHEMAS       { $$ = OBJECT_SCHEMA; }
  580 fujii@postgresql.org     8328                 :             20 :             | LARGE_P OBJECTS_P { $$ = OBJECT_LARGEOBJECT; }
                               8329                 :                :         ;
                               8330                 :                : 
                               8331                 :                : 
                               8332                 :                : /*****************************************************************************
                               8333                 :                :  *
                               8334                 :                :  *      QUERY: CREATE INDEX
                               8335                 :                :  *
                               8336                 :                :  * Note: we cannot put TABLESPACE clause after WHERE clause unless we are
                               8337                 :                :  * willing to make TABLESPACE a fully reserved word.
                               8338                 :                :  *****************************************************************************/
                               8339                 :                : 
                               8340                 :                : IndexStmt:  CREATE opt_unique INDEX opt_concurrently opt_single_name
                               8341                 :                :             ON relation_expr access_method_clause '(' index_params ')'
                               8342                 :                :             opt_include opt_unique_null_treatment opt_reloptions OptTableSpace where_clause
                               8343                 :                :                 {
 7377 tgl@sss.pgh.pa.us        8344                 :           4642 :                     IndexStmt *n = makeNode(IndexStmt);
                               8345                 :                : 
                               8346                 :           4642 :                     n->unique = $2;
 6161                          8347                 :           4642 :                     n->concurrent = $4;
 7377                          8348                 :           4642 :                     n->idxname = $5;
                               8349                 :           4642 :                     n->relation = $7;
                               8350                 :           4642 :                     n->accessMethod = $8;
                               8351                 :           4642 :                     n->indexParams = $10;
 3134 teodor@sigaev.ru         8352                 :           4642 :                     n->indexIncludingParams = $12;
 1736 peter@eisentraut.org     8353                 :           4642 :                     n->nulls_not_distinct = !$13;
                               8354                 :           4642 :                     n->options = $14;
                               8355                 :           4642 :                     n->tableSpace = $15;
                               8356                 :           4642 :                     n->whereClause = $16;
 5225 tgl@sss.pgh.pa.us        8357                 :           4642 :                     n->excludeOpNames = NIL;
                               8358                 :           4642 :                     n->idxcomment = NULL;
 5763                          8359                 :           4642 :                     n->indexOid = InvalidOid;
 1583 rhaas@postgresql.org     8360                 :           4642 :                     n->oldNumber = InvalidRelFileNumber;
 2406 noah@leadboat.com        8361                 :           4642 :                     n->oldCreateSubid = InvalidSubTransactionId;
 1583 rhaas@postgresql.org     8362                 :           4642 :                     n->oldFirstRelfilelocatorSubid = InvalidSubTransactionId;
 5225 tgl@sss.pgh.pa.us        8363                 :           4642 :                     n->primary = false;
                               8364                 :           4642 :                     n->isconstraint = false;
                               8365                 :           4642 :                     n->deferrable = false;
                               8366                 :           4642 :                     n->initdeferred = false;
 4274                          8367                 :           4642 :                     n->transformed = false;
 4382 fujii@postgresql.org     8368                 :           4642 :                     n->if_not_exists = false;
 2751 alvherre@alvh.no-ip.     8369                 :           4642 :                     n->reset_default_tblspc = false;
 1637 peter@eisentraut.org     8370                 :           4642 :                     $$ = (Node *) n;
                               8371                 :                :                 }
                               8372                 :                :             | CREATE opt_unique INDEX opt_concurrently IF_P NOT EXISTS name
                               8373                 :                :             ON relation_expr access_method_clause '(' index_params ')'
                               8374                 :                :             opt_include opt_unique_null_treatment opt_reloptions OptTableSpace where_clause
                               8375                 :                :                 {
 4382 fujii@postgresql.org     8376                 :             12 :                     IndexStmt *n = makeNode(IndexStmt);
                               8377                 :                : 
                               8378                 :             12 :                     n->unique = $2;
                               8379                 :             12 :                     n->concurrent = $4;
                               8380                 :             12 :                     n->idxname = $8;
                               8381                 :             12 :                     n->relation = $10;
                               8382                 :             12 :                     n->accessMethod = $11;
                               8383                 :             12 :                     n->indexParams = $13;
 3134 teodor@sigaev.ru         8384                 :             12 :                     n->indexIncludingParams = $15;
 1736 peter@eisentraut.org     8385                 :             12 :                     n->nulls_not_distinct = !$16;
                               8386                 :             12 :                     n->options = $17;
                               8387                 :             12 :                     n->tableSpace = $18;
                               8388                 :             12 :                     n->whereClause = $19;
 4382 fujii@postgresql.org     8389                 :             12 :                     n->excludeOpNames = NIL;
                               8390                 :             12 :                     n->idxcomment = NULL;
                               8391                 :             12 :                     n->indexOid = InvalidOid;
 1583 rhaas@postgresql.org     8392                 :             12 :                     n->oldNumber = InvalidRelFileNumber;
 2406 noah@leadboat.com        8393                 :             12 :                     n->oldCreateSubid = InvalidSubTransactionId;
 1583 rhaas@postgresql.org     8394                 :             12 :                     n->oldFirstRelfilelocatorSubid = InvalidSubTransactionId;
 4382 fujii@postgresql.org     8395                 :             12 :                     n->primary = false;
                               8396                 :             12 :                     n->isconstraint = false;
                               8397                 :             12 :                     n->deferrable = false;
                               8398                 :             12 :                     n->initdeferred = false;
 4274 tgl@sss.pgh.pa.us        8399                 :             12 :                     n->transformed = false;
 4382 fujii@postgresql.org     8400                 :             12 :                     n->if_not_exists = true;
 2751 alvherre@alvh.no-ip.     8401                 :             12 :                     n->reset_default_tblspc = false;
 1637 peter@eisentraut.org     8402                 :             12 :                     $$ = (Node *) n;
                               8403                 :                :                 }
                               8404                 :                :         ;
                               8405                 :                : 
                               8406                 :                : opt_unique:
 3368 peter_e@gmx.net          8407                 :            904 :             UNIQUE                                  { $$ = true; }
                               8408                 :           3754 :             | /*EMPTY*/                             { $$ = false; }
                               8409                 :                :         ;
                               8410                 :                : 
                               8411                 :                : access_method_clause:
 2339 peter@eisentraut.org     8412                 :           1901 :             USING name                              { $$ = $2; }
 8906 bruce@momjian.us         8413                 :           2923 :             | /*EMPTY*/                             { $$ = DEFAULT_INDEX_TYPE; }
                               8414                 :                :         ;
                               8415                 :                : 
 8194 neilc@samurai.com        8416                 :           5959 : index_params:   index_elem                          { $$ = list_make1($1); }
 8562 tgl@sss.pgh.pa.us        8417                 :           1448 :             | index_params ',' index_elem           { $$ = lappend($1, $3); }
                               8418                 :                :         ;
                               8419                 :                : 
                               8420                 :                : 
                               8421                 :                : index_elem_options:
                               8422                 :                :     opt_collate opt_qualified_name opt_asc_desc opt_nulls_order
                               8423                 :                :         {
 2411 akorotkov@postgresql     8424                 :           7829 :             $$ = makeNode(IndexElem);
                               8425                 :           7829 :             $$->name = NULL;
                               8426                 :           7829 :             $$->expr = NULL;
                               8427                 :           7829 :             $$->indexcolname = NULL;
                               8428                 :           7829 :             $$->collation = $1;
                               8429                 :           7829 :             $$->opclass = $2;
                               8430                 :           7829 :             $$->opclassopts = NIL;
                               8431                 :           7829 :             $$->ordering = $3;
                               8432                 :           7829 :             $$->nulls_ordering = $4;
                               8433                 :                :             /* location will be filled in index_elem production */
                               8434                 :                :         }
                               8435                 :                :     | opt_collate any_name reloptions opt_asc_desc opt_nulls_order
                               8436                 :                :         {
                               8437                 :             91 :             $$ = makeNode(IndexElem);
                               8438                 :             91 :             $$->name = NULL;
                               8439                 :             91 :             $$->expr = NULL;
                               8440                 :             91 :             $$->indexcolname = NULL;
                               8441                 :             91 :             $$->collation = $1;
                               8442                 :             91 :             $$->opclass = $2;
                               8443                 :             91 :             $$->opclassopts = $3;
                               8444                 :             91 :             $$->ordering = $4;
                               8445                 :             91 :             $$->nulls_ordering = $5;
                               8446                 :                :             /* location will be filled in index_elem production */
                               8447                 :                :         }
                               8448                 :                :     ;
                               8449                 :                : 
                               8450                 :                : /*
                               8451                 :                :  * Index attributes can be either simple column references, or arbitrary
                               8452                 :                :  * expressions in parens.  For backwards-compatibility reasons, we allow
                               8453                 :                :  * an expression that's just a function call to be written without parens.
                               8454                 :                :  */
                               8455                 :                : index_elem: ColId index_elem_options
                               8456                 :                :                 {
                               8457                 :           6933 :                     $$ = $2;
 8562 tgl@sss.pgh.pa.us        8458                 :           6933 :                     $$->name = $1;
  305                          8459                 :           6933 :                     $$->location = @1;
                               8460                 :                :                 }
                               8461                 :                :             | func_expr_windowless index_elem_options
                               8462                 :                :                 {
 2411 akorotkov@postgresql     8463                 :            571 :                     $$ = $2;
 8072 tgl@sss.pgh.pa.us        8464                 :            571 :                     $$->expr = $1;
  305                          8465                 :            571 :                     $$->location = @1;
                               8466                 :                :                 }
                               8467                 :                :             | '(' a_expr ')' index_elem_options
                               8468                 :                :                 {
 2411 akorotkov@postgresql     8469                 :            416 :                     $$ = $4;
 8562 tgl@sss.pgh.pa.us        8470                 :            416 :                     $$->expr = $2;
  305                          8471                 :            416 :                     $$->location = @1;
                               8472                 :                :                 }
                               8473                 :                :         ;
                               8474                 :                : 
 3134 teodor@sigaev.ru         8475                 :            149 : opt_include:        INCLUDE '(' index_including_params ')'          { $$ = $3; }
                               8476                 :           4505 :              |      /* EMPTY */                     { $$ = NIL; }
                               8477                 :                :         ;
                               8478                 :                : 
                               8479                 :            149 : index_including_params: index_elem                      { $$ = list_make1($1); }
                               8480                 :            109 :             | index_including_params ',' index_elem     { $$ = lappend($1, $3); }
                               8481                 :                :         ;
                               8482                 :                : 
 5749 peter_e@gmx.net          8483                 :            142 : opt_collate: COLLATE any_name                       { $$ = $2; }
                               8484                 :          11559 :             | /*EMPTY*/                             { $$ = NIL; }
                               8485                 :                :         ;
                               8486                 :                : 
                               8487                 :                : 
 7240 tgl@sss.pgh.pa.us        8488                 :           1024 : opt_asc_desc: ASC                           { $$ = SORTBY_ASC; }
 6639                          8489                 :           2369 :             | DESC                          { $$ = SORTBY_DESC; }
                               8490                 :          76169 :             | /*EMPTY*/                     { $$ = SORTBY_DEFAULT; }
                               8491                 :                :         ;
                               8492                 :                : 
 4272                          8493                 :            214 : opt_nulls_order: NULLS_LA FIRST_P           { $$ = SORTBY_NULLS_FIRST; }
                               8494                 :            908 :             | NULLS_LA LAST_P               { $$ = SORTBY_NULLS_LAST; }
 7240                          8495                 :          78582 :             | /*EMPTY*/                     { $$ = SORTBY_NULLS_DEFAULT; }
                               8496                 :                :         ;
                               8497                 :                : 
                               8498                 :                : 
                               8499                 :                : /*****************************************************************************
                               8500                 :                :  *
                               8501                 :                :  *      QUERY:
                               8502                 :                :  *              create [or replace] function <fname>
                               8503                 :                :  *                      [(<type-1> { , <type-n>})]
                               8504                 :                :  *                      returns <type-r>
                               8505                 :                :  *                      as <filename or code in language as appropriate>
                               8506                 :                :  *                      language <lang> [with parameters]
                               8507                 :                :  *
                               8508                 :                :  *****************************************************************************/
                               8509                 :                : 
                               8510                 :                : CreateFunctionStmt:
                               8511                 :                :             CREATE opt_or_replace FUNCTION func_name func_args_with_defaults
                               8512                 :                :             RETURNS func_return opt_createfunc_opt_list opt_routine_body
                               8513                 :                :                 {
 8938 peter_e@gmx.net          8514                 :          12946 :                     CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
                               8515                 :                : 
 3205 tgl@sss.pgh.pa.us        8516                 :          12946 :                     n->is_procedure = false;
 9165                          8517                 :          12946 :                     n->replace = $2;
 8976                          8518                 :          12946 :                     n->funcname = $4;
 8339                          8519                 :          12946 :                     n->parameters = $5;
 8987                          8520                 :          12946 :                     n->returnType = $7;
 8938 peter_e@gmx.net          8521                 :          12946 :                     n->options = $8;
 2038 peter@eisentraut.org     8522                 :          12946 :                     n->sql_body = $9;
 1637                          8523                 :          12946 :                     $$ = (Node *) n;
                               8524                 :                :                 }
                               8525                 :                :             | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults
                               8526                 :                :               RETURNS TABLE '(' table_func_column_list ')' opt_createfunc_opt_list opt_routine_body
                               8527                 :                :                 {
 6684 tgl@sss.pgh.pa.us        8528                 :            141 :                     CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
                               8529                 :                : 
 3205                          8530                 :            141 :                     n->is_procedure = false;
 6684                          8531                 :            141 :                     n->replace = $2;
                               8532                 :            141 :                     n->funcname = $4;
  735                          8533                 :            141 :                     n->parameters = mergeTableFuncParameters($5, $9, yyscanner);
 6684                          8534                 :            141 :                     n->returnType = TableFuncTypeName($9);
                               8535                 :            141 :                     n->returnType->location = @7;
                               8536                 :            141 :                     n->options = $11;
 2038 peter@eisentraut.org     8537                 :            141 :                     n->sql_body = $12;
 1637                          8538                 :            141 :                     $$ = (Node *) n;
                               8539                 :                :                 }
                               8540                 :                :             | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults
                               8541                 :                :               opt_createfunc_opt_list opt_routine_body
                               8542                 :                :                 {
 7889 tgl@sss.pgh.pa.us        8543                 :            315 :                     CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
                               8544                 :                : 
 3205                          8545                 :            315 :                     n->is_procedure = false;
 7889                          8546                 :            315 :                     n->replace = $2;
                               8547                 :            315 :                     n->funcname = $4;
                               8548                 :            315 :                     n->parameters = $5;
                               8549                 :            315 :                     n->returnType = NULL;
                               8550                 :            315 :                     n->options = $6;
 2038 peter@eisentraut.org     8551                 :            315 :                     n->sql_body = $7;
 1637                          8552                 :            315 :                     $$ = (Node *) n;
                               8553                 :                :                 }
                               8554                 :                :             | CREATE opt_or_replace PROCEDURE func_name func_args_with_defaults
                               8555                 :                :               opt_createfunc_opt_list opt_routine_body
                               8556                 :                :                 {
 3262 peter_e@gmx.net          8557                 :            225 :                     CreateFunctionStmt *n = makeNode(CreateFunctionStmt);
                               8558                 :                : 
 3205 tgl@sss.pgh.pa.us        8559                 :            225 :                     n->is_procedure = true;
 3262 peter_e@gmx.net          8560                 :            225 :                     n->replace = $2;
                               8561                 :            225 :                     n->funcname = $4;
                               8562                 :            225 :                     n->parameters = $5;
                               8563                 :            225 :                     n->returnType = NULL;
                               8564                 :            225 :                     n->options = $6;
 2038 peter@eisentraut.org     8565                 :            225 :                     n->sql_body = $7;
 1637                          8566                 :            225 :                     $$ = (Node *) n;
                               8567                 :                :                 }
                               8568                 :                :         ;
                               8569                 :                : 
                               8570                 :                : opt_or_replace:
 3368 peter_e@gmx.net          8571                 :           3894 :             OR REPLACE                              { $$ = true; }
                               8572                 :          13213 :             | /*EMPTY*/                             { $$ = false; }
                               8573                 :                :         ;
                               8574                 :                : 
 8907 bruce@momjian.us         8575                 :           4120 : func_args:  '(' func_args_list ')'                  { $$ = $2; }
                               8576                 :           1294 :             | '(' ')'                               { $$ = NIL; }
                               8577                 :                :         ;
                               8578                 :                : 
                               8579                 :                : func_args_list:
 8194 neilc@samurai.com        8580                 :           4120 :             func_arg                                { $$ = list_make1($1); }
 8907 bruce@momjian.us         8581                 :           4050 :             | func_args_list ',' func_arg           { $$ = lappend($1, $3); }
                               8582                 :                :         ;
                               8583                 :                : 
                               8584                 :                : function_with_argtypes_list:
 3703 peter_e@gmx.net          8585                 :           3195 :             function_with_argtypes                  { $$ = list_make1($1); }
                               8586                 :                :             | function_with_argtypes_list ',' function_with_argtypes
                               8587                 :             56 :                                                     { $$ = lappend($1, $3); }
                               8588                 :                :         ;
                               8589                 :                : 
                               8590                 :                : function_with_argtypes:
                               8591                 :                :             func_name func_args
                               8592                 :                :                 {
 3599                          8593                 :           5414 :                     ObjectWithArgs *n = makeNode(ObjectWithArgs);
                               8594                 :                : 
                               8595                 :           5414 :                     n->objname = $1;
 1974 tgl@sss.pgh.pa.us        8596                 :           5414 :                     n->objargs = extractArgTypes($2);
                               8597                 :           5414 :                     n->objfuncargs = $2;
 3703 peter_e@gmx.net          8598                 :           5414 :                     $$ = n;
                               8599                 :                :                 }
                               8600                 :                :             /*
                               8601                 :                :              * Because of reduce/reduce conflicts, we can't use func_name
                               8602                 :                :              * below, but we can write it out the long way, which actually
                               8603                 :                :              * allows more cases.
                               8604                 :                :              */
                               8605                 :                :             | type_func_name_keyword
                               8606                 :                :                 {
 3528 peter_e@gmx.net          8607                 :UBC           0 :                     ObjectWithArgs *n = makeNode(ObjectWithArgs);
                               8608                 :                : 
                               8609                 :              0 :                     n->objname = list_make1(makeString(pstrdup($1)));
                               8610                 :              0 :                     n->args_unspecified = true;
                               8611                 :              0 :                     $$ = n;
                               8612                 :                :                 }
                               8613                 :                :             | ColId
                               8614                 :                :                 {
 3528 peter_e@gmx.net          8615                 :CBC         315 :                     ObjectWithArgs *n = makeNode(ObjectWithArgs);
                               8616                 :                : 
                               8617                 :            315 :                     n->objname = list_make1(makeString($1));
                               8618                 :            315 :                     n->args_unspecified = true;
                               8619                 :            315 :                     $$ = n;
                               8620                 :                :                 }
                               8621                 :                :             | ColId indirection
                               8622                 :                :                 {
                               8623                 :             14 :                     ObjectWithArgs *n = makeNode(ObjectWithArgs);
                               8624                 :                : 
                               8625                 :             14 :                     n->objname = check_func_name(lcons(makeString($1), $2),
                               8626                 :                :                                                   yyscanner);
                               8627                 :             14 :                     n->args_unspecified = true;
                               8628                 :             14 :                     $$ = n;
                               8629                 :                :                 }
                               8630                 :                :         ;
                               8631                 :                : 
                               8632                 :                : /*
                               8633                 :                :  * func_args_with_defaults is separate because we only want to accept
                               8634                 :                :  * defaults in CREATE FUNCTION, not in ALTER etc.
                               8635                 :                :  */
                               8636                 :                : func_args_with_defaults:
 6545                          8637                 :          10782 :         '(' func_args_with_defaults_list ')'        { $$ = $2; }
 6531 tgl@sss.pgh.pa.us        8638                 :           2845 :         | '(' ')'                                   { $$ = NIL; }
                               8639                 :                :         ;
                               8640                 :                : 
                               8641                 :                : func_args_with_defaults_list:
                               8642                 :          10782 :         func_arg_with_default                       { $$ = list_make1($1); }
                               8643                 :                :         | func_args_with_defaults_list ',' func_arg_with_default
                               8644                 :          15528 :                                                     { $$ = lappend($1, $3); }
                               8645                 :                :         ;
                               8646                 :                : 
                               8647                 :                : /*
                               8648                 :                :  * The style with arg_class first is SQL99 standard, but Oracle puts
                               8649                 :                :  * param_name first; accept both since it's likely people will try both
                               8650                 :                :  * anyway.  Don't bother trying to save productions by letting arg_class
                               8651                 :                :  * have an empty alternative ... you'll get shift/reduce conflicts.
                               8652                 :                :  *
                               8653                 :                :  * We can catch over-specified arguments here if we want to,
                               8654                 :                :  * but for now better to silently swallow typmod, etc.
                               8655                 :                :  * - thomas 2000-03-22
                               8656                 :                :  */
                               8657                 :                : func_arg:
                               8658                 :                :             arg_class param_name func_type
                               8659                 :                :                 {
 8339                          8660                 :           8266 :                     FunctionParameter *n = makeNode(FunctionParameter);
                               8661                 :                : 
                               8662                 :           8266 :                     n->name = $2;
                               8663                 :           8266 :                     n->argType = $3;
 7891                          8664                 :           8266 :                     n->mode = $1;
 6545 peter_e@gmx.net          8665                 :           8266 :                     n->defexpr = NULL;
  735 tgl@sss.pgh.pa.us        8666                 :           8266 :                     n->location = @1;
 8339                          8667                 :           8266 :                     $$ = n;
                               8668                 :                :                 }
                               8669                 :                :             | param_name arg_class func_type
                               8670                 :                :                 {
                               8671                 :            274 :                     FunctionParameter *n = makeNode(FunctionParameter);
                               8672                 :                : 
 7891                          8673                 :            274 :                     n->name = $1;
                               8674                 :            274 :                     n->argType = $3;
                               8675                 :            274 :                     n->mode = $2;
 6545 peter_e@gmx.net          8676                 :            274 :                     n->defexpr = NULL;
  735 tgl@sss.pgh.pa.us        8677                 :            274 :                     n->location = @1;
 7891                          8678                 :            274 :                     $$ = n;
                               8679                 :                :                 }
                               8680                 :                :             | param_name func_type
                               8681                 :                :                 {
                               8682                 :           4389 :                     FunctionParameter *n = makeNode(FunctionParameter);
                               8683                 :                : 
                               8684                 :           4389 :                     n->name = $1;
 8339                          8685                 :           4389 :                     n->argType = $2;
 1974                          8686                 :           4389 :                     n->mode = FUNC_PARAM_DEFAULT;
 6545 peter_e@gmx.net          8687                 :           4389 :                     n->defexpr = NULL;
  735 tgl@sss.pgh.pa.us        8688                 :           4389 :                     n->location = @1;
 8339                          8689                 :           4389 :                     $$ = n;
                               8690                 :                :                 }
                               8691                 :                :             | arg_class func_type
                               8692                 :                :                 {
 7891                          8693                 :            204 :                     FunctionParameter *n = makeNode(FunctionParameter);
                               8694                 :                : 
                               8695                 :            204 :                     n->name = NULL;
                               8696                 :            204 :                     n->argType = $2;
                               8697                 :            204 :                     n->mode = $1;
 6545 peter_e@gmx.net          8698                 :            204 :                     n->defexpr = NULL;
  735 tgl@sss.pgh.pa.us        8699                 :            204 :                     n->location = @1;
 7891                          8700                 :            204 :                     $$ = n;
                               8701                 :                :                 }
                               8702                 :                :             | func_type
                               8703                 :                :                 {
                               8704                 :          21903 :                     FunctionParameter *n = makeNode(FunctionParameter);
                               8705                 :                : 
                               8706                 :          21903 :                     n->name = NULL;
                               8707                 :          21903 :                     n->argType = $1;
 1974                          8708                 :          21903 :                     n->mode = FUNC_PARAM_DEFAULT;
 6545 peter_e@gmx.net          8709                 :          21903 :                     n->defexpr = NULL;
  735 tgl@sss.pgh.pa.us        8710                 :          21903 :                     n->location = @1;
 7891                          8711                 :          21903 :                     $$ = n;
                               8712                 :                :                 }
                               8713                 :                :         ;
                               8714                 :                : 
                               8715                 :                : /* INOUT is SQL99 standard, IN OUT is for Oracle compatibility */
 6686                          8716                 :           2024 : arg_class:  IN_P                                { $$ = FUNC_PARAM_IN; }
                               8717                 :           6476 :             | OUT_P                             { $$ = FUNC_PARAM_OUT; }
                               8718                 :            123 :             | INOUT                             { $$ = FUNC_PARAM_INOUT; }
 6686 tgl@sss.pgh.pa.us        8719                 :UBC           0 :             | IN_P OUT_P                        { $$ = FUNC_PARAM_INOUT; }
 6686 tgl@sss.pgh.pa.us        8720                 :CBC         121 :             | VARIADIC                          { $$ = FUNC_PARAM_VARIADIC; }
                               8721                 :                :         ;
                               8722                 :                : 
                               8723                 :                : /*
                               8724                 :                :  * Ideally param_name should be ColId, but that causes too many conflicts.
                               8725                 :                :  */
                               8726                 :                : param_name: type_function_name
                               8727                 :                :         ;
                               8728                 :                : 
                               8729                 :                : func_return:
                               8730                 :                :             func_type
                               8731                 :                :                 {
                               8732                 :                :                     /* We can catch over-specified results here if we want to,
                               8733                 :                :                      * but for now better to silently swallow typmod, etc.
                               8734                 :                :                      * - thomas 2000-03-22
                               8735                 :                :                      */
 9719 lockhart@fourpalms.o     8736                 :          12946 :                     $$ = $1;
                               8737                 :                :                 }
                               8738                 :                :         ;
                               8739                 :                : 
                               8740                 :                : /*
                               8741                 :                :  * We would like to make the %TYPE productions here be ColId attrs etc,
                               8742                 :                :  * but that causes reduce/reduce conflicts.  type_function_name
                               8743                 :                :  * is next best choice.
                               8744                 :                :  */
 8907 bruce@momjian.us         8745                 :          60838 : func_type:  Typename                                { $$ = $1; }
                               8746                 :                :             | type_function_name attrs '%' TYPE_P
                               8747                 :                :                 {
 7250 tgl@sss.pgh.pa.us        8748                 :             16 :                     $$ = makeTypeNameFromNameList(lcons(makeString($1), $2));
 8987                          8749                 :             16 :                     $$->pct_type = true;
 7541                          8750                 :             16 :                     $$->location = @1;
                               8751                 :                :                 }
                               8752                 :                :             | SETOF type_function_name attrs '%' TYPE_P
                               8753                 :                :                 {
 7250                          8754                 :              4 :                     $$ = makeTypeNameFromNameList(lcons(makeString($2), $3));
 7583                          8755                 :              4 :                     $$->pct_type = true;
 3368 peter_e@gmx.net          8756                 :              4 :                     $$->setof = true;
 7541 tgl@sss.pgh.pa.us        8757                 :              4 :                     $$->location = @2;
                               8758                 :                :                 }
                               8759                 :                :         ;
                               8760                 :                : 
                               8761                 :                : func_arg_with_default:
                               8762                 :                :         func_arg
                               8763                 :                :                 {
 5483 peter_e@gmx.net          8764                 :          25584 :                     $$ = $1;
                               8765                 :                :                 }
                               8766                 :                :         | func_arg DEFAULT a_expr
                               8767                 :                :                 {
                               8768                 :            598 :                     $$ = $1;
                               8769                 :            598 :                     $$->defexpr = $3;
                               8770                 :                :                 }
                               8771                 :                :         | func_arg '=' a_expr
                               8772                 :                :                 {
                               8773                 :            128 :                     $$ = $1;
                               8774                 :            128 :                     $$->defexpr = $3;
                               8775                 :                :                 }
                               8776                 :                :         ;
                               8777                 :                : 
                               8778                 :                : /* Aggregate args can be most things that function args can be */
                               8779                 :                : aggr_arg:   func_arg
                               8780                 :                :                 {
 1974 tgl@sss.pgh.pa.us        8781         [ +  + ]:            556 :                     if (!($1->mode == FUNC_PARAM_DEFAULT ||
                               8782         [ +  - ]:             36 :                           $1->mode == FUNC_PARAM_IN ||
 4811                          8783         [ -  + ]:             36 :                           $1->mode == FUNC_PARAM_VARIADIC))
 4811 tgl@sss.pgh.pa.us        8784         [ #  # ]:UBC           0 :                         ereport(ERROR,
                               8785                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                               8786                 :                :                                  errmsg("aggregates cannot have output arguments"),
                               8787                 :                :                                  parser_errposition(@1)));
 4811 tgl@sss.pgh.pa.us        8788                 :CBC         556 :                     $$ = $1;
                               8789                 :                :                 }
                               8790                 :                :         ;
                               8791                 :                : 
                               8792                 :                : /*
                               8793                 :                :  * The SQL standard offers no guidance on how to declare aggregate argument
                               8794                 :                :  * lists, since it doesn't have CREATE AGGREGATE etc.  We accept these cases:
                               8795                 :                :  *
                               8796                 :                :  * (*)                                  - normal agg with no args
                               8797                 :                :  * (aggr_arg,...)                       - normal agg with args
                               8798                 :                :  * (ORDER BY aggr_arg,...)              - ordered-set agg with no direct args
                               8799                 :                :  * (aggr_arg,... ORDER BY aggr_arg,...) - ordered-set agg with direct args
                               8800                 :                :  *
                               8801                 :                :  * The zero-argument case is spelled with '*' for consistency with COUNT(*).
                               8802                 :                :  *
                               8803                 :                :  * An additional restriction is that if the direct-args list ends in a
                               8804                 :                :  * VARIADIC item, the ordered-args list must contain exactly one item that
                               8805                 :                :  * is also VARIADIC with the same type.  This allows us to collapse the two
                               8806                 :                :  * VARIADIC items into one, which is necessary to represent the aggregate in
                               8807                 :                :  * pg_proc.  We check this at the grammar stage so that we can return a list
                               8808                 :                :  * in which the second VARIADIC item is already discarded, avoiding extra work
                               8809                 :                :  * in cases such as DROP AGGREGATE.
                               8810                 :                :  *
                               8811                 :                :  * The return value of this production is a two-element list, in which the
                               8812                 :                :  * first item is a sublist of FunctionParameter nodes (with any duplicate
                               8813                 :                :  * VARIADIC item already dropped, as per above) and the second is an Integer
                               8814                 :                :  * node, containing -1 if there was no ORDER BY and otherwise the number
                               8815                 :                :  * of argument declarations before the ORDER BY.  (If this number is equal
                               8816                 :                :  * to the first sublist's length, then we dropped a duplicate VARIADIC item.)
                               8817                 :                :  * This representation is passed as-is to CREATE AGGREGATE; for operations
                               8818                 :                :  * on existing aggregates, we can just apply extractArgTypes to the first
                               8819                 :                :  * sublist.
                               8820                 :                :  */
                               8821                 :                : aggr_args:  '(' '*' ')'
                               8822                 :                :                 {
 4700                          8823                 :             85 :                     $$ = list_make2(NIL, makeInteger(-1));
                               8824                 :                :                 }
                               8825                 :                :             | '(' aggr_args_list ')'
                               8826                 :                :                 {
                               8827                 :            452 :                     $$ = list_make2($2, makeInteger(-1));
                               8828                 :                :                 }
                               8829                 :                :             | '(' ORDER BY aggr_args_list ')'
                               8830                 :                :                 {
                               8831                 :              4 :                     $$ = list_make2($4, makeInteger(0));
                               8832                 :                :                 }
                               8833                 :                :             | '(' aggr_args_list ORDER BY aggr_args_list ')'
                               8834                 :                :                 {
                               8835                 :                :                     /* this is the only case requiring consistency checking */
                               8836                 :             20 :                     $$ = makeOrderedSetArgs($2, $5, yyscanner);
                               8837                 :                :                 }
                               8838                 :                :         ;
                               8839                 :                : 
                               8840                 :                : aggr_args_list:
 4811                          8841                 :            496 :             aggr_arg                                { $$ = list_make1($1); }
                               8842                 :             60 :             | aggr_args_list ',' aggr_arg           { $$ = lappend($1, $3); }
                               8843                 :                :         ;
                               8844                 :                : 
                               8845                 :                : aggregate_with_argtypes:
                               8846                 :                :             func_name aggr_args
                               8847                 :                :                 {
 3599 peter_e@gmx.net          8848                 :            220 :                     ObjectWithArgs *n = makeNode(ObjectWithArgs);
                               8849                 :                : 
                               8850                 :            220 :                     n->objname = $1;
                               8851                 :            220 :                     n->objargs = extractAggrArgTypes($2);
 1974 tgl@sss.pgh.pa.us        8852                 :            220 :                     n->objfuncargs = (List *) linitial($2);
 3703 peter_e@gmx.net          8853                 :            220 :                     $$ = n;
                               8854                 :                :                 }
                               8855                 :                :         ;
                               8856                 :                : 
                               8857                 :                : aggregate_with_argtypes_list:
 3599                          8858                 :             69 :             aggregate_with_argtypes                 { $$ = list_make1($1); }
                               8859                 :                :             | aggregate_with_argtypes_list ',' aggregate_with_argtypes
 3599 peter_e@gmx.net          8860                 :UBC           0 :                                                     { $$ = lappend($1, $3); }
                               8861                 :                :         ;
                               8862                 :                : 
                               8863                 :                : opt_createfunc_opt_list:
                               8864                 :                :             createfunc_opt_list
 2038 peter@eisentraut.org     8865                 :CBC          70 :             | /*EMPTY*/ { $$ = NIL; }
                               8866                 :                :     ;
                               8867                 :                : 
                               8868                 :                : createfunc_opt_list:
                               8869                 :                :             /* Must be at least one to prevent conflict */
 5483 peter_e@gmx.net          8870                 :          13557 :             createfunc_opt_item                     { $$ = list_make1($1); }
 8906 bruce@momjian.us         8871                 :          32956 :             | createfunc_opt_list createfunc_opt_item { $$ = lappend($1, $2); }
                               8872                 :                :     ;
                               8873                 :                : 
                               8874                 :                : /*
                               8875                 :                :  * Options common to both CREATE FUNCTION and ALTER FUNCTION
                               8876                 :                :  */
                               8877                 :                : common_func_opt_item:
                               8878                 :                :             CALLED ON NULL_P INPUT_P
                               8879                 :                :                 {
 1637 peter@eisentraut.org     8880                 :             99 :                     $$ = makeDefElem("strict", (Node *) makeBoolean(false), @1);
                               8881                 :                :                 }
                               8882                 :                :             | RETURNS NULL_P ON NULL_P INPUT_P
                               8883                 :                :                 {
                               8884                 :            526 :                     $$ = makeDefElem("strict", (Node *) makeBoolean(true), @1);
                               8885                 :                :                 }
                               8886                 :                :             | STRICT_P
                               8887                 :                :                 {
                               8888                 :           6484 :                     $$ = makeDefElem("strict", (Node *) makeBoolean(true), @1);
                               8889                 :                :                 }
                               8890                 :                :             | IMMUTABLE
                               8891                 :                :                 {
                               8892                 :           5098 :                     $$ = makeDefElem("volatility", (Node *) makeString("immutable"), @1);
                               8893                 :                :                 }
                               8894                 :                :             | STABLE
                               8895                 :                :                 {
                               8896                 :           1007 :                     $$ = makeDefElem("volatility", (Node *) makeString("stable"), @1);
                               8897                 :                :                 }
                               8898                 :                :             | VOLATILE
                               8899                 :                :                 {
                               8900                 :            225 :                     $$ = makeDefElem("volatility", (Node *) makeString("volatile"), @1);
                               8901                 :                :                 }
                               8902                 :                :             | EXTERNAL SECURITY DEFINER
                               8903                 :                :                 {
 1637 peter@eisentraut.org     8904                 :UBC           0 :                     $$ = makeDefElem("security", (Node *) makeBoolean(true), @1);
                               8905                 :                :                 }
                               8906                 :                :             | EXTERNAL SECURITY INVOKER
                               8907                 :                :                 {
                               8908                 :              0 :                     $$ = makeDefElem("security", (Node *) makeBoolean(false), @1);
                               8909                 :                :                 }
                               8910                 :                :             | SECURITY DEFINER
                               8911                 :                :                 {
 1637 peter@eisentraut.org     8912                 :CBC          36 :                     $$ = makeDefElem("security", (Node *) makeBoolean(true), @1);
                               8913                 :                :                 }
                               8914                 :                :             | SECURITY INVOKER
                               8915                 :                :                 {
                               8916                 :             12 :                     $$ = makeDefElem("security", (Node *) makeBoolean(false), @1);
                               8917                 :                :                 }
                               8918                 :                :             | LEAKPROOF
                               8919                 :                :                 {
                               8920                 :             30 :                     $$ = makeDefElem("leakproof", (Node *) makeBoolean(true), @1);
                               8921                 :                :                 }
                               8922                 :                :             | NOT LEAKPROOF
                               8923                 :                :                 {
                               8924                 :              8 :                     $$ = makeDefElem("leakproof", (Node *) makeBoolean(false), @1);
                               8925                 :                :                 }
                               8926                 :                :             | COST NumericOnly
                               8927                 :                :                 {
                               8928                 :           2248 :                     $$ = makeDefElem("cost", (Node *) $2, @1);
                               8929                 :                :                 }
                               8930                 :                :             | ROWS NumericOnly
                               8931                 :                :                 {
                               8932                 :             70 :                     $$ = makeDefElem("rows", (Node *) $2, @1);
                               8933                 :                :                 }
                               8934                 :                :             | SUPPORT any_name
                               8935                 :                :                 {
                               8936                 :             72 :                     $$ = makeDefElem("support", (Node *) $2, @1);
                               8937                 :                :                 }
                               8938                 :                :             | FunctionSetResetClause
                               8939                 :                :                 {
                               8940                 :                :                     /* we abuse the normal content of a DefElem here */
                               8941                 :             97 :                     $$ = makeDefElem("set", (Node *) $1, @1);
                               8942                 :                :                 }
                               8943                 :                :             | PARALLEL ColId
                               8944                 :                :                 {
                               8945                 :           6855 :                     $$ = makeDefElem("parallel", (Node *) makeString($2), @1);
                               8946                 :                :                 }
                               8947                 :                :         ;
                               8948                 :                : 
                               8949                 :                : createfunc_opt_item:
                               8950                 :                :             AS func_as
                               8951                 :                :                 {
                               8952                 :          10236 :                     $$ = makeDefElem("as", (Node *) $2, @1);
                               8953                 :                :                 }
                               8954                 :                :             | LANGUAGE NonReservedWord_or_Sconst
                               8955                 :                :                 {
                               8956                 :          13544 :                     $$ = makeDefElem("language", (Node *) makeString($2), @1);
                               8957                 :                :                 }
                               8958                 :                :             | TRANSFORM transform_type_list
                               8959                 :                :                 {
                               8960                 :             76 :                     $$ = makeDefElem("transform", (Node *) $2, @1);
                               8961                 :                :                 }
                               8962                 :                :             | WINDOW
                               8963                 :                :                 {
                               8964                 :             13 :                     $$ = makeDefElem("window", (Node *) makeBoolean(true), @1);
                               8965                 :                :                 }
                               8966                 :                :             | common_func_opt_item
                               8967                 :                :                 {
 7906 neilc@samurai.com        8968                 :          22644 :                     $$ = $1;
                               8969                 :                :                 }
                               8970                 :                :         ;
                               8971                 :                : 
 8194                          8972                 :           7991 : func_as:    Sconst                      { $$ = list_make1(makeString($1)); }
                               8973                 :                :             | Sconst ',' Sconst
                               8974                 :                :                 {
                               8975                 :           2245 :                     $$ = list_make2(makeString($1), makeString($3));
                               8976                 :                :                 }
                               8977                 :                :         ;
                               8978                 :                : 
                               8979                 :                : ReturnStmt: RETURN a_expr
                               8980                 :                :                 {
 2038 peter@eisentraut.org     8981                 :           2880 :                     ReturnStmt *r = makeNode(ReturnStmt);
                               8982                 :                : 
                               8983                 :           2880 :                     r->returnval = (Node *) $2;
                               8984                 :           2880 :                     $$ = (Node *) r;
                               8985                 :                :                 }
                               8986                 :                :         ;
                               8987                 :                : 
                               8988                 :                : opt_routine_body:
                               8989                 :                :             ReturnStmt
                               8990                 :                :                 {
                               8991                 :           2876 :                     $$ = $1;
                               8992                 :                :                 }
                               8993                 :                :             | BEGIN_P ATOMIC routine_body_stmt_list END_P
                               8994                 :                :                 {
                               8995                 :                :                     /*
                               8996                 :                :                      * A compound statement is stored as a single-item list
                               8997                 :                :                      * containing the list of statements as its member.  That
                               8998                 :                :                      * way, the parse analysis code can tell apart an empty
                               8999                 :                :                      * body from no body at all.
                               9000                 :                :                      */
                               9001                 :            519 :                     $$ = (Node *) list_make1($3);
                               9002                 :                :                 }
                               9003                 :                :             | /*EMPTY*/
                               9004                 :                :                 {
                               9005                 :          10232 :                     $$ = NULL;
                               9006                 :                :                 }
                               9007                 :                :         ;
                               9008                 :                : 
                               9009                 :                : routine_body_stmt_list:
                               9010                 :                :             routine_body_stmt_list routine_body_stmt ';'
                               9011                 :                :                 {
                               9012                 :                :                     /* As in stmtmulti, discard empty statements */
 1976 tgl@sss.pgh.pa.us        9013         [ +  + ]:            534 :                     if ($2 != NULL)
                               9014                 :            518 :                         $$ = lappend($1, $2);
                               9015                 :                :                     else
                               9016                 :             16 :                         $$ = $1;
                               9017                 :                :                 }
                               9018                 :                :             | /*EMPTY*/
                               9019                 :                :                 {
 2038 peter@eisentraut.org     9020                 :            519 :                     $$ = NIL;
                               9021                 :                :                 }
                               9022                 :                :         ;
                               9023                 :                : 
                               9024                 :                : routine_body_stmt:
                               9025                 :                :             stmt
                               9026                 :                :             | ReturnStmt
                               9027                 :                :         ;
                               9028                 :                : 
                               9029                 :                : transform_type_list:
 4211 peter_e@gmx.net          9030                 :             76 :             FOR TYPE_P Typename { $$ = list_make1($3); }
                               9031                 :              2 :             | transform_type_list ',' FOR TYPE_P Typename { $$ = lappend($1, $5); }
                               9032                 :                :         ;
                               9033                 :                : 
                               9034                 :                : opt_definition:
 8907 bruce@momjian.us         9035                 :            506 :             WITH definition                         { $$ = $2; }
                               9036                 :           6635 :             | /*EMPTY*/                             { $$ = NIL; }
                               9037                 :                :         ;
                               9038                 :                : 
                               9039                 :                : table_func_column:  param_name func_type
                               9040                 :                :                 {
 6684 tgl@sss.pgh.pa.us        9041                 :            333 :                     FunctionParameter *n = makeNode(FunctionParameter);
                               9042                 :                : 
                               9043                 :            333 :                     n->name = $1;
                               9044                 :            333 :                     n->argType = $2;
                               9045                 :            333 :                     n->mode = FUNC_PARAM_TABLE;
 6531                          9046                 :            333 :                     n->defexpr = NULL;
  735                          9047                 :            333 :                     n->location = @1;
 6684                          9048                 :            333 :                     $$ = n;
                               9049                 :                :                 }
                               9050                 :                :         ;
                               9051                 :                : 
                               9052                 :                : table_func_column_list:
                               9053                 :                :             table_func_column
                               9054                 :                :                 {
                               9055                 :            141 :                     $$ = list_make1($1);
                               9056                 :                :                 }
                               9057                 :                :             | table_func_column_list ',' table_func_column
                               9058                 :                :                 {
                               9059                 :            192 :                     $$ = lappend($1, $3);
                               9060                 :                :                 }
                               9061                 :                :         ;
                               9062                 :                : 
                               9063                 :                : /*****************************************************************************
                               9064                 :                :  * ALTER FUNCTION / ALTER PROCEDURE / ALTER ROUTINE
                               9065                 :                :  *
                               9066                 :                :  * RENAME and OWNER subcommands are already provided by the generic
                               9067                 :                :  * ALTER infrastructure, here we just specify alterations that can
                               9068                 :                :  * only be applied to functions.
                               9069                 :                :  *
                               9070                 :                :  *****************************************************************************/
                               9071                 :                : AlterFunctionStmt:
                               9072                 :                :             ALTER FUNCTION function_with_argtypes alterfunc_opt_list opt_restrict
                               9073                 :                :                 {
 7906 neilc@samurai.com        9074                 :            209 :                     AlterFunctionStmt *n = makeNode(AlterFunctionStmt);
                               9075                 :                : 
 3262 peter_e@gmx.net          9076                 :            209 :                     n->objtype = OBJECT_FUNCTION;
                               9077                 :            209 :                     n->func = $3;
                               9078                 :            209 :                     n->actions = $4;
                               9079                 :            209 :                     $$ = (Node *) n;
                               9080                 :                :                 }
                               9081                 :                :             | ALTER PROCEDURE function_with_argtypes alterfunc_opt_list opt_restrict
                               9082                 :                :                 {
                               9083                 :             12 :                     AlterFunctionStmt *n = makeNode(AlterFunctionStmt);
                               9084                 :                : 
                               9085                 :             12 :                     n->objtype = OBJECT_PROCEDURE;
                               9086                 :             12 :                     n->func = $3;
                               9087                 :             12 :                     n->actions = $4;
                               9088                 :             12 :                     $$ = (Node *) n;
                               9089                 :                :                 }
                               9090                 :                :             | ALTER ROUTINE function_with_argtypes alterfunc_opt_list opt_restrict
                               9091                 :                :                 {
 3262 peter_e@gmx.net          9092                 :UBC           0 :                     AlterFunctionStmt *n = makeNode(AlterFunctionStmt);
                               9093                 :                : 
                               9094                 :              0 :                     n->objtype = OBJECT_ROUTINE;
 7891 tgl@sss.pgh.pa.us        9095                 :              0 :                     n->func = $3;
 7906 neilc@samurai.com        9096                 :              0 :                     n->actions = $4;
                               9097                 :              0 :                     $$ = (Node *) n;
                               9098                 :                :                 }
                               9099                 :                :         ;
                               9100                 :                : 
                               9101                 :                : alterfunc_opt_list:
                               9102                 :                :             /* At least one option must be specified */
 7906 neilc@samurai.com        9103                 :CBC         221 :             common_func_opt_item                    { $$ = list_make1($1); }
                               9104                 :              2 :             | alterfunc_opt_list common_func_opt_item { $$ = lappend($1, $2); }
                               9105                 :                :         ;
                               9106                 :                : 
                               9107                 :                : /* Ignored, merely for SQL compliance */
                               9108                 :                : opt_restrict:
                               9109                 :                :             RESTRICT
                               9110                 :                :             | /* EMPTY */
                               9111                 :                :         ;
                               9112                 :                : 
                               9113                 :                : 
                               9114                 :                : /*****************************************************************************
                               9115                 :                :  *
                               9116                 :                :  *      QUERY:
                               9117                 :                :  *
                               9118                 :                :  *      DROP FUNCTION funcname (arg1, arg2, ...) [ RESTRICT | CASCADE ]
                               9119                 :                :  *      DROP PROCEDURE procname (arg1, arg2, ...) [ RESTRICT | CASCADE ]
                               9120                 :                :  *      DROP ROUTINE routname (arg1, arg2, ...) [ RESTRICT | CASCADE ]
                               9121                 :                :  *      DROP AGGREGATE aggname (arg1, ...) [ RESTRICT | CASCADE ]
                               9122                 :                :  *      DROP OPERATOR opname (leftoperand_typ, rightoperand_typ) [ RESTRICT | CASCADE ]
                               9123                 :                :  *
                               9124                 :                :  *****************************************************************************/
                               9125                 :                : 
                               9126                 :                : RemoveFuncStmt:
                               9127                 :                :             DROP FUNCTION function_with_argtypes_list opt_drop_behavior
                               9128                 :                :                 {
 5467 rhaas@postgresql.org     9129                 :           2225 :                     DropStmt *n = makeNode(DropStmt);
                               9130                 :                : 
                               9131                 :           2225 :                     n->removeType = OBJECT_FUNCTION;
 3599 peter_e@gmx.net          9132                 :           2225 :                     n->objects = $3;
 3703                          9133                 :           2225 :                     n->behavior = $4;
 7447 andrew@dunslane.net      9134                 :           2225 :                     n->missing_ok = false;
 5326 simon@2ndQuadrant.co     9135                 :           2225 :                     n->concurrent = false;
 1637 peter@eisentraut.org     9136                 :           2225 :                     $$ = (Node *) n;
                               9137                 :                :                 }
                               9138                 :                :             | DROP FUNCTION IF_P EXISTS function_with_argtypes_list opt_drop_behavior
                               9139                 :                :                 {
 5467 rhaas@postgresql.org     9140                 :            255 :                     DropStmt *n = makeNode(DropStmt);
                               9141                 :                : 
                               9142                 :            255 :                     n->removeType = OBJECT_FUNCTION;
 3599 peter_e@gmx.net          9143                 :            255 :                     n->objects = $5;
 3703                          9144                 :            255 :                     n->behavior = $6;
 7447 andrew@dunslane.net      9145                 :            255 :                     n->missing_ok = true;
 5326 simon@2ndQuadrant.co     9146                 :            255 :                     n->concurrent = false;
 1637 peter@eisentraut.org     9147                 :            255 :                     $$ = (Node *) n;
                               9148                 :                :                 }
                               9149                 :                :             | DROP PROCEDURE function_with_argtypes_list opt_drop_behavior
                               9150                 :                :                 {
 3262 peter_e@gmx.net          9151                 :             94 :                     DropStmt *n = makeNode(DropStmt);
                               9152                 :                : 
                               9153                 :             94 :                     n->removeType = OBJECT_PROCEDURE;
                               9154                 :             94 :                     n->objects = $3;
                               9155                 :             94 :                     n->behavior = $4;
                               9156                 :             94 :                     n->missing_ok = false;
                               9157                 :             94 :                     n->concurrent = false;
 1637 peter@eisentraut.org     9158                 :             94 :                     $$ = (Node *) n;
                               9159                 :                :                 }
                               9160                 :                :             | DROP PROCEDURE IF_P EXISTS function_with_argtypes_list opt_drop_behavior
                               9161                 :                :                 {
 3262 peter_e@gmx.net          9162                 :              4 :                     DropStmt *n = makeNode(DropStmt);
                               9163                 :                : 
                               9164                 :              4 :                     n->removeType = OBJECT_PROCEDURE;
                               9165                 :              4 :                     n->objects = $5;
                               9166                 :              4 :                     n->behavior = $6;
                               9167                 :              4 :                     n->missing_ok = true;
                               9168                 :              4 :                     n->concurrent = false;
 1637 peter@eisentraut.org     9169                 :              4 :                     $$ = (Node *) n;
                               9170                 :                :                 }
                               9171                 :                :             | DROP ROUTINE function_with_argtypes_list opt_drop_behavior
                               9172                 :                :                 {
 3262 peter_e@gmx.net          9173                 :              8 :                     DropStmt *n = makeNode(DropStmt);
                               9174                 :                : 
                               9175                 :              8 :                     n->removeType = OBJECT_ROUTINE;
                               9176                 :              8 :                     n->objects = $3;
                               9177                 :              8 :                     n->behavior = $4;
                               9178                 :              8 :                     n->missing_ok = false;
                               9179                 :              8 :                     n->concurrent = false;
 1637 peter@eisentraut.org     9180                 :              8 :                     $$ = (Node *) n;
                               9181                 :                :                 }
                               9182                 :                :             | DROP ROUTINE IF_P EXISTS function_with_argtypes_list opt_drop_behavior
                               9183                 :                :                 {
 3262 peter_e@gmx.net          9184                 :              4 :                     DropStmt *n = makeNode(DropStmt);
                               9185                 :                : 
                               9186                 :              4 :                     n->removeType = OBJECT_ROUTINE;
                               9187                 :              4 :                     n->objects = $5;
                               9188                 :              4 :                     n->behavior = $6;
                               9189                 :              4 :                     n->missing_ok = true;
                               9190                 :              4 :                     n->concurrent = false;
 1637 peter@eisentraut.org     9191                 :              4 :                     $$ = (Node *) n;
                               9192                 :                :                 }
                               9193                 :                :         ;
                               9194                 :                : 
                               9195                 :                : RemoveAggrStmt:
                               9196                 :                :             DROP AGGREGATE aggregate_with_argtypes_list opt_drop_behavior
                               9197                 :                :                 {
 5467 rhaas@postgresql.org     9198                 :             49 :                     DropStmt *n = makeNode(DropStmt);
                               9199                 :                : 
                               9200                 :             49 :                     n->removeType = OBJECT_AGGREGATE;
 3599 peter_e@gmx.net          9201                 :             49 :                     n->objects = $3;
 3703                          9202                 :             49 :                     n->behavior = $4;
 7447 andrew@dunslane.net      9203                 :             49 :                     n->missing_ok = false;
 5326 simon@2ndQuadrant.co     9204                 :             49 :                     n->concurrent = false;
 1637 peter@eisentraut.org     9205                 :             49 :                     $$ = (Node *) n;
                               9206                 :                :                 }
                               9207                 :                :             | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes_list opt_drop_behavior
                               9208                 :                :                 {
 5467 rhaas@postgresql.org     9209                 :             20 :                     DropStmt *n = makeNode(DropStmt);
                               9210                 :                : 
                               9211                 :             20 :                     n->removeType = OBJECT_AGGREGATE;
 3599 peter_e@gmx.net          9212                 :             20 :                     n->objects = $5;
 3703                          9213                 :             20 :                     n->behavior = $6;
 7447 andrew@dunslane.net      9214                 :             20 :                     n->missing_ok = true;
 5326 simon@2ndQuadrant.co     9215                 :             20 :                     n->concurrent = false;
 1637 peter@eisentraut.org     9216                 :             20 :                     $$ = (Node *) n;
                               9217                 :                :                 }
                               9218                 :                :         ;
                               9219                 :                : 
                               9220                 :                : RemoveOperStmt:
                               9221                 :                :             DROP OPERATOR operator_with_argtypes_list opt_drop_behavior
                               9222                 :                :                 {
 5467 rhaas@postgresql.org     9223                 :            124 :                     DropStmt *n = makeNode(DropStmt);
                               9224                 :                : 
                               9225                 :            124 :                     n->removeType = OBJECT_OPERATOR;
 3599 peter_e@gmx.net          9226                 :            124 :                     n->objects = $3;
                               9227                 :            124 :                     n->behavior = $4;
 7447 andrew@dunslane.net      9228                 :            124 :                     n->missing_ok = false;
 5326 simon@2ndQuadrant.co     9229                 :            124 :                     n->concurrent = false;
 1637 peter@eisentraut.org     9230                 :            124 :                     $$ = (Node *) n;
                               9231                 :                :                 }
                               9232                 :                :             | DROP OPERATOR IF_P EXISTS operator_with_argtypes_list opt_drop_behavior
                               9233                 :                :                 {
 5467 rhaas@postgresql.org     9234                 :             20 :                     DropStmt *n = makeNode(DropStmt);
                               9235                 :                : 
                               9236                 :             20 :                     n->removeType = OBJECT_OPERATOR;
 3599 peter_e@gmx.net          9237                 :             20 :                     n->objects = $5;
                               9238                 :             20 :                     n->behavior = $6;
 7447 andrew@dunslane.net      9239                 :             20 :                     n->missing_ok = true;
 5326 simon@2ndQuadrant.co     9240                 :             20 :                     n->concurrent = false;
 1637 peter@eisentraut.org     9241                 :             20 :                     $$ = (Node *) n;
                               9242                 :                :                 }
                               9243                 :                :         ;
                               9244                 :                : 
                               9245                 :                : oper_argtypes:
                               9246                 :                :             '(' Typename ')'
                               9247                 :                :                 {
 8510 tgl@sss.pgh.pa.us        9248         [ +  - ]:              8 :                    ereport(ERROR,
                               9249                 :                :                            (errcode(ERRCODE_SYNTAX_ERROR),
                               9250                 :                :                             errmsg("missing argument"),
                               9251                 :                :                             errhint("Use NONE to denote the missing argument of a unary operator."),
                               9252                 :                :                             parser_errposition(@3)));
                               9253                 :                :                 }
                               9254                 :                :             | '(' Typename ',' Typename ')'
 6639                          9255                 :           1331 :                     { $$ = list_make2($2, $4); }
                               9256                 :                :             | '(' NONE ',' Typename ')'                 /* left unary */
                               9257                 :             20 :                     { $$ = list_make2(NULL, $4); }
                               9258                 :                :             | '(' Typename ',' NONE ')'                 /* right unary */
                               9259                 :              8 :                     { $$ = list_make2($2, NULL); }
                               9260                 :                :         ;
                               9261                 :                : 
                               9262                 :                : any_operator:
                               9263                 :                :             all_Op
 8194 neilc@samurai.com        9264                 :          13492 :                     { $$ = list_make1(makeString($1)); }
                               9265                 :                :             | ColId '.' any_operator
 8906 bruce@momjian.us         9266                 :           9907 :                     { $$ = lcons(makeString($1), $3); }
                               9267                 :                :         ;
                               9268                 :                : 
                               9269                 :                : operator_with_argtypes_list:
 3599 peter_e@gmx.net          9270                 :            144 :             operator_with_argtypes                  { $$ = list_make1($1); }
                               9271                 :                :             | operator_with_argtypes_list ',' operator_with_argtypes
 3599 peter_e@gmx.net          9272                 :UBC           0 :                                                     { $$ = lappend($1, $3); }
                               9273                 :                :         ;
                               9274                 :                : 
                               9275                 :                : operator_with_argtypes:
                               9276                 :                :             any_operator oper_argtypes
                               9277                 :                :                 {
 3599 peter_e@gmx.net          9278                 :CBC        1359 :                     ObjectWithArgs *n = makeNode(ObjectWithArgs);
                               9279                 :                : 
                               9280                 :           1359 :                     n->objname = $1;
                               9281                 :           1359 :                     n->objargs = $2;
                               9282                 :           1359 :                     $$ = n;
                               9283                 :                :                 }
                               9284                 :                :         ;
                               9285                 :                : 
                               9286                 :                : /*****************************************************************************
                               9287                 :                :  *
                               9288                 :                :  *      DO <anonymous code block> [ LANGUAGE language ]
                               9289                 :                :  *
                               9290                 :                :  * We use a DefElem list for future extensibility, and to allow flexibility
                               9291                 :                :  * in the clause order.
                               9292                 :                :  *
                               9293                 :                :  *****************************************************************************/
                               9294                 :                : 
                               9295                 :                : DoStmt: DO dostmt_opt_list
                               9296                 :                :                 {
 6253 tgl@sss.pgh.pa.us        9297                 :            715 :                     DoStmt *n = makeNode(DoStmt);
                               9298                 :                : 
                               9299                 :            715 :                     n->args = $2;
 1637 peter@eisentraut.org     9300                 :            715 :                     $$ = (Node *) n;
                               9301                 :                :                 }
                               9302                 :                :         ;
                               9303                 :                : 
                               9304                 :                : dostmt_opt_list:
 6253 tgl@sss.pgh.pa.us        9305                 :            715 :             dostmt_opt_item                     { $$ = list_make1($1); }
                               9306                 :            103 :             | dostmt_opt_list dostmt_opt_item   { $$ = lappend($1, $2); }
                               9307                 :                :         ;
                               9308                 :                : 
                               9309                 :                : dostmt_opt_item:
                               9310                 :                :             Sconst
                               9311                 :                :                 {
 1637 peter@eisentraut.org     9312                 :            715 :                     $$ = makeDefElem("as", (Node *) makeString($1), @1);
                               9313                 :                :                 }
                               9314                 :                :             | LANGUAGE NonReservedWord_or_Sconst
                               9315                 :                :                 {
                               9316                 :            103 :                     $$ = makeDefElem("language", (Node *) makeString($2), @1);
                               9317                 :                :                 }
                               9318                 :                :         ;
                               9319                 :                : 
                               9320                 :                : /*****************************************************************************
                               9321                 :                :  *
                               9322                 :                :  *      CREATE CAST / DROP CAST
                               9323                 :                :  *
                               9324                 :                :  *****************************************************************************/
                               9325                 :                : 
                               9326                 :                : CreateCastStmt: CREATE CAST '(' Typename AS Typename ')'
                               9327                 :                :                     WITH FUNCTION function_with_argtypes cast_context
                               9328                 :                :                 {
 8876 peter_e@gmx.net          9329                 :             94 :                     CreateCastStmt *n = makeNode(CreateCastStmt);
                               9330                 :                : 
                               9331                 :             94 :                     n->sourcetype = $4;
                               9332                 :             94 :                     n->targettype = $6;
 7891 tgl@sss.pgh.pa.us        9333                 :             94 :                     n->func = $10;
 8814                          9334                 :             94 :                     n->context = (CoercionContext) $11;
 6579 heikki.linnakangas@i     9335                 :             94 :                     n->inout = false;
 1637 peter@eisentraut.org     9336                 :             94 :                     $$ = (Node *) n;
                               9337                 :                :                 }
                               9338                 :                :             | CREATE CAST '(' Typename AS Typename ')'
                               9339                 :                :                     WITHOUT FUNCTION cast_context
                               9340                 :                :                 {
 8876 peter_e@gmx.net          9341                 :            101 :                     CreateCastStmt *n = makeNode(CreateCastStmt);
                               9342                 :                : 
                               9343                 :            101 :                     n->sourcetype = $4;
                               9344                 :            101 :                     n->targettype = $6;
                               9345                 :            101 :                     n->func = NULL;
 8814 tgl@sss.pgh.pa.us        9346                 :            101 :                     n->context = (CoercionContext) $10;
 6579 heikki.linnakangas@i     9347                 :            101 :                     n->inout = false;
 1637 peter@eisentraut.org     9348                 :            101 :                     $$ = (Node *) n;
                               9349                 :                :                 }
                               9350                 :                :             | CREATE CAST '(' Typename AS Typename ')'
                               9351                 :                :                     WITH INOUT cast_context
                               9352                 :                :                 {
 6579 heikki.linnakangas@i     9353                 :              9 :                     CreateCastStmt *n = makeNode(CreateCastStmt);
                               9354                 :                : 
                               9355                 :              9 :                     n->sourcetype = $4;
                               9356                 :              9 :                     n->targettype = $6;
                               9357                 :              9 :                     n->func = NULL;
                               9358                 :              9 :                     n->context = (CoercionContext) $10;
                               9359                 :              9 :                     n->inout = true;
 1637 peter@eisentraut.org     9360                 :              9 :                     $$ = (Node *) n;
                               9361                 :                :                 }
                               9362                 :                :         ;
                               9363                 :                : 
 8814 tgl@sss.pgh.pa.us        9364                 :             63 : cast_context:  AS IMPLICIT_P                    { $$ = COERCION_IMPLICIT; }
                               9365                 :             30 :         | AS ASSIGNMENT                         { $$ = COERCION_ASSIGNMENT; }
                               9366                 :            111 :         | /*EMPTY*/                             { $$ = COERCION_EXPLICIT; }
                               9367                 :                :         ;
                               9368                 :                : 
                               9369                 :                : 
                               9370                 :                : DropCastStmt: DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_behavior
                               9371                 :                :                 {
 5467 rhaas@postgresql.org     9372                 :             58 :                     DropStmt *n = makeNode(DropStmt);
                               9373                 :                : 
                               9374                 :             58 :                     n->removeType = OBJECT_CAST;
 3645 peter_e@gmx.net          9375                 :             58 :                     n->objects = list_make1(list_make2($5, $7));
 7447 andrew@dunslane.net      9376                 :             58 :                     n->behavior = $9;
      tgl@sss.pgh.pa.us        9377                 :             58 :                     n->missing_ok = $3;
 5326 simon@2ndQuadrant.co     9378                 :             58 :                     n->concurrent = false;
 1637 peter@eisentraut.org     9379                 :             58 :                     $$ = (Node *) n;
                               9380                 :                :                 }
                               9381                 :                :         ;
                               9382                 :                : 
 3368 peter_e@gmx.net          9383                 :             23 : opt_if_exists: IF_P EXISTS                      { $$ = true; }
                               9384                 :             42 :         | /*EMPTY*/                             { $$ = false; }
                               9385                 :                :         ;
                               9386                 :                : 
                               9387                 :                : 
                               9388                 :                : /*****************************************************************************
                               9389                 :                :  *
                               9390                 :                :  *      CREATE TRANSFORM / DROP TRANSFORM
                               9391                 :                :  *
                               9392                 :                :  *****************************************************************************/
                               9393                 :                : 
                               9394                 :                : CreateTransformStmt: CREATE opt_or_replace TRANSFORM FOR Typename LANGUAGE name '(' transform_element_list ')'
                               9395                 :                :                 {
 4211                          9396                 :             26 :                     CreateTransformStmt *n = makeNode(CreateTransformStmt);
                               9397                 :                : 
                               9398                 :             26 :                     n->replace = $2;
                               9399                 :             26 :                     n->type_name = $5;
                               9400                 :             26 :                     n->lang = $7;
                               9401                 :             26 :                     n->fromsql = linitial($9);
                               9402                 :             26 :                     n->tosql = lsecond($9);
 1637 peter@eisentraut.org     9403                 :             26 :                     $$ = (Node *) n;
                               9404                 :                :                 }
                               9405                 :                :         ;
                               9406                 :                : 
                               9407                 :                : transform_element_list: FROM SQL_P WITH FUNCTION function_with_argtypes ',' TO SQL_P WITH FUNCTION function_with_argtypes
                               9408                 :                :                 {
 4211 peter_e@gmx.net          9409                 :             23 :                     $$ = list_make2($5, $11);
                               9410                 :                :                 }
                               9411                 :                :                 | TO SQL_P WITH FUNCTION function_with_argtypes ',' FROM SQL_P WITH FUNCTION function_with_argtypes
                               9412                 :                :                 {
 4211 peter_e@gmx.net          9413                 :UBC           0 :                     $$ = list_make2($11, $5);
                               9414                 :                :                 }
                               9415                 :                :                 | FROM SQL_P WITH FUNCTION function_with_argtypes
                               9416                 :                :                 {
 4211 peter_e@gmx.net          9417                 :CBC           2 :                     $$ = list_make2($5, NULL);
                               9418                 :                :                 }
                               9419                 :                :                 | TO SQL_P WITH FUNCTION function_with_argtypes
                               9420                 :                :                 {
                               9421                 :              1 :                     $$ = list_make2(NULL, $5);
                               9422                 :                :                 }
                               9423                 :                :         ;
                               9424                 :                : 
                               9425                 :                : 
                               9426                 :                : DropTransformStmt: DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_drop_behavior
                               9427                 :                :                 {
                               9428                 :              7 :                     DropStmt *n = makeNode(DropStmt);
                               9429                 :                : 
                               9430                 :              7 :                     n->removeType = OBJECT_TRANSFORM;
 3645                          9431                 :              7 :                     n->objects = list_make1(list_make2($5, makeString($7)));
 4211                          9432                 :              7 :                     n->behavior = $8;
                               9433                 :              7 :                     n->missing_ok = $3;
 1637 peter@eisentraut.org     9434                 :              7 :                     $$ = (Node *) n;
                               9435                 :                :                 }
                               9436                 :                :         ;
                               9437                 :                : 
                               9438                 :                : 
                               9439                 :                : /*****************************************************************************
                               9440                 :                :  *
                               9441                 :                :  *      QUERY:
                               9442                 :                :  *
                               9443                 :                :  *      REINDEX [ (options) ] {INDEX | TABLE | SCHEMA} [CONCURRENTLY] <name>
                               9444                 :                :  *      REINDEX [ (options) ] {DATABASE | SYSTEM} [CONCURRENTLY] [<name>]
                               9445                 :                :  *****************************************************************************/
                               9446                 :                : 
                               9447                 :                : ReindexStmt:
                               9448                 :                :             REINDEX opt_utility_option_list reindex_target_relation opt_concurrently qualified_name
                               9449                 :                :                 {
 9757 inoue@tpf.co.jp          9450                 :            605 :                     ReindexStmt *n = makeNode(ReindexStmt);
                               9451                 :                : 
 1567 alvherre@alvh.no-ip.     9452                 :            605 :                     n->kind = $3;
                               9453                 :            605 :                     n->relation = $5;
 8995 tgl@sss.pgh.pa.us        9454                 :            605 :                     n->name = NULL;
 1567 alvherre@alvh.no-ip.     9455                 :            605 :                     n->params = $2;
                               9456         [ +  + ]:            605 :                     if ($4)
 2163 michael@paquier.xyz      9457                 :            347 :                         n->params = lappend(n->params,
 1567 alvherre@alvh.no-ip.     9458                 :            347 :                                             makeDefElem("concurrently", NULL, @4));
 1637 peter@eisentraut.org     9459                 :            605 :                     $$ = (Node *) n;
                               9460                 :                :                 }
                               9461                 :                :             | REINDEX opt_utility_option_list SCHEMA opt_concurrently name
                               9462                 :                :                 {
 4349 simon@2ndQuadrant.co     9463                 :             75 :                     ReindexStmt *n = makeNode(ReindexStmt);
                               9464                 :                : 
 1567 alvherre@alvh.no-ip.     9465                 :             75 :                     n->kind = REINDEX_OBJECT_SCHEMA;
 4349 simon@2ndQuadrant.co     9466                 :             75 :                     n->relation = NULL;
 1563 michael@paquier.xyz      9467                 :             75 :                     n->name = $5;
 1567 alvherre@alvh.no-ip.     9468                 :             75 :                     n->params = $2;
                               9469         [ +  + ]:             75 :                     if ($4)
 2163 michael@paquier.xyz      9470                 :             26 :                         n->params = lappend(n->params,
 1567 alvherre@alvh.no-ip.     9471                 :             26 :                                             makeDefElem("concurrently", NULL, @4));
 1637 peter@eisentraut.org     9472                 :             75 :                     $$ = (Node *) n;
                               9473                 :                :                 }
                               9474                 :                :             | REINDEX opt_utility_option_list reindex_target_all opt_concurrently opt_single_name
                               9475                 :                :                 {
 8995 tgl@sss.pgh.pa.us        9476                 :             37 :                     ReindexStmt *n = makeNode(ReindexStmt);
                               9477                 :                : 
 1563 michael@paquier.xyz      9478                 :             37 :                     n->kind = $3;
 8995 tgl@sss.pgh.pa.us        9479                 :             37 :                     n->relation = NULL;
 1563 michael@paquier.xyz      9480                 :             37 :                     n->name = $5;
 1567 alvherre@alvh.no-ip.     9481                 :             37 :                     n->params = $2;
 1563 michael@paquier.xyz      9482         [ +  + ]:             37 :                     if ($4)
                               9483                 :              6 :                         n->params = lappend(n->params,
                               9484                 :              6 :                                             makeDefElem("concurrently", NULL, @4));
 1637 peter@eisentraut.org     9485                 :             37 :                     $$ = (Node *) n;
                               9486                 :                :                 }
                               9487                 :                :         ;
                               9488                 :                : reindex_target_relation:
 4192 fujii@postgresql.org     9489                 :            276 :             INDEX                   { $$ = REINDEX_OBJECT_INDEX; }
                               9490                 :            329 :             | TABLE                 { $$ = REINDEX_OBJECT_TABLE; }
                               9491                 :                :         ;
                               9492                 :                : reindex_target_all:
 1563 michael@paquier.xyz      9493                 :             20 :             SYSTEM_P                { $$ = REINDEX_OBJECT_SYSTEM; }
                               9494                 :             17 :             | DATABASE              { $$ = REINDEX_OBJECT_DATABASE; }
                               9495                 :                :         ;
                               9496                 :                : 
                               9497                 :                : /*****************************************************************************
                               9498                 :                :  *
                               9499                 :                :  * ALTER TABLESPACE
                               9500                 :                :  *
                               9501                 :                :  *****************************************************************************/
                               9502                 :                : 
                               9503                 :                : AlterTblSpcStmt:
                               9504                 :                :             ALTER TABLESPACE name SET reloptions
                               9505                 :                :                 {
                               9506                 :                :                     AlterTableSpaceOptionsStmt *n =
 4589 sfrost@snowman.net       9507                 :             11 :                         makeNode(AlterTableSpaceOptionsStmt);
                               9508                 :                : 
                               9509                 :             11 :                     n->tablespacename = $3;
                               9510                 :             11 :                     n->options = $5;
 3368 peter_e@gmx.net          9511                 :             11 :                     n->isReset = false;
 1637 peter@eisentraut.org     9512                 :             11 :                     $$ = (Node *) n;
                               9513                 :                :                 }
                               9514                 :                :             | ALTER TABLESPACE name RESET reloptions
                               9515                 :                :                 {
                               9516                 :                :                     AlterTableSpaceOptionsStmt *n =
 4589 sfrost@snowman.net       9517                 :              8 :                         makeNode(AlterTableSpaceOptionsStmt);
                               9518                 :                : 
                               9519                 :              8 :                     n->tablespacename = $3;
                               9520                 :              8 :                     n->options = $5;
 3368 peter_e@gmx.net          9521                 :              8 :                     n->isReset = true;
 1637 peter@eisentraut.org     9522                 :              8 :                     $$ = (Node *) n;
                               9523                 :                :                 }
                               9524                 :                :         ;
                               9525                 :                : 
                               9526                 :                : /*****************************************************************************
                               9527                 :                :  *
                               9528                 :                :  * ALTER THING name RENAME TO newname
                               9529                 :                :  *
                               9530                 :                :  *****************************************************************************/
                               9531                 :                : 
                               9532                 :                : RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
                               9533                 :                :                 {
 8532 peter_e@gmx.net          9534                 :             28 :                     RenameStmt *n = makeNode(RenameStmt);
                               9535                 :                : 
                               9536                 :             28 :                     n->renameType = OBJECT_AGGREGATE;
 3645                          9537                 :             28 :                     n->object = (Node *) $3;
 3703                          9538                 :             28 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9539                 :             28 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9540                 :             28 :                     $$ = (Node *) n;
                               9541                 :                :                 }
                               9542                 :                :             | ALTER COLLATION any_name RENAME TO name
                               9543                 :                :                 {
 5745 peter_e@gmx.net          9544                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                               9545                 :                : 
                               9546                 :             12 :                     n->renameType = OBJECT_COLLATION;
 3645                          9547                 :             12 :                     n->object = (Node *) $3;
 5745                          9548                 :             12 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9549                 :             12 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9550                 :             12 :                     $$ = (Node *) n;
                               9551                 :                :                 }
                               9552                 :                :             | ALTER CONVERSION_P any_name RENAME TO name
                               9553                 :                :                 {
 8532 peter_e@gmx.net          9554                 :             16 :                     RenameStmt *n = makeNode(RenameStmt);
                               9555                 :                : 
                               9556                 :             16 :                     n->renameType = OBJECT_CONVERSION;
 3645                          9557                 :             16 :                     n->object = (Node *) $3;
 8532                          9558                 :             16 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9559                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9560                 :             16 :                     $$ = (Node *) n;
                               9561                 :                :                 }
                               9562                 :                :             | ALTER DATABASE name RENAME TO name
                               9563                 :                :                 {
 8532 peter_e@gmx.net          9564                 :              9 :                     RenameStmt *n = makeNode(RenameStmt);
                               9565                 :                : 
                               9566                 :              9 :                     n->renameType = OBJECT_DATABASE;
                               9567                 :              9 :                     n->subname = $3;
                               9568                 :              9 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9569                 :              9 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9570                 :              9 :                     $$ = (Node *) n;
                               9571                 :                :                 }
                               9572                 :                :             | ALTER DOMAIN_P any_name RENAME TO name
                               9573                 :                :                 {
 5432 peter_e@gmx.net          9574                 :              4 :                     RenameStmt *n = makeNode(RenameStmt);
                               9575                 :                : 
                               9576                 :              4 :                     n->renameType = OBJECT_DOMAIN;
 3645                          9577                 :              4 :                     n->object = (Node *) $3;
 5432                          9578                 :              4 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9579                 :              4 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9580                 :              4 :                     $$ = (Node *) n;
                               9581                 :                :                 }
                               9582                 :                :             | ALTER DOMAIN_P any_name RENAME CONSTRAINT name TO name
                               9583                 :                :                 {
 5329 peter_e@gmx.net          9584                 :              4 :                     RenameStmt *n = makeNode(RenameStmt);
                               9585                 :                : 
 4335 alvherre@alvh.no-ip.     9586                 :              4 :                     n->renameType = OBJECT_DOMCONSTRAINT;
 3645 peter_e@gmx.net          9587                 :              4 :                     n->object = (Node *) $3;
 5329                          9588                 :              4 :                     n->subname = $6;
                               9589                 :              4 :                     n->newname = $8;
 1637 peter@eisentraut.org     9590                 :              4 :                     $$ = (Node *) n;
                               9591                 :                :                 }
                               9592                 :                :             | ALTER FOREIGN DATA_P WRAPPER name RENAME TO name
                               9593                 :                :                 {
 5445 peter_e@gmx.net          9594                 :             16 :                     RenameStmt *n = makeNode(RenameStmt);
                               9595                 :                : 
                               9596                 :             16 :                     n->renameType = OBJECT_FDW;
 3645                          9597                 :             16 :                     n->object = (Node *) makeString($5);
 5445                          9598                 :             16 :                     n->newname = $8;
 5400 simon@2ndQuadrant.co     9599                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9600                 :             16 :                     $$ = (Node *) n;
                               9601                 :                :                 }
                               9602                 :                :             | ALTER FUNCTION function_with_argtypes RENAME TO name
                               9603                 :                :                 {
 8532 peter_e@gmx.net          9604                 :             16 :                     RenameStmt *n = makeNode(RenameStmt);
                               9605                 :                : 
                               9606                 :             16 :                     n->renameType = OBJECT_FUNCTION;
 3645                          9607                 :             16 :                     n->object = (Node *) $3;
 7003 tgl@sss.pgh.pa.us        9608                 :             16 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9609                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9610                 :             16 :                     $$ = (Node *) n;
                               9611                 :                :                 }
                               9612                 :                :             | ALTER GROUP_P RoleId RENAME TO RoleId
                               9613                 :                :                 {
 8532 peter_e@gmx.net          9614                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9615                 :                : 
 7800 tgl@sss.pgh.pa.us        9616                 :              0 :                     n->renameType = OBJECT_ROLE;
 8532 peter_e@gmx.net          9617                 :              0 :                     n->subname = $3;
                               9618                 :              0 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9619                 :              0 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9620                 :              0 :                     $$ = (Node *) n;
                               9621                 :                :                 }
                               9622                 :                :             | ALTER opt_procedural LANGUAGE name RENAME TO name
                               9623                 :                :                 {
 8532 peter_e@gmx.net          9624                 :CBC          12 :                     RenameStmt *n = makeNode(RenameStmt);
                               9625                 :                : 
                               9626                 :             12 :                     n->renameType = OBJECT_LANGUAGE;
 3645                          9627                 :             12 :                     n->object = (Node *) makeString($4);
 7164 tgl@sss.pgh.pa.us        9628                 :             12 :                     n->newname = $7;
 5400 simon@2ndQuadrant.co     9629                 :             12 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9630                 :             12 :                     $$ = (Node *) n;
                               9631                 :                :                 }
                               9632                 :                :             | ALTER OPERATOR CLASS any_name USING name RENAME TO name
                               9633                 :                :                 {
 8532 peter_e@gmx.net          9634                 :             16 :                     RenameStmt *n = makeNode(RenameStmt);
                               9635                 :                : 
                               9636                 :             16 :                     n->renameType = OBJECT_OPCLASS;
 3645                          9637                 :             16 :                     n->object = (Node *) lcons(makeString($6), $4);
 8532                          9638                 :             16 :                     n->newname = $9;
 5400 simon@2ndQuadrant.co     9639                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9640                 :             16 :                     $$ = (Node *) n;
                               9641                 :                :                 }
                               9642                 :                :             | ALTER OPERATOR FAMILY any_name USING name RENAME TO name
                               9643                 :                :                 {
 7226 tgl@sss.pgh.pa.us        9644                 :             16 :                     RenameStmt *n = makeNode(RenameStmt);
                               9645                 :                : 
                               9646                 :             16 :                     n->renameType = OBJECT_OPFAMILY;
 3645 peter_e@gmx.net          9647                 :             16 :                     n->object = (Node *) lcons(makeString($6), $4);
 7226 tgl@sss.pgh.pa.us        9648                 :             16 :                     n->newname = $9;
 5400 simon@2ndQuadrant.co     9649                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9650                 :             16 :                     $$ = (Node *) n;
                               9651                 :                :                 }
                               9652                 :                :             | ALTER POLICY name ON qualified_name RENAME TO name
                               9653                 :                :                 {
 4430 sfrost@snowman.net       9654                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                               9655                 :                : 
                               9656                 :             12 :                     n->renameType = OBJECT_POLICY;
                               9657                 :             12 :                     n->relation = $5;
                               9658                 :             12 :                     n->subname = $3;
                               9659                 :             12 :                     n->newname = $8;
                               9660                 :             12 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9661                 :             12 :                     $$ = (Node *) n;
                               9662                 :                :                 }
                               9663                 :                :             | ALTER POLICY IF_P EXISTS name ON qualified_name RENAME TO name
                               9664                 :                :                 {
 4430 sfrost@snowman.net       9665                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9666                 :                : 
                               9667                 :              0 :                     n->renameType = OBJECT_POLICY;
                               9668                 :              0 :                     n->relation = $7;
                               9669                 :              0 :                     n->subname = $5;
                               9670                 :              0 :                     n->newname = $10;
                               9671                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     9672                 :              0 :                     $$ = (Node *) n;
                               9673                 :                :                 }
                               9674                 :                :             | ALTER PROCEDURE function_with_argtypes RENAME TO name
                               9675                 :                :                 {
 3262 peter_e@gmx.net          9676                 :              0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9677                 :                : 
                               9678                 :              0 :                     n->renameType = OBJECT_PROCEDURE;
                               9679                 :              0 :                     n->object = (Node *) $3;
                               9680                 :              0 :                     n->newname = $6;
                               9681                 :              0 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9682                 :              0 :                     $$ = (Node *) n;
                               9683                 :                :                 }
                               9684                 :                :             | ALTER PUBLICATION name RENAME TO name
                               9685                 :                :                 {
 3534 peter_e@gmx.net          9686                 :CBC          24 :                     RenameStmt *n = makeNode(RenameStmt);
                               9687                 :                : 
                               9688                 :             24 :                     n->renameType = OBJECT_PUBLICATION;
 3645                          9689                 :             24 :                     n->object = (Node *) makeString($3);
 3534                          9690                 :             24 :                     n->newname = $6;
                               9691                 :             24 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9692                 :             24 :                     $$ = (Node *) n;
                               9693                 :                :                 }
                               9694                 :                :             | ALTER ROUTINE function_with_argtypes RENAME TO name
                               9695                 :                :                 {
 3262 peter_e@gmx.net          9696                 :             16 :                     RenameStmt *n = makeNode(RenameStmt);
                               9697                 :                : 
                               9698                 :             16 :                     n->renameType = OBJECT_ROUTINE;
                               9699                 :             16 :                     n->object = (Node *) $3;
                               9700                 :             16 :                     n->newname = $6;
                               9701                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9702                 :             16 :                     $$ = (Node *) n;
                               9703                 :                :                 }
                               9704                 :                :             | ALTER SCHEMA name RENAME TO name
                               9705                 :                :                 {
 8532 peter_e@gmx.net          9706                 :             13 :                     RenameStmt *n = makeNode(RenameStmt);
                               9707                 :                : 
                               9708                 :             13 :                     n->renameType = OBJECT_SCHEMA;
                               9709                 :             13 :                     n->subname = $3;
                               9710                 :             13 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9711                 :             13 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9712                 :             13 :                     $$ = (Node *) n;
                               9713                 :                :                 }
                               9714                 :                :             | ALTER SERVER name RENAME TO name
                               9715                 :                :                 {
 5445 peter_e@gmx.net          9716                 :             16 :                     RenameStmt *n = makeNode(RenameStmt);
                               9717                 :                : 
                               9718                 :             16 :                     n->renameType = OBJECT_FOREIGN_SERVER;
 3645                          9719                 :             16 :                     n->object = (Node *) makeString($3);
 5445                          9720                 :             16 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9721                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9722                 :             16 :                     $$ = (Node *) n;
                               9723                 :                :                 }
                               9724                 :                :             | ALTER SUBSCRIPTION name RENAME TO name
                               9725                 :                :                 {
 3534 peter_e@gmx.net          9726                 :             25 :                     RenameStmt *n = makeNode(RenameStmt);
                               9727                 :                : 
                               9728                 :             25 :                     n->renameType = OBJECT_SUBSCRIPTION;
 3645                          9729                 :             25 :                     n->object = (Node *) makeString($3);
 3534                          9730                 :             25 :                     n->newname = $6;
                               9731                 :             25 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9732                 :             25 :                     $$ = (Node *) n;
                               9733                 :                :                 }
                               9734                 :                :             | ALTER TABLE relation_expr RENAME TO name
                               9735                 :                :                 {
10650 bruce@momjian.us         9736                 :            174 :                     RenameStmt *n = makeNode(RenameStmt);
                               9737                 :                : 
 8219 tgl@sss.pgh.pa.us        9738                 :            174 :                     n->renameType = OBJECT_TABLE;
                               9739                 :            174 :                     n->relation = $3;
                               9740                 :            174 :                     n->subname = NULL;
                               9741                 :            174 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9742                 :            174 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9743                 :            174 :                     $$ = (Node *) n;
                               9744                 :                :                 }
                               9745                 :                :             | ALTER TABLE IF_P EXISTS relation_expr RENAME TO name
                               9746                 :                :                 {
 5400 simon@2ndQuadrant.co     9747                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9748                 :                : 
                               9749                 :              0 :                     n->renameType = OBJECT_TABLE;
                               9750                 :              0 :                     n->relation = $5;
                               9751                 :              0 :                     n->subname = NULL;
                               9752                 :              0 :                     n->newname = $8;
                               9753                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     9754                 :              0 :                     $$ = (Node *) n;
                               9755                 :                :                 }
                               9756                 :                :             | ALTER SEQUENCE qualified_name RENAME TO name
                               9757                 :                :                 {
 7065 neilc@samurai.com        9758                 :CBC           1 :                     RenameStmt *n = makeNode(RenameStmt);
                               9759                 :                : 
                               9760                 :              1 :                     n->renameType = OBJECT_SEQUENCE;
                               9761                 :              1 :                     n->relation = $3;
                               9762                 :              1 :                     n->subname = NULL;
                               9763                 :              1 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9764                 :              1 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9765                 :              1 :                     $$ = (Node *) n;
                               9766                 :                :                 }
                               9767                 :                :             | ALTER SEQUENCE IF_P EXISTS qualified_name RENAME TO name
                               9768                 :                :                 {
 5400 simon@2ndQuadrant.co     9769                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9770                 :                : 
                               9771                 :              0 :                     n->renameType = OBJECT_SEQUENCE;
                               9772                 :              0 :                     n->relation = $5;
                               9773                 :              0 :                     n->subname = NULL;
                               9774                 :              0 :                     n->newname = $8;
                               9775                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     9776                 :              0 :                     $$ = (Node *) n;
                               9777                 :                :                 }
                               9778                 :                :             | ALTER VIEW qualified_name RENAME TO name
                               9779                 :                :                 {
 7065 neilc@samurai.com        9780                 :CBC           4 :                     RenameStmt *n = makeNode(RenameStmt);
                               9781                 :                : 
                               9782                 :              4 :                     n->renameType = OBJECT_VIEW;
                               9783                 :              4 :                     n->relation = $3;
                               9784                 :              4 :                     n->subname = NULL;
                               9785                 :              4 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9786                 :              4 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9787                 :              4 :                     $$ = (Node *) n;
                               9788                 :                :                 }
                               9789                 :                :             | ALTER VIEW IF_P EXISTS qualified_name RENAME TO name
                               9790                 :                :                 {
 5400 simon@2ndQuadrant.co     9791                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9792                 :                : 
                               9793                 :              0 :                     n->renameType = OBJECT_VIEW;
                               9794                 :              0 :                     n->relation = $5;
                               9795                 :              0 :                     n->subname = NULL;
                               9796                 :              0 :                     n->newname = $8;
                               9797                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     9798                 :              0 :                     $$ = (Node *) n;
                               9799                 :                :                 }
                               9800                 :                :             | ALTER MATERIALIZED VIEW qualified_name RENAME TO name
                               9801                 :                :                 {
 4995 kgrittn@postgresql.o     9802                 :              0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9803                 :                : 
                               9804                 :              0 :                     n->renameType = OBJECT_MATVIEW;
                               9805                 :              0 :                     n->relation = $4;
                               9806                 :              0 :                     n->subname = NULL;
                               9807                 :              0 :                     n->newname = $7;
                               9808                 :              0 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9809                 :              0 :                     $$ = (Node *) n;
                               9810                 :                :                 }
                               9811                 :                :             | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME TO name
                               9812                 :                :                 {
 4995 kgrittn@postgresql.o     9813                 :              0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9814                 :                : 
                               9815                 :              0 :                     n->renameType = OBJECT_MATVIEW;
                               9816                 :              0 :                     n->relation = $6;
                               9817                 :              0 :                     n->subname = NULL;
                               9818                 :              0 :                     n->newname = $9;
                               9819                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     9820                 :              0 :                     $$ = (Node *) n;
                               9821                 :                :                 }
                               9822                 :                :             | ALTER INDEX qualified_name RENAME TO name
                               9823                 :                :                 {
 8112 bruce@momjian.us         9824                 :CBC         108 :                     RenameStmt *n = makeNode(RenameStmt);
                               9825                 :                : 
                               9826                 :            108 :                     n->renameType = OBJECT_INDEX;
                               9827                 :            108 :                     n->relation = $3;
                               9828                 :            108 :                     n->subname = NULL;
                               9829                 :            108 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co     9830                 :            108 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9831                 :            108 :                     $$ = (Node *) n;
                               9832                 :                :                 }
                               9833                 :                :             | ALTER INDEX IF_P EXISTS qualified_name RENAME TO name
                               9834                 :                :                 {
 5400 simon@2ndQuadrant.co     9835                 :              8 :                     RenameStmt *n = makeNode(RenameStmt);
                               9836                 :                : 
                               9837                 :              8 :                     n->renameType = OBJECT_INDEX;
                               9838                 :              8 :                     n->relation = $5;
                               9839                 :              8 :                     n->subname = NULL;
                               9840                 :              8 :                     n->newname = $8;
                               9841                 :              8 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     9842                 :              8 :                     $$ = (Node *) n;
                               9843                 :                :                 }
                               9844                 :                :             | ALTER FOREIGN TABLE relation_expr RENAME TO name
                               9845                 :                :                 {
 5787 rhaas@postgresql.org     9846                 :              4 :                     RenameStmt *n = makeNode(RenameStmt);
                               9847                 :                : 
                               9848                 :              4 :                     n->renameType = OBJECT_FOREIGN_TABLE;
                               9849                 :              4 :                     n->relation = $4;
                               9850                 :              4 :                     n->subname = NULL;
                               9851                 :              4 :                     n->newname = $7;
 5400 simon@2ndQuadrant.co     9852                 :              4 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9853                 :              4 :                     $$ = (Node *) n;
                               9854                 :                :                 }
                               9855                 :                :             | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME TO name
                               9856                 :                :                 {
 5400 simon@2ndQuadrant.co     9857                 :              4 :                     RenameStmt *n = makeNode(RenameStmt);
                               9858                 :                : 
                               9859                 :              4 :                     n->renameType = OBJECT_FOREIGN_TABLE;
                               9860                 :              4 :                     n->relation = $6;
                               9861                 :              4 :                     n->subname = NULL;
                               9862                 :              4 :                     n->newname = $9;
                               9863                 :              4 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     9864                 :              4 :                     $$ = (Node *) n;
                               9865                 :                :                 }
                               9866                 :                :             | ALTER TABLE relation_expr RENAME opt_column name TO name
                               9867                 :                :                 {
 8219 tgl@sss.pgh.pa.us        9868                 :            161 :                     RenameStmt *n = makeNode(RenameStmt);
                               9869                 :                : 
                               9870                 :            161 :                     n->renameType = OBJECT_COLUMN;
 5787 rhaas@postgresql.org     9871                 :            161 :                     n->relationType = OBJECT_TABLE;
 8995 tgl@sss.pgh.pa.us        9872                 :            161 :                     n->relation = $3;
 8532 peter_e@gmx.net          9873                 :            161 :                     n->subname = $6;
 9313 tgl@sss.pgh.pa.us        9874                 :            161 :                     n->newname = $8;
 5400 simon@2ndQuadrant.co     9875                 :            161 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9876                 :            161 :                     $$ = (Node *) n;
                               9877                 :                :                 }
                               9878                 :                :             | ALTER TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
                               9879                 :                :                 {
 5400 simon@2ndQuadrant.co     9880                 :             16 :                     RenameStmt *n = makeNode(RenameStmt);
                               9881                 :                : 
                               9882                 :             16 :                     n->renameType = OBJECT_COLUMN;
                               9883                 :             16 :                     n->relationType = OBJECT_TABLE;
                               9884                 :             16 :                     n->relation = $5;
                               9885                 :             16 :                     n->subname = $8;
                               9886                 :             16 :                     n->newname = $10;
                               9887                 :             16 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     9888                 :             16 :                     $$ = (Node *) n;
                               9889                 :                :                 }
                               9890                 :                :             | ALTER VIEW qualified_name RENAME opt_column name TO name
                               9891                 :                :                 {
 2541 fujii@postgresql.org     9892                 :             12 :                     RenameStmt *n = makeNode(RenameStmt);
                               9893                 :                : 
                               9894                 :             12 :                     n->renameType = OBJECT_COLUMN;
                               9895                 :             12 :                     n->relationType = OBJECT_VIEW;
                               9896                 :             12 :                     n->relation = $3;
                               9897                 :             12 :                     n->subname = $6;
                               9898                 :             12 :                     n->newname = $8;
                               9899                 :             12 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9900                 :             12 :                     $$ = (Node *) n;
                               9901                 :                :                 }
                               9902                 :                :             | ALTER VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name
                               9903                 :                :                 {
 2541 fujii@postgresql.org     9904                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9905                 :                : 
                               9906                 :              0 :                     n->renameType = OBJECT_COLUMN;
                               9907                 :              0 :                     n->relationType = OBJECT_VIEW;
                               9908                 :              0 :                     n->relation = $5;
                               9909                 :              0 :                     n->subname = $8;
                               9910                 :              0 :                     n->newname = $10;
                               9911                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     9912                 :              0 :                     $$ = (Node *) n;
                               9913                 :                :                 }
                               9914                 :                :             | ALTER MATERIALIZED VIEW qualified_name RENAME opt_column name TO name
                               9915                 :                :                 {
 4995 kgrittn@postgresql.o     9916                 :              0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9917                 :                : 
                               9918                 :              0 :                     n->renameType = OBJECT_COLUMN;
                               9919                 :              0 :                     n->relationType = OBJECT_MATVIEW;
                               9920                 :              0 :                     n->relation = $4;
                               9921                 :              0 :                     n->subname = $7;
                               9922                 :              0 :                     n->newname = $9;
                               9923                 :              0 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9924                 :              0 :                     $$ = (Node *) n;
                               9925                 :                :                 }
                               9926                 :                :             | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name
                               9927                 :                :                 {
 4995 kgrittn@postgresql.o     9928                 :              0 :                     RenameStmt *n = makeNode(RenameStmt);
                               9929                 :                : 
                               9930                 :              0 :                     n->renameType = OBJECT_COLUMN;
                               9931                 :              0 :                     n->relationType = OBJECT_MATVIEW;
                               9932                 :              0 :                     n->relation = $6;
                               9933                 :              0 :                     n->subname = $9;
                               9934                 :              0 :                     n->newname = $11;
                               9935                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     9936                 :              0 :                     $$ = (Node *) n;
                               9937                 :                :                 }
                               9938                 :                :             | ALTER TABLE relation_expr RENAME CONSTRAINT name TO name
                               9939                 :                :                 {
 5353 peter_e@gmx.net          9940                 :CBC          52 :                     RenameStmt *n = makeNode(RenameStmt);
                               9941                 :                : 
 4335 alvherre@alvh.no-ip.     9942                 :             52 :                     n->renameType = OBJECT_TABCONSTRAINT;
 5353 peter_e@gmx.net          9943                 :             52 :                     n->relation = $3;
                               9944                 :             52 :                     n->subname = $6;
                               9945                 :             52 :                     n->newname = $8;
 4244 bruce@momjian.us         9946                 :             52 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9947                 :             52 :                     $$ = (Node *) n;
                               9948                 :                :                 }
                               9949                 :                :             | ALTER TABLE IF_P EXISTS relation_expr RENAME CONSTRAINT name TO name
                               9950                 :                :                 {
 4244 bruce@momjian.us         9951                 :              4 :                     RenameStmt *n = makeNode(RenameStmt);
                               9952                 :                : 
                               9953                 :              4 :                     n->renameType = OBJECT_TABCONSTRAINT;
                               9954                 :              4 :                     n->relation = $5;
                               9955                 :              4 :                     n->subname = $8;
                               9956                 :              4 :                     n->newname = $10;
                               9957                 :              4 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     9958                 :              4 :                     $$ = (Node *) n;
                               9959                 :                :                 }
                               9960                 :                :             | ALTER FOREIGN TABLE relation_expr RENAME opt_column name TO name
                               9961                 :                :                 {
 5787 rhaas@postgresql.org     9962                 :              4 :                     RenameStmt *n = makeNode(RenameStmt);
                               9963                 :                : 
                               9964                 :              4 :                     n->renameType = OBJECT_COLUMN;
                               9965                 :              4 :                     n->relationType = OBJECT_FOREIGN_TABLE;
                               9966                 :              4 :                     n->relation = $4;
                               9967                 :              4 :                     n->subname = $7;
                               9968                 :              4 :                     n->newname = $9;
 5400 simon@2ndQuadrant.co     9969                 :              4 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9970                 :              4 :                     $$ = (Node *) n;
                               9971                 :                :                 }
                               9972                 :                :             | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
                               9973                 :                :                 {
 5400 simon@2ndQuadrant.co     9974                 :              4 :                     RenameStmt *n = makeNode(RenameStmt);
                               9975                 :                : 
                               9976                 :              4 :                     n->renameType = OBJECT_COLUMN;
                               9977                 :              4 :                     n->relationType = OBJECT_FOREIGN_TABLE;
                               9978                 :              4 :                     n->relation = $6;
                               9979                 :              4 :                     n->subname = $9;
                               9980                 :              4 :                     n->newname = $11;
                               9981                 :              4 :                     n->missing_ok = true;
 1637 peter@eisentraut.org     9982                 :              4 :                     $$ = (Node *) n;
                               9983                 :                :                 }
                               9984                 :                :             | ALTER RULE name ON qualified_name RENAME TO name
                               9985                 :                :                 {
 5018 tgl@sss.pgh.pa.us        9986                 :             30 :                     RenameStmt *n = makeNode(RenameStmt);
                               9987                 :                : 
                               9988                 :             30 :                     n->renameType = OBJECT_RULE;
                               9989                 :             30 :                     n->relation = $5;
                               9990                 :             30 :                     n->subname = $3;
                               9991                 :             30 :                     n->newname = $8;
                               9992                 :             30 :                     n->missing_ok = false;
 1637 peter@eisentraut.org     9993                 :             30 :                     $$ = (Node *) n;
                               9994                 :                :                 }
                               9995                 :                :             | ALTER TRIGGER name ON qualified_name RENAME TO name
                               9996                 :                :                 {
 8961 bruce@momjian.us         9997                 :             38 :                     RenameStmt *n = makeNode(RenameStmt);
                               9998                 :                : 
 7766 tgl@sss.pgh.pa.us        9999                 :             38 :                     n->renameType = OBJECT_TRIGGER;
 8961 bruce@momjian.us        10000                 :             38 :                     n->relation = $5;
 8532 peter_e@gmx.net         10001                 :             38 :                     n->subname = $3;
 8961 bruce@momjian.us        10002                 :             38 :                     n->newname = $8;
 5400 simon@2ndQuadrant.co    10003                 :             38 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10004                 :             38 :                     $$ = (Node *) n;
                              10005                 :                :                 }
                              10006                 :                :             | ALTER EVENT TRIGGER name RENAME TO name
                              10007                 :                :                 {
 5223 rhaas@postgresql.org    10008                 :              8 :                     RenameStmt *n = makeNode(RenameStmt);
                              10009                 :                : 
                              10010                 :              8 :                     n->renameType = OBJECT_EVENT_TRIGGER;
 3645 peter_e@gmx.net         10011                 :              8 :                     n->object = (Node *) makeString($4);
 5223 rhaas@postgresql.org    10012                 :              8 :                     n->newname = $7;
 1637 peter@eisentraut.org    10013                 :              8 :                     $$ = (Node *) n;
                              10014                 :                :                 }
                              10015                 :                :             | ALTER ROLE RoleId RENAME TO RoleId
                              10016                 :                :                 {
 8532 peter_e@gmx.net         10017                 :             20 :                     RenameStmt *n = makeNode(RenameStmt);
                              10018                 :                : 
 7800 tgl@sss.pgh.pa.us       10019                 :             20 :                     n->renameType = OBJECT_ROLE;
                              10020                 :             20 :                     n->subname = $3;
                              10021                 :             20 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co    10022                 :             20 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10023                 :             20 :                     $$ = (Node *) n;
                              10024                 :                :                 }
                              10025                 :                :             | ALTER USER RoleId RENAME TO RoleId
                              10026                 :                :                 {
 7800 tgl@sss.pgh.pa.us       10027                 :UBC           0 :                     RenameStmt *n = makeNode(RenameStmt);
                              10028                 :                : 
                              10029                 :              0 :                     n->renameType = OBJECT_ROLE;
 8532 peter_e@gmx.net         10030                 :              0 :                     n->subname = $3;
                              10031                 :              0 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co    10032                 :              0 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10033                 :              0 :                     $$ = (Node *) n;
                              10034                 :                :                 }
                              10035                 :                :             | ALTER TABLESPACE name RENAME TO name
                              10036                 :                :                 {
 8168 tgl@sss.pgh.pa.us       10037                 :CBC          17 :                     RenameStmt *n = makeNode(RenameStmt);
                              10038                 :                : 
                              10039                 :             17 :                     n->renameType = OBJECT_TABLESPACE;
                              10040                 :             17 :                     n->subname = $3;
                              10041                 :             17 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co    10042                 :             17 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10043                 :             17 :                     $$ = (Node *) n;
                              10044                 :                :                 }
                              10045                 :                :             | ALTER STATISTICS any_name RENAME TO name
                              10046                 :                :                 {
 3513 alvherre@alvh.no-ip.    10047                 :             20 :                     RenameStmt *n = makeNode(RenameStmt);
                              10048                 :                : 
                              10049                 :             20 :                     n->renameType = OBJECT_STATISTIC_EXT;
                              10050                 :             20 :                     n->object = (Node *) $3;
                              10051                 :             20 :                     n->newname = $6;
                              10052                 :             20 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10053                 :             20 :                     $$ = (Node *) n;
                              10054                 :                :                 }
                              10055                 :                :             | ALTER TEXT_P SEARCH PARSER any_name RENAME TO name
                              10056                 :                :                 {
 7016 tgl@sss.pgh.pa.us       10057                 :              8 :                     RenameStmt *n = makeNode(RenameStmt);
                              10058                 :                : 
                              10059                 :              8 :                     n->renameType = OBJECT_TSPARSER;
 3645 peter_e@gmx.net         10060                 :              8 :                     n->object = (Node *) $5;
 7016 tgl@sss.pgh.pa.us       10061                 :              8 :                     n->newname = $8;
 5400 simon@2ndQuadrant.co    10062                 :              8 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10063                 :              8 :                     $$ = (Node *) n;
                              10064                 :                :                 }
                              10065                 :                :             | ALTER TEXT_P SEARCH DICTIONARY any_name RENAME TO name
                              10066                 :                :                 {
 7016 tgl@sss.pgh.pa.us       10067                 :             16 :                     RenameStmt *n = makeNode(RenameStmt);
                              10068                 :                : 
                              10069                 :             16 :                     n->renameType = OBJECT_TSDICTIONARY;
 3645 peter_e@gmx.net         10070                 :             16 :                     n->object = (Node *) $5;
 7016 tgl@sss.pgh.pa.us       10071                 :             16 :                     n->newname = $8;
 5400 simon@2ndQuadrant.co    10072                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10073                 :             16 :                     $$ = (Node *) n;
                              10074                 :                :                 }
                              10075                 :                :             | ALTER TEXT_P SEARCH TEMPLATE any_name RENAME TO name
                              10076                 :                :                 {
 7016 tgl@sss.pgh.pa.us       10077                 :              8 :                     RenameStmt *n = makeNode(RenameStmt);
                              10078                 :                : 
                              10079                 :              8 :                     n->renameType = OBJECT_TSTEMPLATE;
 3645 peter_e@gmx.net         10080                 :              8 :                     n->object = (Node *) $5;
 7016 tgl@sss.pgh.pa.us       10081                 :              8 :                     n->newname = $8;
 5400 simon@2ndQuadrant.co    10082                 :              8 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10083                 :              8 :                     $$ = (Node *) n;
                              10084                 :                :                 }
                              10085                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name
                              10086                 :                :                 {
 7016 tgl@sss.pgh.pa.us       10087                 :             16 :                     RenameStmt *n = makeNode(RenameStmt);
                              10088                 :                : 
                              10089                 :             16 :                     n->renameType = OBJECT_TSCONFIGURATION;
 3645 peter_e@gmx.net         10090                 :             16 :                     n->object = (Node *) $5;
 7016 tgl@sss.pgh.pa.us       10091                 :             16 :                     n->newname = $8;
 5400 simon@2ndQuadrant.co    10092                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10093                 :             16 :                     $$ = (Node *) n;
                              10094                 :                :                 }
                              10095                 :                :             | ALTER TYPE_P any_name RENAME TO name
                              10096                 :                :                 {
 6805 tgl@sss.pgh.pa.us       10097                 :             17 :                     RenameStmt *n = makeNode(RenameStmt);
                              10098                 :                : 
                              10099                 :             17 :                     n->renameType = OBJECT_TYPE;
 3645 peter_e@gmx.net         10100                 :             17 :                     n->object = (Node *) $3;
 6805 tgl@sss.pgh.pa.us       10101                 :             17 :                     n->newname = $6;
 5400 simon@2ndQuadrant.co    10102                 :             17 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10103                 :             17 :                     $$ = (Node *) n;
                              10104                 :                :                 }
                              10105                 :                :             | ALTER TYPE_P any_name RENAME ATTRIBUTE name TO name opt_drop_behavior
                              10106                 :                :                 {
 5884 peter_e@gmx.net         10107                 :             16 :                     RenameStmt *n = makeNode(RenameStmt);
                              10108                 :                : 
                              10109                 :             16 :                     n->renameType = OBJECT_ATTRIBUTE;
 5787 rhaas@postgresql.org    10110                 :             16 :                     n->relationType = OBJECT_TYPE;
 5884 peter_e@gmx.net         10111                 :             16 :                     n->relation = makeRangeVarFromAnyName($3, @3, yyscanner);
                              10112                 :             16 :                     n->subname = $6;
                              10113                 :             16 :                     n->newname = $8;
 5826                         10114                 :             16 :                     n->behavior = $9;
 5400 simon@2ndQuadrant.co    10115                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10116                 :             16 :                     $$ = (Node *) n;
                              10117                 :                :                 }
                              10118                 :                :         ;
                              10119                 :                : 
                              10120                 :                : opt_column: COLUMN
                              10121                 :                :             | /*EMPTY*/
                              10122                 :                :         ;
                              10123                 :                : 
 5720 tgl@sss.pgh.pa.us       10124                 :            121 : opt_set_data: SET DATA_P                            { $$ = 1; }
 6589 peter_e@gmx.net         10125                 :            697 :             | /*EMPTY*/                             { $$ = 0; }
                              10126                 :                :         ;
                              10127                 :                : 
                              10128                 :                : /*****************************************************************************
                              10129                 :                :  *
                              10130                 :                :  * ALTER THING name DEPENDS ON EXTENSION name
                              10131                 :                :  *
                              10132                 :                :  *****************************************************************************/
                              10133                 :                : 
                              10134                 :                : AlterObjectDependsStmt:
                              10135                 :                :             ALTER FUNCTION function_with_argtypes opt_no DEPENDS ON EXTENSION name
                              10136                 :                :                 {
 3866 alvherre@alvh.no-ip.    10137                 :              6 :                     AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
                              10138                 :                : 
                              10139                 :              6 :                     n->objectType = OBJECT_FUNCTION;
 3645 peter_e@gmx.net         10140                 :              6 :                     n->object = (Node *) $3;
 2390 alvherre@alvh.no-ip.    10141                 :              6 :                     n->extname = makeString($8);
                              10142                 :              6 :                     n->remove = $4;
 1637 peter@eisentraut.org    10143                 :              6 :                     $$ = (Node *) n;
                              10144                 :                :                 }
                              10145                 :                :             | ALTER PROCEDURE function_with_argtypes opt_no DEPENDS ON EXTENSION name
                              10146                 :                :                 {
 3262 peter_e@gmx.net         10147                 :UBC           0 :                     AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
                              10148                 :                : 
                              10149                 :              0 :                     n->objectType = OBJECT_PROCEDURE;
                              10150                 :              0 :                     n->object = (Node *) $3;
 2390 alvherre@alvh.no-ip.    10151                 :              0 :                     n->extname = makeString($8);
                              10152                 :              0 :                     n->remove = $4;
 1637 peter@eisentraut.org    10153                 :              0 :                     $$ = (Node *) n;
                              10154                 :                :                 }
                              10155                 :                :             | ALTER ROUTINE function_with_argtypes opt_no DEPENDS ON EXTENSION name
                              10156                 :                :                 {
 3262 peter_e@gmx.net         10157                 :              0 :                     AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
                              10158                 :                : 
                              10159                 :              0 :                     n->objectType = OBJECT_ROUTINE;
                              10160                 :              0 :                     n->object = (Node *) $3;
 2390 alvherre@alvh.no-ip.    10161                 :              0 :                     n->extname = makeString($8);
                              10162                 :              0 :                     n->remove = $4;
 1637 peter@eisentraut.org    10163                 :              0 :                     $$ = (Node *) n;
                              10164                 :                :                 }
                              10165                 :                :             | ALTER TRIGGER name ON qualified_name opt_no DEPENDS ON EXTENSION name
                              10166                 :                :                 {
 3866 alvherre@alvh.no-ip.    10167                 :CBC           5 :                     AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
                              10168                 :                : 
                              10169                 :              5 :                     n->objectType = OBJECT_TRIGGER;
                              10170                 :              5 :                     n->relation = $5;
 3645 peter_e@gmx.net         10171                 :              5 :                     n->object = (Node *) list_make1(makeString($3));
 2390 alvherre@alvh.no-ip.    10172                 :              5 :                     n->extname = makeString($10);
                              10173                 :              5 :                     n->remove = $6;
 1637 peter@eisentraut.org    10174                 :              5 :                     $$ = (Node *) n;
                              10175                 :                :                 }
                              10176                 :                :             | ALTER MATERIALIZED VIEW qualified_name opt_no DEPENDS ON EXTENSION name
                              10177                 :                :                 {
 3866 alvherre@alvh.no-ip.    10178                 :              5 :                     AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
                              10179                 :                : 
                              10180                 :              5 :                     n->objectType = OBJECT_MATVIEW;
                              10181                 :              5 :                     n->relation = $4;
 2390                         10182                 :              5 :                     n->extname = makeString($9);
                              10183                 :              5 :                     n->remove = $5;
 1637 peter@eisentraut.org    10184                 :              5 :                     $$ = (Node *) n;
                              10185                 :                :                 }
                              10186                 :                :             | ALTER INDEX qualified_name opt_no DEPENDS ON EXTENSION name
                              10187                 :                :                 {
 3866 alvherre@alvh.no-ip.    10188                 :              7 :                     AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
                              10189                 :                : 
                              10190                 :              7 :                     n->objectType = OBJECT_INDEX;
                              10191                 :              7 :                     n->relation = $3;
 2390                         10192                 :              7 :                     n->extname = makeString($8);
                              10193                 :              7 :                     n->remove = $4;
 1637 peter@eisentraut.org    10194                 :              7 :                     $$ = (Node *) n;
                              10195                 :                :                 }
                              10196                 :                :         ;
                              10197                 :                : 
 2390 alvherre@alvh.no-ip.    10198                 :              4 : opt_no:     NO              { $$ = true; }
                              10199                 :             19 :             | /* EMPTY */   { $$ = false;   }
                              10200                 :                :         ;
                              10201                 :                : 
                              10202                 :                : /*****************************************************************************
                              10203                 :                :  *
                              10204                 :                :  * ALTER THING name SET SCHEMA name
                              10205                 :                :  *
                              10206                 :                :  *****************************************************************************/
                              10207                 :                : 
                              10208                 :                : AlterObjectSchemaStmt:
                              10209                 :                :             ALTER AGGREGATE aggregate_with_argtypes SET SCHEMA name
                              10210                 :                :                 {
 7766 tgl@sss.pgh.pa.us       10211                 :             16 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10212                 :                : 
                              10213                 :             16 :                     n->objectType = OBJECT_AGGREGATE;
 3645 peter_e@gmx.net         10214                 :             16 :                     n->object = (Node *) $3;
 3703                         10215                 :             16 :                     n->newschema = $6;
 5400 simon@2ndQuadrant.co    10216                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10217                 :             16 :                     $$ = (Node *) n;
                              10218                 :                :                 }
                              10219                 :                :             | ALTER COLLATION any_name SET SCHEMA name
                              10220                 :                :                 {
 5745 peter_e@gmx.net         10221                 :              4 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10222                 :                : 
                              10223                 :              4 :                     n->objectType = OBJECT_COLLATION;
 3645                         10224                 :              4 :                     n->object = (Node *) $3;
 5745                         10225                 :              4 :                     n->newschema = $6;
 5400 simon@2ndQuadrant.co    10226                 :              4 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10227                 :              4 :                     $$ = (Node *) n;
                              10228                 :                :                 }
                              10229                 :                :             | ALTER CONVERSION_P any_name SET SCHEMA name
                              10230                 :                :                 {
 5823 rhaas@postgresql.org    10231                 :             16 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10232                 :                : 
                              10233                 :             16 :                     n->objectType = OBJECT_CONVERSION;
 3645 peter_e@gmx.net         10234                 :             16 :                     n->object = (Node *) $3;
 5823 rhaas@postgresql.org    10235                 :             16 :                     n->newschema = $6;
 5400 simon@2ndQuadrant.co    10236                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10237                 :             16 :                     $$ = (Node *) n;
                              10238                 :                :                 }
                              10239                 :                :             | ALTER DOMAIN_P any_name SET SCHEMA name
                              10240                 :                :                 {
 7766 tgl@sss.pgh.pa.us       10241                 :              4 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10242                 :                : 
                              10243                 :              4 :                     n->objectType = OBJECT_DOMAIN;
 3645 peter_e@gmx.net         10244                 :              4 :                     n->object = (Node *) $3;
 7766 tgl@sss.pgh.pa.us       10245                 :              4 :                     n->newschema = $6;
 5400 simon@2ndQuadrant.co    10246                 :              4 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10247                 :              4 :                     $$ = (Node *) n;
                              10248                 :                :                 }
                              10249                 :                :             | ALTER EXTENSION name SET SCHEMA name
                              10250                 :                :                 {
 5749 tgl@sss.pgh.pa.us       10251                 :              6 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10252                 :                : 
                              10253                 :              6 :                     n->objectType = OBJECT_EXTENSION;
 3645 peter_e@gmx.net         10254                 :              6 :                     n->object = (Node *) makeString($3);
 5749 tgl@sss.pgh.pa.us       10255                 :              6 :                     n->newschema = $6;
 5400 simon@2ndQuadrant.co    10256                 :              6 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10257                 :              6 :                     $$ = (Node *) n;
                              10258                 :                :                 }
                              10259                 :                :             | ALTER FUNCTION function_with_argtypes SET SCHEMA name
                              10260                 :                :                 {
 7766 tgl@sss.pgh.pa.us       10261                 :             29 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10262                 :                : 
                              10263                 :             29 :                     n->objectType = OBJECT_FUNCTION;
 3645 peter_e@gmx.net         10264                 :             29 :                     n->object = (Node *) $3;
 7003 tgl@sss.pgh.pa.us       10265                 :             29 :                     n->newschema = $6;
 5400 simon@2ndQuadrant.co    10266                 :             29 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10267                 :             29 :                     $$ = (Node *) n;
                              10268                 :                :                 }
                              10269                 :                :             | ALTER OPERATOR operator_with_argtypes SET SCHEMA name
                              10270                 :                :                 {
 5823 rhaas@postgresql.org    10271                 :             12 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10272                 :                : 
                              10273                 :             12 :                     n->objectType = OBJECT_OPERATOR;
 3645 peter_e@gmx.net         10274                 :             12 :                     n->object = (Node *) $3;
 3599                         10275                 :             12 :                     n->newschema = $6;
 5400 simon@2ndQuadrant.co    10276                 :             12 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10277                 :             12 :                     $$ = (Node *) n;
                              10278                 :                :                 }
                              10279                 :                :             | ALTER OPERATOR CLASS any_name USING name SET SCHEMA name
                              10280                 :                :                 {
 5823 rhaas@postgresql.org    10281                 :             16 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10282                 :                : 
                              10283                 :             16 :                     n->objectType = OBJECT_OPCLASS;
 3645 peter_e@gmx.net         10284                 :             16 :                     n->object = (Node *) lcons(makeString($6), $4);
 5823 rhaas@postgresql.org    10285                 :             16 :                     n->newschema = $9;
 5400 simon@2ndQuadrant.co    10286                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10287                 :             16 :                     $$ = (Node *) n;
                              10288                 :                :                 }
                              10289                 :                :             | ALTER OPERATOR FAMILY any_name USING name SET SCHEMA name
                              10290                 :                :                 {
 5823 rhaas@postgresql.org    10291                 :             16 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10292                 :                : 
                              10293                 :             16 :                     n->objectType = OBJECT_OPFAMILY;
 3645 peter_e@gmx.net         10294                 :             16 :                     n->object = (Node *) lcons(makeString($6), $4);
 5823 rhaas@postgresql.org    10295                 :             16 :                     n->newschema = $9;
 5400 simon@2ndQuadrant.co    10296                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10297                 :             16 :                     $$ = (Node *) n;
                              10298                 :                :                 }
                              10299                 :                :             | ALTER PROCEDURE function_with_argtypes SET SCHEMA name
                              10300                 :                :                 {
 3262 peter_e@gmx.net         10301                 :UBC           0 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10302                 :                : 
                              10303                 :              0 :                     n->objectType = OBJECT_PROCEDURE;
                              10304                 :              0 :                     n->object = (Node *) $3;
                              10305                 :              0 :                     n->newschema = $6;
                              10306                 :              0 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10307                 :              0 :                     $$ = (Node *) n;
                              10308                 :                :                 }
                              10309                 :                :             | ALTER ROUTINE function_with_argtypes SET SCHEMA name
                              10310                 :                :                 {
 3262 peter_e@gmx.net         10311                 :              0 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10312                 :                : 
                              10313                 :              0 :                     n->objectType = OBJECT_ROUTINE;
                              10314                 :              0 :                     n->object = (Node *) $3;
                              10315                 :              0 :                     n->newschema = $6;
                              10316                 :              0 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10317                 :              0 :                     $$ = (Node *) n;
                              10318                 :                :                 }
                              10319                 :                :             | ALTER TABLE relation_expr SET SCHEMA name
                              10320                 :                :                 {
 6717 tgl@sss.pgh.pa.us       10321                 :CBC          51 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10322                 :                : 
                              10323                 :             51 :                     n->objectType = OBJECT_TABLE;
                              10324                 :             51 :                     n->relation = $3;
                              10325                 :             51 :                     n->newschema = $6;
 5400 simon@2ndQuadrant.co    10326                 :             51 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10327                 :             51 :                     $$ = (Node *) n;
                              10328                 :                :                 }
                              10329                 :                :             | ALTER TABLE IF_P EXISTS relation_expr SET SCHEMA name
                              10330                 :                :                 {
 5400 simon@2ndQuadrant.co    10331                 :              8 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10332                 :                : 
                              10333                 :              8 :                     n->objectType = OBJECT_TABLE;
                              10334                 :              8 :                     n->relation = $5;
                              10335                 :              8 :                     n->newschema = $8;
                              10336                 :              8 :                     n->missing_ok = true;
 1637 peter@eisentraut.org    10337                 :              8 :                     $$ = (Node *) n;
                              10338                 :                :                 }
                              10339                 :                :             | ALTER STATISTICS any_name SET SCHEMA name
                              10340                 :                :                 {
 3513 alvherre@alvh.no-ip.    10341                 :             12 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10342                 :                : 
                              10343                 :             12 :                     n->objectType = OBJECT_STATISTIC_EXT;
                              10344                 :             12 :                     n->object = (Node *) $3;
                              10345                 :             12 :                     n->newschema = $6;
                              10346                 :             12 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10347                 :             12 :                     $$ = (Node *) n;
                              10348                 :                :                 }
                              10349                 :                :             | ALTER TEXT_P SEARCH PARSER any_name SET SCHEMA name
                              10350                 :                :                 {
 5823 rhaas@postgresql.org    10351                 :             12 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10352                 :                : 
                              10353                 :             12 :                     n->objectType = OBJECT_TSPARSER;
 3645 peter_e@gmx.net         10354                 :             12 :                     n->object = (Node *) $5;
 5823 rhaas@postgresql.org    10355                 :             12 :                     n->newschema = $8;
 5400 simon@2ndQuadrant.co    10356                 :             12 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10357                 :             12 :                     $$ = (Node *) n;
                              10358                 :                :                 }
                              10359                 :                :             | ALTER TEXT_P SEARCH DICTIONARY any_name SET SCHEMA name
                              10360                 :                :                 {
 5823 rhaas@postgresql.org    10361                 :             16 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10362                 :                : 
                              10363                 :             16 :                     n->objectType = OBJECT_TSDICTIONARY;
 3645 peter_e@gmx.net         10364                 :             16 :                     n->object = (Node *) $5;
 5823 rhaas@postgresql.org    10365                 :             16 :                     n->newschema = $8;
 5400 simon@2ndQuadrant.co    10366                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10367                 :             16 :                     $$ = (Node *) n;
                              10368                 :                :                 }
                              10369                 :                :             | ALTER TEXT_P SEARCH TEMPLATE any_name SET SCHEMA name
                              10370                 :                :                 {
 5823 rhaas@postgresql.org    10371                 :             12 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10372                 :                : 
                              10373                 :             12 :                     n->objectType = OBJECT_TSTEMPLATE;
 3645 peter_e@gmx.net         10374                 :             12 :                     n->object = (Node *) $5;
 5823 rhaas@postgresql.org    10375                 :             12 :                     n->newschema = $8;
 5400 simon@2ndQuadrant.co    10376                 :             12 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10377                 :             12 :                     $$ = (Node *) n;
                              10378                 :                :                 }
                              10379                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name SET SCHEMA name
                              10380                 :                :                 {
 5823 rhaas@postgresql.org    10381                 :             16 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10382                 :                : 
                              10383                 :             16 :                     n->objectType = OBJECT_TSCONFIGURATION;
 3645 peter_e@gmx.net         10384                 :             16 :                     n->object = (Node *) $5;
 5823 rhaas@postgresql.org    10385                 :             16 :                     n->newschema = $8;
 5400 simon@2ndQuadrant.co    10386                 :             16 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10387                 :             16 :                     $$ = (Node *) n;
                              10388                 :                :                 }
                              10389                 :                :             | ALTER SEQUENCE qualified_name SET SCHEMA name
                              10390                 :                :                 {
 7766 tgl@sss.pgh.pa.us       10391                 :              5 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10392                 :                : 
                              10393                 :              5 :                     n->objectType = OBJECT_SEQUENCE;
                              10394                 :              5 :                     n->relation = $3;
                              10395                 :              5 :                     n->newschema = $6;
 5400 simon@2ndQuadrant.co    10396                 :              5 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10397                 :              5 :                     $$ = (Node *) n;
                              10398                 :                :                 }
                              10399                 :                :             | ALTER SEQUENCE IF_P EXISTS qualified_name SET SCHEMA name
                              10400                 :                :                 {
 5400 simon@2ndQuadrant.co    10401                 :UBC           0 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10402                 :                : 
                              10403                 :              0 :                     n->objectType = OBJECT_SEQUENCE;
                              10404                 :              0 :                     n->relation = $5;
                              10405                 :              0 :                     n->newschema = $8;
                              10406                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org    10407                 :              0 :                     $$ = (Node *) n;
                              10408                 :                :                 }
                              10409                 :                :             | ALTER VIEW qualified_name SET SCHEMA name
                              10410                 :                :                 {
 7766 tgl@sss.pgh.pa.us       10411                 :              0 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10412                 :                : 
 6717                         10413                 :              0 :                     n->objectType = OBJECT_VIEW;
 7766                         10414                 :              0 :                     n->relation = $3;
                              10415                 :              0 :                     n->newschema = $6;
 5400 simon@2ndQuadrant.co    10416                 :              0 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10417                 :              0 :                     $$ = (Node *) n;
                              10418                 :                :                 }
                              10419                 :                :             | ALTER VIEW IF_P EXISTS qualified_name SET SCHEMA name
                              10420                 :                :                 {
 5400 simon@2ndQuadrant.co    10421                 :              0 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10422                 :                : 
                              10423                 :              0 :                     n->objectType = OBJECT_VIEW;
                              10424                 :              0 :                     n->relation = $5;
                              10425                 :              0 :                     n->newschema = $8;
                              10426                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org    10427                 :              0 :                     $$ = (Node *) n;
                              10428                 :                :                 }
                              10429                 :                :             | ALTER MATERIALIZED VIEW qualified_name SET SCHEMA name
                              10430                 :                :                 {
 4995 kgrittn@postgresql.o    10431                 :CBC           4 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10432                 :                : 
                              10433                 :              4 :                     n->objectType = OBJECT_MATVIEW;
                              10434                 :              4 :                     n->relation = $4;
                              10435                 :              4 :                     n->newschema = $7;
                              10436                 :              4 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10437                 :              4 :                     $$ = (Node *) n;
                              10438                 :                :                 }
                              10439                 :                :             | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name SET SCHEMA name
                              10440                 :                :                 {
 4995 kgrittn@postgresql.o    10441                 :UBC           0 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10442                 :                : 
                              10443                 :              0 :                     n->objectType = OBJECT_MATVIEW;
                              10444                 :              0 :                     n->relation = $6;
                              10445                 :              0 :                     n->newschema = $9;
                              10446                 :              0 :                     n->missing_ok = true;
 1637 peter@eisentraut.org    10447                 :              0 :                     $$ = (Node *) n;
                              10448                 :                :                 }
                              10449                 :                :             | ALTER FOREIGN TABLE relation_expr SET SCHEMA name
                              10450                 :                :                 {
 5787 rhaas@postgresql.org    10451                 :CBC           4 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10452                 :                : 
                              10453                 :              4 :                     n->objectType = OBJECT_FOREIGN_TABLE;
                              10454                 :              4 :                     n->relation = $4;
                              10455                 :              4 :                     n->newschema = $7;
 5400 simon@2ndQuadrant.co    10456                 :              4 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10457                 :              4 :                     $$ = (Node *) n;
                              10458                 :                :                 }
                              10459                 :                :             | ALTER FOREIGN TABLE IF_P EXISTS relation_expr SET SCHEMA name
                              10460                 :                :                 {
 5400 simon@2ndQuadrant.co    10461                 :              4 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10462                 :                : 
                              10463                 :              4 :                     n->objectType = OBJECT_FOREIGN_TABLE;
                              10464                 :              4 :                     n->relation = $6;
                              10465                 :              4 :                     n->newschema = $9;
                              10466                 :              4 :                     n->missing_ok = true;
 1637 peter@eisentraut.org    10467                 :              4 :                     $$ = (Node *) n;
                              10468                 :                :                 }
                              10469                 :                :             | ALTER TYPE_P any_name SET SCHEMA name
                              10470                 :                :                 {
 7766 tgl@sss.pgh.pa.us       10471                 :              8 :                     AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                              10472                 :                : 
                              10473                 :              8 :                     n->objectType = OBJECT_TYPE;
 3645 peter_e@gmx.net         10474                 :              8 :                     n->object = (Node *) $3;
 7766 tgl@sss.pgh.pa.us       10475                 :              8 :                     n->newschema = $6;
 5400 simon@2ndQuadrant.co    10476                 :              8 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    10477                 :              8 :                     $$ = (Node *) n;
                              10478                 :                :                 }
                              10479                 :                :         ;
                              10480                 :                : 
                              10481                 :                : /*****************************************************************************
                              10482                 :                :  *
                              10483                 :                :  * ALTER OPERATOR name SET define
                              10484                 :                :  *
                              10485                 :                :  *****************************************************************************/
                              10486                 :                : 
                              10487                 :                : AlterOperatorStmt:
                              10488                 :                :             ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')'
                              10489                 :                :                 {
 4132 heikki.linnakangas@i    10490                 :            332 :                     AlterOperatorStmt *n = makeNode(AlterOperatorStmt);
                              10491                 :                : 
 3599 peter_e@gmx.net         10492                 :            332 :                     n->opername = $3;
                              10493                 :            332 :                     n->options = $6;
 1637 peter@eisentraut.org    10494                 :            332 :                     $$ = (Node *) n;
                              10495                 :                :                 }
                              10496                 :                :         ;
                              10497                 :                : 
 4132 heikki.linnakangas@i    10498                 :            370 : operator_def_list:  operator_def_elem                               { $$ = list_make1($1); }
                              10499                 :            261 :             | operator_def_list ',' operator_def_elem               { $$ = lappend($1, $3); }
                              10500                 :                :         ;
                              10501                 :                : 
                              10502                 :                : operator_def_elem: ColLabel '=' NONE
 3712 peter_e@gmx.net         10503                 :             20 :                         { $$ = makeDefElem($1, NULL, @1); }
                              10504                 :                :                    | ColLabel '=' operator_def_arg
 3467                         10505                 :            589 :                         { $$ = makeDefElem($1, (Node *) $3, @1); }
                              10506                 :                :                    | ColLabel
 1112 tgl@sss.pgh.pa.us       10507                 :             22 :                         { $$ = makeDefElem($1, NULL, @1); }
                              10508                 :                :         ;
                              10509                 :                : 
                              10510                 :                : /* must be similar enough to def_arg to avoid reduce/reduce conflicts */
                              10511                 :                : operator_def_arg:
 1637 peter@eisentraut.org    10512                 :            537 :             func_type                       { $$ = (Node *) $1; }
                              10513                 :             16 :             | reserved_keyword              { $$ = (Node *) makeString(pstrdup($1)); }
                              10514                 :             36 :             | qual_all_Op                   { $$ = (Node *) $1; }
 1637 peter@eisentraut.org    10515                 :UBC           0 :             | NumericOnly                   { $$ = (Node *) $1; }
                              10516                 :              0 :             | Sconst                        { $$ = (Node *) makeString($1); }
                              10517                 :                :         ;
                              10518                 :                : 
                              10519                 :                : /*****************************************************************************
                              10520                 :                :  *
                              10521                 :                :  * ALTER TYPE name SET define
                              10522                 :                :  *
                              10523                 :                :  * We repurpose ALTER OPERATOR's version of "definition" here
                              10524                 :                :  *
                              10525                 :                :  *****************************************************************************/
                              10526                 :                : 
                              10527                 :                : AlterTypeStmt:
                              10528                 :                :             ALTER TYPE_P any_name SET '(' operator_def_list ')'
                              10529                 :                :                 {
 2435 tgl@sss.pgh.pa.us       10530                 :CBC          38 :                     AlterTypeStmt *n = makeNode(AlterTypeStmt);
                              10531                 :                : 
                              10532                 :             38 :                     n->typeName = $3;
                              10533                 :             38 :                     n->options = $6;
 1637 peter@eisentraut.org    10534                 :             38 :                     $$ = (Node *) n;
                              10535                 :                :                 }
                              10536                 :                :         ;
                              10537                 :                : 
                              10538                 :                : /*****************************************************************************
                              10539                 :                :  *
                              10540                 :                :  * ALTER THING name OWNER TO newname
                              10541                 :                :  *
                              10542                 :                :  *****************************************************************************/
                              10543                 :                : 
                              10544                 :                : AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
                              10545                 :                :                 {
 8168 tgl@sss.pgh.pa.us       10546                 :             76 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10547                 :                : 
                              10548                 :             76 :                     n->objectType = OBJECT_AGGREGATE;
 3645 peter_e@gmx.net         10549                 :             76 :                     n->object = (Node *) $3;
 3703                         10550                 :             76 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10551                 :             76 :                     $$ = (Node *) n;
                              10552                 :                :                 }
                              10553                 :                :             | ALTER COLLATION any_name OWNER TO RoleSpec
                              10554                 :                :                 {
 5745 peter_e@gmx.net         10555                 :             11 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10556                 :                : 
                              10557                 :             11 :                     n->objectType = OBJECT_COLLATION;
 3645                         10558                 :             11 :                     n->object = (Node *) $3;
 5745                         10559                 :             11 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10560                 :             11 :                     $$ = (Node *) n;
                              10561                 :                :                 }
                              10562                 :                :             | ALTER CONVERSION_P any_name OWNER TO RoleSpec
                              10563                 :                :                 {
 8168 tgl@sss.pgh.pa.us       10564                 :             16 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10565                 :                : 
                              10566                 :             16 :                     n->objectType = OBJECT_CONVERSION;
 3645 peter_e@gmx.net         10567                 :             16 :                     n->object = (Node *) $3;
 8168 tgl@sss.pgh.pa.us       10568                 :             16 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10569                 :             16 :                     $$ = (Node *) n;
                              10570                 :                :                 }
                              10571                 :                :             | ALTER DATABASE name OWNER TO RoleSpec
                              10572                 :                :                 {
 8168 tgl@sss.pgh.pa.us       10573                 :             51 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10574                 :                : 
                              10575                 :             51 :                     n->objectType = OBJECT_DATABASE;
 3645 peter_e@gmx.net         10576                 :             51 :                     n->object = (Node *) makeString($3);
 8168 tgl@sss.pgh.pa.us       10577                 :             51 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10578                 :             51 :                     $$ = (Node *) n;
                              10579                 :                :                 }
                              10580                 :                :             | ALTER DOMAIN_P any_name OWNER TO RoleSpec
                              10581                 :                :                 {
 8168 tgl@sss.pgh.pa.us       10582                 :             26 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10583                 :                : 
                              10584                 :             26 :                     n->objectType = OBJECT_DOMAIN;
 3645 peter_e@gmx.net         10585                 :             26 :                     n->object = (Node *) $3;
 8168 tgl@sss.pgh.pa.us       10586                 :             26 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10587                 :             26 :                     $$ = (Node *) n;
                              10588                 :                :                 }
                              10589                 :                :             | ALTER FUNCTION function_with_argtypes OWNER TO RoleSpec
                              10590                 :                :                 {
 8168 tgl@sss.pgh.pa.us       10591                 :            314 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10592                 :                : 
                              10593                 :            314 :                     n->objectType = OBJECT_FUNCTION;
 3645 peter_e@gmx.net         10594                 :            314 :                     n->object = (Node *) $3;
 7003 tgl@sss.pgh.pa.us       10595                 :            314 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10596                 :            314 :                     $$ = (Node *) n;
                              10597                 :                :                 }
                              10598                 :                :             | ALTER opt_procedural LANGUAGE name OWNER TO RoleSpec
                              10599                 :                :                 {
 7164 tgl@sss.pgh.pa.us       10600                 :             85 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10601                 :                : 
                              10602                 :             85 :                     n->objectType = OBJECT_LANGUAGE;
 3645 peter_e@gmx.net         10603                 :             85 :                     n->object = (Node *) makeString($4);
 7164 tgl@sss.pgh.pa.us       10604                 :             85 :                     n->newowner = $7;
 1637 peter@eisentraut.org    10605                 :             85 :                     $$ = (Node *) n;
                              10606                 :                :                 }
                              10607                 :                :             | ALTER LARGE_P OBJECT_P NumericOnly OWNER TO RoleSpec
                              10608                 :                :                 {
 6173 itagaki.takahiro@gma    10609                 :              9 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10610                 :                : 
                              10611                 :              9 :                     n->objectType = OBJECT_LARGEOBJECT;
 3645 peter_e@gmx.net         10612                 :              9 :                     n->object = (Node *) $4;
 6173 itagaki.takahiro@gma    10613                 :              9 :                     n->newowner = $7;
 1637 peter@eisentraut.org    10614                 :              9 :                     $$ = (Node *) n;
                              10615                 :                :                 }
                              10616                 :                :             | ALTER OPERATOR operator_with_argtypes OWNER TO RoleSpec
                              10617                 :                :                 {
 8168 tgl@sss.pgh.pa.us       10618                 :             27 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10619                 :                : 
                              10620                 :             27 :                     n->objectType = OBJECT_OPERATOR;
 3645 peter_e@gmx.net         10621                 :             27 :                     n->object = (Node *) $3;
 3599                         10622                 :             27 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10623                 :             27 :                     $$ = (Node *) n;
                              10624                 :                :                 }
                              10625                 :                :             | ALTER OPERATOR CLASS any_name USING name OWNER TO RoleSpec
                              10626                 :                :                 {
 8168 tgl@sss.pgh.pa.us       10627                 :             35 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10628                 :                : 
                              10629                 :             35 :                     n->objectType = OBJECT_OPCLASS;
 3645 peter_e@gmx.net         10630                 :             35 :                     n->object = (Node *) lcons(makeString($6), $4);
 8168 tgl@sss.pgh.pa.us       10631                 :             35 :                     n->newowner = $9;
 1637 peter@eisentraut.org    10632                 :             35 :                     $$ = (Node *) n;
                              10633                 :                :                 }
                              10634                 :                :             | ALTER OPERATOR FAMILY any_name USING name OWNER TO RoleSpec
                              10635                 :                :                 {
 7226 tgl@sss.pgh.pa.us       10636                 :             39 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10637                 :                : 
                              10638                 :             39 :                     n->objectType = OBJECT_OPFAMILY;
 3645 peter_e@gmx.net         10639                 :             39 :                     n->object = (Node *) lcons(makeString($6), $4);
 7226 tgl@sss.pgh.pa.us       10640                 :             39 :                     n->newowner = $9;
 1637 peter@eisentraut.org    10641                 :             39 :                     $$ = (Node *) n;
                              10642                 :                :                 }
                              10643                 :                :             | ALTER PROCEDURE function_with_argtypes OWNER TO RoleSpec
                              10644                 :                :                 {
 3262 peter_e@gmx.net         10645                 :             12 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10646                 :                : 
                              10647                 :             12 :                     n->objectType = OBJECT_PROCEDURE;
                              10648                 :             12 :                     n->object = (Node *) $3;
                              10649                 :             12 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10650                 :             12 :                     $$ = (Node *) n;
                              10651                 :                :                 }
                              10652                 :                :             | ALTER ROUTINE function_with_argtypes OWNER TO RoleSpec
                              10653                 :                :                 {
 3262 peter_e@gmx.net         10654                 :UBC           0 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10655                 :                : 
                              10656                 :              0 :                     n->objectType = OBJECT_ROUTINE;
                              10657                 :              0 :                     n->object = (Node *) $3;
                              10658                 :              0 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10659                 :              0 :                     $$ = (Node *) n;
                              10660                 :                :                 }
                              10661                 :                :             | ALTER SCHEMA name OWNER TO RoleSpec
                              10662                 :                :                 {
 8168 tgl@sss.pgh.pa.us       10663                 :CBC          37 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10664                 :                : 
                              10665                 :             37 :                     n->objectType = OBJECT_SCHEMA;
 3645 peter_e@gmx.net         10666                 :             37 :                     n->object = (Node *) makeString($3);
 8168 tgl@sss.pgh.pa.us       10667                 :             37 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10668                 :             37 :                     $$ = (Node *) n;
                              10669                 :                :                 }
                              10670                 :                :             | ALTER TYPE_P any_name OWNER TO RoleSpec
                              10671                 :                :                 {
 8168 tgl@sss.pgh.pa.us       10672                 :             45 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10673                 :                : 
                              10674                 :             45 :                     n->objectType = OBJECT_TYPE;
 3645 peter_e@gmx.net         10675                 :             45 :                     n->object = (Node *) $3;
 8168 tgl@sss.pgh.pa.us       10676                 :             45 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10677                 :             45 :                     $$ = (Node *) n;
                              10678                 :                :                 }
                              10679                 :                :             | ALTER TABLESPACE name OWNER TO RoleSpec
                              10680                 :                :                 {
 8168 tgl@sss.pgh.pa.us       10681                 :              4 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10682                 :                : 
                              10683                 :              4 :                     n->objectType = OBJECT_TABLESPACE;
 3645 peter_e@gmx.net         10684                 :              4 :                     n->object = (Node *) makeString($3);
 8168 tgl@sss.pgh.pa.us       10685                 :              4 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10686                 :              4 :                     $$ = (Node *) n;
                              10687                 :                :                 }
                              10688                 :                :             | ALTER STATISTICS any_name OWNER TO RoleSpec
                              10689                 :                :                 {
 3513 alvherre@alvh.no-ip.    10690                 :             24 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10691                 :                : 
                              10692                 :             24 :                     n->objectType = OBJECT_STATISTIC_EXT;
                              10693                 :             24 :                     n->object = (Node *) $3;
                              10694                 :             24 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10695                 :             24 :                     $$ = (Node *) n;
                              10696                 :                :                 }
                              10697                 :                :             | ALTER TEXT_P SEARCH DICTIONARY any_name OWNER TO RoleSpec
                              10698                 :                :                 {
 7016 tgl@sss.pgh.pa.us       10699                 :             25 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10700                 :                : 
                              10701                 :             25 :                     n->objectType = OBJECT_TSDICTIONARY;
 3645 peter_e@gmx.net         10702                 :             25 :                     n->object = (Node *) $5;
 7016 tgl@sss.pgh.pa.us       10703                 :             25 :                     n->newowner = $8;
 1637 peter@eisentraut.org    10704                 :             25 :                     $$ = (Node *) n;
                              10705                 :                :                 }
                              10706                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name OWNER TO RoleSpec
                              10707                 :                :                 {
 7016 tgl@sss.pgh.pa.us       10708                 :             20 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10709                 :                : 
                              10710                 :             20 :                     n->objectType = OBJECT_TSCONFIGURATION;
 3645 peter_e@gmx.net         10711                 :             20 :                     n->object = (Node *) $5;
 7016 tgl@sss.pgh.pa.us       10712                 :             20 :                     n->newowner = $8;
 1637 peter@eisentraut.org    10713                 :             20 :                     $$ = (Node *) n;
                              10714                 :                :                 }
                              10715                 :                :             | ALTER FOREIGN DATA_P WRAPPER name OWNER TO RoleSpec
                              10716                 :                :                 {
 6530 peter_e@gmx.net         10717                 :             13 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10718                 :                : 
                              10719                 :             13 :                     n->objectType = OBJECT_FDW;
 3645                         10720                 :             13 :                     n->object = (Node *) makeString($5);
 6530                         10721                 :             13 :                     n->newowner = $8;
 1637 peter@eisentraut.org    10722                 :             13 :                     $$ = (Node *) n;
                              10723                 :                :                 }
                              10724                 :                :             | ALTER SERVER name OWNER TO RoleSpec
                              10725                 :                :                 {
 6530 peter_e@gmx.net         10726                 :             45 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10727                 :                : 
                              10728                 :             45 :                     n->objectType = OBJECT_FOREIGN_SERVER;
 3645                         10729                 :             45 :                     n->object = (Node *) makeString($3);
 6530                         10730                 :             45 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10731                 :             45 :                     $$ = (Node *) n;
                              10732                 :                :                 }
                              10733                 :                :             | ALTER EVENT TRIGGER name OWNER TO RoleSpec
                              10734                 :                :                 {
 5223 rhaas@postgresql.org    10735                 :              9 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10736                 :                : 
                              10737                 :              9 :                     n->objectType = OBJECT_EVENT_TRIGGER;
 3645 peter_e@gmx.net         10738                 :              9 :                     n->object = (Node *) makeString($4);
 5223 rhaas@postgresql.org    10739                 :              9 :                     n->newowner = $7;
 1637 peter@eisentraut.org    10740                 :              9 :                     $$ = (Node *) n;
                              10741                 :                :                 }
                              10742                 :                :             | ALTER PUBLICATION name OWNER TO RoleSpec
                              10743                 :                :                 {
 3577 peter_e@gmx.net         10744                 :             26 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10745                 :                : 
                              10746                 :             26 :                     n->objectType = OBJECT_PUBLICATION;
 3645                         10747                 :             26 :                     n->object = (Node *) makeString($3);
 3577                         10748                 :             26 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10749                 :             26 :                     $$ = (Node *) n;
                              10750                 :                :                 }
                              10751                 :                :             | ALTER SUBSCRIPTION name OWNER TO RoleSpec
                              10752                 :                :                 {
 3577 peter_e@gmx.net         10753                 :             28 :                     AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                              10754                 :                : 
                              10755                 :             28 :                     n->objectType = OBJECT_SUBSCRIPTION;
 3645                         10756                 :             28 :                     n->object = (Node *) makeString($3);
 3577                         10757                 :             28 :                     n->newowner = $6;
 1637 peter@eisentraut.org    10758                 :             28 :                     $$ = (Node *) n;
                              10759                 :                :                 }
                              10760                 :                :         ;
                              10761                 :                : 
                              10762                 :                : 
                              10763                 :                : /*****************************************************************************
                              10764                 :                :  *
                              10765                 :                :  * CREATE PUBLICATION name [WITH options]
                              10766                 :                :  *
                              10767                 :                :  * CREATE PUBLICATION FOR ALL pub_all_obj_type [, ...] [WITH options]
                              10768                 :                :  *
                              10769                 :                :  * pub_all_obj_type is one of:
                              10770                 :                :  *
                              10771                 :                :  *      TABLES [EXCEPT (TABLE table [, ...] )]
                              10772                 :                :  *      SEQUENCES
                              10773                 :                :  *
                              10774                 :                :  * CREATE PUBLICATION FOR pub_obj [, ...] [WITH options]
                              10775                 :                :  *
                              10776                 :                :  * pub_obj is one of:
                              10777                 :                :  *
                              10778                 :                :  *      TABLE table [, ...]
                              10779                 :                :  *      TABLES IN SCHEMA schema [, ...]
                              10780                 :                :  *
                              10781                 :                :  *****************************************************************************/
                              10782                 :                : 
                              10783                 :                : CreatePublicationStmt:
                              10784                 :                :             CREATE PUBLICATION name opt_definition
                              10785                 :                :                 {
 3577 peter_e@gmx.net         10786                 :             94 :                     CreatePublicationStmt *n = makeNode(CreatePublicationStmt);
                              10787                 :                : 
                              10788                 :             94 :                     n->pubname = $3;
 1835 akapila@postgresql.o    10789                 :             94 :                     n->options = $4;
 1637 peter@eisentraut.org    10790                 :             94 :                     $$ = (Node *) n;
                              10791                 :                :                 }
                              10792                 :                :             | CREATE PUBLICATION name FOR pub_all_obj_type_list opt_definition
                              10793                 :                :                 {
 1835 akapila@postgresql.o    10794                 :            151 :                     CreatePublicationStmt *n = makeNode(CreatePublicationStmt);
                              10795                 :                : 
                              10796                 :            151 :                     n->pubname = $3;
  246                         10797                 :            151 :                     preprocess_pub_all_objtype_list($5, &n->pubobjects,
                              10798                 :                :                                                     &n->for_all_tables,
                              10799                 :                :                                                     &n->for_all_sequences,
                              10800                 :                :                                                     yyscanner);
  392                         10801                 :            143 :                     n->options = $6;
 1637 peter@eisentraut.org    10802                 :            143 :                     $$ = (Node *) n;
                              10803                 :                :                 }
                              10804                 :                :             | CREATE PUBLICATION name FOR pub_obj_list opt_definition
                              10805                 :                :                 {
 1835 akapila@postgresql.o    10806                 :            446 :                     CreatePublicationStmt *n = makeNode(CreatePublicationStmt);
                              10807                 :                : 
                              10808                 :            446 :                     n->pubname = $3;
                              10809                 :            446 :                     n->options = $6;
 1637 peter@eisentraut.org    10810                 :            446 :                     n->pubobjects = (List *) $5;
 1835 akapila@postgresql.o    10811                 :            446 :                     preprocess_pubobj_list(n->pubobjects, yyscanner);
 1637 peter@eisentraut.org    10812                 :            426 :                     $$ = (Node *) n;
                              10813                 :                :                 }
                              10814                 :                :         ;
                              10815                 :                : 
                              10816                 :                : /*
                              10817                 :                :  * FOR TABLE and FOR TABLES IN SCHEMA specifications
                              10818                 :                :  *
                              10819                 :                :  * This rule parses publication objects with and without keyword prefixes.
                              10820                 :                :  *
                              10821                 :                :  * The actual type of the object without keyword prefix depends on the previous
                              10822                 :                :  * one with keyword prefix. It will be preprocessed in preprocess_pubobj_list().
                              10823                 :                :  *
                              10824                 :                :  * For the object without keyword prefix, we cannot just use relation_expr here,
                              10825                 :                :  * because some extended expressions in relation_expr cannot be used as a
                              10826                 :                :  * schemaname and we cannot differentiate it. So, we extract the rules from
                              10827                 :                :  * relation_expr here.
                              10828                 :                :  */
                              10829                 :                : PublicationObjSpec:
                              10830                 :                :             TABLE relation_expr opt_column_list OptWhereClause
                              10831                 :                :                 {
 1835 akapila@postgresql.o    10832                 :            879 :                     $$ = makeNode(PublicationObjSpec);
                              10833                 :            879 :                     $$->pubobjtype = PUBLICATIONOBJ_TABLE;
                              10834                 :            879 :                     $$->pubtable = makeNode(PublicationTable);
                              10835                 :            879 :                     $$->pubtable->relation = $2;
 1685 tomas.vondra@postgre    10836                 :            879 :                     $$->pubtable->columns = $3;
                              10837                 :            879 :                     $$->pubtable->whereClause = $4;
                              10838                 :                :                 }
                              10839                 :                :             | TABLES IN_P SCHEMA ColId
                              10840                 :                :                 {
 1835 akapila@postgresql.o    10841                 :            249 :                     $$ = makeNode(PublicationObjSpec);
 1771 alvherre@alvh.no-ip.    10842                 :            249 :                     $$->pubobjtype = PUBLICATIONOBJ_TABLES_IN_SCHEMA;
 1505                         10843                 :            249 :                     $$->name = $4;
                              10844                 :            249 :                     $$->location = @4;
                              10845                 :                :                 }
                              10846                 :                :             | TABLES IN_P SCHEMA CURRENT_SCHEMA
                              10847                 :                :                 {
 1835 akapila@postgresql.o    10848                 :             12 :                     $$ = makeNode(PublicationObjSpec);
 1771 alvherre@alvh.no-ip.    10849                 :             12 :                     $$->pubobjtype = PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA;
 1505                         10850                 :             12 :                     $$->location = @4;
                              10851                 :                :                 }
                              10852                 :                :             | ColId opt_column_list OptWhereClause
                              10853                 :                :                 {
 1835 akapila@postgresql.o    10854                 :             83 :                     $$ = makeNode(PublicationObjSpec);
                              10855                 :             83 :                     $$->pubobjtype = PUBLICATIONOBJ_CONTINUATION;
                              10856                 :                :                     /*
                              10857                 :                :                      * If either a row filter or column list is specified, create
                              10858                 :                :                      * a PublicationTable object.
                              10859                 :                :                      */
 1685 tomas.vondra@postgre    10860   [ +  +  +  + ]:             83 :                     if ($2 || $3)
                              10861                 :                :                     {
                              10862                 :                :                         /*
                              10863                 :                :                          * The OptWhereClause must be stored here but it is
                              10864                 :                :                          * valid only for tables. For non-table objects, an
                              10865                 :                :                          * error will be thrown later via
                              10866                 :                :                          * preprocess_pubobj_list().
                              10867                 :                :                          */
 1717 akapila@postgresql.o    10868                 :             26 :                         $$->pubtable = makeNode(PublicationTable);
                              10869                 :             26 :                         $$->pubtable->relation = makeRangeVar(NULL, $1, @1);
 1685 tomas.vondra@postgre    10870                 :             26 :                         $$->pubtable->columns = $2;
                              10871                 :             26 :                         $$->pubtable->whereClause = $3;
                              10872                 :                :                     }
                              10873                 :                :                     else
                              10874                 :                :                     {
 1717 akapila@postgresql.o    10875                 :             57 :                         $$->name = $1;
                              10876                 :                :                     }
 1835                         10877                 :             83 :                     $$->location = @1;
                              10878                 :                :                 }
                              10879                 :                :             | ColId indirection opt_column_list OptWhereClause
                              10880                 :                :                 {
                              10881                 :             21 :                     $$ = makeNode(PublicationObjSpec);
                              10882                 :             21 :                     $$->pubobjtype = PUBLICATIONOBJ_CONTINUATION;
                              10883                 :             21 :                     $$->pubtable = makeNode(PublicationTable);
                              10884                 :             21 :                     $$->pubtable->relation = makeRangeVarFromQualifiedName($1, $2, @1, yyscanner);
 1685 tomas.vondra@postgre    10885                 :             21 :                     $$->pubtable->columns = $3;
                              10886                 :             21 :                     $$->pubtable->whereClause = $4;
 1835 akapila@postgresql.o    10887                 :             21 :                     $$->location = @1;
                              10888                 :                :                 }
                              10889                 :                :             /* grammar like tablename * , ONLY tablename, ONLY ( tablename ) */
                              10890                 :                :             | extended_relation_expr opt_column_list OptWhereClause
                              10891                 :                :                 {
                              10892                 :              4 :                     $$ = makeNode(PublicationObjSpec);
                              10893                 :              4 :                     $$->pubobjtype = PUBLICATIONOBJ_CONTINUATION;
                              10894                 :              4 :                     $$->pubtable = makeNode(PublicationTable);
                              10895                 :              4 :                     $$->pubtable->relation = $1;
 1685 tomas.vondra@postgre    10896                 :              4 :                     $$->pubtable->columns = $2;
                              10897                 :              4 :                     $$->pubtable->whereClause = $3;
                              10898                 :                :                 }
                              10899                 :                :             | CURRENT_SCHEMA
                              10900                 :                :                 {
 1835 akapila@postgresql.o    10901                 :             12 :                     $$ = makeNode(PublicationObjSpec);
                              10902                 :             12 :                     $$->pubobjtype = PUBLICATIONOBJ_CONTINUATION;
                              10903                 :             12 :                     $$->location = @1;
                              10904                 :                :                 }
                              10905                 :                :                 ;
                              10906                 :                : 
                              10907                 :                : pub_obj_list:   PublicationObjSpec
 1886 alvherre@alvh.no-ip.    10908                 :           1095 :                     { $$ = list_make1($1); }
                              10909                 :                :             | pub_obj_list ',' PublicationObjSpec
 1835 akapila@postgresql.o    10910                 :            165 :                     { $$ = lappend($1, $3); }
                              10911                 :                :     ;
                              10912                 :                : 
                              10913                 :                : opt_pub_except_clause:
  219                         10914                 :             77 :             EXCEPT '(' TABLE pub_except_obj_list ')'    { $$ = $4; }
  246                         10915                 :            110 :             | /*EMPTY*/                                 { $$ = NIL; }
                              10916                 :                :         ;
                              10917                 :                : 
                              10918                 :                : PublicationAllObjSpec:
                              10919                 :                :                 ALL TABLES opt_pub_except_clause
                              10920                 :                :                     {
  392                         10921                 :            187 :                         $$ = makeNode(PublicationAllObjSpec);
                              10922                 :            187 :                         $$->pubobjtype = PUBLICATION_ALL_TABLES;
  246                         10923                 :            187 :                         $$->except_tables = $3;
  392                         10924                 :            187 :                         $$->location = @1;
                              10925                 :                :                     }
                              10926                 :                :                 | ALL SEQUENCES
                              10927                 :                :                     {
                              10928                 :             50 :                         $$ = makeNode(PublicationAllObjSpec);
                              10929                 :             50 :                         $$->pubobjtype = PUBLICATION_ALL_SEQUENCES;
                              10930                 :             50 :                         $$->location = @1;
                              10931                 :                :                     }
                              10932                 :                :                     ;
                              10933                 :                : 
                              10934                 :                : pub_all_obj_type_list:  PublicationAllObjSpec
                              10935                 :            212 :                     { $$ = list_make1($1); }
                              10936                 :                :                 | pub_all_obj_type_list ',' PublicationAllObjSpec
                              10937                 :             25 :                     { $$ = lappend($1, $3); }
                              10938                 :                :     ;
                              10939                 :                : 
                              10940                 :                : PublicationExceptObjSpec:
                              10941                 :                :              relation_expr
                              10942                 :                :                 {
  246                         10943                 :            104 :                     $$ = makeNode(PublicationObjSpec);
                              10944                 :            104 :                     $$->pubobjtype = PUBLICATIONOBJ_EXCEPT_TABLE;
                              10945                 :            104 :                     $$->pubtable = makeNode(PublicationTable);
                              10946                 :            104 :                     $$->pubtable->except = true;
                              10947                 :            104 :                     $$->pubtable->relation = $1;
                              10948                 :            104 :                     $$->location = @1;
                              10949                 :                :                 }
                              10950                 :                :     ;
                              10951                 :                : 
                              10952                 :                : pub_except_obj_list: PublicationExceptObjSpec
                              10953                 :             77 :                     { $$ = list_make1($1); }
                              10954                 :                :             | pub_except_obj_list ',' opt_table PublicationExceptObjSpec
  219                         10955                 :             27 :                     { $$ = lappend($1, $4); }
                              10956                 :                :     ;
                              10957                 :                : 
                              10958                 :                : /*****************************************************************************
                              10959                 :                :  *
                              10960                 :                :  * ALTER PUBLICATION name SET ( options )
                              10961                 :                :  *
                              10962                 :                :  * ALTER PUBLICATION name ADD pub_obj [, ...]
                              10963                 :                :  *
                              10964                 :                :  * ALTER PUBLICATION name DROP pub_obj [, ...]
                              10965                 :                :  *
                              10966                 :                :  * ALTER PUBLICATION name SET pub_obj [, ...]
                              10967                 :                :  *
                              10968                 :                :  * ALTER PUBLICATION name SET pub_all_obj_type [, ...]
                              10969                 :                :  *
                              10970                 :                :  * pub_obj is one of:
                              10971                 :                :  *
                              10972                 :                :  *      TABLE table_name [, ...]
                              10973                 :                :  *      TABLES IN SCHEMA schema_name [, ...]
                              10974                 :                :  *
                              10975                 :                :  * pub_all_obj_type is one of:
                              10976                 :                :  *
                              10977                 :                :  *      ALL TABLES [ EXCEPT ( TABLE table_name [, ...] ) ]
                              10978                 :                :  *      ALL SEQUENCES
                              10979                 :                :  *
                              10980                 :                :  *****************************************************************************/
                              10981                 :                : 
                              10982                 :                : AlterPublicationStmt:
                              10983                 :                :             ALTER PUBLICATION name SET definition
                              10984                 :                :                 {
 3577 peter_e@gmx.net         10985                 :             84 :                     AlterPublicationStmt *n = makeNode(AlterPublicationStmt);
                              10986                 :                : 
                              10987                 :             84 :                     n->pubname = $3;
                              10988                 :             84 :                     n->options = $5;
  230 akapila@postgresql.o    10989                 :             84 :                     n->for_all_tables = false;
 1637 peter@eisentraut.org    10990                 :             84 :                     $$ = (Node *) n;
                              10991                 :                :                 }
                              10992                 :                :             | ALTER PUBLICATION name ADD_P pub_obj_list
                              10993                 :                :                 {
 3577 peter_e@gmx.net         10994                 :            235 :                     AlterPublicationStmt *n = makeNode(AlterPublicationStmt);
                              10995                 :                : 
                              10996                 :            235 :                     n->pubname = $3;
 1835 akapila@postgresql.o    10997                 :            235 :                     n->pubobjects = $5;
                              10998                 :            235 :                     preprocess_pubobj_list(n->pubobjects, yyscanner);
 1767 alvherre@alvh.no-ip.    10999                 :            231 :                     n->action = AP_AddObjects;
  230 akapila@postgresql.o    11000                 :            231 :                     n->for_all_tables = false;
 1637 peter@eisentraut.org    11001                 :            231 :                     $$ = (Node *) n;
                              11002                 :                :                 }
                              11003                 :                :             | ALTER PUBLICATION name SET pub_obj_list
                              11004                 :                :                 {
 3577 peter_e@gmx.net         11005                 :            308 :                     AlterPublicationStmt *n = makeNode(AlterPublicationStmt);
                              11006                 :                : 
                              11007                 :            308 :                     n->pubname = $3;
 1835 akapila@postgresql.o    11008                 :            308 :                     n->pubobjects = $5;
                              11009                 :            308 :                     preprocess_pubobj_list(n->pubobjects, yyscanner);
 1767 alvherre@alvh.no-ip.    11010                 :            308 :                     n->action = AP_SetObjects;
  230 akapila@postgresql.o    11011                 :            308 :                     n->for_all_tables = false;
                              11012                 :            308 :                     $$ = (Node *) n;
                              11013                 :                :                 }
                              11014                 :                :             | ALTER PUBLICATION name SET pub_all_obj_type_list
                              11015                 :                :                 {
                              11016                 :             61 :                     AlterPublicationStmt *n = makeNode(AlterPublicationStmt);
                              11017                 :                : 
                              11018                 :             61 :                     n->pubname = $3;
                              11019                 :             61 :                     n->action = AP_SetObjects;
                              11020                 :             61 :                     preprocess_pub_all_objtype_list($5, &n->pubobjects,
                              11021                 :                :                                                     &n->for_all_tables,
                              11022                 :                :                                                     &n->for_all_sequences,
                              11023                 :                :                                                     yyscanner);
 1637 peter@eisentraut.org    11024                 :             61 :                     $$ = (Node *) n;
                              11025                 :                :                 }
                              11026                 :                :             | ALTER PUBLICATION name DROP pub_obj_list
                              11027                 :                :                 {
 3577 peter_e@gmx.net         11028                 :            106 :                     AlterPublicationStmt *n = makeNode(AlterPublicationStmt);
                              11029                 :                : 
                              11030                 :            106 :                     n->pubname = $3;
 1835 akapila@postgresql.o    11031                 :            106 :                     n->pubobjects = $5;
                              11032                 :            106 :                     preprocess_pubobj_list(n->pubobjects, yyscanner);
 1767 alvherre@alvh.no-ip.    11033                 :            106 :                     n->action = AP_DropObjects;
  230 akapila@postgresql.o    11034                 :            106 :                     n->for_all_tables = false;
 1637 peter@eisentraut.org    11035                 :            106 :                     $$ = (Node *) n;
                              11036                 :                :                 }
                              11037                 :                :         ;
                              11038                 :                : 
                              11039                 :                : /*****************************************************************************
                              11040                 :                :  *
                              11041                 :                :  * CREATE SUBSCRIPTION name ...
                              11042                 :                :  *
                              11043                 :                :  *****************************************************************************/
                              11044                 :                : 
                              11045                 :                : CreateSubscriptionStmt:
                              11046                 :                :             CREATE SUBSCRIPTION name CONNECTION Sconst PUBLICATION name_list opt_definition
                              11047                 :                :                 {
                              11048                 :                :                     CreateSubscriptionStmt *n =
 3577 peter_e@gmx.net         11049                 :            320 :                         makeNode(CreateSubscriptionStmt);
                              11050                 :            320 :                     n->subname = $3;
                              11051                 :            320 :                     n->conninfo = $5;
                              11052                 :            320 :                     n->publication = $7;
                              11053                 :            320 :                     n->options = $8;
 1637 peter@eisentraut.org    11054                 :            320 :                     $$ = (Node *) n;
                              11055                 :                :                 }
                              11056                 :                :             | CREATE SUBSCRIPTION name SERVER name PUBLICATION name_list opt_definition
                              11057                 :                :                 {
                              11058                 :                :                     CreateSubscriptionStmt *n =
  244 jdavis@postgresql.or    11059                 :             20 :                         makeNode(CreateSubscriptionStmt);
                              11060                 :             20 :                     n->subname = $3;
                              11061                 :             20 :                     n->servername = $5;
                              11062                 :             20 :                     n->publication = $7;
                              11063                 :             20 :                     n->options = $8;
                              11064                 :             20 :                     $$ = (Node *) n;
                              11065                 :                :                 }
                              11066                 :                :         ;
                              11067                 :                : 
                              11068                 :                : /*****************************************************************************
                              11069                 :                :  *
                              11070                 :                :  * ALTER SUBSCRIPTION name ...
                              11071                 :                :  *
                              11072                 :                :  *****************************************************************************/
                              11073                 :                : 
                              11074                 :                : AlterSubscriptionStmt:
                              11075                 :                :             ALTER SUBSCRIPTION name SET definition
                              11076                 :                :                 {
                              11077                 :                :                     AlterSubscriptionStmt *n =
 3577 peter_e@gmx.net         11078                 :            211 :                         makeNode(AlterSubscriptionStmt);
                              11079                 :                : 
 3514                         11080                 :            211 :                     n->kind = ALTER_SUBSCRIPTION_OPTIONS;
 3577                         11081                 :            211 :                     n->subname = $3;
                              11082                 :            211 :                     n->options = $5;
 1637 peter@eisentraut.org    11083                 :            211 :                     $$ = (Node *) n;
                              11084                 :                :                 }
                              11085                 :                :             | ALTER SUBSCRIPTION name CONNECTION Sconst
                              11086                 :                :                 {
                              11087                 :                :                     AlterSubscriptionStmt *n =
 3577 peter_e@gmx.net         11088                 :             27 :                         makeNode(AlterSubscriptionStmt);
                              11089                 :                : 
 3514                         11090                 :             27 :                     n->kind = ALTER_SUBSCRIPTION_CONNECTION;
 3577                         11091                 :             27 :                     n->subname = $3;
 3514                         11092                 :             27 :                     n->conninfo = $5;
 1637 peter@eisentraut.org    11093                 :             27 :                     $$ = (Node *) n;
                              11094                 :                :                 }
                              11095                 :                :             | ALTER SUBSCRIPTION name SERVER name
                              11096                 :                :                 {
                              11097                 :                :                     AlterSubscriptionStmt *n =
  244 jdavis@postgresql.or    11098                 :              1 :                         makeNode(AlterSubscriptionStmt);
                              11099                 :                : 
                              11100                 :              1 :                     n->kind = ALTER_SUBSCRIPTION_SERVER;
                              11101                 :              1 :                     n->subname = $3;
                              11102                 :              1 :                     n->servername = $5;
                              11103                 :              1 :                     $$ = (Node *) n;
                              11104                 :                :                 }
                              11105                 :                :             | ALTER SUBSCRIPTION name REFRESH PUBLICATION opt_definition
                              11106                 :                :                 {
                              11107                 :                :                     AlterSubscriptionStmt *n =
 3514 peter_e@gmx.net         11108                 :             47 :                         makeNode(AlterSubscriptionStmt);
                              11109                 :                : 
  386 akapila@postgresql.o    11110                 :             47 :                     n->kind = ALTER_SUBSCRIPTION_REFRESH_PUBLICATION;
 3514 peter_e@gmx.net         11111                 :             47 :                     n->subname = $3;
                              11112                 :             47 :                     n->options = $6;
 1637 peter@eisentraut.org    11113                 :             47 :                     $$ = (Node *) n;
                              11114                 :                :                 }
                              11115                 :                :             | ALTER SUBSCRIPTION name REFRESH SEQUENCES
                              11116                 :                :                 {
                              11117                 :                :                     AlterSubscriptionStmt *n =
  378 akapila@postgresql.o    11118                 :              6 :                         makeNode(AlterSubscriptionStmt);
                              11119                 :                : 
                              11120                 :              6 :                     n->kind = ALTER_SUBSCRIPTION_REFRESH_SEQUENCES;
                              11121                 :              6 :                     n->subname = $3;
                              11122                 :              6 :                     $$ = (Node *) n;
                              11123                 :                :                 }
                              11124                 :                :             | ALTER SUBSCRIPTION name ADD_P PUBLICATION name_list opt_definition
                              11125                 :                :                 {
                              11126                 :                :                     AlterSubscriptionStmt *n =
 2039 peter@eisentraut.org    11127                 :             18 :                         makeNode(AlterSubscriptionStmt);
                              11128                 :                : 
                              11129                 :             18 :                     n->kind = ALTER_SUBSCRIPTION_ADD_PUBLICATION;
                              11130                 :             18 :                     n->subname = $3;
                              11131                 :             18 :                     n->publication = $6;
                              11132                 :             18 :                     n->options = $7;
 1637                         11133                 :             18 :                     $$ = (Node *) n;
                              11134                 :                :                 }
                              11135                 :                :             | ALTER SUBSCRIPTION name DROP PUBLICATION name_list opt_definition
                              11136                 :                :                 {
                              11137                 :                :                     AlterSubscriptionStmt *n =
 2039                         11138                 :             17 :                         makeNode(AlterSubscriptionStmt);
                              11139                 :                : 
                              11140                 :             17 :                     n->kind = ALTER_SUBSCRIPTION_DROP_PUBLICATION;
                              11141                 :             17 :                     n->subname = $3;
                              11142                 :             17 :                     n->publication = $6;
                              11143                 :             17 :                     n->options = $7;
 1637                         11144                 :             17 :                     $$ = (Node *) n;
                              11145                 :                :                 }
                              11146                 :                :             | ALTER SUBSCRIPTION name SET PUBLICATION name_list opt_definition
                              11147                 :                :                 {
                              11148                 :                :                     AlterSubscriptionStmt *n =
 3577 peter_e@gmx.net         11149                 :             32 :                         makeNode(AlterSubscriptionStmt);
                              11150                 :                : 
 2039 peter@eisentraut.org    11151                 :             32 :                     n->kind = ALTER_SUBSCRIPTION_SET_PUBLICATION;
 3577 peter_e@gmx.net         11152                 :             32 :                     n->subname = $3;
 3514                         11153                 :             32 :                     n->publication = $6;
 3440                         11154                 :             32 :                     n->options = $7;
 1637 peter@eisentraut.org    11155                 :             32 :                     $$ = (Node *) n;
                              11156                 :                :                 }
                              11157                 :                :             | ALTER SUBSCRIPTION name ENABLE_P
                              11158                 :                :                 {
                              11159                 :                :                     AlterSubscriptionStmt *n =
 3577 peter_e@gmx.net         11160                 :             40 :                         makeNode(AlterSubscriptionStmt);
                              11161                 :                : 
 3514                         11162                 :             40 :                     n->kind = ALTER_SUBSCRIPTION_ENABLED;
 3577                         11163                 :             40 :                     n->subname = $3;
                              11164                 :             40 :                     n->options = list_make1(makeDefElem("enabled",
                              11165                 :                :                                             (Node *) makeBoolean(true), @1));
 1637 peter@eisentraut.org    11166                 :             40 :                     $$ = (Node *) n;
                              11167                 :                :                 }
                              11168                 :                :             | ALTER SUBSCRIPTION name DISABLE_P
                              11169                 :                :                 {
                              11170                 :                :                     AlterSubscriptionStmt *n =
 3577 peter_e@gmx.net         11171                 :             51 :                         makeNode(AlterSubscriptionStmt);
                              11172                 :                : 
 3514                         11173                 :             51 :                     n->kind = ALTER_SUBSCRIPTION_ENABLED;
 3577                         11174                 :             51 :                     n->subname = $3;
                              11175                 :             51 :                     n->options = list_make1(makeDefElem("enabled",
                              11176                 :                :                                             (Node *) makeBoolean(false), @1));
 1637 peter@eisentraut.org    11177                 :             51 :                     $$ = (Node *) n;
                              11178                 :                :                 }
                              11179                 :                :             | ALTER SUBSCRIPTION name SKIP definition
                              11180                 :                :                 {
                              11181                 :                :                     AlterSubscriptionStmt *n =
 1689 akapila@postgresql.o    11182                 :             15 :                         makeNode(AlterSubscriptionStmt);
                              11183                 :                : 
                              11184                 :             15 :                     n->kind = ALTER_SUBSCRIPTION_SKIP;
                              11185                 :             15 :                     n->subname = $3;
                              11186                 :             15 :                     n->options = $5;
 1637 peter@eisentraut.org    11187                 :             15 :                     $$ = (Node *) n;
                              11188                 :                :                 }
                              11189                 :                :         ;
                              11190                 :                : 
                              11191                 :                : /*****************************************************************************
                              11192                 :                :  *
                              11193                 :                :  * DROP SUBSCRIPTION [ IF EXISTS ] name
                              11194                 :                :  *
                              11195                 :                :  *****************************************************************************/
                              11196                 :                : 
                              11197                 :                : DropSubscriptionStmt: DROP SUBSCRIPTION name opt_drop_behavior
                              11198                 :                :                 {
 3577 peter_e@gmx.net         11199                 :            181 :                     DropSubscriptionStmt *n = makeNode(DropSubscriptionStmt);
                              11200                 :                : 
                              11201                 :            181 :                     n->subname = $3;
                              11202                 :            181 :                     n->missing_ok = false;
 3467                         11203                 :            181 :                     n->behavior = $4;
 3577                         11204                 :            181 :                     $$ = (Node *) n;
                              11205                 :                :                 }
                              11206                 :                :                 |  DROP SUBSCRIPTION IF_P EXISTS name opt_drop_behavior
                              11207                 :                :                 {
                              11208                 :              4 :                     DropSubscriptionStmt *n = makeNode(DropSubscriptionStmt);
                              11209                 :                : 
                              11210                 :              4 :                     n->subname = $5;
                              11211                 :              4 :                     n->missing_ok = true;
 3467                         11212                 :              4 :                     n->behavior = $6;
 3577                         11213                 :              4 :                     $$ = (Node *) n;
                              11214                 :                :                 }
                              11215                 :                :         ;
                              11216                 :                : 
                              11217                 :                : /*****************************************************************************
                              11218                 :                :  *
                              11219                 :                :  *      QUERY:  Define Rewrite Rule
                              11220                 :                :  *
                              11221                 :                :  *****************************************************************************/
                              11222                 :                : 
                              11223                 :                : RuleStmt:   CREATE opt_or_replace RULE name AS
                              11224                 :                :             ON event TO qualified_name where_clause
                              11225                 :                :             DO opt_instead RuleActionList
                              11226                 :                :                 {
 1637 peter@eisentraut.org    11227                 :            734 :                     RuleStmt   *n = makeNode(RuleStmt);
                              11228                 :                : 
 8830 tgl@sss.pgh.pa.us       11229                 :            734 :                     n->replace = $2;
 6209                         11230                 :            734 :                     n->relation = $9;
 8830                         11231                 :            734 :                     n->rulename = $4;
 6209                         11232                 :            734 :                     n->whereClause = $10;
                              11233                 :            734 :                     n->event = $7;
                              11234                 :            734 :                     n->instead = $12;
                              11235                 :            734 :                     n->actions = $13;
 1637 peter@eisentraut.org    11236                 :            734 :                     $$ = (Node *) n;
                              11237                 :                :                 }
                              11238                 :                :         ;
                              11239                 :                : 
                              11240                 :                : RuleActionList:
 8907 bruce@momjian.us        11241                 :            110 :             NOTHING                                 { $$ = NIL; }
 8194 neilc@samurai.com       11242                 :            594 :             | RuleActionStmt                        { $$ = list_make1($1); }
 8907 bruce@momjian.us        11243                 :             30 :             | '(' RuleActionMulti ')'               { $$ = $2; }
                              11244                 :                :         ;
                              11245                 :                : 
                              11246                 :                : /* the thrashing around here is to discard "empty" statements... */
                              11247                 :                : RuleActionMulti:
                              11248                 :                :             RuleActionMulti ';' RuleActionStmtOrEmpty
 8338 neilc@samurai.com       11249         [ +  + ]:             40 :                 { if ($3 != NULL)
 9504 bruce@momjian.us        11250                 :             30 :                     $$ = lappend($1, $3);
                              11251                 :                :                   else
 9891 tgl@sss.pgh.pa.us       11252                 :             10 :                     $$ = $1;
                              11253                 :                :                 }
                              11254                 :                :             | RuleActionStmtOrEmpty
 8338 neilc@samurai.com       11255         [ +  - ]:             30 :                 { if ($1 != NULL)
 8194                         11256                 :             30 :                     $$ = list_make1($1);
                              11257                 :                :                   else
 9891 tgl@sss.pgh.pa.us       11258                 :UBC           0 :                     $$ = NIL;
                              11259                 :                :                 }
                              11260                 :                :         ;
                              11261                 :                : 
                              11262                 :                : RuleActionStmt:
                              11263                 :                :             SelectStmt
                              11264                 :                :             | InsertStmt
                              11265                 :                :             | UpdateStmt
                              11266                 :                :             | DeleteStmt
                              11267                 :                :             | NotifyStmt
                              11268                 :                :         ;
                              11269                 :                : 
                              11270                 :                : RuleActionStmtOrEmpty:
 8907 bruce@momjian.us        11271                 :CBC          60 :             RuleActionStmt                          { $$ = $1; }
 8338 neilc@samurai.com       11272                 :             10 :             |   /*EMPTY*/                           { $$ = NULL; }
                              11273                 :                :         ;
                              11274                 :                : 
 8907 bruce@momjian.us        11275                 :             12 : event:      SELECT                                  { $$ = CMD_SELECT; }
                              11276                 :            286 :             | UPDATE                                { $$ = CMD_UPDATE; }
                              11277                 :            106 :             | DELETE_P                              { $$ = CMD_DELETE; }
                              11278                 :            330 :             | INSERT                                { $$ = CMD_INSERT; }
                              11279                 :                :          ;
                              11280                 :                : 
                              11281                 :                : opt_instead:
 3368 peter_e@gmx.net         11282                 :            505 :             INSTEAD                                 { $$ = true; }
                              11283                 :            119 :             | ALSO                                  { $$ = false; }
                              11284                 :            110 :             | /*EMPTY*/                             { $$ = false; }
                              11285                 :                :         ;
                              11286                 :                : 
                              11287                 :                : 
                              11288                 :                : /*****************************************************************************
                              11289                 :                :  *
                              11290                 :                :  *      QUERY:
                              11291                 :                :  *              NOTIFY <identifier> can appear both in rule bodies and
                              11292                 :                :  *              as a query-level command
                              11293                 :                :  *
                              11294                 :                :  *****************************************************************************/
                              11295                 :                : 
                              11296                 :                : NotifyStmt: NOTIFY ColId notify_payload
                              11297                 :                :                 {
10650 bruce@momjian.us        11298                 :             78 :                     NotifyStmt *n = makeNode(NotifyStmt);
                              11299                 :                : 
 6639 tgl@sss.pgh.pa.us       11300                 :             78 :                     n->conditionname = $2;
 6106                         11301                 :             78 :                     n->payload = $3;
 1637 peter@eisentraut.org    11302                 :             78 :                     $$ = (Node *) n;
                              11303                 :                :                 }
                              11304                 :                :         ;
                              11305                 :                : 
                              11306                 :                : notify_payload:
 6106 tgl@sss.pgh.pa.us       11307                 :             37 :             ',' Sconst                          { $$ = $2; }
                              11308                 :             41 :             | /*EMPTY*/                         { $$ = NULL; }
                              11309                 :                :         ;
                              11310                 :                : 
                              11311                 :                : ListenStmt: LISTEN ColId
                              11312                 :                :                 {
10650 bruce@momjian.us        11313                 :             52 :                     ListenStmt *n = makeNode(ListenStmt);
                              11314                 :                : 
 6639 tgl@sss.pgh.pa.us       11315                 :             52 :                     n->conditionname = $2;
 1637 peter@eisentraut.org    11316                 :             52 :                     $$ = (Node *) n;
                              11317                 :                :                 }
                              11318                 :                :         ;
                              11319                 :                : 
                              11320                 :                : UnlistenStmt:
                              11321                 :                :             UNLISTEN ColId
                              11322                 :                :                 {
10299 scrappy@hub.org         11323                 :              4 :                     UnlistenStmt *n = makeNode(UnlistenStmt);
                              11324                 :                : 
 6639 tgl@sss.pgh.pa.us       11325                 :              4 :                     n->conditionname = $2;
 1637 peter@eisentraut.org    11326                 :              4 :                     $$ = (Node *) n;
                              11327                 :                :                 }
                              11328                 :                :             | UNLISTEN '*'
                              11329                 :                :                 {
10254 lockhart@fourpalms.o    11330                 :             58 :                     UnlistenStmt *n = makeNode(UnlistenStmt);
                              11331                 :                : 
 6639 tgl@sss.pgh.pa.us       11332                 :             58 :                     n->conditionname = NULL;
 1637 peter@eisentraut.org    11333                 :             58 :                     $$ = (Node *) n;
                              11334                 :                :                 }
                              11335                 :                :         ;
                              11336                 :                : 
                              11337                 :                : 
                              11338                 :                : /*****************************************************************************
                              11339                 :                :  *
                              11340                 :                :  *      Transactions:
                              11341                 :                :  *
                              11342                 :                :  *      BEGIN / COMMIT / ROLLBACK
                              11343                 :                :  *      (also older versions END / ABORT)
                              11344                 :                :  *
                              11345                 :                :  *****************************************************************************/
                              11346                 :                : 
                              11347                 :                : TransactionStmt:
                              11348                 :                :             ABORT_P opt_transaction opt_transaction_chain
                              11349                 :                :                 {
10650 bruce@momjian.us        11350                 :            419 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11351                 :                : 
 8669 tgl@sss.pgh.pa.us       11352                 :            419 :                     n->kind = TRANS_STMT_ROLLBACK;
 8859 bruce@momjian.us        11353                 :            419 :                     n->options = NIL;
 2783 peter@eisentraut.org    11354                 :            419 :                     n->chain = $3;
 1197 michael@paquier.xyz     11355                 :            419 :                     n->location = -1;
 1637 peter@eisentraut.org    11356                 :            419 :                     $$ = (Node *) n;
                              11357                 :                :                 }
                              11358                 :                :             | START TRANSACTION transaction_mode_list_or_empty
                              11359                 :                :                 {
10650 bruce@momjian.us        11360                 :            906 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11361                 :                : 
 8669 tgl@sss.pgh.pa.us       11362                 :            906 :                     n->kind = TRANS_STMT_START;
 8859 bruce@momjian.us        11363                 :            906 :                     n->options = $3;
 1197 michael@paquier.xyz     11364                 :            906 :                     n->location = -1;
 1637 peter@eisentraut.org    11365                 :            906 :                     $$ = (Node *) n;
                              11366                 :                :                 }
                              11367                 :                :             | COMMIT opt_transaction opt_transaction_chain
                              11368                 :                :                 {
 9587 lockhart@fourpalms.o    11369                 :           9370 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11370                 :                : 
 8669 tgl@sss.pgh.pa.us       11371                 :           9369 :                     n->kind = TRANS_STMT_COMMIT;
 8859 bruce@momjian.us        11372                 :           9369 :                     n->options = NIL;
 2783 peter@eisentraut.org    11373                 :           9369 :                     n->chain = $3;
 1197 michael@paquier.xyz     11374                 :           9369 :                     n->location = -1;
 1637 peter@eisentraut.org    11375                 :           9369 :                     $$ = (Node *) n;
                              11376                 :                :                 }
                              11377                 :                :             | ROLLBACK opt_transaction opt_transaction_chain
                              11378                 :                :                 {
10650 bruce@momjian.us        11379                 :           1882 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11380                 :                : 
 8669 tgl@sss.pgh.pa.us       11381                 :           1882 :                     n->kind = TRANS_STMT_ROLLBACK;
 8859 bruce@momjian.us        11382                 :           1882 :                     n->options = NIL;
 2783 peter@eisentraut.org    11383                 :           1882 :                     n->chain = $3;
 1197 michael@paquier.xyz     11384                 :           1882 :                     n->location = -1;
 1637 peter@eisentraut.org    11385                 :           1882 :                     $$ = (Node *) n;
                              11386                 :                :                 }
                              11387                 :                :             | SAVEPOINT ColId
                              11388                 :                :                 {
 8136 tgl@sss.pgh.pa.us       11389                 :           1216 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11390                 :                : 
                              11391                 :           1215 :                     n->kind = TRANS_STMT_SAVEPOINT;
 3184 peter_e@gmx.net         11392                 :           1215 :                     n->savepoint_name = $2;
 1197 michael@paquier.xyz     11393                 :           1215 :                     n->location = @2;
 1637 peter@eisentraut.org    11394                 :           1215 :                     $$ = (Node *) n;
                              11395                 :                :                 }
                              11396                 :                :             | RELEASE SAVEPOINT ColId
                              11397                 :                :                 {
 8120 tgl@sss.pgh.pa.us       11398                 :            138 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11399                 :                : 
                              11400                 :            138 :                     n->kind = TRANS_STMT_RELEASE;
 3184 peter_e@gmx.net         11401                 :            138 :                     n->savepoint_name = $3;
 1197 michael@paquier.xyz     11402                 :            138 :                     n->location = @3;
 1637 peter@eisentraut.org    11403                 :            138 :                     $$ = (Node *) n;
                              11404                 :                :                 }
                              11405                 :                :             | RELEASE ColId
                              11406                 :                :                 {
 8136 tgl@sss.pgh.pa.us       11407                 :             58 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11408                 :                : 
                              11409                 :             57 :                     n->kind = TRANS_STMT_RELEASE;
 3184 peter_e@gmx.net         11410                 :             57 :                     n->savepoint_name = $2;
 1197 michael@paquier.xyz     11411                 :             57 :                     n->location = @2;
 1637 peter@eisentraut.org    11412                 :             57 :                     $$ = (Node *) n;
                              11413                 :                :                 }
                              11414                 :                :             | ROLLBACK opt_transaction TO SAVEPOINT ColId
                              11415                 :                :                 {
 8136 tgl@sss.pgh.pa.us       11416                 :            206 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11417                 :                : 
                              11418                 :            206 :                     n->kind = TRANS_STMT_ROLLBACK_TO;
 3184 peter_e@gmx.net         11419                 :            206 :                     n->savepoint_name = $5;
 1197 michael@paquier.xyz     11420                 :            206 :                     n->location = @5;
 1637 peter@eisentraut.org    11421                 :            206 :                     $$ = (Node *) n;
                              11422                 :                :                 }
                              11423                 :                :             | ROLLBACK opt_transaction TO ColId
                              11424                 :                :                 {
 8120 tgl@sss.pgh.pa.us       11425                 :            331 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11426                 :                : 
                              11427                 :            331 :                     n->kind = TRANS_STMT_ROLLBACK_TO;
 3184 peter_e@gmx.net         11428                 :            331 :                     n->savepoint_name = $4;
 1197 michael@paquier.xyz     11429                 :            331 :                     n->location = @4;
 1637 peter@eisentraut.org    11430                 :            331 :                     $$ = (Node *) n;
                              11431                 :                :                 }
                              11432                 :                :             | PREPARE TRANSACTION Sconst
                              11433                 :                :                 {
 7811 tgl@sss.pgh.pa.us       11434                 :            361 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11435                 :                : 
                              11436                 :            361 :                     n->kind = TRANS_STMT_PREPARE;
                              11437                 :            361 :                     n->gid = $3;
 1181 michael@paquier.xyz     11438                 :            361 :                     n->location = @3;
 1637 peter@eisentraut.org    11439                 :            361 :                     $$ = (Node *) n;
                              11440                 :                :                 }
                              11441                 :                :             | COMMIT PREPARED Sconst
                              11442                 :                :                 {
 7811 tgl@sss.pgh.pa.us       11443                 :            257 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11444                 :                : 
                              11445                 :            257 :                     n->kind = TRANS_STMT_COMMIT_PREPARED;
                              11446                 :            257 :                     n->gid = $3;
 1181 michael@paquier.xyz     11447                 :            257 :                     n->location = @3;
 1637 peter@eisentraut.org    11448                 :            257 :                     $$ = (Node *) n;
                              11449                 :                :                 }
                              11450                 :                :             | ROLLBACK PREPARED Sconst
                              11451                 :                :                 {
 7811 tgl@sss.pgh.pa.us       11452                 :             51 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11453                 :                : 
                              11454                 :             51 :                     n->kind = TRANS_STMT_ROLLBACK_PREPARED;
                              11455                 :             51 :                     n->gid = $3;
 1181 michael@paquier.xyz     11456                 :             51 :                     n->location = @3;
 1637 peter@eisentraut.org    11457                 :             51 :                     $$ = (Node *) n;
                              11458                 :                :                 }
                              11459                 :                :         ;
                              11460                 :                : 
                              11461                 :                : TransactionStmtLegacy:
                              11462                 :                :             BEGIN_P opt_transaction transaction_mode_list_or_empty
                              11463                 :                :                 {
 2038                         11464                 :          11496 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11465                 :                : 
                              11466                 :          11495 :                     n->kind = TRANS_STMT_BEGIN;
                              11467                 :          11495 :                     n->options = $3;
 1197 michael@paquier.xyz     11468                 :          11495 :                     n->location = -1;
 1637 peter@eisentraut.org    11469                 :          11495 :                     $$ = (Node *) n;
                              11470                 :                :                 }
                              11471                 :                :             | END_P opt_transaction opt_transaction_chain
                              11472                 :                :                 {
 2038                         11473                 :            207 :                     TransactionStmt *n = makeNode(TransactionStmt);
                              11474                 :                : 
                              11475                 :            207 :                     n->kind = TRANS_STMT_COMMIT;
                              11476                 :            207 :                     n->options = NIL;
                              11477                 :            207 :                     n->chain = $3;
 1197 michael@paquier.xyz     11478                 :            207 :                     n->location = -1;
 1637 peter@eisentraut.org    11479                 :            207 :                     $$ = (Node *) n;
                              11480                 :                :                 }
                              11481                 :                :         ;
                              11482                 :                : 
                              11483                 :                : opt_transaction:    WORK
                              11484                 :                :             | TRANSACTION
                              11485                 :                :             | /*EMPTY*/
                              11486                 :                :         ;
                              11487                 :                : 
                              11488                 :                : transaction_mode_item:
                              11489                 :                :             ISOLATION LEVEL iso_level
 8120 tgl@sss.pgh.pa.us       11490                 :           3663 :                     { $$ = makeDefElem("transaction_isolation",
 3712 peter_e@gmx.net         11491                 :           3663 :                                        makeStringConst($3, @3), @1); }
                              11492                 :                :             | READ ONLY
 8120 tgl@sss.pgh.pa.us       11493                 :            787 :                     { $$ = makeDefElem("transaction_read_only",
 3368 peter_e@gmx.net         11494                 :            787 :                                        makeIntConst(true, @1), @1); }
                              11495                 :                :             | READ WRITE
 8120 tgl@sss.pgh.pa.us       11496                 :             59 :                     { $$ = makeDefElem("transaction_read_only",
 3368 peter_e@gmx.net         11497                 :             59 :                                        makeIntConst(false, @1), @1); }
                              11498                 :                :             | DEFERRABLE
 5750 heikki.linnakangas@i    11499                 :             33 :                     { $$ = makeDefElem("transaction_deferrable",
                              11500                 :                :                                        makeIntConst(true, @1), @1); }
                              11501                 :                :             | NOT DEFERRABLE
                              11502                 :              6 :                     { $$ = makeDefElem("transaction_deferrable",
 3368 peter_e@gmx.net         11503                 :              6 :                                        makeIntConst(false, @1), @1); }
                              11504                 :                :         ;
                              11505                 :                : 
                              11506                 :                : /* Syntax with commas is SQL-spec, without commas is Postgres historical */
                              11507                 :                : transaction_mode_list:
                              11508                 :                :             transaction_mode_item
 8120 tgl@sss.pgh.pa.us       11509                 :           3822 :                     { $$ = list_make1($1); }
                              11510                 :                :             | transaction_mode_list ',' transaction_mode_item
                              11511                 :            492 :                     { $$ = lappend($1, $3); }
                              11512                 :                :             | transaction_mode_list transaction_mode_item
                              11513                 :            234 :                     { $$ = lappend($1, $2); }
                              11514                 :                :         ;
                              11515                 :                : 
                              11516                 :                : transaction_mode_list_or_empty:
                              11517                 :                :             transaction_mode_list
                              11518                 :                :             | /* EMPTY */
 8700 peter_e@gmx.net         11519                 :           8928 :                     { $$ = NIL; }
                              11520                 :                :         ;
                              11521                 :                : 
                              11522                 :                : opt_transaction_chain:
 2783 peter@eisentraut.org    11523                 :             80 :             AND CHAIN       { $$ = true; }
                              11524                 :              1 :             | AND NO CHAIN  { $$ = false; }
                              11525                 :          11797 :             | /* EMPTY */   { $$ = false; }
                              11526                 :                :         ;
                              11527                 :                : 
                              11528                 :                : 
                              11529                 :                : /*****************************************************************************
                              11530                 :                :  *
                              11531                 :                :  *  QUERY:
                              11532                 :                :  *      CREATE [ OR REPLACE ] [ TEMP ] VIEW <viewname> '('target-list ')'
                              11533                 :                :  *          AS <query> [ WITH [ CASCADED | LOCAL ] CHECK OPTION ]
                              11534                 :                :  *
                              11535                 :                :  *****************************************************************************/
                              11536                 :                : 
                              11537                 :                : ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions
                              11538                 :                :                 AS SelectStmt opt_check_option
                              11539                 :                :                 {
 1637                         11540                 :          10549 :                     ViewStmt   *n = makeNode(ViewStmt);
                              11541                 :                : 
 8830 tgl@sss.pgh.pa.us       11542                 :          10549 :                     n->view = $4;
 5806 rhaas@postgresql.org    11543                 :          10549 :                     n->view->relpersistence = $2;
 8830 tgl@sss.pgh.pa.us       11544                 :          10549 :                     n->aliases = $5;
 5432 rhaas@postgresql.org    11545                 :          10549 :                     n->query = $8;
 7177 tgl@sss.pgh.pa.us       11546                 :          10549 :                     n->replace = false;
 5432 rhaas@postgresql.org    11547                 :          10549 :                     n->options = $6;
 4858 sfrost@snowman.net      11548                 :          10549 :                     n->withCheckOption = $9;
 7946 neilc@samurai.com       11549                 :          10549 :                     $$ = (Node *) n;
                              11550                 :                :                 }
                              11551                 :                :         | CREATE OR REPLACE OptTemp VIEW qualified_name opt_column_list opt_reloptions
                              11552                 :                :                 AS SelectStmt opt_check_option
                              11553                 :                :                 {
 1637 peter@eisentraut.org    11554                 :            177 :                     ViewStmt   *n = makeNode(ViewStmt);
                              11555                 :                : 
 7946 neilc@samurai.com       11556                 :            177 :                     n->view = $6;
 5806 rhaas@postgresql.org    11557                 :            177 :                     n->view->relpersistence = $4;
 7946 neilc@samurai.com       11558                 :            177 :                     n->aliases = $7;
 5432 rhaas@postgresql.org    11559                 :            177 :                     n->query = $10;
 7177 tgl@sss.pgh.pa.us       11560                 :            177 :                     n->replace = true;
 5432 rhaas@postgresql.org    11561                 :            177 :                     n->options = $8;
 4858 sfrost@snowman.net      11562                 :            177 :                     n->withCheckOption = $11;
 7946 neilc@samurai.com       11563                 :            177 :                     $$ = (Node *) n;
                              11564                 :                :                 }
                              11565                 :                :         | CREATE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions
                              11566                 :                :                 AS SelectStmt opt_check_option
                              11567                 :                :                 {
 1637 peter@eisentraut.org    11568                 :              5 :                     ViewStmt   *n = makeNode(ViewStmt);
                              11569                 :                : 
 5026 peter_e@gmx.net         11570                 :              5 :                     n->view = $5;
                              11571                 :              5 :                     n->view->relpersistence = $2;
                              11572                 :              5 :                     n->aliases = $7;
                              11573                 :              5 :                     n->query = makeRecursiveViewSelect(n->view->relname, n->aliases, $11);
                              11574                 :              5 :                     n->replace = false;
                              11575                 :              5 :                     n->options = $9;
 4858 sfrost@snowman.net      11576                 :              5 :                     n->withCheckOption = $12;
                              11577         [ -  + ]:              5 :                     if (n->withCheckOption != NO_CHECK_OPTION)
 4858 sfrost@snowman.net      11578         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              11579                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              11580                 :                :                                  errmsg("WITH CHECK OPTION not supported on recursive views"),
                              11581                 :                :                                  parser_errposition(@12)));
 5026 peter_e@gmx.net         11582                 :CBC           5 :                     $$ = (Node *) n;
                              11583                 :                :                 }
                              11584                 :                :         | CREATE OR REPLACE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions
                              11585                 :                :                 AS SelectStmt opt_check_option
                              11586                 :                :                 {
 1637 peter@eisentraut.org    11587                 :              4 :                     ViewStmt   *n = makeNode(ViewStmt);
                              11588                 :                : 
 5026 peter_e@gmx.net         11589                 :              4 :                     n->view = $7;
                              11590                 :              4 :                     n->view->relpersistence = $4;
                              11591                 :              4 :                     n->aliases = $9;
                              11592                 :              4 :                     n->query = makeRecursiveViewSelect(n->view->relname, n->aliases, $13);
                              11593                 :              4 :                     n->replace = true;
                              11594                 :              4 :                     n->options = $11;
 4858 sfrost@snowman.net      11595                 :              4 :                     n->withCheckOption = $14;
                              11596         [ -  + ]:              4 :                     if (n->withCheckOption != NO_CHECK_OPTION)
 4858 sfrost@snowman.net      11597         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              11598                 :                :                                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              11599                 :                :                                  errmsg("WITH CHECK OPTION not supported on recursive views"),
                              11600                 :                :                                  parser_errposition(@14)));
 5026 peter_e@gmx.net         11601                 :CBC           4 :                     $$ = (Node *) n;
                              11602                 :                :                 }
                              11603                 :                :         ;
                              11604                 :                : 
                              11605                 :                : opt_check_option:
 4858 sfrost@snowman.net      11606                 :             63 :         WITH CHECK OPTION               { $$ = CASCADED_CHECK_OPTION; }
                              11607                 :              4 :         | WITH CASCADED CHECK OPTION    { $$ = CASCADED_CHECK_OPTION; }
                              11608                 :             16 :         | WITH LOCAL CHECK OPTION       { $$ = LOCAL_CHECK_OPTION; }
                              11609                 :          10652 :         | /* EMPTY */                   { $$ = NO_CHECK_OPTION; }
                              11610                 :                :         ;
                              11611                 :                : 
                              11612                 :                : /*****************************************************************************
                              11613                 :                :  *
                              11614                 :                :  *      QUERY:
                              11615                 :                :  *              LOAD "filename"
                              11616                 :                :  *
                              11617                 :                :  *****************************************************************************/
                              11618                 :                : 
                              11619                 :                : LoadStmt:   LOAD file_name
                              11620                 :                :                 {
 1637 peter@eisentraut.org    11621                 :             50 :                     LoadStmt   *n = makeNode(LoadStmt);
                              11622                 :                : 
10650 bruce@momjian.us        11623                 :             50 :                     n->filename = $2;
 1637 peter@eisentraut.org    11624                 :             50 :                     $$ = (Node *) n;
                              11625                 :                :                 }
                              11626                 :                :         ;
                              11627                 :                : 
                              11628                 :                : 
                              11629                 :                : /*****************************************************************************
                              11630                 :                :  *
                              11631                 :                :  *      CREATE DATABASE
                              11632                 :                :  *
                              11633                 :                :  *****************************************************************************/
                              11634                 :                : 
                              11635                 :                : CreatedbStmt:
                              11636                 :                :             CREATE DATABASE name opt_with createdb_opt_list
                              11637                 :                :                 {
 9507 tgl@sss.pgh.pa.us       11638                 :            457 :                     CreatedbStmt *n = makeNode(CreatedbStmt);
                              11639                 :                : 
10650 bruce@momjian.us        11640                 :            457 :                     n->dbname = $3;
 8906                         11641                 :            457 :                     n->options = $5;
 1637 peter@eisentraut.org    11642                 :            457 :                     $$ = (Node *) n;
                              11643                 :                :                 }
                              11644                 :                :         ;
                              11645                 :                : 
                              11646                 :                : createdb_opt_list:
 4510 tgl@sss.pgh.pa.us       11647                 :            373 :             createdb_opt_items                      { $$ = $1; }
 8906 bruce@momjian.us        11648                 :            122 :             | /* EMPTY */                           { $$ = NIL; }
                              11649                 :                :         ;
                              11650                 :                : 
                              11651                 :                : createdb_opt_items:
 4510 tgl@sss.pgh.pa.us       11652                 :            373 :             createdb_opt_item                       { $$ = list_make1($1); }
                              11653                 :            566 :             | createdb_opt_items createdb_opt_item  { $$ = lappend($1, $2); }
                              11654                 :                :         ;
                              11655                 :                : 
                              11656                 :                : createdb_opt_item:
                              11657                 :                :             createdb_opt_name opt_equal NumericOnly
                              11658                 :                :                 {
 1462                         11659                 :            157 :                     $$ = makeDefElem($1, $3, @1);
                              11660                 :                :                 }
                              11661                 :                :             | createdb_opt_name opt_equal opt_boolean_or_string
                              11662                 :                :                 {
 1637 peter@eisentraut.org    11663                 :            782 :                     $$ = makeDefElem($1, (Node *) makeString($3), @1);
                              11664                 :                :                 }
                              11665                 :                :             | createdb_opt_name opt_equal DEFAULT
                              11666                 :                :                 {
 3712 peter_e@gmx.net         11667                 :UBC           0 :                     $$ = makeDefElem($1, NULL, @1);
                              11668                 :                :                 }
                              11669                 :                :         ;
                              11670                 :                : 
                              11671                 :                : /*
                              11672                 :                :  * Ideally we'd use ColId here, but that causes shift/reduce conflicts against
                              11673                 :                :  * the ALTER DATABASE SET/RESET syntaxes.  Instead call out specific keywords
                              11674                 :                :  * we need, and allow IDENT so that database option names don't have to be
                              11675                 :                :  * parser keywords unless they are already keywords for other reasons.
                              11676                 :                :  *
                              11677                 :                :  * XXX this coding technique is fragile since if someone makes a formerly
                              11678                 :                :  * non-keyword option name into a keyword and forgets to add it here, the
                              11679                 :                :  * option will silently break.  Best defense is to provide a regression test
                              11680                 :                :  * exercising every such option, at least at the syntax level.
                              11681                 :                :  */
                              11682                 :                : createdb_opt_name:
 4510 tgl@sss.pgh.pa.us       11683                 :CBC         662 :             IDENT                           { $$ = $1; }
                              11684                 :              2 :             | CONNECTION LIMIT              { $$ = pstrdup("connection_limit"); }
                              11685                 :             58 :             | ENCODING                      { $$ = pstrdup($1); }
 4510 tgl@sss.pgh.pa.us       11686                 :UBC           0 :             | LOCATION                      { $$ = pstrdup($1); }
 4510 tgl@sss.pgh.pa.us       11687                 :CBC           1 :             | OWNER                         { $$ = pstrdup($1); }
                              11688                 :             17 :             | TABLESPACE                    { $$ = pstrdup($1); }
                              11689                 :            199 :             | TEMPLATE                      { $$ = pstrdup($1); }
                              11690                 :                :         ;
                              11691                 :                : 
                              11692                 :                : /*
                              11693                 :                :  *  Though the equals sign doesn't match other WITH options, pg_dump uses
                              11694                 :                :  *  equals for backward compatibility, and it doesn't seem worth removing it.
                              11695                 :                :  */
                              11696                 :                : opt_equal:  '='
                              11697                 :                :             | /*EMPTY*/
                              11698                 :                :         ;
                              11699                 :                : 
                              11700                 :                : 
                              11701                 :                : /*****************************************************************************
                              11702                 :                :  *
                              11703                 :                :  *      ALTER DATABASE
                              11704                 :                :  *
                              11705                 :                :  *****************************************************************************/
                              11706                 :                : 
                              11707                 :                : AlterDatabaseStmt:
                              11708                 :                :             ALTER DATABASE name WITH createdb_opt_list
                              11709                 :                :                  {
 7767 tgl@sss.pgh.pa.us       11710                 :UBC           0 :                     AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt);
                              11711                 :                : 
                              11712                 :              0 :                     n->dbname = $3;
                              11713                 :              0 :                     n->options = $5;
 1637 peter@eisentraut.org    11714                 :              0 :                     $$ = (Node *) n;
                              11715                 :                :                  }
                              11716                 :                :             | ALTER DATABASE name createdb_opt_list
                              11717                 :                :                  {
 4510 tgl@sss.pgh.pa.us       11718                 :CBC          38 :                     AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt);
                              11719                 :                : 
                              11720                 :             38 :                     n->dbname = $3;
                              11721                 :             38 :                     n->options = $4;
 1637 peter@eisentraut.org    11722                 :             38 :                     $$ = (Node *) n;
                              11723                 :                :                  }
                              11724                 :                :             | ALTER DATABASE name SET TABLESPACE name
                              11725                 :                :                  {
 6572 tgl@sss.pgh.pa.us       11726                 :             14 :                     AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt);
                              11727                 :                : 
                              11728                 :             14 :                     n->dbname = $3;
                              11729                 :             14 :                     n->options = list_make1(makeDefElem("tablespace",
                              11730                 :                :                                                         (Node *) makeString($6), @6));
 1637 peter@eisentraut.org    11731                 :             14 :                     $$ = (Node *) n;
                              11732                 :                :                  }
                              11733                 :                :             | ALTER DATABASE name REFRESH COLLATION VERSION_P
                              11734                 :                :                  {
 1725                         11735                 :              4 :                     AlterDatabaseRefreshCollStmt *n = makeNode(AlterDatabaseRefreshCollStmt);
                              11736                 :                : 
                              11737                 :              4 :                     n->dbname = $3;
 1637                         11738                 :              4 :                     $$ = (Node *) n;
                              11739                 :                :                  }
                              11740                 :                :         ;
                              11741                 :                : 
                              11742                 :                : AlterDatabaseSetStmt:
                              11743                 :                :             ALTER DATABASE name SetResetClause
                              11744                 :                :                 {
 9015 peter_e@gmx.net         11745                 :            676 :                     AlterDatabaseSetStmt *n = makeNode(AlterDatabaseSetStmt);
                              11746                 :                : 
                              11747                 :            676 :                     n->dbname = $3;
 7003 tgl@sss.pgh.pa.us       11748                 :            676 :                     n->setstmt = $4;
 1637 peter@eisentraut.org    11749                 :            676 :                     $$ = (Node *) n;
                              11750                 :                :                 }
                              11751                 :                :         ;
                              11752                 :                : 
                              11753                 :                : 
                              11754                 :                : /*****************************************************************************
                              11755                 :                :  *
                              11756                 :                :  *      DROP DATABASE [ IF EXISTS ] dbname [ [ WITH ] ( options ) ]
                              11757                 :                :  *
                              11758                 :                :  * This is implicitly CASCADE, no need for drop behavior
                              11759                 :                :  *****************************************************************************/
                              11760                 :                : 
                              11761                 :                : DropdbStmt: DROP DATABASE name
                              11762                 :                :                 {
 8995 tgl@sss.pgh.pa.us       11763                 :             62 :                     DropdbStmt *n = makeNode(DropdbStmt);
                              11764                 :                : 
                              11765                 :             62 :                     n->dbname = $3;
 3368 peter_e@gmx.net         11766                 :             62 :                     n->missing_ok = false;
 2550 akapila@postgresql.o    11767                 :             62 :                     n->options = NULL;
 1637 peter@eisentraut.org    11768                 :             62 :                     $$ = (Node *) n;
                              11769                 :                :                 }
                              11770                 :                :             | DROP DATABASE IF_P EXISTS name
                              11771                 :                :                 {
 7653 andrew@dunslane.net     11772                 :              3 :                     DropdbStmt *n = makeNode(DropdbStmt);
                              11773                 :                : 
                              11774                 :              3 :                     n->dbname = $5;
 3368 peter_e@gmx.net         11775                 :              3 :                     n->missing_ok = true;
 2550 akapila@postgresql.o    11776                 :              3 :                     n->options = NULL;
 1637 peter@eisentraut.org    11777                 :              3 :                     $$ = (Node *) n;
                              11778                 :                :                 }
                              11779                 :                :             | DROP DATABASE name opt_with '(' drop_option_list ')'
                              11780                 :                :                 {
 2550 akapila@postgresql.o    11781                 :             11 :                     DropdbStmt *n = makeNode(DropdbStmt);
                              11782                 :                : 
                              11783                 :             11 :                     n->dbname = $3;
                              11784                 :             11 :                     n->missing_ok = false;
                              11785                 :             11 :                     n->options = $6;
 1637 peter@eisentraut.org    11786                 :             11 :                     $$ = (Node *) n;
                              11787                 :                :                 }
                              11788                 :                :             | DROP DATABASE IF_P EXISTS name opt_with '(' drop_option_list ')'
                              11789                 :                :                 {
 2550 akapila@postgresql.o    11790                 :              8 :                     DropdbStmt *n = makeNode(DropdbStmt);
                              11791                 :                : 
                              11792                 :              8 :                     n->dbname = $5;
                              11793                 :              8 :                     n->missing_ok = true;
                              11794                 :              8 :                     n->options = $8;
 1637 peter@eisentraut.org    11795                 :              8 :                     $$ = (Node *) n;
                              11796                 :                :                 }
                              11797                 :                :         ;
                              11798                 :                : 
                              11799                 :                : drop_option_list:
                              11800                 :                :             drop_option
                              11801                 :                :                 {
 2550 akapila@postgresql.o    11802                 :             19 :                     $$ = list_make1((Node *) $1);
                              11803                 :                :                 }
                              11804                 :                :             | drop_option_list ',' drop_option
                              11805                 :                :                 {
 2550 akapila@postgresql.o    11806                 :UBC           0 :                     $$ = lappend($1, (Node *) $3);
                              11807                 :                :                 }
                              11808                 :                :         ;
                              11809                 :                : 
                              11810                 :                : /*
                              11811                 :                :  * Currently only the FORCE option is supported, but the syntax is designed
                              11812                 :                :  * to be extensible so that we can add more options in the future if required.
                              11813                 :                :  */
                              11814                 :                : drop_option:
                              11815                 :                :             FORCE
                              11816                 :                :                 {
 2550 akapila@postgresql.o    11817                 :CBC          19 :                     $$ = makeDefElem("force", NULL, @1);
                              11818                 :                :                 }
                              11819                 :                :         ;
                              11820                 :                : 
                              11821                 :                : /*****************************************************************************
                              11822                 :                :  *
                              11823                 :                :  *      ALTER COLLATION
                              11824                 :                :  *
                              11825                 :                :  *****************************************************************************/
                              11826                 :                : 
                              11827                 :                : AlterCollationStmt: ALTER COLLATION any_name REFRESH VERSION_P
                              11828                 :                :                 {
 2008 tmunro@postgresql.or    11829                 :              4 :                     AlterCollationStmt *n = makeNode(AlterCollationStmt);
                              11830                 :                : 
                              11831                 :              4 :                     n->collname = $3;
 1637 peter@eisentraut.org    11832                 :              4 :                     $$ = (Node *) n;
                              11833                 :                :                 }
                              11834                 :                :         ;
                              11835                 :                : 
                              11836                 :                : 
                              11837                 :                : /*****************************************************************************
                              11838                 :                :  *
                              11839                 :                :  *      ALTER SYSTEM
                              11840                 :                :  *
                              11841                 :                :  * This is used to change configuration parameters persistently.
                              11842                 :                :  *****************************************************************************/
                              11843                 :                : 
                              11844                 :                : AlterSystemStmt:
                              11845                 :                :             ALTER SYSTEM_P SET generic_set
                              11846                 :                :                 {
 4705 ishii@postgresql.org    11847                 :            103 :                     AlterSystemStmt *n = makeNode(AlterSystemStmt);
                              11848                 :                : 
                              11849                 :            103 :                     n->setstmt = $4;
 1637 peter@eisentraut.org    11850                 :            103 :                     $$ = (Node *) n;
                              11851                 :                :                 }
                              11852                 :                :             | ALTER SYSTEM_P RESET generic_reset
                              11853                 :                :                 {
 4447 fujii@postgresql.org    11854                 :             29 :                     AlterSystemStmt *n = makeNode(AlterSystemStmt);
                              11855                 :                : 
                              11856                 :             29 :                     n->setstmt = $4;
 1637 peter@eisentraut.org    11857                 :             29 :                     $$ = (Node *) n;
                              11858                 :                :                 }
                              11859                 :                :         ;
                              11860                 :                : 
                              11861                 :                : 
                              11862                 :                : /*****************************************************************************
                              11863                 :                :  *
                              11864                 :                :  * Manipulate a domain
                              11865                 :                :  *
                              11866                 :                :  *****************************************************************************/
                              11867                 :                : 
                              11868                 :                : CreateDomainStmt:
                              11869                 :                :             CREATE DOMAIN_P any_name opt_as Typename ColQualList
                              11870                 :                :                 {
 8997 bruce@momjian.us        11871                 :           1036 :                     CreateDomainStmt *n = makeNode(CreateDomainStmt);
                              11872                 :                : 
                              11873                 :           1036 :                     n->domainname = $3;
 6321 peter_e@gmx.net         11874                 :           1036 :                     n->typeName = $5;
 5720 tgl@sss.pgh.pa.us       11875                 :           1036 :                     SplitColQualList($6, &n->constraints, &n->collClause,
                              11876                 :                :                                      yyscanner);
 1637 peter@eisentraut.org    11877                 :           1036 :                     $$ = (Node *) n;
                              11878                 :                :                 }
                              11879                 :                :         ;
                              11880                 :                : 
                              11881                 :                : AlterDomainStmt:
                              11882                 :                :             /* ALTER DOMAIN <domain> {SET DEFAULT <expr>|DROP DEFAULT} */
                              11883                 :                :             ALTER DOMAIN_P any_name alter_column_default
                              11884                 :                :                 {
 8735 bruce@momjian.us        11885                 :              9 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11886                 :                : 
  490 michael@paquier.xyz     11887                 :              9 :                     n->subtype = AD_AlterDefault;
 6321 peter_e@gmx.net         11888                 :              9 :                     n->typeName = $3;
 8735 bruce@momjian.us        11889                 :              9 :                     n->def = $4;
 1637 peter@eisentraut.org    11890                 :              9 :                     $$ = (Node *) n;
                              11891                 :                :                 }
                              11892                 :                :             /* ALTER DOMAIN <domain> DROP NOT NULL */
                              11893                 :                :             | ALTER DOMAIN_P any_name DROP NOT NULL_P
                              11894                 :                :                 {
 8735 bruce@momjian.us        11895                 :              8 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11896                 :                : 
  490 michael@paquier.xyz     11897                 :              8 :                     n->subtype = AD_DropNotNull;
 6321 peter_e@gmx.net         11898                 :              8 :                     n->typeName = $3;
 1637 peter@eisentraut.org    11899                 :              8 :                     $$ = (Node *) n;
                              11900                 :                :                 }
                              11901                 :                :             /* ALTER DOMAIN <domain> SET NOT NULL */
                              11902                 :                :             | ALTER DOMAIN_P any_name SET NOT NULL_P
                              11903                 :                :                 {
 8735 bruce@momjian.us        11904                 :             16 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11905                 :                : 
  490 michael@paquier.xyz     11906                 :             16 :                     n->subtype = AD_SetNotNull;
 6321 peter_e@gmx.net         11907                 :             16 :                     n->typeName = $3;
 1637 peter@eisentraut.org    11908                 :             16 :                     $$ = (Node *) n;
                              11909                 :                :                 }
                              11910                 :                :             /* ALTER DOMAIN <domain> ADD CONSTRAINT ... */
                              11911                 :                :             | ALTER DOMAIN_P any_name ADD_P DomainConstraint
                              11912                 :                :                 {
 8735 bruce@momjian.us        11913                 :            125 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11914                 :                : 
  490 michael@paquier.xyz     11915                 :            125 :                     n->subtype = AD_AddConstraint;
 6321 peter_e@gmx.net         11916                 :            125 :                     n->typeName = $3;
 8735 bruce@momjian.us        11917                 :            125 :                     n->def = $5;
 1637 peter@eisentraut.org    11918                 :            125 :                     $$ = (Node *) n;
                              11919                 :                :                 }
                              11920                 :                :             /* ALTER DOMAIN <domain> DROP CONSTRAINT <name> [RESTRICT|CASCADE] */
                              11921                 :                :             | ALTER DOMAIN_P any_name DROP CONSTRAINT name opt_drop_behavior
                              11922                 :                :                 {
 8735 bruce@momjian.us        11923                 :             36 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11924                 :                : 
  490 michael@paquier.xyz     11925                 :             36 :                     n->subtype = AD_DropConstraint;
 6321 peter_e@gmx.net         11926                 :             36 :                     n->typeName = $3;
 8735 bruce@momjian.us        11927                 :             36 :                     n->name = $6;
                              11928                 :             36 :                     n->behavior = $7;
 5418 peter_e@gmx.net         11929                 :             36 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    11930                 :             36 :                     $$ = (Node *) n;
                              11931                 :                :                 }
                              11932                 :                :             /* ALTER DOMAIN <domain> DROP CONSTRAINT IF EXISTS <name> [RESTRICT|CASCADE] */
                              11933                 :                :             | ALTER DOMAIN_P any_name DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
                              11934                 :                :                 {
 5418 peter_e@gmx.net         11935                 :              4 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11936                 :                : 
  490 michael@paquier.xyz     11937                 :              4 :                     n->subtype = AD_DropConstraint;
 5418 peter_e@gmx.net         11938                 :              4 :                     n->typeName = $3;
                              11939                 :              4 :                     n->name = $8;
                              11940                 :              4 :                     n->behavior = $9;
                              11941                 :              4 :                     n->missing_ok = true;
 1637 peter@eisentraut.org    11942                 :              4 :                     $$ = (Node *) n;
                              11943                 :                :                 }
                              11944                 :                :             /* ALTER DOMAIN <domain> VALIDATE CONSTRAINT <name> */
                              11945                 :                :             | ALTER DOMAIN_P any_name VALIDATE CONSTRAINT name
                              11946                 :                :                 {
 5636 alvherre@alvh.no-ip.    11947                 :              9 :                     AlterDomainStmt *n = makeNode(AlterDomainStmt);
                              11948                 :                : 
  490 michael@paquier.xyz     11949                 :              9 :                     n->subtype = AD_ValidateConstraint;
 5636 alvherre@alvh.no-ip.    11950                 :              9 :                     n->typeName = $3;
                              11951                 :              9 :                     n->name = $6;
 1637 peter@eisentraut.org    11952                 :              9 :                     $$ = (Node *) n;
                              11953                 :                :                 }
                              11954                 :                :             ;
                              11955                 :                : 
                              11956                 :                : opt_as:     AS
                              11957                 :                :             | /* EMPTY */
                              11958                 :                :         ;
                              11959                 :                : 
                              11960                 :                : 
                              11961                 :                : /*****************************************************************************
                              11962                 :                :  *
                              11963                 :                :  * Manipulate a text search dictionary or configuration
                              11964                 :                :  *
                              11965                 :                :  *****************************************************************************/
                              11966                 :                : 
                              11967                 :                : AlterTSDictionaryStmt:
                              11968                 :                :             ALTER TEXT_P SEARCH DICTIONARY any_name definition
                              11969                 :                :                 {
 7016 tgl@sss.pgh.pa.us       11970                 :             23 :                     AlterTSDictionaryStmt *n = makeNode(AlterTSDictionaryStmt);
                              11971                 :                : 
                              11972                 :             23 :                     n->dictname = $5;
                              11973                 :             23 :                     n->options = $6;
 1637 peter@eisentraut.org    11974                 :             23 :                     $$ = (Node *) n;
                              11975                 :                :                 }
                              11976                 :                :         ;
                              11977                 :                : 
                              11978                 :                : AlterTSConfigurationStmt:
                              11979                 :                :             ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with any_name_list
                              11980                 :                :                 {
 7016 tgl@sss.pgh.pa.us       11981                 :           5386 :                     AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
                              11982                 :                : 
 4196 alvherre@alvh.no-ip.    11983                 :           5386 :                     n->kind = ALTER_TSCONFIG_ADD_MAPPING;
 7016 tgl@sss.pgh.pa.us       11984                 :           5386 :                     n->cfgname = $5;
                              11985                 :           5386 :                     n->tokentype = $9;
                              11986                 :           5386 :                     n->dicts = $11;
                              11987                 :           5386 :                     n->override = false;
                              11988                 :           5386 :                     n->replace = false;
 1637 peter@eisentraut.org    11989                 :           5386 :                     $$ = (Node *) n;
                              11990                 :                :                 }
                              11991                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with any_name_list
                              11992                 :                :                 {
 7016 tgl@sss.pgh.pa.us       11993                 :             17 :                     AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
                              11994                 :                : 
 4196 alvherre@alvh.no-ip.    11995                 :             17 :                     n->kind = ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN;
 7016 tgl@sss.pgh.pa.us       11996                 :             17 :                     n->cfgname = $5;
                              11997                 :             17 :                     n->tokentype = $9;
                              11998                 :             17 :                     n->dicts = $11;
                              11999                 :             17 :                     n->override = true;
                              12000                 :             17 :                     n->replace = false;
 1637 peter@eisentraut.org    12001                 :             17 :                     $$ = (Node *) n;
                              12002                 :                :                 }
                              12003                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING REPLACE any_name any_with any_name
                              12004                 :                :                 {
 7016 tgl@sss.pgh.pa.us       12005                 :             12 :                     AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
                              12006                 :                : 
 4196 alvherre@alvh.no-ip.    12007                 :             12 :                     n->kind = ALTER_TSCONFIG_REPLACE_DICT;
 7016 tgl@sss.pgh.pa.us       12008                 :             12 :                     n->cfgname = $5;
                              12009                 :             12 :                     n->tokentype = NIL;
                              12010                 :             12 :                     n->dicts = list_make2($9,$11);
                              12011                 :             12 :                     n->override = false;
                              12012                 :             12 :                     n->replace = true;
 1637 peter@eisentraut.org    12013                 :             12 :                     $$ = (Node *) n;
                              12014                 :                :                 }
                              12015                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list REPLACE any_name any_with any_name
                              12016                 :                :                 {
 7016 tgl@sss.pgh.pa.us       12017                 :UBC           0 :                     AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
                              12018                 :                : 
 4196 alvherre@alvh.no-ip.    12019                 :              0 :                     n->kind = ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN;
 7016 tgl@sss.pgh.pa.us       12020                 :              0 :                     n->cfgname = $5;
                              12021                 :              0 :                     n->tokentype = $9;
                              12022                 :              0 :                     n->dicts = list_make2($11,$13);
                              12023                 :              0 :                     n->override = false;
                              12024                 :              0 :                     n->replace = true;
 1637 peter@eisentraut.org    12025                 :              0 :                     $$ = (Node *) n;
                              12026                 :                :                 }
                              12027                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING FOR name_list
                              12028                 :                :                 {
 7016 tgl@sss.pgh.pa.us       12029                 :CBC          13 :                     AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
                              12030                 :                : 
 4196 alvherre@alvh.no-ip.    12031                 :             13 :                     n->kind = ALTER_TSCONFIG_DROP_MAPPING;
 7016 tgl@sss.pgh.pa.us       12032                 :             13 :                     n->cfgname = $5;
                              12033                 :             13 :                     n->tokentype = $9;
                              12034                 :             13 :                     n->missing_ok = false;
 1637 peter@eisentraut.org    12035                 :             13 :                     $$ = (Node *) n;
                              12036                 :                :                 }
                              12037                 :                :             | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING IF_P EXISTS FOR name_list
                              12038                 :                :                 {
 7016 tgl@sss.pgh.pa.us       12039                 :              8 :                     AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
                              12040                 :                : 
 4196 alvherre@alvh.no-ip.    12041                 :              8 :                     n->kind = ALTER_TSCONFIG_DROP_MAPPING;
 7016 tgl@sss.pgh.pa.us       12042                 :              8 :                     n->cfgname = $5;
                              12043                 :              8 :                     n->tokentype = $11;
                              12044                 :              8 :                     n->missing_ok = true;
 1637 peter@eisentraut.org    12045                 :              8 :                     $$ = (Node *) n;
                              12046                 :                :                 }
                              12047                 :                :         ;
                              12048                 :                : 
                              12049                 :                : /* Use this if TIME or ORDINALITY after WITH should be taken as an identifier */
                              12050                 :                : any_with:   WITH
                              12051                 :                :             | WITH_LA
                              12052                 :                :         ;
                              12053                 :                : 
                              12054                 :                : 
                              12055                 :                : /*****************************************************************************
                              12056                 :                :  *
                              12057                 :                :  * Manipulate a conversion
                              12058                 :                :  *
                              12059                 :                :  *      CREATE [DEFAULT] CONVERSION <conversion_name>
                              12060                 :                :  *      FOR <encoding_name> TO <encoding_name> FROM <func_name>
                              12061                 :                :  *
                              12062                 :                :  *****************************************************************************/
                              12063                 :                : 
                              12064                 :                : CreateConversionStmt:
                              12065                 :                :             CREATE opt_default CONVERSION_P any_name FOR Sconst
                              12066                 :                :             TO Sconst FROM any_name
                              12067                 :                :             {
 5483 peter_e@gmx.net         12068                 :             42 :                 CreateConversionStmt *n = makeNode(CreateConversionStmt);
                              12069                 :                : 
                              12070                 :             42 :                 n->conversion_name = $4;
                              12071                 :             42 :                 n->for_encoding_name = $6;
                              12072                 :             42 :                 n->to_encoding_name = $8;
                              12073                 :             42 :                 n->func_name = $10;
                              12074                 :             42 :                 n->def = $2;
 1637 peter@eisentraut.org    12075                 :             42 :                 $$ = (Node *) n;
                              12076                 :                :             }
                              12077                 :                :         ;
                              12078                 :                : 
                              12079                 :                : /*****************************************************************************
                              12080                 :                :  *
                              12081                 :                :  *      QUERY:
                              12082                 :                :  *              REPACK [ (options) ] [ <qualified_name> [ <name_list> ] [ USING INDEX <index_name> ] ]
                              12083                 :                :  *
                              12084                 :                :  *          obsolete variants:
                              12085                 :                :  *              CLUSTER (options) [ <qualified_name> [ USING <index_name> ] ]
                              12086                 :                :  *              CLUSTER [VERBOSE] [ <qualified_name> [ USING <index_name> ] ]
                              12087                 :                :  *              CLUSTER [VERBOSE] <index_name> ON <qualified_name> (for pre-8.3)
                              12088                 :                :  *
                              12089                 :                :  *****************************************************************************/
                              12090                 :                : 
                              12091                 :                : RepackStmt:
                              12092                 :                :             REPACK opt_utility_option_list qualified_name opt_name_list USING INDEX name
                              12093                 :                :                 {
  240 alvherre@kurilemu.de    12094                 :             27 :                     RepackStmt *n = makeNode(RepackStmt);
                              12095                 :                : 
                              12096                 :             27 :                     n->command = REPACK_COMMAND_REPACK;
   68 nathan@postgresql.or    12097                 :             27 :                     n->relation = makeVacuumRelation($3, InvalidOid, $4);
                              12098                 :             27 :                     n->indexname = $7;
  240 alvherre@kurilemu.de    12099                 :             27 :                     n->usingindex = true;
                              12100                 :             27 :                     n->params = $2;
                              12101                 :             27 :                     $$ = (Node *) n;
                              12102                 :                :                 }
                              12103                 :                :             | REPACK opt_utility_option_list qualified_name opt_name_list opt_usingindex
                              12104                 :                :                 {
                              12105                 :             84 :                     RepackStmt *n = makeNode(RepackStmt);
                              12106                 :                : 
                              12107                 :             84 :                     n->command = REPACK_COMMAND_REPACK;
   68 nathan@postgresql.or    12108                 :             84 :                     n->relation = makeVacuumRelation($3, InvalidOid, $4);
  240 alvherre@kurilemu.de    12109                 :             84 :                     n->indexname = NULL;
   68 nathan@postgresql.or    12110                 :             84 :                     n->usingindex = $5;
  240 alvherre@kurilemu.de    12111                 :             84 :                     n->params = $2;
                              12112                 :             84 :                     $$ = (Node *) n;
                              12113                 :                :                 }
                              12114                 :                :             | REPACK opt_utility_option_list opt_usingindex
                              12115                 :                :                 {
                              12116                 :              4 :                     RepackStmt *n = makeNode(RepackStmt);
                              12117                 :                : 
                              12118                 :              4 :                     n->command = REPACK_COMMAND_REPACK;
                              12119                 :              4 :                     n->relation = NULL;
                              12120                 :              4 :                     n->indexname = NULL;
                              12121                 :              4 :                     n->usingindex = $3;
                              12122                 :              4 :                     n->params = $2;
                              12123                 :              4 :                     $$ = (Node *) n;
                              12124                 :                :                 }
                              12125                 :                :             | CLUSTER '(' utility_option_list ')' qualified_name cluster_index_specification
                              12126                 :                :                 {
  240 alvherre@kurilemu.de    12127                 :UBC           0 :                     RepackStmt *n = makeNode(RepackStmt);
                              12128                 :                : 
                              12129                 :              0 :                     n->command = REPACK_COMMAND_CLUSTER;
                              12130                 :              0 :                     n->relation = makeNode(VacuumRelation);
                              12131                 :              0 :                     n->relation->relation = $5;
                              12132                 :              0 :                     n->indexname = $6;
                              12133                 :              0 :                     n->usingindex = true;
 1205 nathan@postgresql.or    12134                 :              0 :                     n->params = $3;
 1637 peter@eisentraut.org    12135                 :              0 :                     $$ = (Node *) n;
                              12136                 :                :                 }
                              12137                 :                :             | CLUSTER opt_utility_option_list
                              12138                 :                :                 {
  240 alvherre@kurilemu.de    12139                 :CBC           9 :                     RepackStmt *n = makeNode(RepackStmt);
                              12140                 :                : 
                              12141                 :              9 :                     n->command = REPACK_COMMAND_CLUSTER;
 1205 nathan@postgresql.or    12142                 :              9 :                     n->relation = NULL;
                              12143                 :              9 :                     n->indexname = NULL;
  240 alvherre@kurilemu.de    12144                 :              9 :                     n->usingindex = true;
  468                         12145                 :              9 :                     n->params = $2;
 1205 nathan@postgresql.or    12146                 :              9 :                     $$ = (Node *) n;
                              12147                 :                :                 }
                              12148                 :                :             /* unparenthesized VERBOSE kept for pre-14 compatibility */
                              12149                 :                :             | CLUSTER opt_verbose qualified_name cluster_index_specification
                              12150                 :                :                 {
  240 alvherre@kurilemu.de    12151                 :            157 :                     RepackStmt *n = makeNode(RepackStmt);
                              12152                 :                : 
                              12153                 :            157 :                     n->command = REPACK_COMMAND_CLUSTER;
                              12154                 :            157 :                     n->relation = makeNode(VacuumRelation);
                              12155                 :            157 :                     n->relation->relation = $3;
 1205 nathan@postgresql.or    12156                 :            157 :                     n->indexname = $4;
  240 alvherre@kurilemu.de    12157                 :            157 :                     n->usingindex = true;
 1205 nathan@postgresql.or    12158         [ -  + ]:            157 :                     if ($2)
  468 alvherre@kurilemu.de    12159                 :UBC           0 :                         n->params = list_make1(makeDefElem("verbose", NULL, @2));
 1637 peter@eisentraut.org    12160                 :CBC         157 :                     $$ = (Node *) n;
                              12161                 :                :                 }
                              12162                 :                :             /* unparenthesized VERBOSE kept for pre-17 compatibility */
                              12163                 :                :             | CLUSTER VERBOSE
                              12164                 :                :                 {
  240 alvherre@kurilemu.de    12165                 :              7 :                     RepackStmt *n = makeNode(RepackStmt);
                              12166                 :                : 
                              12167                 :              7 :                     n->command = REPACK_COMMAND_CLUSTER;
 5483 peter_e@gmx.net         12168                 :              7 :                     n->relation = NULL;
                              12169                 :              7 :                     n->indexname = NULL;
  240 alvherre@kurilemu.de    12170                 :              7 :                     n->usingindex = true;
  468                         12171                 :              7 :                     n->params = list_make1(makeDefElem("verbose", NULL, @2));
 1637 peter@eisentraut.org    12172                 :              7 :                     $$ = (Node *) n;
                              12173                 :                :                 }
                              12174                 :                :             /* kept for pre-8.3 compatibility */
                              12175                 :                :             | CLUSTER opt_verbose name ON qualified_name
                              12176                 :                :                 {
  240 alvherre@kurilemu.de    12177                 :             13 :                     RepackStmt *n = makeNode(RepackStmt);
                              12178                 :                : 
                              12179                 :             13 :                     n->command = REPACK_COMMAND_CLUSTER;
                              12180                 :             13 :                     n->relation = makeNode(VacuumRelation);
                              12181                 :             13 :                     n->relation->relation = $5;
 5483 peter_e@gmx.net         12182                 :             13 :                     n->indexname = $3;
  240 alvherre@kurilemu.de    12183                 :             13 :                     n->usingindex = true;
 3026 michael@paquier.xyz     12184         [ -  + ]:             13 :                     if ($2)
  468 alvherre@kurilemu.de    12185                 :UBC           0 :                         n->params = list_make1(makeDefElem("verbose", NULL, @2));
 1637 peter@eisentraut.org    12186                 :CBC          13 :                     $$ = (Node *) n;
                              12187                 :                :                 }
                              12188                 :                :         ;
                              12189                 :                : 
                              12190                 :                : cluster_index_specification:
 2339                         12191                 :            131 :             USING name              { $$ = $2; }
 7151 bruce@momjian.us        12192                 :             26 :             | /*EMPTY*/             { $$ = NULL; }
                              12193                 :                :         ;
                              12194                 :                : 
                              12195                 :                : 
                              12196                 :                : /*****************************************************************************
                              12197                 :                :  *
                              12198                 :                :  *      QUERY:
                              12199                 :                :  *              VACUUM
                              12200                 :                :  *              ANALYZE
                              12201                 :                :  *
                              12202                 :                :  *****************************************************************************/
                              12203                 :                : 
                              12204                 :                : VacuumStmt: VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relation_list
                              12205                 :                :                 {
10650                         12206                 :            832 :                     VacuumStmt *n = makeNode(VacuumStmt);
                              12207                 :                : 
 2789 rhaas@postgresql.org    12208                 :            832 :                     n->options = NIL;
 6198 tgl@sss.pgh.pa.us       12209         [ +  + ]:            832 :                     if ($2)
 2789 rhaas@postgresql.org    12210                 :            109 :                         n->options = lappend(n->options,
                              12211                 :            109 :                                              makeDefElem("full", NULL, @2));
 4250 alvherre@alvh.no-ip.    12212         [ +  + ]:            832 :                     if ($3)
 2789 rhaas@postgresql.org    12213                 :             92 :                         n->options = lappend(n->options,
                              12214                 :             92 :                                              makeDefElem("freeze", NULL, @3));
 6198 tgl@sss.pgh.pa.us       12215         [ +  + ]:            832 :                     if ($4)
 2789 rhaas@postgresql.org    12216                 :              9 :                         n->options = lappend(n->options,
                              12217                 :              9 :                                              makeDefElem("verbose", NULL, @4));
 3222                         12218         [ +  + ]:            832 :                     if ($5)
 2789                         12219                 :            226 :                         n->options = lappend(n->options,
                              12220                 :            226 :                                              makeDefElem("analyze", NULL, @5));
 3222                         12221                 :            832 :                     n->rels = $6;
 2789                         12222                 :            832 :                     n->is_vacuumcmd = true;
 1637 peter@eisentraut.org    12223                 :            832 :                     $$ = (Node *) n;
                              12224                 :                :                 }
                              12225                 :                :             | VACUUM '(' utility_option_list ')' opt_vacuum_relation_list
                              12226                 :                :                 {
 6198 tgl@sss.pgh.pa.us       12227                 :           4521 :                     VacuumStmt *n = makeNode(VacuumStmt);
                              12228                 :                : 
 2789 rhaas@postgresql.org    12229                 :           4521 :                     n->options = $3;
 3320 tgl@sss.pgh.pa.us       12230                 :           4521 :                     n->rels = $5;
 2789 rhaas@postgresql.org    12231                 :           4521 :                     n->is_vacuumcmd = true;
 6198 tgl@sss.pgh.pa.us       12232                 :           4521 :                     $$ = (Node *) n;
                              12233                 :                :                 }
                              12234                 :                :         ;
                              12235                 :                : 
                              12236                 :                : AnalyzeStmt: analyze_keyword opt_utility_option_list opt_vacuum_relation_list
                              12237                 :                :                 {
 9313                         12238                 :           3186 :                     VacuumStmt *n = makeNode(VacuumStmt);
                              12239                 :                : 
  468 alvherre@kurilemu.de    12240                 :           3186 :                     n->options = $2;
 3320 tgl@sss.pgh.pa.us       12241                 :           3186 :                     n->rels = $3;
 2789 rhaas@postgresql.org    12242                 :           3186 :                     n->is_vacuumcmd = false;
 1637 peter@eisentraut.org    12243                 :           3186 :                     $$ = (Node *) n;
                              12244                 :                :                 }
                              12245                 :                :             | analyze_keyword VERBOSE opt_vacuum_relation_list
                              12246                 :                :                 {
 3167 andres@anarazel.de      12247                 :              8 :                     VacuumStmt *n = makeNode(VacuumStmt);
                              12248                 :                : 
  468 alvherre@kurilemu.de    12249                 :              8 :                     n->options = list_make1(makeDefElem("verbose", NULL, @2));
                              12250                 :              8 :                     n->rels = $3;
 2789 rhaas@postgresql.org    12251                 :              8 :                     n->is_vacuumcmd = false;
 3167 andres@anarazel.de      12252                 :              8 :                     $$ = (Node *) n;
                              12253                 :                :                 }
                              12254                 :                :         ;
                              12255                 :                : 
                              12256                 :                : analyze_keyword:
                              12257                 :                :             ANALYZE
                              12258                 :                :             | ANALYSE /* British */
                              12259                 :                :         ;
                              12260                 :                : 
                              12261                 :                : opt_analyze:
 3222 rhaas@postgresql.org    12262                 :            226 :             analyze_keyword                         { $$ = true; }
                              12263                 :            606 :             | /*EMPTY*/                             { $$ = false; }
                              12264                 :                :         ;
                              12265                 :                : 
                              12266                 :                : opt_verbose:
 3368 peter_e@gmx.net         12267                 :              9 :             VERBOSE                                 { $$ = true; }
                              12268                 :           2569 :             | /*EMPTY*/                             { $$ = false; }
                              12269                 :                :         ;
                              12270                 :                : 
                              12271                 :            109 : opt_full:   FULL                                    { $$ = true; }
                              12272                 :            723 :             | /*EMPTY*/                             { $$ = false; }
                              12273                 :                :         ;
                              12274                 :                : 
                              12275                 :             92 : opt_freeze: FREEZE                                  { $$ = true; }
                              12276                 :            740 :             | /*EMPTY*/                             { $$ = false; }
                              12277                 :                :         ;
                              12278                 :                : 
                              12279                 :                : opt_name_list:
 8907 bruce@momjian.us        12280                 :           1848 :             '(' name_list ')'                       { $$ = $2; }
                              12281                 :          10554 :             | /*EMPTY*/                             { $$ = NIL; }
                              12282                 :                :         ;
                              12283                 :                : 
                              12284                 :                : vacuum_relation:
                              12285                 :                :             relation_expr opt_name_list
                              12286                 :                :                 {
 3320 tgl@sss.pgh.pa.us       12287                 :           8468 :                     $$ = (Node *) makeVacuumRelation($1, InvalidOid, $2);
                              12288                 :                :                 }
                              12289                 :                :         ;
                              12290                 :                : 
                              12291                 :                : vacuum_relation_list:
                              12292                 :                :             vacuum_relation
                              12293                 :           8339 :                     { $$ = list_make1($1); }
                              12294                 :                :             | vacuum_relation_list ',' vacuum_relation
                              12295                 :            129 :                     { $$ = lappend($1, $3); }
                              12296                 :                :         ;
                              12297                 :                : 
                              12298                 :                : opt_vacuum_relation_list:
                              12299                 :           8339 :             vacuum_relation_list                    { $$ = $1; }
                              12300                 :            208 :             | /*EMPTY*/                             { $$ = NIL; }
                              12301                 :                :         ;
                              12302                 :                : 
                              12303                 :                : 
                              12304                 :                : /*****************************************************************************
                              12305                 :                :  *
                              12306                 :                :  *      QUERY:
                              12307                 :                :  *              EXPLAIN [ANALYZE] [VERBOSE] query
                              12308                 :                :  *              EXPLAIN ( options ) query
                              12309                 :                :  *
                              12310                 :                :  *****************************************************************************/
                              12311                 :                : 
                              12312                 :                : ExplainStmt:
                              12313                 :                :         EXPLAIN ExplainableStmt
                              12314                 :                :                 {
 6311                         12315                 :           4765 :                     ExplainStmt *n = makeNode(ExplainStmt);
                              12316                 :                : 
                              12317                 :           4765 :                     n->query = $2;
                              12318                 :           4765 :                     n->options = NIL;
                              12319                 :           4765 :                     $$ = (Node *) n;
                              12320                 :                :                 }
                              12321                 :                :         | EXPLAIN analyze_keyword opt_verbose ExplainableStmt
                              12322                 :                :                 {
 9179                         12323                 :           1576 :                     ExplainStmt *n = makeNode(ExplainStmt);
                              12324                 :                : 
 7177                         12325                 :           1576 :                     n->query = $4;
 3712 peter_e@gmx.net         12326                 :           1576 :                     n->options = list_make1(makeDefElem("analyze", NULL, @2));
 6311 tgl@sss.pgh.pa.us       12327         [ -  + ]:           1576 :                     if ($3)
 6311 tgl@sss.pgh.pa.us       12328                 :UBC           0 :                         n->options = lappend(n->options,
 3712 peter_e@gmx.net         12329                 :              0 :                                              makeDefElem("verbose", NULL, @3));
 6311 tgl@sss.pgh.pa.us       12330                 :CBC        1576 :                     $$ = (Node *) n;
                              12331                 :                :                 }
                              12332                 :                :         | EXPLAIN VERBOSE ExplainableStmt
                              12333                 :                :                 {
                              12334                 :              8 :                     ExplainStmt *n = makeNode(ExplainStmt);
                              12335                 :                : 
                              12336                 :              8 :                     n->query = $3;
 3712 peter_e@gmx.net         12337                 :              8 :                     n->options = list_make1(makeDefElem("verbose", NULL, @2));
 6311 tgl@sss.pgh.pa.us       12338                 :              8 :                     $$ = (Node *) n;
                              12339                 :                :                 }
                              12340                 :                :         | EXPLAIN '(' utility_option_list ')' ExplainableStmt
                              12341                 :                :                 {
                              12342                 :          11037 :                     ExplainStmt *n = makeNode(ExplainStmt);
                              12343                 :                : 
                              12344                 :          11037 :                     n->query = $5;
                              12345                 :          11037 :                     n->options = $3;
                              12346                 :          11037 :                     $$ = (Node *) n;
                              12347                 :                :                 }
                              12348                 :                :         ;
                              12349                 :                : 
                              12350                 :                : ExplainableStmt:
                              12351                 :                :             SelectStmt
                              12352                 :                :             | InsertStmt
                              12353                 :                :             | UpdateStmt
                              12354                 :                :             | DeleteStmt
                              12355                 :                :             | MergeStmt
                              12356                 :                :             | DeclareCursorStmt
                              12357                 :                :             | CreateAsStmt
                              12358                 :                :             | CreateMatViewStmt
                              12359                 :                :             | RefreshMatViewStmt
                              12360                 :                :             | ExecuteStmt                   /* by default all are $$=$1 */
                              12361                 :                :         ;
                              12362                 :                : 
                              12363                 :                : /*****************************************************************************
                              12364                 :                :  *
                              12365                 :                :  *      QUERY:
                              12366                 :                :  *              PREPARE <plan_name> [(args, ...)] AS <query>
                              12367                 :                :  *
                              12368                 :                :  *****************************************************************************/
                              12369                 :                : 
                              12370                 :                : PrepareStmt: PREPARE name prep_type_clause AS PreparableStmt
                              12371                 :                :                 {
 8836                         12372                 :           1123 :                     PrepareStmt *n = makeNode(PrepareStmt);
                              12373                 :                : 
                              12374                 :           1123 :                     n->name = $2;
                              12375                 :           1123 :                     n->argtypes = $3;
 7177                         12376                 :           1123 :                     n->query = $5;
 8836                         12377                 :           1123 :                     $$ = (Node *) n;
                              12378                 :                :                 }
                              12379                 :                :         ;
                              12380                 :                : 
 7226                         12381                 :            908 : prep_type_clause: '(' type_list ')'         { $$ = $2; }
 8836                         12382                 :            227 :                 | /* EMPTY */               { $$ = NIL; }
                              12383                 :                :         ;
                              12384                 :                : 
                              12385                 :                : PreparableStmt:
                              12386                 :                :             SelectStmt
                              12387                 :                :             | InsertStmt
                              12388                 :                :             | UpdateStmt
                              12389                 :                :             | DeleteStmt
                              12390                 :                :             | MergeStmt                     /* by default all are $$=$1 */
                              12391                 :                :         ;
                              12392                 :                : 
                              12393                 :                : /*****************************************************************************
                              12394                 :                :  *
                              12395                 :                :  * EXECUTE <plan_name> [(params, ...)]
                              12396                 :                :  * CREATE TABLE <name> AS EXECUTE <plan_name> [(params, ...)]
                              12397                 :                :  *
                              12398                 :                :  *****************************************************************************/
                              12399                 :                : 
                              12400                 :                : ExecuteStmt: EXECUTE name execute_param_clause
                              12401                 :                :                 {
                              12402                 :           8716 :                     ExecuteStmt *n = makeNode(ExecuteStmt);
                              12403                 :                : 
                              12404                 :           8716 :                     n->name = $2;
                              12405                 :           8716 :                     n->params = $3;
 8528 peter_e@gmx.net         12406                 :           8716 :                     $$ = (Node *) n;
                              12407                 :                :                 }
                              12408                 :                :             | CREATE OptTemp TABLE create_as_target AS
                              12409                 :                :                 EXECUTE name execute_param_clause opt_with_data
                              12410                 :                :                 {
 5344 tgl@sss.pgh.pa.us       12411                 :             50 :                     CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
 8528 peter_e@gmx.net         12412                 :             50 :                     ExecuteStmt *n = makeNode(ExecuteStmt);
                              12413                 :                : 
 7198 tgl@sss.pgh.pa.us       12414                 :             50 :                     n->name = $7;
                              12415                 :             50 :                     n->params = $8;
 5344                         12416                 :             50 :                     ctas->query = (Node *) n;
                              12417                 :             50 :                     ctas->into = $4;
 2308 michael@paquier.xyz     12418                 :             50 :                     ctas->objtype = OBJECT_TABLE;
 5344 tgl@sss.pgh.pa.us       12419                 :             50 :                     ctas->is_select_into = false;
 2820 michael@paquier.xyz     12420                 :             50 :                     ctas->if_not_exists = false;
                              12421                 :                :                     /* cram additional flags into the IntoClause */
 5460 tgl@sss.pgh.pa.us       12422                 :             50 :                     $4->rel->relpersistence = $2;
                              12423                 :             50 :                     $4->skipData = !($9);
 5344                         12424                 :             50 :                     $$ = (Node *) ctas;
                              12425                 :                :                 }
                              12426                 :                :             | CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS
                              12427                 :                :                 EXECUTE name execute_param_clause opt_with_data
                              12428                 :                :                 {
 2820 michael@paquier.xyz     12429                 :              8 :                     CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
                              12430                 :              8 :                     ExecuteStmt *n = makeNode(ExecuteStmt);
                              12431                 :                : 
                              12432                 :              8 :                     n->name = $10;
                              12433                 :              8 :                     n->params = $11;
                              12434                 :              8 :                     ctas->query = (Node *) n;
                              12435                 :              8 :                     ctas->into = $7;
 2308                         12436                 :              8 :                     ctas->objtype = OBJECT_TABLE;
 2820                         12437                 :              8 :                     ctas->is_select_into = false;
                              12438                 :              8 :                     ctas->if_not_exists = true;
                              12439                 :                :                     /* cram additional flags into the IntoClause */
                              12440                 :              8 :                     $7->rel->relpersistence = $2;
                              12441                 :              8 :                     $7->skipData = !($12);
                              12442                 :              8 :                     $$ = (Node *) ctas;
                              12443                 :                :                 }
                              12444                 :                :         ;
                              12445                 :                : 
 8769 tgl@sss.pgh.pa.us       12446                 :           8002 : execute_param_clause: '(' expr_list ')'             { $$ = $2; }
 8836                         12447                 :            772 :                     | /* EMPTY */                   { $$ = NIL; }
                              12448                 :                :                     ;
                              12449                 :                : 
                              12450                 :                : /*****************************************************************************
                              12451                 :                :  *
                              12452                 :                :  *      QUERY:
                              12453                 :                :  *              DEALLOCATE [PREPARE] <plan_name>
                              12454                 :                :  *
                              12455                 :                :  *****************************************************************************/
                              12456                 :                : 
                              12457                 :                : DeallocateStmt: DEALLOCATE name
                              12458                 :                :                     {
                              12459                 :           1185 :                         DeallocateStmt *n = makeNode(DeallocateStmt);
                              12460                 :                : 
                              12461                 :           1185 :                         n->name = $2;
 1166 michael@paquier.xyz     12462                 :           1185 :                         n->isall = false;
                              12463                 :           1185 :                         n->location = @2;
 8836 tgl@sss.pgh.pa.us       12464                 :           1185 :                         $$ = (Node *) n;
                              12465                 :                :                     }
                              12466                 :                :                 | DEALLOCATE PREPARE name
                              12467                 :                :                     {
                              12468                 :             13 :                         DeallocateStmt *n = makeNode(DeallocateStmt);
                              12469                 :                : 
                              12470                 :             13 :                         n->name = $3;
 1166 michael@paquier.xyz     12471                 :             13 :                         n->isall = false;
                              12472                 :             13 :                         n->location = @3;
 8836 tgl@sss.pgh.pa.us       12473                 :             13 :                         $$ = (Node *) n;
                              12474                 :                :                     }
                              12475                 :                :                 | DEALLOCATE ALL
                              12476                 :                :                     {
 7147 neilc@samurai.com       12477                 :             36 :                         DeallocateStmt *n = makeNode(DeallocateStmt);
                              12478                 :                : 
                              12479                 :             36 :                         n->name = NULL;
 1166 michael@paquier.xyz     12480                 :             36 :                         n->isall = true;
                              12481                 :             36 :                         n->location = -1;
 7147 neilc@samurai.com       12482                 :             36 :                         $$ = (Node *) n;
                              12483                 :                :                     }
                              12484                 :                :                 | DEALLOCATE PREPARE ALL
                              12485                 :                :                     {
                              12486                 :              1 :                         DeallocateStmt *n = makeNode(DeallocateStmt);
                              12487                 :                : 
                              12488                 :              1 :                         n->name = NULL;
 1166 michael@paquier.xyz     12489                 :              1 :                         n->isall = true;
                              12490                 :              1 :                         n->location = -1;
 7147 neilc@samurai.com       12491                 :              1 :                         $$ = (Node *) n;
                              12492                 :                :                     }
                              12493                 :                :         ;
                              12494                 :                : 
                              12495                 :                : /*****************************************************************************
                              12496                 :                :  *
                              12497                 :                :  *      QUERY:
                              12498                 :                :  *              INSERT STATEMENTS
                              12499                 :                :  *
                              12500                 :                :  *****************************************************************************/
                              12501                 :                : 
                              12502                 :                : InsertStmt:
                              12503                 :                :             opt_with_clause INSERT INTO insert_target insert_rest
                              12504                 :                :             opt_on_conflict returning_clause
                              12505                 :                :                 {
 5865 tgl@sss.pgh.pa.us       12506                 :          44322 :                     $5->relation = $4;
 4199 andres@anarazel.de      12507                 :          44322 :                     $5->onConflictClause = $6;
  658 dean.a.rasheed@gmail    12508                 :          44322 :                     $5->returningClause = $7;
 5865 tgl@sss.pgh.pa.us       12509                 :          44322 :                     $5->withClause = $1;
                              12510                 :          44322 :                     $$ = (Node *) $5;
                              12511                 :                :                 }
                              12512                 :                :         ;
                              12513                 :                : 
                              12514                 :                : /*
                              12515                 :                :  * Can't easily make AS optional here, because VALUES in insert_rest would
                              12516                 :                :  * have a shift/reduce conflict with VALUES as an optional alias.  We could
                              12517                 :                :  * easily allow unreserved_keywords as optional aliases, but that'd be an odd
                              12518                 :                :  * divergence from other places.  So just require AS for now.
                              12519                 :                :  */
                              12520                 :                : insert_target:
                              12521                 :                :             qualified_name
                              12522                 :                :                 {
 4199 andres@anarazel.de      12523                 :          44215 :                     $$ = $1;
                              12524                 :                :                 }
                              12525                 :                :             | qualified_name AS ColId
                              12526                 :                :                 {
                              12527                 :            111 :                     $1->alias = makeAlias($3, NIL);
                              12528                 :            111 :                     $$ = $1;
                              12529                 :                :                 }
                              12530                 :                :         ;
                              12531                 :                : 
                              12532                 :                : insert_rest:
                              12533                 :                :             SelectStmt
                              12534                 :                :                 {
10527 bruce@momjian.us        12535                 :          30290 :                     $$ = makeNode(InsertStmt);
 9970 tgl@sss.pgh.pa.us       12536                 :          30289 :                     $$->cols = NIL;
 9527                         12537                 :          30289 :                     $$->selectStmt = $1;
                              12538                 :                :                 }
                              12539                 :                :             | OVERRIDING override_kind VALUE_P SelectStmt
                              12540                 :                :                 {
 3500 peter_e@gmx.net         12541                 :             64 :                     $$ = makeNode(InsertStmt);
                              12542                 :             64 :                     $$->cols = NIL;
                              12543                 :             64 :                     $$->override = $2;
                              12544                 :             64 :                     $$->selectStmt = $4;
                              12545                 :                :                 }
                              12546                 :                :             | '(' insert_column_list ')' SelectStmt
                              12547                 :                :                 {
10153 bruce@momjian.us        12548                 :           8404 :                     $$ = makeNode(InsertStmt);
                              12549                 :           8404 :                     $$->cols = $2;
 7400 mail@joeconway.com      12550                 :           8404 :                     $$->selectStmt = $4;
                              12551                 :                :                 }
                              12552                 :                :             | '(' insert_column_list ')' OVERRIDING override_kind VALUE_P SelectStmt
                              12553                 :                :                 {
 3500 peter_e@gmx.net         12554                 :UBC           0 :                     $$ = makeNode(InsertStmt);
                              12555                 :              0 :                     $$->cols = $2;
                              12556                 :              0 :                     $$->override = $5;
                              12557                 :              0 :                     $$->selectStmt = $7;
                              12558                 :                :                 }
                              12559                 :                :             | DEFAULT VALUES
                              12560                 :                :                 {
10153 bruce@momjian.us        12561                 :CBC        5568 :                     $$ = makeNode(InsertStmt);
 7400 mail@joeconway.com      12562                 :           5568 :                     $$->cols = NIL;
                              12563                 :           5568 :                     $$->selectStmt = NULL;
                              12564                 :                :                 }
                              12565                 :                :         ;
                              12566                 :                : 
                              12567                 :                : override_kind:
 3500 peter_e@gmx.net         12568                 :             44 :             USER        { $$ = OVERRIDING_USER_VALUE; }
                              12569                 :             40 :             | SYSTEM_P  { $$ = OVERRIDING_SYSTEM_VALUE; }
                              12570                 :                :         ;
                              12571                 :                : 
                              12572                 :                : insert_column_list:
                              12573                 :                :             insert_column_item
 8184 tgl@sss.pgh.pa.us       12574                 :           8623 :                     { $$ = list_make1($1); }
                              12575                 :                :             | insert_column_list ',' insert_column_item
 8906 bruce@momjian.us        12576                 :           9185 :                     { $$ = lappend($1, $3); }
                              12577                 :                :         ;
                              12578                 :                : 
                              12579                 :                : insert_column_item:
                              12580                 :                :             ColId opt_indirection
                              12581                 :                :                 {
 8184 tgl@sss.pgh.pa.us       12582                 :          17808 :                     $$ = makeNode(ResTarget);
                              12583                 :          17808 :                     $$->name = $1;
 6324                         12584                 :          17808 :                     $$->indirection = check_indirection($2, yyscanner);
 8184                         12585                 :          17808 :                     $$->val = NULL;
 7532                         12586                 :          17808 :                     $$->location = @1;
                              12587                 :                :                 }
                              12588                 :                :         ;
                              12589                 :                : 
                              12590                 :                : opt_on_conflict:
                              12591                 :                :             ON CONFLICT opt_conf_expr DO SELECT opt_for_locking_strength where_clause
                              12592                 :                :                 {
  266 dean.a.rasheed@gmail    12593                 :            262 :                     $$ = makeNode(OnConflictClause);
                              12594                 :            262 :                     $$->action = ONCONFLICT_SELECT;
                              12595                 :            262 :                     $$->infer = $3;
                              12596                 :            262 :                     $$->targetList = NIL;
                              12597                 :            262 :                     $$->lockStrength = $6;
                              12598                 :            262 :                     $$->whereClause = $7;
                              12599                 :            262 :                     $$->location = @1;
                              12600                 :                :                 }
                              12601                 :                :             |
                              12602                 :                :             ON CONFLICT opt_conf_expr DO UPDATE SET set_clause_list where_clause
                              12603                 :                :                 {
 4199 andres@anarazel.de      12604                 :            960 :                     $$ = makeNode(OnConflictClause);
                              12605                 :            960 :                     $$->action = ONCONFLICT_UPDATE;
                              12606                 :            960 :                     $$->infer = $3;
                              12607                 :            960 :                     $$->targetList = $7;
  266 dean.a.rasheed@gmail    12608                 :            960 :                     $$->lockStrength = LCS_NONE;
 4199 andres@anarazel.de      12609                 :            960 :                     $$->whereClause = $8;
                              12610                 :            960 :                     $$->location = @1;
                              12611                 :                :                 }
                              12612                 :                :             |
                              12613                 :                :             ON CONFLICT opt_conf_expr DO NOTHING
                              12614                 :                :                 {
                              12615                 :            425 :                     $$ = makeNode(OnConflictClause);
                              12616                 :            425 :                     $$->action = ONCONFLICT_NOTHING;
                              12617                 :            425 :                     $$->infer = $3;
                              12618                 :            425 :                     $$->targetList = NIL;
  266 dean.a.rasheed@gmail    12619                 :            425 :                     $$->lockStrength = LCS_NONE;
 4199 andres@anarazel.de      12620                 :            425 :                     $$->whereClause = NULL;
                              12621                 :            425 :                     $$->location = @1;
                              12622                 :                :                 }
                              12623                 :                :             | /*EMPTY*/
                              12624                 :                :                 {
                              12625                 :          42679 :                     $$ = NULL;
                              12626                 :                :                 }
                              12627                 :                :         ;
                              12628                 :                : 
                              12629                 :                : opt_conf_expr:
                              12630                 :                :             '(' index_params ')' where_clause
                              12631                 :                :                 {
                              12632                 :           1305 :                     $$ = makeNode(InferClause);
                              12633                 :           1305 :                     $$->indexElems = $2;
                              12634                 :           1305 :                     $$->whereClause = $4;
                              12635                 :           1305 :                     $$->conname = NULL;
                              12636                 :           1305 :                     $$->location = @1;
                              12637                 :                :                 }
                              12638                 :                :             |
                              12639                 :                :             ON CONSTRAINT name
                              12640                 :                :                 {
                              12641                 :            190 :                     $$ = makeNode(InferClause);
                              12642                 :            190 :                     $$->indexElems = NIL;
                              12643                 :            190 :                     $$->whereClause = NULL;
                              12644                 :            190 :                     $$->conname = $3;
                              12645                 :            190 :                     $$->location = @1;
                              12646                 :                :                 }
                              12647                 :                :             | /*EMPTY*/
                              12648                 :                :                 {
                              12649                 :            152 :                     $$ = NULL;
                              12650                 :                :                 }
                              12651                 :                :         ;
                              12652                 :                : 
                              12653                 :                : returning_clause:
                              12654                 :                :             RETURNING returning_with_clause target_list
                              12655                 :                :                 {
  658 dean.a.rasheed@gmail    12656                 :           2439 :                     ReturningClause *n = makeNode(ReturningClause);
                              12657                 :                : 
                              12658                 :           2439 :                     n->options = $2;
                              12659                 :           2439 :                     n->exprs = $3;
                              12660                 :           2439 :                     $$ = n;
                              12661                 :                :                 }
                              12662                 :                :             | /* EMPTY */
                              12663                 :                :                 {
                              12664                 :          55391 :                     $$ = NULL;
                              12665                 :                :                 }
                              12666                 :                :         ;
                              12667                 :                : 
                              12668                 :                : returning_with_clause:
                              12669                 :             64 :             WITH '(' returning_options ')'      { $$ = $3; }
                              12670                 :           2375 :             | /* EMPTY */                       { $$ = NIL; }
                              12671                 :                :         ;
                              12672                 :                : 
                              12673                 :                : returning_options:
                              12674                 :             64 :             returning_option                            { $$ = list_make1($1); }
                              12675                 :             48 :             | returning_options ',' returning_option    { $$ = lappend($1, $3); }
                              12676                 :                :         ;
                              12677                 :                : 
                              12678                 :                : returning_option:
                              12679                 :                :             returning_option_kind AS ColId
                              12680                 :                :                 {
                              12681                 :            112 :                     ReturningOption *n = makeNode(ReturningOption);
                              12682                 :                : 
                              12683                 :            112 :                     n->option = $1;
                              12684                 :            112 :                     n->value = $3;
                              12685                 :            112 :                     n->location = @1;
                              12686                 :            112 :                     $$ = (Node *) n;
                              12687                 :                :                 }
                              12688                 :                :         ;
                              12689                 :                : 
                              12690                 :                : returning_option_kind:
                              12691                 :             52 :             OLD         { $$ = RETURNING_OPTION_OLD; }
                              12692                 :             60 :             | NEW       { $$ = RETURNING_OPTION_NEW; }
                              12693                 :                :         ;
                              12694                 :                : 
                              12695                 :                : 
                              12696                 :                : /*****************************************************************************
                              12697                 :                :  *
                              12698                 :                :  *      QUERY:
                              12699                 :                :  *              DELETE STATEMENTS
                              12700                 :                :  *
                              12701                 :                :  *****************************************************************************/
                              12702                 :                : 
                              12703                 :                : DeleteStmt: opt_with_clause DELETE_P FROM relation_expr_opt_alias
                              12704                 :                :             using_clause where_or_current_clause returning_clause
                              12705                 :                :                 {
10650 bruce@momjian.us        12706                 :           3149 :                     DeleteStmt *n = makeNode(DeleteStmt);
                              12707                 :                : 
 5865 tgl@sss.pgh.pa.us       12708                 :           3149 :                     n->relation = $4;
                              12709                 :           3149 :                     n->usingClause = $5;
                              12710                 :           3149 :                     n->whereClause = $6;
  658 dean.a.rasheed@gmail    12711                 :           3149 :                     n->returningClause = $7;
 5865 tgl@sss.pgh.pa.us       12712                 :           3149 :                     n->withClause = $1;
 1637 peter@eisentraut.org    12713                 :           3149 :                     $$ = (Node *) n;
                              12714                 :                :                 }
                              12715                 :                :         ;
                              12716                 :                : 
                              12717                 :                : using_clause:
 5483 peter_e@gmx.net         12718                 :             68 :                 USING from_list                     { $$ = $2; }
 7882 neilc@samurai.com       12719                 :           3081 :             | /*EMPTY*/                             { $$ = NIL; }
                              12720                 :                :         ;
                              12721                 :                : 
                              12722                 :                : 
                              12723                 :                : /*****************************************************************************
                              12724                 :                :  *
                              12725                 :                :  *      QUERY:
                              12726                 :                :  *              LOCK TABLE
                              12727                 :                :  *
                              12728                 :                :  *****************************************************************************/
                              12729                 :                : 
                              12730                 :                : LockStmt:   LOCK_P opt_table relation_expr_list opt_lock opt_nowait
                              12731                 :                :                 {
 1637 peter@eisentraut.org    12732                 :            602 :                     LockStmt   *n = makeNode(LockStmt);
                              12733                 :                : 
 8995 tgl@sss.pgh.pa.us       12734                 :            602 :                     n->relations = $3;
10034 bruce@momjian.us        12735                 :            602 :                     n->mode = $4;
 8274 ishii@postgresql.org    12736                 :            602 :                     n->nowait = $5;
 1637 peter@eisentraut.org    12737                 :            602 :                     $$ = (Node *) n;
                              12738                 :                :                 }
                              12739                 :                :         ;
                              12740                 :                : 
 5483 peter_e@gmx.net         12741                 :            533 : opt_lock:   IN_P lock_type MODE             { $$ = $2; }
 8906 bruce@momjian.us        12742                 :             69 :             | /*EMPTY*/                     { $$ = AccessExclusiveLock; }
                              12743                 :                :         ;
                              12744                 :                : 
                              12745                 :            242 : lock_type:  ACCESS SHARE                    { $$ = AccessShareLock; }
                              12746                 :              9 :             | ROW SHARE                     { $$ = RowShareLock; }
                              12747                 :             53 :             | ROW EXCLUSIVE                 { $$ = RowExclusiveLock; }
                              12748                 :             35 :             | SHARE UPDATE EXCLUSIVE        { $$ = ShareUpdateExclusiveLock; }
                              12749                 :             42 :             | SHARE                         { $$ = ShareLock; }
                              12750                 :              9 :             | SHARE ROW EXCLUSIVE           { $$ = ShareRowExclusiveLock; }
                              12751                 :             63 :             | EXCLUSIVE                     { $$ = ExclusiveLock; }
                              12752                 :             80 :             | ACCESS EXCLUSIVE              { $$ = AccessExclusiveLock; }
                              12753                 :                :         ;
                              12754                 :                : 
 3368 peter_e@gmx.net         12755                 :            104 : opt_nowait: NOWAIT                          { $$ = true; }
                              12756                 :            519 :             | /*EMPTY*/                     { $$ = false; }
                              12757                 :                :         ;
                              12758                 :                : 
                              12759                 :                : opt_nowait_or_skip:
 4412 alvherre@alvh.no-ip.    12760                 :             31 :             NOWAIT                          { $$ = LockWaitError; }
                              12761                 :             96 :             | SKIP LOCKED                   { $$ = LockWaitSkip; }
                              12762                 :           4949 :             | /*EMPTY*/                     { $$ = LockWaitBlock; }
                              12763                 :                :         ;
                              12764                 :                : 
                              12765                 :                : 
                              12766                 :                : /*****************************************************************************
                              12767                 :                :  *
                              12768                 :                :  *      QUERY:
                              12769                 :                :  *              UpdateStmt (UPDATE)
                              12770                 :                :  *
                              12771                 :                :  *****************************************************************************/
                              12772                 :                : 
                              12773                 :                : UpdateStmt: opt_with_clause UPDATE relation_expr_opt_alias
                              12774                 :                :             SET set_clause_list
                              12775                 :                :             from_clause
                              12776                 :                :             where_or_current_clause
                              12777                 :                :             returning_clause
                              12778                 :                :                 {
 7369 bruce@momjian.us        12779                 :           8923 :                     UpdateStmt *n = makeNode(UpdateStmt);
                              12780                 :                : 
 5865 tgl@sss.pgh.pa.us       12781                 :           8923 :                     n->relation = $3;
                              12782                 :           8923 :                     n->targetList = $5;
                              12783                 :           8923 :                     n->fromClause = $6;
                              12784                 :           8923 :                     n->whereClause = $7;
  658 dean.a.rasheed@gmail    12785                 :           8923 :                     n->returningClause = $8;
 5865 tgl@sss.pgh.pa.us       12786                 :           8923 :                     n->withClause = $1;
 1637 peter@eisentraut.org    12787                 :           8923 :                     $$ = (Node *) n;
                              12788                 :                :                 }
                              12789                 :                :         ;
                              12790                 :                : 
                              12791                 :                : set_clause_list:
 7368 tgl@sss.pgh.pa.us       12792                 :          10950 :             set_clause                          { $$ = $1; }
                              12793                 :           2492 :             | set_clause_list ',' set_clause    { $$ = list_concat($1,$3); }
                              12794                 :                :         ;
                              12795                 :                : 
                              12796                 :                : set_clause:
                              12797                 :                :             set_target '=' a_expr
                              12798                 :                :                 {
 3635                         12799                 :          13322 :                     $1->val = (Node *) $3;
                              12800                 :          13322 :                     $$ = list_make1($1);
                              12801                 :                :                 }
                              12802                 :                :             | '(' set_target_list ')' '=' a_expr
                              12803                 :                :                 {
 1637 peter@eisentraut.org    12804                 :            120 :                     int         ncolumns = list_length($2);
                              12805                 :            120 :                     int         i = 1;
                              12806                 :                :                     ListCell   *col_cell;
                              12807                 :                : 
                              12808                 :                :                     /* Create a MultiAssignRef source for each target */
 4523 tgl@sss.pgh.pa.us       12809   [ +  -  +  +  :            371 :                     foreach(col_cell, $2)
                                              +  + ]
                              12810                 :                :                     {
 1637 peter@eisentraut.org    12811                 :            251 :                         ResTarget  *res_col = (ResTarget *) lfirst(col_cell);
 4523 tgl@sss.pgh.pa.us       12812                 :            251 :                         MultiAssignRef *r = makeNode(MultiAssignRef);
                              12813                 :                : 
 3635                         12814                 :            251 :                         r->source = (Node *) $5;
 4523                         12815                 :            251 :                         r->colno = i;
                              12816                 :            251 :                         r->ncolumns = ncolumns;
                              12817                 :            251 :                         res_col->val = (Node *) r;
                              12818                 :            251 :                         i++;
                              12819                 :                :                     }
                              12820                 :                : 
 7368                         12821                 :            120 :                     $$ = $2;
                              12822                 :                :                 }
                              12823                 :                :         ;
                              12824                 :                : 
                              12825                 :                : set_target:
                              12826                 :                :             ColId opt_indirection
                              12827                 :                :                 {
                              12828                 :          13577 :                     $$ = makeNode(ResTarget);
                              12829                 :          13577 :                     $$->name = $1;
 6324                         12830                 :          13577 :                     $$->indirection = check_indirection($2, yyscanner);
 7368                         12831                 :          13577 :                     $$->val = NULL;  /* upper production sets this */
                              12832                 :          13577 :                     $$->location = @1;
                              12833                 :                :                 }
                              12834                 :                :         ;
                              12835                 :                : 
                              12836                 :                : set_target_list:
                              12837                 :            124 :             set_target                              { $$ = list_make1($1); }
                              12838                 :            131 :             | set_target_list ',' set_target        { $$ = lappend($1,$3); }
                              12839                 :                :         ;
                              12840                 :                : 
                              12841                 :                : 
                              12842                 :                : /*****************************************************************************
                              12843                 :                :  *
                              12844                 :                :  *      QUERY:
                              12845                 :                :  *              MERGE
                              12846                 :                :  *
                              12847                 :                :  *****************************************************************************/
                              12848                 :                : 
                              12849                 :                : MergeStmt:
                              12850                 :                :             opt_with_clause MERGE INTO relation_expr_opt_alias
                              12851                 :                :             USING table_ref
                              12852                 :                :             ON a_expr
                              12853                 :                :             merge_when_list
                              12854                 :                :             returning_clause
                              12855                 :                :                 {
 1637 peter@eisentraut.org    12856                 :           1436 :                     MergeStmt  *m = makeNode(MergeStmt);
                              12857                 :                : 
 1683 alvherre@alvh.no-ip.    12858                 :           1436 :                     m->withClause = $1;
                              12859                 :           1436 :                     m->relation = $4;
                              12860                 :           1436 :                     m->sourceRelation = $6;
                              12861                 :           1436 :                     m->joinCondition = $8;
                              12862                 :           1436 :                     m->mergeWhenClauses = $9;
  658 dean.a.rasheed@gmail    12863                 :           1436 :                     m->returningClause = $10;
                              12864                 :                : 
 1637 peter@eisentraut.org    12865                 :           1436 :                     $$ = (Node *) m;
                              12866                 :                :                 }
                              12867                 :                :         ;
                              12868                 :                : 
                              12869                 :                : merge_when_list:
 1683 alvherre@alvh.no-ip.    12870                 :           1436 :             merge_when_clause                       { $$ = list_make1($1); }
                              12871                 :            811 :             | merge_when_list merge_when_clause     { $$ = lappend($1,$2); }
                              12872                 :                :         ;
                              12873                 :                : 
                              12874                 :                : /*
                              12875                 :                :  * A WHEN clause may be WHEN MATCHED, WHEN NOT MATCHED BY SOURCE, or WHEN NOT
                              12876                 :                :  * MATCHED [BY TARGET]. The first two cases match target tuples, and support
                              12877                 :                :  * UPDATE/DELETE/DO NOTHING actions. The third case does not match target
                              12878                 :                :  * tuples, and only supports INSERT/DO NOTHING actions.
                              12879                 :                :  */
                              12880                 :                : merge_when_clause:
                              12881                 :                :             merge_when_tgt_matched opt_merge_when_condition THEN merge_update
                              12882                 :                :                 {
  950 dean.a.rasheed@gmail    12883                 :           1067 :                     $4->matchKind = $1;
                              12884                 :           1067 :                     $4->condition = $2;
                              12885                 :                : 
                              12886                 :           1067 :                     $$ = (Node *) $4;
                              12887                 :                :                 }
                              12888                 :                :             | merge_when_tgt_matched opt_merge_when_condition THEN merge_delete
                              12889                 :                :                 {
                              12890                 :            375 :                     $4->matchKind = $1;
                              12891                 :            375 :                     $4->condition = $2;
                              12892                 :                : 
                              12893                 :            375 :                     $$ = (Node *) $4;
                              12894                 :                :                 }
                              12895                 :                :             | merge_when_tgt_not_matched opt_merge_when_condition THEN merge_insert
                              12896                 :                :                 {
                              12897                 :            742 :                     $4->matchKind = $1;
                              12898                 :            742 :                     $4->condition = $2;
                              12899                 :                : 
                              12900                 :            742 :                     $$ = (Node *) $4;
                              12901                 :                :                 }
                              12902                 :                :             | merge_when_tgt_matched opt_merge_when_condition THEN DO NOTHING
                              12903                 :                :                 {
 1683 alvherre@alvh.no-ip.    12904                 :             46 :                     MergeWhenClause *m = makeNode(MergeWhenClause);
                              12905                 :                : 
  950 dean.a.rasheed@gmail    12906                 :             46 :                     m->matchKind = $1;
 1683 alvherre@alvh.no-ip.    12907                 :             46 :                     m->commandType = CMD_NOTHING;
  950 dean.a.rasheed@gmail    12908                 :             46 :                     m->condition = $2;
                              12909                 :                : 
 1637 peter@eisentraut.org    12910                 :             46 :                     $$ = (Node *) m;
                              12911                 :                :                 }
                              12912                 :                :             | merge_when_tgt_not_matched opt_merge_when_condition THEN DO NOTHING
                              12913                 :                :                 {
 1683 alvherre@alvh.no-ip.    12914                 :             17 :                     MergeWhenClause *m = makeNode(MergeWhenClause);
                              12915                 :                : 
  950 dean.a.rasheed@gmail    12916                 :             17 :                     m->matchKind = $1;
 1683 alvherre@alvh.no-ip.    12917                 :             17 :                     m->commandType = CMD_NOTHING;
  950 dean.a.rasheed@gmail    12918                 :             17 :                     m->condition = $2;
                              12919                 :                : 
 1637 peter@eisentraut.org    12920                 :             17 :                     $$ = (Node *) m;
                              12921                 :                :                 }
                              12922                 :                :         ;
                              12923                 :                : 
                              12924                 :                : merge_when_tgt_matched:
  950 dean.a.rasheed@gmail    12925                 :           1372 :             WHEN MATCHED                    { $$ = MERGE_WHEN_MATCHED; }
                              12926                 :            128 :             | WHEN NOT MATCHED BY SOURCE    { $$ = MERGE_WHEN_NOT_MATCHED_BY_SOURCE; }
                              12927                 :                :         ;
                              12928                 :                : 
                              12929                 :                : merge_when_tgt_not_matched:
                              12930                 :            763 :             WHEN NOT MATCHED                { $$ = MERGE_WHEN_NOT_MATCHED_BY_TARGET; }
                              12931                 :             12 :             | WHEN NOT MATCHED BY TARGET    { $$ = MERGE_WHEN_NOT_MATCHED_BY_TARGET; }
                              12932                 :                :         ;
                              12933                 :                : 
                              12934                 :                : opt_merge_when_condition:
 1683 alvherre@alvh.no-ip.    12935                 :            566 :             AND a_expr              { $$ = $2; }
                              12936                 :           1709 :             |                       { $$ = NULL; }
                              12937                 :                :         ;
                              12938                 :                : 
                              12939                 :                : merge_update:
                              12940                 :                :             UPDATE SET set_clause_list
                              12941                 :                :                 {
                              12942                 :           1067 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12943                 :           1067 :                     n->commandType = CMD_UPDATE;
                              12944                 :           1067 :                     n->override = OVERRIDING_NOT_SET;
                              12945                 :           1067 :                     n->targetList = $3;
                              12946                 :           1067 :                     n->values = NIL;
                              12947                 :                : 
                              12948                 :           1067 :                     $$ = n;
                              12949                 :                :                 }
                              12950                 :                :         ;
                              12951                 :                : 
                              12952                 :                : merge_delete:
                              12953                 :                :             DELETE_P
                              12954                 :                :                 {
                              12955                 :            375 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12956                 :            375 :                     n->commandType = CMD_DELETE;
                              12957                 :            375 :                     n->override = OVERRIDING_NOT_SET;
                              12958                 :            375 :                     n->targetList = NIL;
                              12959                 :            375 :                     n->values = NIL;
                              12960                 :                : 
                              12961                 :            375 :                     $$ = n;
                              12962                 :                :                 }
                              12963                 :                :         ;
                              12964                 :                : 
                              12965                 :                : merge_insert:
                              12966                 :                :             INSERT merge_values_clause
                              12967                 :                :                 {
                              12968                 :            499 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12969                 :            499 :                     n->commandType = CMD_INSERT;
                              12970                 :            499 :                     n->override = OVERRIDING_NOT_SET;
                              12971                 :            499 :                     n->targetList = NIL;
                              12972                 :            499 :                     n->values = $2;
                              12973                 :            499 :                     $$ = n;
                              12974                 :                :                 }
                              12975                 :                :             | INSERT OVERRIDING override_kind VALUE_P merge_values_clause
                              12976                 :                :                 {
 1683 alvherre@alvh.no-ip.    12977                 :UBC           0 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12978                 :              0 :                     n->commandType = CMD_INSERT;
                              12979                 :              0 :                     n->override = $3;
                              12980                 :              0 :                     n->targetList = NIL;
                              12981                 :              0 :                     n->values = $5;
                              12982                 :              0 :                     $$ = n;
                              12983                 :                :                 }
                              12984                 :                :             | INSERT '(' insert_column_list ')' merge_values_clause
                              12985                 :                :                 {
 1683 alvherre@alvh.no-ip.    12986                 :CBC         199 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12987                 :            199 :                     n->commandType = CMD_INSERT;
                              12988                 :            199 :                     n->override = OVERRIDING_NOT_SET;
                              12989                 :            199 :                     n->targetList = $3;
                              12990                 :            199 :                     n->values = $5;
                              12991                 :            199 :                     $$ = n;
                              12992                 :                :                 }
                              12993                 :                :             | INSERT '(' insert_column_list ')' OVERRIDING override_kind VALUE_P merge_values_clause
                              12994                 :                :                 {
                              12995                 :             20 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              12996                 :             20 :                     n->commandType = CMD_INSERT;
                              12997                 :             20 :                     n->override = $6;
                              12998                 :             20 :                     n->targetList = $3;
                              12999                 :             20 :                     n->values = $8;
                              13000                 :             20 :                     $$ = n;
                              13001                 :                :                 }
                              13002                 :                :             | INSERT DEFAULT VALUES
                              13003                 :                :                 {
                              13004                 :             24 :                     MergeWhenClause *n = makeNode(MergeWhenClause);
                              13005                 :             24 :                     n->commandType = CMD_INSERT;
                              13006                 :             24 :                     n->override = OVERRIDING_NOT_SET;
                              13007                 :             24 :                     n->targetList = NIL;
                              13008                 :             24 :                     n->values = NIL;
                              13009                 :             24 :                     $$ = n;
                              13010                 :                :                 }
                              13011                 :                :         ;
                              13012                 :                : 
                              13013                 :                : merge_values_clause:
                              13014                 :                :             VALUES '(' expr_list ')'
                              13015                 :                :                 {
                              13016                 :            718 :                     $$ = $3;
                              13017                 :                :                 }
                              13018                 :                :         ;
                              13019                 :                : 
                              13020                 :                : /*****************************************************************************
                              13021                 :                :  *
                              13022                 :                :  *      QUERY:
                              13023                 :                :  *              CURSOR STATEMENTS
                              13024                 :                :  *
                              13025                 :                :  *****************************************************************************/
                              13026                 :                : DeclareCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR SelectStmt
                              13027                 :                :                 {
 8641 tgl@sss.pgh.pa.us       13028                 :           2760 :                     DeclareCursorStmt *n = makeNode(DeclareCursorStmt);
                              13029                 :                : 
10650 bruce@momjian.us        13030                 :           2760 :                     n->portalname = $2;
                              13031                 :                :                     /* currently we always set FAST_PLAN option */
 7143 tgl@sss.pgh.pa.us       13032                 :           2760 :                     n->options = $3 | $5 | CURSOR_OPT_FAST_PLAN;
 8624 bruce@momjian.us        13033                 :           2760 :                     n->query = $7;
 1637 peter@eisentraut.org    13034                 :           2760 :                     $$ = (Node *) n;
                              13035                 :                :                 }
                              13036                 :                :         ;
                              13037                 :                : 
 6203 alvherre@alvh.no-ip.    13038                 :           8523 : cursor_name:    name                        { $$ = $1; }
                              13039                 :                :         ;
                              13040                 :                : 
 8641 tgl@sss.pgh.pa.us       13041                 :           2760 : cursor_options: /*EMPTY*/                   { $$ = 0; }
 8624 bruce@momjian.us        13042                 :             18 :             | cursor_options NO SCROLL      { $$ = $1 | CURSOR_OPT_NO_SCROLL; }
 8641 tgl@sss.pgh.pa.us       13043                 :            165 :             | cursor_options SCROLL         { $$ = $1 | CURSOR_OPT_SCROLL; }
 8624 bruce@momjian.us        13044                 :              6 :             | cursor_options BINARY         { $$ = $1 | CURSOR_OPT_BINARY; }
 2038 peter@eisentraut.org    13045                 :UBC           0 :             | cursor_options ASENSITIVE     { $$ = $1 | CURSOR_OPT_ASENSITIVE; }
 8641 tgl@sss.pgh.pa.us       13046                 :CBC           4 :             | cursor_options INSENSITIVE    { $$ = $1 | CURSOR_OPT_INSENSITIVE; }
                              13047                 :                :         ;
                              13048                 :                : 
 7143                         13049                 :           2693 : opt_hold: /* EMPTY */                       { $$ = 0; }
                              13050                 :             63 :             | WITH HOLD                     { $$ = CURSOR_OPT_HOLD; }
                              13051                 :              4 :             | WITHOUT HOLD                  { $$ = 0; }
                              13052                 :                :         ;
                              13053                 :                : 
                              13054                 :                : /*****************************************************************************
                              13055                 :                :  *
                              13056                 :                :  *      QUERY:
                              13057                 :                :  *              SELECT STATEMENTS
                              13058                 :                :  *
                              13059                 :                :  *****************************************************************************/
                              13060                 :                : 
                              13061                 :                : /* A complete SELECT statement looks like this.
                              13062                 :                :  *
                              13063                 :                :  * The rule returns either a single SelectStmt node or a tree of them,
                              13064                 :                :  * representing a set-operation tree.
                              13065                 :                :  *
                              13066                 :                :  * There is an ambiguity when a sub-SELECT is within an a_expr and there
                              13067                 :                :  * are excess parentheses: do the parentheses belong to the sub-SELECT or
                              13068                 :                :  * to the surrounding a_expr?  We don't really care, but bison wants to know.
                              13069                 :                :  * To resolve the ambiguity, we are careful to define the grammar so that
                              13070                 :                :  * the decision is staved off as long as possible: as long as we can keep
                              13071                 :                :  * absorbing parentheses into the sub-SELECT, we will do so, and only when
                              13072                 :                :  * it's no longer possible to do that will we decide that parens belong to
                              13073                 :                :  * the expression.  For example, in "SELECT (((SELECT 2)) + 3)" the extra
                              13074                 :                :  * parentheses are treated as part of the sub-select.  The necessity of doing
                              13075                 :                :  * it that way is shown by "SELECT (((SELECT 2)) UNION SELECT 2)".    Had we
                              13076                 :                :  * parsed "((SELECT 2))" as an a_expr, it'd be too late to go back to the
                              13077                 :                :  * SELECT viewpoint when we see the UNION.
                              13078                 :                :  *
                              13079                 :                :  * This approach is implemented by defining a nonterminal select_with_parens,
                              13080                 :                :  * which represents a SELECT with at least one outer layer of parentheses,
                              13081                 :                :  * and being careful to use select_with_parens, never '(' SelectStmt ')',
                              13082                 :                :  * in the expression grammar.  We will then have shift-reduce conflicts
                              13083                 :                :  * which we can resolve in favor of always treating '(' <select> ')' as
                              13084                 :                :  * a select_with_parens.  To resolve the conflicts, the productions that
                              13085                 :                :  * conflict with the select_with_parens productions are manually given
                              13086                 :                :  * precedences lower than the precedence of ')', thereby ensuring that we
                              13087                 :                :  * shift ')' (and then reduce to select_with_parens) rather than trying to
                              13088                 :                :  * reduce the inner <select> nonterminal to something else.  We use UMINUS
                              13089                 :                :  * precedence for this, which is a fairly arbitrary choice.
                              13090                 :                :  *
                              13091                 :                :  * To be able to define select_with_parens itself without ambiguity, we need
                              13092                 :                :  * a nonterminal select_no_parens that represents a SELECT structure with no
                              13093                 :                :  * outermost parentheses.  This is a little bit tedious, but it works.
                              13094                 :                :  *
                              13095                 :                :  * In non-expression contexts, we use SelectStmt which can represent a SELECT
                              13096                 :                :  * with or without outer parentheses.
                              13097                 :                :  */
                              13098                 :                : 
                              13099                 :                : SelectStmt: select_no_parens            %prec UMINUS
                              13100                 :                :             | select_with_parens        %prec UMINUS
                              13101                 :                :         ;
                              13102                 :                : 
                              13103                 :                : select_with_parens:
  511 michael@paquier.xyz     13104                 :          49918 :             '(' select_no_parens ')'                { $$ = $2; }
 8907 bruce@momjian.us        13105                 :            104 :             | '(' select_with_parens ')'            { $$ = $2; }
                              13106                 :                :         ;
                              13107                 :                : 
                              13108                 :                : /*
                              13109                 :                :  * This rule parses the equivalent of the standard's <query expression>.
                              13110                 :                :  * The duplicative productions are annoying, but hard to get rid of without
                              13111                 :                :  * creating shift/reduce conflicts.
                              13112                 :                :  *
                              13113                 :                :  *  The locking clause (FOR UPDATE etc) may be before or after LIMIT/OFFSET.
                              13114                 :                :  *  In <=7.2.X, LIMIT/OFFSET had to be after FOR UPDATE
                              13115                 :                :  *  We now support both orderings, but prefer LIMIT/OFFSET before the locking
                              13116                 :                :  * clause.
                              13117                 :                :  *  2002-08-28 bjm
                              13118                 :                :  */
                              13119                 :                : select_no_parens:
                              13120                 :         259808 :             simple_select                       { $$ = $1; }
                              13121                 :                :             | select_clause sort_clause
                              13122                 :                :                 {
 7494 tgl@sss.pgh.pa.us       13123                 :          47857 :                     insertSelectOptions((SelectStmt *) $1, $2, NIL,
                              13124                 :                :                                         NULL, NULL,
                              13125                 :                :                                         yyscanner);
 8907 bruce@momjian.us        13126                 :          47857 :                     $$ = $1;
                              13127                 :                :                 }
                              13128                 :                :             | select_clause opt_sort_clause for_locking_clause opt_select_limit
                              13129                 :                :                 {
 8835                         13130                 :           4850 :                     insertSelectOptions((SelectStmt *) $1, $2, $3,
 2403 alvherre@alvh.no-ip.    13131                 :           4850 :                                         $4,
                              13132                 :                :                                         NULL,
                              13133                 :                :                                         yyscanner);
 8907 bruce@momjian.us        13134                 :           4850 :                     $$ = $1;
                              13135                 :                :                 }
                              13136                 :                :             | select_clause opt_sort_clause select_limit opt_for_locking_clause
                              13137                 :                :                 {
 8835                         13138                 :           3245 :                     insertSelectOptions((SelectStmt *) $1, $2, $4,
 2403 alvherre@alvh.no-ip.    13139                 :           3245 :                                         $3,
                              13140                 :                :                                         NULL,
                              13141                 :                :                                         yyscanner);
 8907 bruce@momjian.us        13142                 :           3237 :                     $$ = $1;
                              13143                 :                :                 }
                              13144                 :                :             | with_clause select_clause
                              13145                 :                :                 {
 6606 tgl@sss.pgh.pa.us       13146                 :           1641 :                     insertSelectOptions((SelectStmt *) $2, NULL, NIL,
                              13147                 :                :                                         NULL,
 6324                         13148                 :           1641 :                                         $1,
                              13149                 :                :                                         yyscanner);
 6606                         13150                 :           1641 :                     $$ = $2;
                              13151                 :                :                 }
                              13152                 :                :             | with_clause select_clause sort_clause
                              13153                 :                :                 {
                              13154                 :            371 :                     insertSelectOptions((SelectStmt *) $2, $3, NIL,
                              13155                 :                :                                         NULL,
 6324                         13156                 :            371 :                                         $1,
                              13157                 :                :                                         yyscanner);
 6606                         13158                 :            371 :                     $$ = $2;
                              13159                 :                :                 }
                              13160                 :                :             | with_clause select_clause opt_sort_clause for_locking_clause opt_select_limit
                              13161                 :                :                 {
                              13162                 :              4 :                     insertSelectOptions((SelectStmt *) $2, $3, $4,
 2403 alvherre@alvh.no-ip.    13163                 :              4 :                                         $5,
 6324 tgl@sss.pgh.pa.us       13164                 :              4 :                                         $1,
                              13165                 :                :                                         yyscanner);
 6606                         13166                 :              4 :                     $$ = $2;
                              13167                 :                :                 }
                              13168                 :                :             | with_clause select_clause opt_sort_clause select_limit opt_for_locking_clause
                              13169                 :                :                 {
                              13170                 :             42 :                     insertSelectOptions((SelectStmt *) $2, $3, $5,
 2403 alvherre@alvh.no-ip.    13171                 :             42 :                                         $4,
 6324 tgl@sss.pgh.pa.us       13172                 :             42 :                                         $1,
                              13173                 :                :                                         yyscanner);
 6606                         13174                 :             42 :                     $$ = $2;
                              13175                 :                :                 }
                              13176                 :                :         ;
                              13177                 :                : 
                              13178                 :                : select_clause:
 8907 bruce@momjian.us        13179                 :          83931 :             simple_select                           { $$ = $1; }
                              13180                 :            419 :             | select_with_parens                    { $$ = $1; }
                              13181                 :                :         ;
                              13182                 :                : 
                              13183                 :                : /*
                              13184                 :                :  * This rule parses SELECT statements that can appear within set operations,
                              13185                 :                :  * including UNION, INTERSECT and EXCEPT.  '(' and ')' can be used to specify
                              13186                 :                :  * the ordering of the set operations.  Without '(' and ')' we want the
                              13187                 :                :  * operations to be ordered per the precedence specs at the head of this file.
                              13188                 :                :  *
                              13189                 :                :  * As with select_no_parens, simple_select cannot have outer parentheses,
                              13190                 :                :  * but can have parenthesized subclauses.
                              13191                 :                :  *
                              13192                 :                :  * It might appear that we could fold the first two alternatives into one
                              13193                 :                :  * by using opt_distinct_clause.  However, that causes a shift/reduce conflict
                              13194                 :                :  * against INSERT ... SELECT ... ON CONFLICT.  We avoid the ambiguity by
                              13195                 :                :  * requiring SELECT DISTINCT [ON] to be followed by a non-empty target_list.
                              13196                 :                :  *
                              13197                 :                :  * Note that sort clauses cannot be included at this level --- SQL requires
                              13198                 :                :  *      SELECT foo UNION SELECT bar ORDER BY baz
                              13199                 :                :  * to be parsed as
                              13200                 :                :  *      (SELECT foo UNION SELECT bar) ORDER BY baz
                              13201                 :                :  * not
                              13202                 :                :  *      SELECT foo UNION (SELECT bar ORDER BY baz)
                              13203                 :                :  * Likewise for WITH, FOR UPDATE and LIMIT.  Therefore, those clauses are
                              13204                 :                :  * described as part of the select_no_parens production, not simple_select.
                              13205                 :                :  * This does not limit functionality, because you can reintroduce these
                              13206                 :                :  * clauses inside parentheses.
                              13207                 :                :  *
                              13208                 :                :  * NOTE: only the leftmost component SelectStmt should have INTO.
                              13209                 :                :  * However, this is not checked by the grammar; parse analysis must check it.
                              13210                 :                :  */
                              13211                 :                : simple_select:
                              13212                 :                :             SELECT opt_all_clause opt_target_list
                              13213                 :                :             into_clause from_clause where_clause
                              13214                 :                :             group_clause having_clause window_clause
                              13215                 :                :                 {
 4199 andres@anarazel.de      13216                 :         287684 :                     SelectStmt *n = makeNode(SelectStmt);
                              13217                 :                : 
                              13218                 :         287683 :                     n->targetList = $3;
                              13219                 :         287683 :                     n->intoClause = $4;
                              13220                 :         287683 :                     n->fromClause = $5;
                              13221                 :         287683 :                     n->whereClause = $6;
 2058 tomas.vondra@postgre    13222                 :         287683 :                     n->groupClause = ($7)->list;
                              13223                 :         287683 :                     n->groupDistinct = ($7)->distinct;
 4199 andres@anarazel.de      13224                 :         287683 :                     n->havingClause = $8;
                              13225                 :         287683 :                     n->windowClause = $9;
 1637 peter@eisentraut.org    13226                 :         287683 :                     $$ = (Node *) n;
                              13227                 :                :                 }
                              13228                 :                :             | SELECT distinct_clause target_list
                              13229                 :                :             into_clause from_clause where_clause
                              13230                 :                :             group_clause having_clause window_clause
                              13231                 :                :                 {
10527 bruce@momjian.us        13232                 :           2497 :                     SelectStmt *n = makeNode(SelectStmt);
                              13233                 :                : 
 9779 tgl@sss.pgh.pa.us       13234                 :           2497 :                     n->distinctClause = $2;
10650 bruce@momjian.us        13235                 :           2497 :                     n->targetList = $3;
 7132 tgl@sss.pgh.pa.us       13236                 :           2497 :                     n->intoClause = $4;
10650 bruce@momjian.us        13237                 :           2497 :                     n->fromClause = $5;
                              13238                 :           2497 :                     n->whereClause = $6;
 2058 tomas.vondra@postgre    13239                 :           2497 :                     n->groupClause = ($7)->list;
                              13240                 :           2497 :                     n->groupDistinct = ($7)->distinct;
10650 bruce@momjian.us        13241                 :           2497 :                     n->havingClause = $8;
 6521 tgl@sss.pgh.pa.us       13242                 :           2497 :                     n->windowClause = $9;
 1637 peter@eisentraut.org    13243                 :           2497 :                     $$ = (Node *) n;
                              13244                 :                :                 }
 7400 mail@joeconway.com      13245                 :          40139 :             | values_clause                         { $$ = $1; }
                              13246                 :                :             | TABLE relation_expr
                              13247                 :                :                 {
                              13248                 :                :                     /* same as SELECT * FROM relation_expr */
 1637 peter@eisentraut.org    13249                 :            253 :                     ColumnRef  *cr = makeNode(ColumnRef);
                              13250                 :            253 :                     ResTarget  *rt = makeNode(ResTarget);
 6559 peter_e@gmx.net         13251                 :            253 :                     SelectStmt *n = makeNode(SelectStmt);
                              13252                 :                : 
                              13253                 :            253 :                     cr->fields = list_make1(makeNode(A_Star));
                              13254                 :            253 :                     cr->location = -1;
                              13255                 :                : 
                              13256                 :            253 :                     rt->name = NULL;
                              13257                 :            253 :                     rt->indirection = NIL;
 1637 peter@eisentraut.org    13258                 :            253 :                     rt->val = (Node *) cr;
 6559 peter_e@gmx.net         13259                 :            253 :                     rt->location = -1;
                              13260                 :                : 
                              13261                 :            253 :                     n->targetList = list_make1(rt);
                              13262                 :            253 :                     n->fromClause = list_make1($2);
 1637 peter@eisentraut.org    13263                 :            253 :                     $$ = (Node *) n;
                              13264                 :                :                 }
                              13265                 :                :             | select_clause UNION set_quantifier select_clause
                              13266                 :                :                 {
  511 michael@paquier.xyz     13267                 :          12585 :                     $$ = makeSetOp(SETOP_UNION, $3 == SET_QUANTIFIER_ALL, $1, $4);
                              13268                 :                :                 }
                              13269                 :                :             | select_clause INTERSECT set_quantifier select_clause
                              13270                 :                :                 {
                              13271                 :            230 :                     $$ = makeSetOp(SETOP_INTERSECT, $3 == SET_QUANTIFIER_ALL, $1, $4);
                              13272                 :                :                 }
                              13273                 :                :             | select_clause EXCEPT set_quantifier select_clause
                              13274                 :                :                 {
                              13275                 :            351 :                     $$ = makeSetOp(SETOP_EXCEPT, $3 == SET_QUANTIFIER_ALL, $1, $4);
                              13276                 :                :                 }
                              13277                 :                :         ;
                              13278                 :                : 
                              13279                 :                : /*
                              13280                 :                :  * SQL standard WITH clause looks like:
                              13281                 :                :  *
                              13282                 :                :  * WITH [ RECURSIVE ] <query name> [ (<column>,...) ]
                              13283                 :                :  *      AS (query) [ SEARCH or CYCLE clause ]
                              13284                 :                :  *
                              13285                 :                :  * Recognizing WITH_LA here allows a CTE to be named TIME or ORDINALITY.
                              13286                 :                :  */
                              13287                 :                : with_clause:
                              13288                 :                :         WITH cte_list
                              13289                 :                :             {
 6606 tgl@sss.pgh.pa.us       13290                 :           1533 :                 $$ = makeNode(WithClause);
                              13291                 :           1533 :                 $$->ctes = $2;
                              13292                 :           1533 :                 $$->recursive = false;
                              13293                 :           1533 :                 $$->location = @1;
                              13294                 :                :             }
                              13295                 :                :         | WITH_LA cte_list
                              13296                 :                :             {
 4272                         13297                 :              4 :                 $$ = makeNode(WithClause);
                              13298                 :              4 :                 $$->ctes = $2;
                              13299                 :              4 :                 $$->recursive = false;
                              13300                 :              4 :                 $$->location = @1;
                              13301                 :                :             }
                              13302                 :                :         | WITH RECURSIVE cte_list
                              13303                 :                :             {
 6606                         13304                 :            834 :                 $$ = makeNode(WithClause);
                              13305                 :            834 :                 $$->ctes = $3;
                              13306                 :            834 :                 $$->recursive = true;
                              13307                 :            834 :                 $$->location = @1;
                              13308                 :                :             }
                              13309                 :                :         ;
                              13310                 :                : 
                              13311                 :                : cte_list:
                              13312                 :           2371 :         common_table_expr                       { $$ = list_make1($1); }
                              13313                 :            765 :         | cte_list ',' common_table_expr        { $$ = lappend($1, $3); }
                              13314                 :                :         ;
                              13315                 :                : 
                              13316                 :                : common_table_expr:  name opt_name_list AS opt_materialized '(' PreparableStmt ')' opt_search_clause opt_cycle_clause
                              13317                 :                :             {
                              13318                 :           3136 :                 CommonTableExpr *n = makeNode(CommonTableExpr);
                              13319                 :                : 
                              13320                 :           3136 :                 n->ctename = $1;
                              13321                 :           3136 :                 n->aliascolnames = $2;
 2819                         13322                 :           3136 :                 n->ctematerialized = $4;
                              13323                 :           3136 :                 n->ctequery = $6;
 2103 peter@eisentraut.org    13324                 :           3136 :                 n->search_clause = castNode(CTESearchClause, $8);
                              13325                 :           3136 :                 n->cycle_clause = castNode(CTECycleClause, $9);
 6606 tgl@sss.pgh.pa.us       13326                 :           3136 :                 n->location = @1;
                              13327                 :           3136 :                 $$ = (Node *) n;
                              13328                 :                :             }
                              13329                 :                :         ;
                              13330                 :                : 
                              13331                 :                : opt_materialized:
 2819                         13332                 :            119 :         MATERIALIZED                            { $$ = CTEMaterializeAlways; }
                              13333                 :             32 :         | NOT MATERIALIZED                      { $$ = CTEMaterializeNever; }
                              13334                 :           2985 :         | /*EMPTY*/                             { $$ = CTEMaterializeDefault; }
                              13335                 :                :         ;
                              13336                 :                : 
                              13337                 :                : opt_search_clause:
                              13338                 :                :         SEARCH DEPTH FIRST_P BY columnList SET ColId
                              13339                 :                :             {
 2103 peter@eisentraut.org    13340                 :             60 :                 CTESearchClause *n = makeNode(CTESearchClause);
                              13341                 :                : 
                              13342                 :             60 :                 n->search_col_list = $5;
                              13343                 :             60 :                 n->search_breadth_first = false;
                              13344                 :             60 :                 n->search_seq_column = $7;
                              13345                 :             60 :                 n->location = @1;
                              13346                 :             60 :                 $$ = (Node *) n;
                              13347                 :                :             }
                              13348                 :                :         | SEARCH BREADTH FIRST_P BY columnList SET ColId
                              13349                 :                :             {
                              13350                 :             24 :                 CTESearchClause *n = makeNode(CTESearchClause);
                              13351                 :                : 
                              13352                 :             24 :                 n->search_col_list = $5;
                              13353                 :             24 :                 n->search_breadth_first = true;
                              13354                 :             24 :                 n->search_seq_column = $7;
                              13355                 :             24 :                 n->location = @1;
                              13356                 :             24 :                 $$ = (Node *) n;
                              13357                 :                :             }
                              13358                 :                :         | /*EMPTY*/
                              13359                 :                :             {
                              13360                 :           3052 :                 $$ = NULL;
                              13361                 :                :             }
                              13362                 :                :         ;
                              13363                 :                : 
                              13364                 :                : opt_cycle_clause:
                              13365                 :                :         CYCLE columnList SET ColId TO AexprConst DEFAULT AexprConst USING ColId
                              13366                 :                :             {
                              13367                 :             44 :                 CTECycleClause *n = makeNode(CTECycleClause);
                              13368                 :                : 
                              13369                 :             44 :                 n->cycle_col_list = $2;
                              13370                 :             44 :                 n->cycle_mark_column = $4;
                              13371                 :             44 :                 n->cycle_mark_value = $6;
                              13372                 :             44 :                 n->cycle_mark_default = $8;
                              13373                 :             44 :                 n->cycle_path_column = $10;
                              13374                 :             44 :                 n->location = @1;
                              13375                 :             44 :                 $$ = (Node *) n;
                              13376                 :                :             }
                              13377                 :                :         | CYCLE columnList SET ColId USING ColId
                              13378                 :                :             {
 2077                         13379                 :             40 :                 CTECycleClause *n = makeNode(CTECycleClause);
                              13380                 :                : 
                              13381                 :             40 :                 n->cycle_col_list = $2;
                              13382                 :             40 :                 n->cycle_mark_column = $4;
                              13383                 :             40 :                 n->cycle_mark_value = makeBoolAConst(true, -1);
                              13384                 :             40 :                 n->cycle_mark_default = makeBoolAConst(false, -1);
                              13385                 :             40 :                 n->cycle_path_column = $6;
                              13386                 :             40 :                 n->location = @1;
                              13387                 :             40 :                 $$ = (Node *) n;
                              13388                 :                :             }
                              13389                 :                :         | /*EMPTY*/
                              13390                 :                :             {
 2103                         13391                 :           3052 :                 $$ = NULL;
                              13392                 :                :             }
                              13393                 :                :         ;
                              13394                 :                : 
                              13395                 :                : opt_with_clause:
 5865 tgl@sss.pgh.pa.us       13396                 :            313 :         with_clause                             { $$ = $1; }
                              13397                 :          57589 :         | /*EMPTY*/                             { $$ = NULL; }
                              13398                 :                :         ;
                              13399                 :                : 
                              13400                 :                : into_clause:
                              13401                 :                :             INTO OptTempTableName
                              13402                 :                :                 {
 7198                         13403                 :             90 :                     $$ = makeNode(IntoClause);
                              13404                 :             90 :                     $$->rel = $2;
                              13405                 :             90 :                     $$->colNames = NIL;
                              13406                 :             90 :                     $$->options = NIL;
                              13407                 :             90 :                     $$->onCommit = ONCOMMIT_NOOP;
                              13408                 :             90 :                     $$->tableSpaceName = NULL;
 4955                         13409                 :             90 :                     $$->viewQuery = NULL;
 5460                         13410                 :             90 :                     $$->skipData = false;
                              13411                 :                :                 }
                              13412                 :                :             | /*EMPTY*/
 7198                         13413                 :         290111 :                 { $$ = NULL; }
                              13414                 :                :         ;
                              13415                 :                : 
                              13416                 :                : /*
                              13417                 :                :  * Redundancy here is needed to avoid shift/reduce conflicts,
                              13418                 :                :  * since TEMP is not a reserved word.  See also OptTemp.
                              13419                 :                :  */
                              13420                 :                : OptTempTableName:
                              13421                 :                :             TEMPORARY opt_table qualified_name
                              13422                 :                :                 {
 8995 tgl@sss.pgh.pa.us       13423                 :UBC           0 :                     $$ = $3;
 5806 rhaas@postgresql.org    13424                 :              0 :                     $$->relpersistence = RELPERSISTENCE_TEMP;
                              13425                 :                :                 }
                              13426                 :                :             | TEMP opt_table qualified_name
                              13427                 :                :                 {
 8995 tgl@sss.pgh.pa.us       13428                 :CBC           4 :                     $$ = $3;
 5806 rhaas@postgresql.org    13429                 :              4 :                     $$->relpersistence = RELPERSISTENCE_TEMP;
                              13430                 :                :                 }
                              13431                 :                :             | LOCAL TEMPORARY opt_table qualified_name
                              13432                 :                :                 {
 8995 tgl@sss.pgh.pa.us       13433                 :UBC           0 :                     $$ = $4;
 5806 rhaas@postgresql.org    13434                 :              0 :                     $$->relpersistence = RELPERSISTENCE_TEMP;
                              13435                 :                :                 }
                              13436                 :                :             | LOCAL TEMP opt_table qualified_name
                              13437                 :                :                 {
 8995 tgl@sss.pgh.pa.us       13438                 :              0 :                     $$ = $4;
 5806 rhaas@postgresql.org    13439                 :              0 :                     $$->relpersistence = RELPERSISTENCE_TEMP;
                              13440                 :                :                 }
                              13441                 :                :             | GLOBAL TEMPORARY opt_table qualified_name
                              13442                 :                :                 {
 5258 tgl@sss.pgh.pa.us       13443         [ #  # ]:              0 :                     ereport(WARNING,
                              13444                 :                :                             (errmsg("GLOBAL is deprecated in temporary table creation"),
                              13445                 :                :                              parser_errposition(@1)));
 8995                         13446                 :              0 :                     $$ = $4;
 5806 rhaas@postgresql.org    13447                 :              0 :                     $$->relpersistence = RELPERSISTENCE_TEMP;
                              13448                 :                :                 }
                              13449                 :                :             | GLOBAL TEMP opt_table qualified_name
                              13450                 :                :                 {
 5258 tgl@sss.pgh.pa.us       13451         [ #  # ]:              0 :                     ereport(WARNING,
                              13452                 :                :                             (errmsg("GLOBAL is deprecated in temporary table creation"),
                              13453                 :                :                              parser_errposition(@1)));
 8995                         13454                 :              0 :                     $$ = $4;
 5806 rhaas@postgresql.org    13455                 :              0 :                     $$->relpersistence = RELPERSISTENCE_TEMP;
                              13456                 :                :                 }
                              13457                 :                :             | UNLOGGED opt_table qualified_name
                              13458                 :                :                 {
 5790                         13459                 :              0 :                     $$ = $3;
                              13460                 :              0 :                     $$->relpersistence = RELPERSISTENCE_UNLOGGED;
                              13461                 :                :                 }
                              13462                 :                :             | TABLE qualified_name
                              13463                 :                :                 {
 8995 tgl@sss.pgh.pa.us       13464                 :CBC          20 :                     $$ = $2;
 5806 rhaas@postgresql.org    13465                 :             20 :                     $$->relpersistence = RELPERSISTENCE_PERMANENT;
                              13466                 :                :                 }
                              13467                 :                :             | qualified_name
                              13468                 :                :                 {
 8995 tgl@sss.pgh.pa.us       13469                 :             66 :                     $$ = $1;
 5806 rhaas@postgresql.org    13470                 :             66 :                     $$->relpersistence = RELPERSISTENCE_PERMANENT;
                              13471                 :                :                 }
                              13472                 :                :         ;
                              13473                 :                : 
                              13474                 :                : opt_table:  TABLE
                              13475                 :                :             | /*EMPTY*/
                              13476                 :                :         ;
                              13477                 :                : 
                              13478                 :                : set_quantifier:
 2058 tomas.vondra@postgre    13479                 :           7340 :             ALL                                     { $$ = SET_QUANTIFIER_ALL; }
                              13480                 :             25 :             | DISTINCT                              { $$ = SET_QUANTIFIER_DISTINCT; }
                              13481                 :           9554 :             | /*EMPTY*/                             { $$ = SET_QUANTIFIER_DEFAULT; }
                              13482                 :                :         ;
                              13483                 :                : 
                              13484                 :                : /* We use (NIL) as a placeholder to indicate that all target expressions
                              13485                 :                :  * should be placed in the DISTINCT list during parsetree analysis.
                              13486                 :                :  */
                              13487                 :                : distinct_clause:
 8194 neilc@samurai.com       13488                 :           2290 :             DISTINCT                                { $$ = list_make1(NIL); }
 8907 bruce@momjian.us        13489                 :            211 :             | DISTINCT ON '(' expr_list ')'         { $$ = $4; }
                              13490                 :                :         ;
                              13491                 :                : 
                              13492                 :                : opt_all_clause:
                              13493                 :                :             ALL
                              13494                 :                :             | /*EMPTY*/
                              13495                 :                :         ;
                              13496                 :                : 
                              13497                 :                : opt_distinct_clause:
 2113 tgl@sss.pgh.pa.us       13498                 :UBC           0 :             distinct_clause                         { $$ = $1; }
 2113 tgl@sss.pgh.pa.us       13499                 :CBC       24933 :             | opt_all_clause                        { $$ = NIL; }
                              13500                 :                :         ;
                              13501                 :                : 
                              13502                 :                : opt_sort_clause:
                              13503                 :           4867 :             sort_clause                             { $$ = $1; }
 8835 bruce@momjian.us        13504                 :         238985 :             | /*EMPTY*/                             { $$ = NIL; }
                              13505                 :                :         ;
                              13506                 :                : 
                              13507                 :                : sort_clause:
 8907                         13508                 :          53323 :             ORDER BY sortby_list                    { $$ = $3; }
                              13509                 :                :         ;
                              13510                 :                : 
                              13511                 :                : sortby_list:
 8194 neilc@samurai.com       13512                 :          53361 :             sortby                                  { $$ = list_make1($1); }
 8907 bruce@momjian.us        13513                 :          18423 :             | sortby_list ',' sortby                { $$ = lappend($1, $3); }
                              13514                 :                :         ;
                              13515                 :                : 
                              13516                 :                : sortby:     a_expr USING qual_all_Op opt_nulls_order
                              13517                 :                :                 {
 8481 tgl@sss.pgh.pa.us       13518                 :            142 :                     $$ = makeNode(SortBy);
10319 scrappy@hub.org         13519                 :            142 :                     $$->node = $1;
 7240 tgl@sss.pgh.pa.us       13520                 :            142 :                     $$->sortby_dir = SORTBY_USING;
                              13521                 :            142 :                     $$->sortby_nulls = $4;
 8481                         13522                 :            142 :                     $$->useOp = $3;
 6639                         13523                 :            142 :                     $$->location = @3;
                              13524                 :                :                 }
                              13525                 :                :             | a_expr opt_asc_desc opt_nulls_order
                              13526                 :                :                 {
 8481                         13527                 :          71642 :                     $$ = makeNode(SortBy);
                              13528                 :          71642 :                     $$->node = $1;
 7173 meskes@postgresql.or    13529                 :          71642 :                     $$->sortby_dir = $2;
 7240 tgl@sss.pgh.pa.us       13530                 :          71642 :                     $$->sortby_nulls = $3;
 8481                         13531                 :          71642 :                     $$->useOp = NIL;
 6639                         13532                 :          71642 :                     $$->location = -1;       /* no operator */
                              13533                 :                :                 }
                              13534                 :                :         ;
                              13535                 :                : 
                              13536                 :                : 
                              13537                 :                : select_limit:
                              13538                 :                :             limit_clause offset_clause
                              13539                 :                :                 {
 2403 alvherre@alvh.no-ip.    13540                 :             99 :                     $$ = $1;
                              13541                 :             99 :                     ($$)->limitOffset = $2;
  735 tgl@sss.pgh.pa.us       13542                 :             99 :                     ($$)->offsetLoc = @2;
                              13543                 :                :                 }
                              13544                 :                :             | offset_clause limit_clause
                              13545                 :                :                 {
 2403 alvherre@alvh.no-ip.    13546                 :            113 :                     $$ = $2;
                              13547                 :            113 :                     ($$)->limitOffset = $1;
  735 tgl@sss.pgh.pa.us       13548                 :            113 :                     ($$)->offsetLoc = @1;
                              13549                 :                :                 }
                              13550                 :                :             | limit_clause
                              13551                 :                :                 {
 2403 alvherre@alvh.no-ip.    13552                 :           2707 :                     $$ = $1;
                              13553                 :                :                 }
                              13554                 :                :             | offset_clause
                              13555                 :                :                 {
  330 michael@paquier.xyz     13556                 :            463 :                     SelectLimit *n = palloc_object(SelectLimit);
                              13557                 :                : 
 2403 alvherre@alvh.no-ip.    13558                 :            463 :                     n->limitOffset = $1;
                              13559                 :            463 :                     n->limitCount = NULL;
                              13560                 :            463 :                     n->limitOption = LIMIT_OPTION_COUNT;
  735 tgl@sss.pgh.pa.us       13561                 :            463 :                     n->offsetLoc = @1;
                              13562                 :            463 :                     n->countLoc = -1;
                              13563                 :            463 :                     n->optionLoc = -1;
 2403 alvherre@alvh.no-ip.    13564                 :            463 :                     $$ = n;
                              13565                 :                :                 }
                              13566                 :                :         ;
                              13567                 :                : 
                              13568                 :                : opt_select_limit:
 6288 tgl@sss.pgh.pa.us       13569                 :             95 :             select_limit                        { $$ = $1; }
 2403 alvherre@alvh.no-ip.    13570                 :          29692 :             | /* EMPTY */                       { $$ = NULL; }
                              13571                 :                :         ;
                              13572                 :                : 
                              13573                 :                : limit_clause:
                              13574                 :                :             LIMIT select_limit_value
                              13575                 :                :                 {
  330 michael@paquier.xyz     13576                 :           2858 :                     SelectLimit *n = palloc_object(SelectLimit);
                              13577                 :                : 
 2403 alvherre@alvh.no-ip.    13578                 :           2858 :                     n->limitOffset = NULL;
                              13579                 :           2858 :                     n->limitCount = $2;
                              13580                 :           2858 :                     n->limitOption = LIMIT_OPTION_COUNT;
  735 tgl@sss.pgh.pa.us       13581                 :           2858 :                     n->offsetLoc = -1;
                              13582                 :           2858 :                     n->countLoc = @1;
                              13583                 :           2858 :                     n->optionLoc = -1;
 2403 alvherre@alvh.no-ip.    13584                 :           2858 :                     $$ = n;
                              13585                 :                :                 }
                              13586                 :                :             | LIMIT select_limit_value ',' select_offset_value
                              13587                 :                :                 {
                              13588                 :                :                     /* Disabled because it was too confusing, bjm 2002-02-18 */
 8510 tgl@sss.pgh.pa.us       13589         [ #  # ]:UBC           0 :                     ereport(ERROR,
                              13590                 :                :                             (errcode(ERRCODE_SYNTAX_ERROR),
                              13591                 :                :                              errmsg("LIMIT #,# syntax is not supported"),
                              13592                 :                :                              errhint("Use separate LIMIT and OFFSET clauses."),
                              13593                 :                :                              parser_errposition(@1)));
                              13594                 :                :                 }
                              13595                 :                :             /* SQL:2008 syntax */
                              13596                 :                :             /* to avoid shift/reduce conflicts, handle the optional value with
                              13597                 :                :              * a separate production rather than an opt_ expression.  The fact
                              13598                 :                :              * that ONLY is fully reserved means that this way, we defer any
                              13599                 :                :              * decision about what rule reduces ROW or ROWS to the point where
                              13600                 :                :              * we can see the ONLY token in the lookahead slot.
                              13601                 :                :              */
                              13602                 :                :             | FETCH first_or_next select_fetch_first_value row_or_rows ONLY
                              13603                 :                :                 {
  330 michael@paquier.xyz     13604                 :CBC          15 :                     SelectLimit *n = palloc_object(SelectLimit);
                              13605                 :                : 
 2403 alvherre@alvh.no-ip.    13606                 :             15 :                     n->limitOffset = NULL;
                              13607                 :             15 :                     n->limitCount = $3;
                              13608                 :             15 :                     n->limitOption = LIMIT_OPTION_COUNT;
  735 tgl@sss.pgh.pa.us       13609                 :             15 :                     n->offsetLoc = -1;
                              13610                 :             15 :                     n->countLoc = @1;
                              13611                 :             15 :                     n->optionLoc = -1;
 2403 alvherre@alvh.no-ip.    13612                 :             15 :                     $$ = n;
                              13613                 :                :                 }
                              13614                 :                :             | FETCH first_or_next select_fetch_first_value row_or_rows WITH TIES
                              13615                 :                :                 {
  330 michael@paquier.xyz     13616                 :             42 :                     SelectLimit *n = palloc_object(SelectLimit);
                              13617                 :                : 
 2403 alvherre@alvh.no-ip.    13618                 :             42 :                     n->limitOffset = NULL;
                              13619                 :             42 :                     n->limitCount = $3;
                              13620                 :             42 :                     n->limitOption = LIMIT_OPTION_WITH_TIES;
  735 tgl@sss.pgh.pa.us       13621                 :             42 :                     n->offsetLoc = -1;
                              13622                 :             42 :                     n->countLoc = @1;
                              13623                 :             42 :                     n->optionLoc = @5;
 2403 alvherre@alvh.no-ip.    13624                 :             42 :                     $$ = n;
                              13625                 :                :                 }
                              13626                 :                :             | FETCH first_or_next row_or_rows ONLY
                              13627                 :                :                 {
  330 michael@paquier.xyz     13628                 :UBC           0 :                     SelectLimit *n = palloc_object(SelectLimit);
                              13629                 :                : 
 2403 alvherre@alvh.no-ip.    13630                 :              0 :                     n->limitOffset = NULL;
                              13631                 :              0 :                     n->limitCount = makeIntConst(1, -1);
                              13632                 :              0 :                     n->limitOption = LIMIT_OPTION_COUNT;
  735 tgl@sss.pgh.pa.us       13633                 :              0 :                     n->offsetLoc = -1;
                              13634                 :              0 :                     n->countLoc = @1;
                              13635                 :              0 :                     n->optionLoc = -1;
 2403 alvherre@alvh.no-ip.    13636                 :              0 :                     $$ = n;
                              13637                 :                :                 }
                              13638                 :                :             | FETCH first_or_next row_or_rows WITH TIES
                              13639                 :                :                 {
  330 michael@paquier.xyz     13640                 :CBC           4 :                     SelectLimit *n = palloc_object(SelectLimit);
                              13641                 :                : 
 2362 alvherre@alvh.no-ip.    13642                 :              4 :                     n->limitOffset = NULL;
                              13643                 :              4 :                     n->limitCount = makeIntConst(1, -1);
                              13644                 :              4 :                     n->limitOption = LIMIT_OPTION_WITH_TIES;
  735 tgl@sss.pgh.pa.us       13645                 :              4 :                     n->offsetLoc = -1;
                              13646                 :              4 :                     n->countLoc = @1;
                              13647                 :              4 :                     n->optionLoc = @4;
 2362 alvherre@alvh.no-ip.    13648                 :              4 :                     $$ = n;
                              13649                 :                :                 }
                              13650                 :                :         ;
                              13651                 :                : 
                              13652                 :                : offset_clause:
                              13653                 :                :             OFFSET select_offset_value
 6288 tgl@sss.pgh.pa.us       13654                 :            675 :                 { $$ = $2; }
                              13655                 :                :             /* SQL:2008 syntax */
                              13656                 :                :             | OFFSET select_fetch_first_value row_or_rows
 6288 tgl@sss.pgh.pa.us       13657                 :UBC           0 :                 { $$ = $2; }
                              13658                 :                :         ;
                              13659                 :                : 
                              13660                 :                : select_limit_value:
 8526 tgl@sss.pgh.pa.us       13661                 :CBC        2857 :             a_expr                                  { $$ = $1; }
                              13662                 :                :             | ALL
                              13663                 :                :                 {
                              13664                 :                :                     /* LIMIT ALL is represented as a NULL constant */
 6643                         13665                 :              1 :                     $$ = makeNullAConst(@1);
                              13666                 :                :                 }
                              13667                 :                :         ;
                              13668                 :                : 
                              13669                 :                : select_offset_value:
 6288                         13670                 :            675 :             a_expr                                  { $$ = $1; }
                              13671                 :                :         ;
                              13672                 :                : 
                              13673                 :                : /*
                              13674                 :                :  * Allowing full expressions without parentheses causes various parsing
                              13675                 :                :  * problems with the trailing ROW/ROWS key words.  SQL spec only calls for
                              13676                 :                :  * <simple value specification>, which is either a literal or a parameter (but
                              13677                 :                :  * an <SQL parameter reference> could be an identifier, bringing up conflicts
                              13678                 :                :  * with ROW/ROWS). We solve this by leveraging the presence of ONLY (see above)
                              13679                 :                :  * to determine whether the expression is missing rather than trying to make it
                              13680                 :                :  * optional in this rule.
                              13681                 :                :  *
                              13682                 :                :  * c_expr covers almost all the spec-required cases (and more), but it doesn't
                              13683                 :                :  * cover signed numeric literals, which are allowed by the spec. So we include
                              13684                 :                :  * those here explicitly. We need FCONST as well as ICONST because values that
                              13685                 :                :  * don't fit in the platform's "long", but do fit in bigint, should still be
                              13686                 :                :  * accepted here. (This is possible in 64-bit Windows as well as all 32-bit
                              13687                 :                :  * builds.)
                              13688                 :                :  */
                              13689                 :                : select_fetch_first_value:
 3090 rhodiumtoad@postgres    13690                 :             57 :             c_expr                                  { $$ = $1; }
                              13691                 :                :             | '+' I_or_F_const
 3090 rhodiumtoad@postgres    13692                 :UBC           0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", NULL, $2, @1); }
                              13693                 :                :             | '-' I_or_F_const
                              13694                 :              0 :                 { $$ = doNegate($2, @1); }
                              13695                 :                :         ;
                              13696                 :                : 
                              13697                 :                : I_or_F_const:
                              13698                 :              0 :             Iconst                                  { $$ = makeIntConst($1,@1); }
                              13699                 :              0 :             | FCONST                                { $$ = makeFloatConst($1,@1); }
                              13700                 :                :         ;
                              13701                 :                : 
                              13702                 :                : /* noise words */
 6288 tgl@sss.pgh.pa.us       13703                 :CBC          23 : row_or_rows: ROW                                    { $$ = 0; }
                              13704                 :             38 :             | ROWS                                  { $$ = 0; }
                              13705                 :                :         ;
                              13706                 :                : 
                              13707                 :             61 : first_or_next: FIRST_P                              { $$ = 0; }
 6288 tgl@sss.pgh.pa.us       13708                 :UBC           0 :             | NEXT                                  { $$ = 0; }
                              13709                 :                :         ;
                              13710                 :                : 
                              13711                 :                : 
                              13712                 :                : /*
                              13713                 :                :  * This syntax for group_clause tries to follow the spec quite closely.
                              13714                 :                :  * However, the spec allows only column references, not expressions,
                              13715                 :                :  * which introduces an ambiguity between implicit row constructors
                              13716                 :                :  * (a,b) and lists of column references.
                              13717                 :                :  *
                              13718                 :                :  * We handle this by using the a_expr production for what the spec calls
                              13719                 :                :  * <ordinary grouping set>, which in the spec represents either one column
                              13720                 :                :  * reference or a parenthesized list of column references. Then, we check the
                              13721                 :                :  * top node of the a_expr to see if it's an implicit RowExpr, and if so, just
                              13722                 :                :  * grab and use the list, discarding the node. (this is done in parse analysis,
                              13723                 :                :  * not here)
                              13724                 :                :  *
                              13725                 :                :  * (we abuse the row_format field of RowExpr to distinguish implicit and
                              13726                 :                :  * explicit row constructors; it's debatable if anyone sanely wants to use them
                              13727                 :                :  * in a group clause, but if they have a reason to, we make it possible.)
                              13728                 :                :  *
                              13729                 :                :  * Each item in the group_clause list is either an expression tree or a
                              13730                 :                :  * GroupingSet node of some type.
                              13731                 :                :  */
                              13732                 :                : group_clause:
                              13733                 :                :             GROUP_P BY set_quantifier group_by_list
                              13734                 :                :                 {
  330 michael@paquier.xyz     13735                 :CBC        3745 :                     GroupClause *n = palloc_object(GroupClause);
                              13736                 :                : 
 2058 tomas.vondra@postgre    13737                 :           3745 :                     n->distinct = $3 == SET_QUANTIFIER_DISTINCT;
                              13738                 :           3745 :                     n->list = $4;
                              13739                 :           3745 :                     $$ = n;
                              13740                 :                :                 }
                              13741                 :                :             | /*EMPTY*/
                              13742                 :                :                 {
  330 michael@paquier.xyz     13743                 :         311369 :                     GroupClause *n = palloc_object(GroupClause);
                              13744                 :                : 
 2058 tomas.vondra@postgre    13745                 :         311368 :                     n->distinct = false;
                              13746                 :         311368 :                     n->list = NIL;
                              13747                 :         311368 :                     $$ = n;
                              13748                 :                :                 }
                              13749                 :                :         ;
                              13750                 :                : 
                              13751                 :                : group_by_list:
 4191 andres@anarazel.de      13752                 :           4289 :             group_by_item                           { $$ = list_make1($1); }
                              13753                 :           2159 :             | group_by_list ',' group_by_item       { $$ = lappend($1,$3); }
                              13754                 :                :         ;
                              13755                 :                : 
                              13756                 :                : group_by_item:
                              13757                 :           5336 :             a_expr                                  { $$ = $1; }
                              13758                 :            230 :             | empty_grouping_set                    { $$ = $1; }
                              13759                 :            122 :             | cube_clause                           { $$ = $1; }
                              13760                 :            216 :             | rollup_clause                         { $$ = $1; }
                              13761                 :            544 :             | grouping_sets_clause                  { $$ = $1; }
                              13762                 :                :         ;
                              13763                 :                : 
                              13764                 :                : empty_grouping_set:
                              13765                 :                :             '(' ')'
                              13766                 :                :                 {
                              13767                 :            230 :                     $$ = (Node *) makeGroupingSet(GROUPING_SET_EMPTY, NIL, @1);
                              13768                 :                :                 }
                              13769                 :                :         ;
                              13770                 :                : 
                              13771                 :                : /*
                              13772                 :                :  * These hacks rely on setting precedence of CUBE and ROLLUP below that of '(',
                              13773                 :                :  * so that they shift in these rules rather than reducing the conflicting
                              13774                 :                :  * unreserved_keyword rule.
                              13775                 :                :  */
                              13776                 :                : 
                              13777                 :                : rollup_clause:
                              13778                 :                :             ROLLUP '(' expr_list ')'
                              13779                 :                :                 {
                              13780                 :            216 :                     $$ = (Node *) makeGroupingSet(GROUPING_SET_ROLLUP, $3, @1);
                              13781                 :                :                 }
                              13782                 :                :         ;
                              13783                 :                : 
                              13784                 :                : cube_clause:
                              13785                 :                :             CUBE '(' expr_list ')'
                              13786                 :                :                 {
                              13787                 :            122 :                     $$ = (Node *) makeGroupingSet(GROUPING_SET_CUBE, $3, @1);
                              13788                 :                :                 }
                              13789                 :                :         ;
                              13790                 :                : 
                              13791                 :                : grouping_sets_clause:
                              13792                 :                :             GROUPING SETS '(' group_by_list ')'
                              13793                 :                :                 {
                              13794                 :            544 :                     $$ = (Node *) makeGroupingSet(GROUPING_SET_SETS, $4, @1);
                              13795                 :                :                 }
                              13796                 :                :         ;
                              13797                 :                : 
                              13798                 :                : having_clause:
 8907 bruce@momjian.us        13799                 :            683 :             HAVING a_expr                           { $$ = $2; }
                              13800                 :         314431 :             | /*EMPTY*/                             { $$ = NULL; }
                              13801                 :                :         ;
                              13802                 :                : 
                              13803                 :                : for_locking_clause:
 7494 tgl@sss.pgh.pa.us       13804                 :           5025 :             for_locking_items                       { $$ = $1; }
 7494 tgl@sss.pgh.pa.us       13805                 :UBC           0 :             | FOR READ ONLY                         { $$ = NIL; }
                              13806                 :                :         ;
                              13807                 :                : 
                              13808                 :                : opt_for_locking_clause:
 7494 tgl@sss.pgh.pa.us       13809                 :CBC         171 :             for_locking_clause                      { $$ = $1; }
                              13810                 :          28049 :             | /* EMPTY */                           { $$ = NIL; }
                              13811                 :                :         ;
                              13812                 :                : 
                              13813                 :                : for_locking_items:
                              13814                 :           5025 :             for_locking_item                        { $$ = list_make1($1); }
                              13815                 :             51 :             | for_locking_items for_locking_item    { $$ = lappend($1, $2); }
                              13816                 :                :         ;
                              13817                 :                : 
                              13818                 :                : for_locking_item:
                              13819                 :                :             for_locking_strength locked_rels_list opt_nowait_or_skip
                              13820                 :                :                 {
 7766                         13821                 :           5076 :                     LockingClause *n = makeNode(LockingClause);
                              13822                 :                : 
 5034 alvherre@alvh.no-ip.    13823                 :           5076 :                     n->lockedRels = $2;
                              13824                 :           5076 :                     n->strength = $1;
 4412                         13825                 :           5076 :                     n->waitPolicy = $3;
 7766 tgl@sss.pgh.pa.us       13826                 :           5076 :                     $$ = (Node *) n;
                              13827                 :                :                 }
                              13828                 :                :         ;
                              13829                 :                : 
                              13830                 :                : for_locking_strength:
 2185 peter@eisentraut.org    13831                 :            915 :             FOR UPDATE                          { $$ = LCS_FORUPDATE; }
                              13832                 :             45 :             | FOR NO KEY UPDATE                 { $$ = LCS_FORNOKEYUPDATE; }
                              13833                 :            127 :             | FOR SHARE                         { $$ = LCS_FORSHARE; }
                              13834                 :           4069 :             | FOR KEY SHARE                     { $$ = LCS_FORKEYSHARE; }
                              13835                 :                :         ;
                              13836                 :                : 
                              13837                 :                : opt_for_locking_strength:
  266 dean.a.rasheed@gmail    13838                 :             80 :             for_locking_strength                { $$ = $1; }
                              13839                 :            182 :             | /* EMPTY */                       { $$ = LCS_NONE; }
                              13840                 :                :         ;
                              13841                 :                : 
                              13842                 :                : locked_rels_list:
 6639 tgl@sss.pgh.pa.us       13843                 :           1311 :             OF qualified_name_list                  { $$ = $2; }
 7766                         13844                 :           3765 :             | /* EMPTY */                           { $$ = NIL; }
                              13845                 :                :         ;
                              13846                 :                : 
                              13847                 :                : 
                              13848                 :                : /*
                              13849                 :                :  * We should allow ROW '(' expr_list ')' too, but that seems to require
                              13850                 :                :  * making VALUES a fully reserved word, which will probably break more apps
                              13851                 :                :  * than allowing the noise-word is worth.
                              13852                 :                :  */
                              13853                 :                : values_clause:
                              13854                 :                :             VALUES '(' expr_list ')'
                              13855                 :                :                 {
 7400 mail@joeconway.com      13856                 :          40139 :                     SelectStmt *n = makeNode(SelectStmt);
                              13857                 :                : 
 3635 tgl@sss.pgh.pa.us       13858                 :          40138 :                     n->valuesLists = list_make1($3);
 7400 mail@joeconway.com      13859                 :          40138 :                     $$ = (Node *) n;
                              13860                 :                :                 }
                              13861                 :                :             | values_clause ',' '(' expr_list ')'
                              13862                 :                :                 {
                              13863                 :          17334 :                     SelectStmt *n = (SelectStmt *) $1;
                              13864                 :                : 
 3635 tgl@sss.pgh.pa.us       13865                 :          17334 :                     n->valuesLists = lappend(n->valuesLists, $4);
 7400 mail@joeconway.com      13866                 :          17334 :                     $$ = (Node *) n;
                              13867                 :                :                 }
                              13868                 :                :         ;
                              13869                 :                : 
                              13870                 :                : 
                              13871                 :                : /*****************************************************************************
                              13872                 :                :  *
                              13873                 :                :  *  clauses common to all Optimizable Stmts:
                              13874                 :                :  *      from_clause     - allow list of both JOIN expressions and table names
                              13875                 :                :  *      where_clause    - qualifications for joins or restrictions
                              13876                 :                :  *
                              13877                 :                :  *****************************************************************************/
                              13878                 :                : 
                              13879                 :                : from_clause:
 8907 bruce@momjian.us        13880                 :         212386 :             FROM from_list                          { $$ = $2; }
                              13881                 :         111651 :             | /*EMPTY*/                             { $$ = NIL; }
                              13882                 :                :         ;
                              13883                 :                : 
                              13884                 :                : from_list:
 8194 neilc@samurai.com       13885                 :         213121 :             table_ref                               { $$ = list_make1($1); }
 8906 bruce@momjian.us        13886                 :          38042 :             | from_list ',' table_ref               { $$ = lappend($1, $3); }
                              13887                 :                :         ;
                              13888                 :                : 
                              13889                 :                : /*
                              13890                 :                :  * table_ref is where an alias clause can be attached.
                              13891                 :                :  */
                              13892                 :                : table_ref:  relation_expr opt_alias_clause
                              13893                 :                :                 {
 8995 tgl@sss.pgh.pa.us       13894                 :         262396 :                     $1->alias = $2;
 9550                         13895                 :         262396 :                     $$ = (Node *) $1;
                              13896                 :                :                 }
                              13897                 :                :             | relation_expr opt_alias_clause tablesample_clause
                              13898                 :                :                 {
 4121                         13899                 :            186 :                     RangeTableSample *n = (RangeTableSample *) $3;
                              13900                 :                : 
                              13901                 :            186 :                     $1->alias = $2;
                              13902                 :                :                     /* relation_expr goes inside the RangeTableSample node */
                              13903                 :            186 :                     n->relation = (Node *) $1;
                              13904                 :            186 :                     $$ = (Node *) n;
                              13905                 :                :                 }
                              13906                 :                :             | func_table func_alias_clause
                              13907                 :                :                 {
 4732                         13908                 :          30002 :                     RangeFunction *n = (RangeFunction *) $1;
                              13909                 :                : 
 5203                         13910                 :          30002 :                     n->alias = linitial($2);
                              13911                 :          30002 :                     n->coldeflist = lsecond($2);
 8859 bruce@momjian.us        13912                 :          30002 :                     $$ = (Node *) n;
                              13913                 :                :                 }
                              13914                 :                :             | LATERAL_P func_table func_alias_clause
                              13915                 :                :                 {
 4732 tgl@sss.pgh.pa.us       13916                 :            392 :                     RangeFunction *n = (RangeFunction *) $2;
                              13917                 :                : 
 5203                         13918                 :            392 :                     n->lateral = true;
                              13919                 :            392 :                     n->alias = linitial($3);
                              13920                 :            392 :                     n->coldeflist = lsecond($3);
 8943                         13921                 :            392 :                     $$ = (Node *) n;
                              13922                 :                :                 }
                              13923                 :                :             | xmltable opt_alias_clause
                              13924                 :                :                 {
 3529 alvherre@alvh.no-ip.    13925                 :             57 :                     RangeTableFunc *n = (RangeTableFunc *) $1;
                              13926                 :                : 
                              13927                 :             57 :                     n->alias = $2;
                              13928                 :             57 :                     $$ = (Node *) n;
                              13929                 :                :                 }
                              13930                 :                :             | LATERAL_P xmltable opt_alias_clause
                              13931                 :                :                 {
                              13932                 :             93 :                     RangeTableFunc *n = (RangeTableFunc *) $2;
                              13933                 :                : 
                              13934                 :             93 :                     n->lateral = true;
                              13935                 :             93 :                     n->alias = $3;
                              13936                 :             93 :                     $$ = (Node *) n;
                              13937                 :                :                 }
                              13938                 :                :             | select_with_parens opt_alias_clause
                              13939                 :                :                 {
 5203 tgl@sss.pgh.pa.us       13940                 :          13066 :                     RangeSubselect *n = makeNode(RangeSubselect);
                              13941                 :                : 
                              13942                 :          13066 :                     n->lateral = false;
                              13943                 :          13066 :                     n->subquery = $1;
                              13944                 :          13066 :                     n->alias = $2;
                              13945                 :          13066 :                     $$ = (Node *) n;
                              13946                 :                :                 }
                              13947                 :                :             | LATERAL_P select_with_parens opt_alias_clause
                              13948                 :                :                 {
 9550                         13949                 :           1494 :                     RangeSubselect *n = makeNode(RangeSubselect);
                              13950                 :                : 
 5203                         13951                 :           1494 :                     n->lateral = true;
                              13952                 :           1494 :                     n->subquery = $2;
                              13953                 :           1494 :                     n->alias = $3;
 9550                         13954                 :           1494 :                     $$ = (Node *) n;
                              13955                 :                :                 }
                              13956                 :                :             | joined_table
                              13957                 :                :                 {
                              13958                 :          55411 :                     $$ = (Node *) $1;
                              13959                 :                :                 }
                              13960                 :                :             | '(' joined_table ')' alias_clause
                              13961                 :                :                 {
                              13962                 :            216 :                     $2->alias = $4;
                              13963                 :            216 :                     $$ = (Node *) $2;
                              13964                 :                :                 }
                              13965                 :                :             | json_table opt_alias_clause
                              13966                 :                :                 {
  945 amitlan@postgresql.o    13967                 :            568 :                     JsonTable  *jt = castNode(JsonTable, $1);
                              13968                 :                : 
                              13969                 :            568 :                     jt->alias = $2;
                              13970                 :            568 :                     $$ = (Node *) jt;
                              13971                 :                :                 }
                              13972                 :                :             | LATERAL_P json_table opt_alias_clause
                              13973                 :                :                 {
  945 amitlan@postgresql.o    13974                 :UBC           0 :                     JsonTable  *jt = castNode(JsonTable, $2);
                              13975                 :                : 
                              13976                 :              0 :                     jt->alias = $3;
                              13977                 :              0 :                     jt->lateral = true;
                              13978                 :              0 :                     $$ = (Node *) jt;
                              13979                 :                :                 }
                              13980                 :                :         ;
                              13981                 :                : 
                              13982                 :                : 
                              13983                 :                : /*
                              13984                 :                :  * It may seem silly to separate joined_table from table_ref, but there is
                              13985                 :                :  * method in SQL's madness: if you don't do it this way you get reduce-
                              13986                 :                :  * reduce conflicts, because it's not clear to the parser generator whether
                              13987                 :                :  * to expect alias_clause after ')' or not.  For the same reason we must
                              13988                 :                :  * treat 'JOIN' and 'join_type JOIN' separately, rather than allowing
                              13989                 :                :  * join_type to expand to empty; if we try it, the parser generator can't
                              13990                 :                :  * figure out when to reduce an empty join_type right after table_ref.
                              13991                 :                :  *
                              13992                 :                :  * Note that a CROSS JOIN is the same as an unqualified
                              13993                 :                :  * INNER JOIN, and an INNER JOIN/ON has the same shape
                              13994                 :                :  * but a qualification expression to limit membership.
                              13995                 :                :  * A NATURAL JOIN implicitly matches column names between
                              13996                 :                :  * tables and the shape is determined by which columns are
                              13997                 :                :  * in common. We'll collect columns during the later transformations.
                              13998                 :                :  */
                              13999                 :                : 
                              14000                 :                : joined_table:
                              14001                 :                :             '(' joined_table ')'
                              14002                 :                :                 {
 9550 tgl@sss.pgh.pa.us       14003                 :CBC        2501 :                     $$ = $2;
                              14004                 :                :                 }
                              14005                 :                :             | table_ref CROSS JOIN table_ref
                              14006                 :                :                 {
                              14007                 :                :                     /* CROSS JOIN is same as unqualified inner join */
 1637 peter@eisentraut.org    14008                 :            441 :                     JoinExpr   *n = makeNode(JoinExpr);
                              14009                 :                : 
 9550 tgl@sss.pgh.pa.us       14010                 :            441 :                     n->jointype = JOIN_INNER;
 3368 peter_e@gmx.net         14011                 :            441 :                     n->isNatural = false;
 9550 tgl@sss.pgh.pa.us       14012                 :            441 :                     n->larg = $1;
                              14013                 :            441 :                     n->rarg = $4;
 6321 peter_e@gmx.net         14014                 :            441 :                     n->usingClause = NIL;
 2045 peter@eisentraut.org    14015                 :            441 :                     n->join_using_alias = NULL;
 9550 tgl@sss.pgh.pa.us       14016                 :            441 :                     n->quals = NULL;
 9760 lockhart@fourpalms.o    14017                 :            441 :                     $$ = n;
                              14018                 :                :                 }
                              14019                 :                :             | table_ref join_type JOIN table_ref join_qual
                              14020                 :                :                 {
 1637 peter@eisentraut.org    14021                 :          30223 :                     JoinExpr   *n = makeNode(JoinExpr);
                              14022                 :                : 
 9550 tgl@sss.pgh.pa.us       14023                 :          30223 :                     n->jointype = $2;
 3368 peter_e@gmx.net         14024                 :          30223 :                     n->isNatural = false;
 9550 tgl@sss.pgh.pa.us       14025                 :          30223 :                     n->larg = $1;
                              14026                 :          30223 :                     n->rarg = $4;
                              14027   [ +  -  +  + ]:          30223 :                     if ($5 != NULL && IsA($5, List))
                              14028                 :                :                     {
                              14029                 :                :                          /* USING clause */
 2045 peter@eisentraut.org    14030                 :            391 :                         n->usingClause = linitial_node(List, castNode(List, $5));
                              14031                 :            391 :                         n->join_using_alias = lsecond_node(Alias, castNode(List, $5));
                              14032                 :                :                     }
                              14033                 :                :                     else
                              14034                 :                :                     {
                              14035                 :                :                         /* ON clause */
                              14036                 :          29832 :                         n->quals = $5;
                              14037                 :                :                     }
 9760 lockhart@fourpalms.o    14038                 :          30223 :                     $$ = n;
                              14039                 :                :                 }
                              14040                 :                :             | table_ref JOIN table_ref join_qual
                              14041                 :                :                 {
                              14042                 :                :                     /* letting join_type reduce to empty doesn't work */
 1637 peter@eisentraut.org    14043                 :          24783 :                     JoinExpr   *n = makeNode(JoinExpr);
                              14044                 :                : 
 9550 tgl@sss.pgh.pa.us       14045                 :          24783 :                     n->jointype = JOIN_INNER;
 3368 peter_e@gmx.net         14046                 :          24783 :                     n->isNatural = false;
 9550 tgl@sss.pgh.pa.us       14047                 :          24783 :                     n->larg = $1;
                              14048                 :          24783 :                     n->rarg = $3;
                              14049   [ +  -  +  + ]:          24783 :                     if ($4 != NULL && IsA($4, List))
                              14050                 :                :                     {
                              14051                 :                :                         /* USING clause */
 2045 peter@eisentraut.org    14052                 :            499 :                         n->usingClause = linitial_node(List, castNode(List, $4));
                              14053                 :            499 :                         n->join_using_alias = lsecond_node(Alias, castNode(List, $4));
                              14054                 :                :                     }
                              14055                 :                :                     else
                              14056                 :                :                     {
                              14057                 :                :                         /* ON clause */
                              14058                 :          24284 :                         n->quals = $4;
                              14059                 :                :                     }
 9550 tgl@sss.pgh.pa.us       14060                 :          24783 :                     $$ = n;
                              14061                 :                :                 }
                              14062                 :                :             | table_ref NATURAL join_type JOIN table_ref
                              14063                 :                :                 {
 1637 peter@eisentraut.org    14064                 :             52 :                     JoinExpr   *n = makeNode(JoinExpr);
                              14065                 :                : 
 9550 tgl@sss.pgh.pa.us       14066                 :             52 :                     n->jointype = $3;
 3368 peter_e@gmx.net         14067                 :             52 :                     n->isNatural = true;
 9550 tgl@sss.pgh.pa.us       14068                 :             52 :                     n->larg = $1;
                              14069                 :             52 :                     n->rarg = $5;
 6321 peter_e@gmx.net         14070                 :             52 :                     n->usingClause = NIL; /* figure out which columns later... */
 2045 peter@eisentraut.org    14071                 :             52 :                     n->join_using_alias = NULL;
 9550 tgl@sss.pgh.pa.us       14072                 :             52 :                     n->quals = NULL; /* fill later */
                              14073                 :             52 :                     $$ = n;
                              14074                 :                :                 }
                              14075                 :                :             | table_ref NATURAL JOIN table_ref
                              14076                 :                :                 {
                              14077                 :                :                     /* letting join_type reduce to empty doesn't work */
 1637 peter@eisentraut.org    14078                 :            128 :                     JoinExpr   *n = makeNode(JoinExpr);
                              14079                 :                : 
 9550 tgl@sss.pgh.pa.us       14080                 :            128 :                     n->jointype = JOIN_INNER;
 3368 peter_e@gmx.net         14081                 :            128 :                     n->isNatural = true;
 9550 tgl@sss.pgh.pa.us       14082                 :            128 :                     n->larg = $1;
                              14083                 :            128 :                     n->rarg = $4;
 6321 peter_e@gmx.net         14084                 :            128 :                     n->usingClause = NIL; /* figure out which columns later... */
 2045 peter@eisentraut.org    14085                 :            128 :                     n->join_using_alias = NULL;
 9550 tgl@sss.pgh.pa.us       14086                 :            128 :                     n->quals = NULL; /* fill later */
 9760 lockhart@fourpalms.o    14087                 :            128 :                     $$ = n;
                              14088                 :                :                 }
                              14089                 :                :         ;
                              14090                 :                : 
                              14091                 :                : alias_clause:
                              14092                 :                :             AS ColId '(' name_list ')'
                              14093                 :                :                 {
 8995 tgl@sss.pgh.pa.us       14094                 :           4138 :                     $$ = makeNode(Alias);
                              14095                 :           4138 :                     $$->aliasname = $2;
                              14096                 :           4138 :                     $$->colnames = $4;
                              14097                 :                :                 }
                              14098                 :                :             | AS ColId
                              14099                 :                :                 {
                              14100                 :          10145 :                     $$ = makeNode(Alias);
                              14101                 :          10145 :                     $$->aliasname = $2;
                              14102                 :                :                 }
                              14103                 :                :             | ColId '(' name_list ')'
                              14104                 :                :                 {
                              14105                 :           4196 :                     $$ = makeNode(Alias);
                              14106                 :           4196 :                     $$->aliasname = $1;
                              14107                 :           4196 :                     $$->colnames = $3;
                              14108                 :                :                 }
                              14109                 :                :             | ColId
                              14110                 :                :                 {
                              14111                 :         175665 :                     $$ = makeNode(Alias);
                              14112                 :         175665 :                     $$->aliasname = $1;
                              14113                 :                :                 }
                              14114                 :                :         ;
                              14115                 :                : 
 5203                         14116                 :         175671 : opt_alias_clause: alias_clause                      { $$ = $1; }
                              14117                 :         102189 :             | /*EMPTY*/                             { $$ = NULL; }
                              14118                 :                :         ;
                              14119                 :                : 
                              14120                 :                : /*
                              14121                 :                :  * The alias clause after JOIN ... USING only accepts the AS ColId spelling,
                              14122                 :                :  * per SQL standard.  (The grammar could parse the other variants, but they
                              14123                 :                :  * don't seem to be useful, and it might lead to parser problems in the
                              14124                 :                :  * future.)
                              14125                 :                :  */
                              14126                 :                : opt_alias_clause_for_join_using:
                              14127                 :                :             AS ColId
                              14128                 :                :                 {
 2045 peter@eisentraut.org    14129                 :             56 :                     $$ = makeNode(Alias);
                              14130                 :             56 :                     $$->aliasname = $2;
                              14131                 :                :                     /* the column name list will be inserted later */
                              14132                 :                :                 }
                              14133                 :            834 :             | /*EMPTY*/                             { $$ = NULL; }
                              14134                 :                :         ;
                              14135                 :                : 
                              14136                 :                : /*
                              14137                 :                :  * func_alias_clause can include both an Alias and a coldeflist, so we make it
                              14138                 :                :  * return a 2-element list that gets disassembled by calling production.
                              14139                 :                :  */
                              14140                 :                : func_alias_clause:
                              14141                 :                :             alias_clause
                              14142                 :                :                 {
 5203 tgl@sss.pgh.pa.us       14143                 :          18257 :                     $$ = list_make2($1, NIL);
                              14144                 :                :                 }
                              14145                 :                :             | AS '(' TableFuncElementList ')'
                              14146                 :                :                 {
                              14147                 :             72 :                     $$ = list_make2(NULL, $3);
                              14148                 :                :                 }
                              14149                 :                :             | AS ColId '(' TableFuncElementList ')'
                              14150                 :                :                 {
 1637 peter@eisentraut.org    14151                 :            362 :                     Alias      *a = makeNode(Alias);
                              14152                 :                : 
 5203 tgl@sss.pgh.pa.us       14153                 :            362 :                     a->aliasname = $2;
                              14154                 :            362 :                     $$ = list_make2(a, $4);
                              14155                 :                :                 }
                              14156                 :                :             | ColId '(' TableFuncElementList ')'
                              14157                 :                :                 {
 1637 peter@eisentraut.org    14158                 :             33 :                     Alias      *a = makeNode(Alias);
                              14159                 :                : 
 5203 tgl@sss.pgh.pa.us       14160                 :             33 :                     a->aliasname = $1;
                              14161                 :             33 :                     $$ = list_make2(a, $3);
                              14162                 :                :                 }
                              14163                 :                :             | /*EMPTY*/
                              14164                 :                :                 {
                              14165                 :          11670 :                     $$ = list_make2(NULL, NIL);
                              14166                 :                :                 }
                              14167                 :                :         ;
                              14168                 :                : 
 2184 peter@eisentraut.org    14169                 :            804 : join_type:  FULL opt_outer                          { $$ = JOIN_FULL; }
                              14170                 :          26715 :             | LEFT opt_outer                        { $$ = JOIN_LEFT; }
                              14171                 :            296 :             | RIGHT opt_outer                       { $$ = JOIN_RIGHT; }
 8907 bruce@momjian.us        14172                 :           2460 :             | INNER_P                               { $$ = JOIN_INNER; }
                              14173                 :                :         ;
                              14174                 :                : 
                              14175                 :                : /* OUTER is just noise... */
                              14176                 :                : opt_outer: OUTER_P
                              14177                 :                :             | /*EMPTY*/
                              14178                 :                :         ;
                              14179                 :                : 
                              14180                 :                : /* JOIN qualification clauses
                              14181                 :                :  * Possibilities are:
                              14182                 :                :  *  USING ( column list ) [ AS alias ]
                              14183                 :                :  *                        allows only unqualified column names,
                              14184                 :                :  *                        which must match between tables.
                              14185                 :                :  *  ON expr allows more general qualifications.
                              14186                 :                :  *
                              14187                 :                :  * We return USING as a two-element List (the first item being a sub-List
                              14188                 :                :  * of the common column names, and the second either an Alias item or NULL).
                              14189                 :                :  * An ON-expr will not be a List, so it can be told apart that way.
                              14190                 :                :  */
                              14191                 :                : 
                              14192                 :                : join_qual: USING '(' name_list ')' opt_alias_clause_for_join_using
                              14193                 :                :                 {
 2045 peter@eisentraut.org    14194                 :            890 :                     $$ = (Node *) list_make2($3, $5);
                              14195                 :                :                 }
                              14196                 :                :             | ON a_expr
                              14197                 :                :                 {
                              14198                 :          54116 :                     $$ = $2;
                              14199                 :                :                 }
                              14200                 :                :         ;
                              14201                 :                : 
                              14202                 :                : 
                              14203                 :                : relation_expr:
                              14204                 :                :             qualified_name
                              14205                 :                :                 {
                              14206                 :                :                     /* inheritance query, implicitly */
 8995 tgl@sss.pgh.pa.us       14207                 :         314468 :                     $$ = $1;
 3604                         14208                 :         314468 :                     $$->inh = true;
 8995                         14209                 :         314468 :                     $$->alias = NULL;
                              14210                 :                :                 }
                              14211                 :                :             | extended_relation_expr
                              14212                 :                :                 {
 1835 akapila@postgresql.o    14213                 :           3891 :                     $$ = $1;
                              14214                 :                :                 }
                              14215                 :                :         ;
                              14216                 :                : 
                              14217                 :                : extended_relation_expr:
                              14218                 :                :             qualified_name '*'
                              14219                 :                :                 {
                              14220                 :                :                     /* inheritance query, explicitly */
 8995 tgl@sss.pgh.pa.us       14221                 :            140 :                     $$ = $1;
 3604                         14222                 :            140 :                     $$->inh = true;
 8995                         14223                 :            140 :                     $$->alias = NULL;
                              14224                 :                :                 }
                              14225                 :                :             | ONLY qualified_name
                              14226                 :                :                 {
                              14227                 :                :                     /* no inheritance */
                              14228                 :           3755 :                     $$ = $2;
 3604                         14229                 :           3755 :                     $$->inh = false;
 8995                         14230                 :           3755 :                     $$->alias = NULL;
                              14231                 :                :                 }
                              14232                 :                :             | ONLY '(' qualified_name ')'
                              14233                 :                :                 {
                              14234                 :                :                     /* no inheritance, SQL99-style syntax */
 8859 lockhart@fourpalms.o    14235                 :UBC           0 :                     $$ = $3;
 3604 tgl@sss.pgh.pa.us       14236                 :              0 :                     $$->inh = false;
 8859 lockhart@fourpalms.o    14237                 :              0 :                     $$->alias = NULL;
                              14238                 :                :                 }
                              14239                 :                :         ;
                              14240                 :                : 
                              14241                 :                : 
                              14242                 :                : relation_expr_list:
 6506 peter_e@gmx.net         14243                 :CBC        1790 :             relation_expr                           { $$ = list_make1($1); }
                              14244                 :           6076 :             | relation_expr_list ',' relation_expr  { $$ = lappend($1, $3); }
                              14245                 :                :         ;
                              14246                 :                : 
                              14247                 :                : 
                              14248                 :                : /*
                              14249                 :                :  * Given "UPDATE foo set set ...", we have to decide without looking any
                              14250                 :                :  * further ahead whether the first "set" is an alias or the UPDATE's SET
                              14251                 :                :  * keyword.  Since "set" is allowed as a column name both interpretations
                              14252                 :                :  * are feasible.  We resolve the shift/reduce conflict by giving the first
                              14253                 :                :  * relation_expr_opt_alias production a higher precedence than the SET token
                              14254                 :                :  * has, causing the parser to prefer to reduce, in effect assuming that the
                              14255                 :                :  * SET is not an alias.
                              14256                 :                :  */
                              14257                 :                : relation_expr_opt_alias: relation_expr                  %prec UMINUS
                              14258                 :                :                 {
 7592 neilc@samurai.com       14259                 :          11967 :                     $$ = $1;
                              14260                 :                :                 }
                              14261                 :                :             | relation_expr ColId
                              14262                 :                :                 {
 1637 peter@eisentraut.org    14263                 :           1515 :                     Alias      *alias = makeNode(Alias);
                              14264                 :                : 
 7592 tgl@sss.pgh.pa.us       14265                 :           1515 :                     alias->aliasname = $2;
                              14266                 :           1515 :                     $1->alias = alias;
                              14267                 :           1515 :                     $$ = $1;
                              14268                 :                :                 }
                              14269                 :                :             | relation_expr AS ColId
                              14270                 :                :                 {
 1637 peter@eisentraut.org    14271                 :             62 :                     Alias      *alias = makeNode(Alias);
                              14272                 :                : 
 7592 neilc@samurai.com       14273                 :             62 :                     alias->aliasname = $3;
                              14274                 :             62 :                     $1->alias = alias;
                              14275                 :             62 :                     $$ = $1;
                              14276                 :                :                 }
                              14277                 :                :         ;
                              14278                 :                : 
                              14279                 :                : /*
                              14280                 :                :  * TABLESAMPLE decoration in a FROM item
                              14281                 :                :  */
                              14282                 :                : tablesample_clause:
                              14283                 :                :             TABLESAMPLE func_name '(' expr_list ')' opt_repeatable_clause
                              14284                 :                :                 {
 4192 simon@2ndQuadrant.co    14285                 :            186 :                     RangeTableSample *n = makeNode(RangeTableSample);
                              14286                 :                : 
                              14287                 :                :                     /* n->relation will be filled in later */
                              14288                 :            186 :                     n->method = $2;
                              14289                 :            186 :                     n->args = $4;
                              14290                 :            186 :                     n->repeatable = $6;
 4121 tgl@sss.pgh.pa.us       14291                 :            186 :                     n->location = @2;
 4192 simon@2ndQuadrant.co    14292                 :            186 :                     $$ = (Node *) n;
                              14293                 :                :                 }
                              14294                 :                :         ;
                              14295                 :                : 
                              14296                 :                : opt_repeatable_clause:
                              14297                 :             71 :             REPEATABLE '(' a_expr ')'   { $$ = (Node *) $3; }
                              14298                 :            115 :             | /*EMPTY*/                 { $$ = NULL; }
                              14299                 :                :         ;
                              14300                 :                : 
                              14301                 :                : /*
                              14302                 :                :  * func_table represents a function invocation in a FROM list. It can be
                              14303                 :                :  * a plain function call, like "foo(...)", or a ROWS FROM expression with
                              14304                 :                :  * one or more function calls, "ROWS FROM (foo(...), bar(...))",
                              14305                 :                :  * optionally with WITH ORDINALITY attached.
                              14306                 :                :  * In the ROWS FROM syntax, a column definition list can be given for each
                              14307                 :                :  * function, for example:
                              14308                 :                :  *     ROWS FROM (foo() AS (foo_res_a text, foo_res_b text),
                              14309                 :                :  *                bar() AS (bar_res_a text, bar_res_b text))
                              14310                 :                :  * It's also possible to attach a column definition list to the RangeFunction
                              14311                 :                :  * as a whole, but that's handled by the table_ref production.
                              14312                 :                :  */
                              14313                 :                : func_table: func_expr_windowless opt_ordinality
                              14314                 :                :                 {
 4732 tgl@sss.pgh.pa.us       14315                 :          30300 :                     RangeFunction *n = makeNode(RangeFunction);
                              14316                 :                : 
                              14317                 :          30300 :                     n->lateral = false;
                              14318                 :          30300 :                     n->ordinality = $2;
 4713 noah@leadboat.com       14319                 :          30300 :                     n->is_rowsfrom = false;
 4732 tgl@sss.pgh.pa.us       14320                 :          30300 :                     n->functions = list_make1(list_make2($1, NIL));
                              14321                 :                :                     /* alias and coldeflist are set by table_ref production */
                              14322                 :          30300 :                     $$ = (Node *) n;
                              14323                 :                :                 }
                              14324                 :                :             | ROWS FROM '(' rowsfrom_list ')' opt_ordinality
                              14325                 :                :                 {
                              14326                 :             98 :                     RangeFunction *n = makeNode(RangeFunction);
                              14327                 :                : 
                              14328                 :             98 :                     n->lateral = false;
 4713 noah@leadboat.com       14329                 :             98 :                     n->ordinality = $6;
                              14330                 :             98 :                     n->is_rowsfrom = true;
                              14331                 :             98 :                     n->functions = $4;
                              14332                 :                :                     /* alias and coldeflist are set by table_ref production */
 4732 tgl@sss.pgh.pa.us       14333                 :             98 :                     $$ = (Node *) n;
                              14334                 :                :                 }
                              14335                 :                :         ;
                              14336                 :                : 
                              14337                 :                : rowsfrom_item: func_expr_windowless opt_col_def_list
                              14338                 :            232 :                 { $$ = list_make2($1, $2); }
                              14339                 :                :         ;
                              14340                 :                : 
                              14341                 :                : rowsfrom_list:
 4713 noah@leadboat.com       14342                 :             98 :             rowsfrom_item                       { $$ = list_make1($1); }
                              14343                 :            134 :             | rowsfrom_list ',' rowsfrom_item   { $$ = lappend($1, $3); }
                              14344                 :                :         ;
                              14345                 :                : 
 4732 tgl@sss.pgh.pa.us       14346                 :             36 : opt_col_def_list: AS '(' TableFuncElementList ')'   { $$ = $3; }
                              14347                 :            196 :             | /*EMPTY*/                             { $$ = NIL; }
                              14348                 :                :         ;
                              14349                 :                : 
 4272                         14350                 :            606 : opt_ordinality: WITH_LA ORDINALITY                  { $$ = true; }
 4732                         14351                 :          29792 :             | /*EMPTY*/                             { $$ = false; }
                              14352                 :                :         ;
                              14353                 :                : 
                              14354                 :                : 
                              14355                 :                : where_clause:
 8907 bruce@momjian.us        14356                 :         142055 :             WHERE a_expr                            { $$ = $2; }
 8906                         14357                 :         187232 :             | /*EMPTY*/                             { $$ = NULL; }
                              14358                 :                :         ;
                              14359                 :                : 
                              14360                 :                : /* variant for UPDATE and DELETE */
                              14361                 :                : where_or_current_clause:
 7087 tgl@sss.pgh.pa.us       14362                 :           8598 :             WHERE a_expr                            { $$ = $2; }
                              14363                 :                :             | WHERE CURRENT_P OF cursor_name
                              14364                 :                :                 {
                              14365                 :            188 :                     CurrentOfExpr *n = makeNode(CurrentOfExpr);
                              14366                 :                : 
                              14367                 :                :                     /* cvarno is filled in by parse analysis */
                              14368                 :            188 :                     n->cursor_name = $4;
                              14369                 :            188 :                     n->cursor_param = 0;
                              14370                 :            188 :                     $$ = (Node *) n;
                              14371                 :                :                 }
                              14372                 :           3286 :             | /*EMPTY*/                             { $$ = NULL; }
                              14373                 :                :         ;
                              14374                 :                : 
                              14375                 :                : 
                              14376                 :                : OptTableFuncElementList:
 5884 peter_e@gmx.net         14377                 :            493 :             TableFuncElementList                { $$ = $1; }
                              14378                 :           1894 :             | /*EMPTY*/                         { $$ = NIL; }
                              14379                 :                :         ;
                              14380                 :                : 
                              14381                 :                : TableFuncElementList:
                              14382                 :                :             TableFuncElement
                              14383                 :                :                 {
 8194 neilc@samurai.com       14384                 :            996 :                     $$ = list_make1($1);
                              14385                 :                :                 }
                              14386                 :                :             | TableFuncElementList ',' TableFuncElement
                              14387                 :                :                 {
 8834 tgl@sss.pgh.pa.us       14388                 :           1287 :                     $$ = lappend($1, $3);
                              14389                 :                :                 }
                              14390                 :                :         ;
                              14391                 :                : 
                              14392                 :                : TableFuncElement:   ColId Typename opt_collate_clause
                              14393                 :                :                 {
 8859 bruce@momjian.us        14394                 :           2329 :                     ColumnDef *n = makeNode(ColumnDef);
                              14395                 :                : 
                              14396                 :           2329 :                     n->colname = $1;
 6321 peter_e@gmx.net         14397                 :           2329 :                     n->typeName = $2;
 5720 tgl@sss.pgh.pa.us       14398                 :           2329 :                     n->inhcount = 0;
 8810                         14399                 :           2329 :                     n->is_local = true;
 5720                         14400                 :           2329 :                     n->is_not_null = false;
                              14401                 :           2329 :                     n->is_from_type = false;
  989 peter@eisentraut.org    14402                 :           2329 :                     n->storage = 0;
 5720 tgl@sss.pgh.pa.us       14403                 :           2329 :                     n->raw_default = NULL;
                              14404                 :           2329 :                     n->cooked_default = NULL;
                              14405                 :           2329 :                     n->collClause = (CollateClause *) $3;
                              14406                 :           2329 :                     n->collOid = InvalidOid;
                              14407                 :           2329 :                     n->constraints = NIL;
 4732                         14408                 :           2329 :                     n->location = @1;
 1637 peter@eisentraut.org    14409                 :           2329 :                     $$ = (Node *) n;
                              14410                 :                :                 }
                              14411                 :                :         ;
                              14412                 :                : 
                              14413                 :                : /*
                              14414                 :                :  * XMLTABLE
                              14415                 :                :  */
                              14416                 :                : xmltable:
                              14417                 :                :             XMLTABLE '(' c_expr xmlexists_argument COLUMNS xmltable_column_list ')'
                              14418                 :                :                 {
 3529 alvherre@alvh.no-ip.    14419                 :            137 :                     RangeTableFunc *n = makeNode(RangeTableFunc);
                              14420                 :                : 
                              14421                 :            137 :                     n->rowexpr = $3;
                              14422                 :            137 :                     n->docexpr = $4;
                              14423                 :            137 :                     n->columns = $6;
                              14424                 :            137 :                     n->namespaces = NIL;
                              14425                 :            137 :                     n->location = @1;
 1637 peter@eisentraut.org    14426                 :            137 :                     $$ = (Node *) n;
                              14427                 :                :                 }
                              14428                 :                :             | XMLTABLE '(' XMLNAMESPACES '(' xml_namespace_list ')' ','
                              14429                 :                :                 c_expr xmlexists_argument COLUMNS xmltable_column_list ')'
                              14430                 :                :                 {
 3529 alvherre@alvh.no-ip.    14431                 :             13 :                     RangeTableFunc *n = makeNode(RangeTableFunc);
                              14432                 :                : 
                              14433                 :             13 :                     n->rowexpr = $8;
                              14434                 :             13 :                     n->docexpr = $9;
                              14435                 :             13 :                     n->columns = $11;
                              14436                 :             13 :                     n->namespaces = $5;
                              14437                 :             13 :                     n->location = @1;
 1637 peter@eisentraut.org    14438                 :             13 :                     $$ = (Node *) n;
                              14439                 :                :                 }
                              14440                 :                :         ;
                              14441                 :                : 
 3529 alvherre@alvh.no-ip.    14442                 :            150 : xmltable_column_list: xmltable_column_el                    { $$ = list_make1($1); }
                              14443                 :            351 :             | xmltable_column_list ',' xmltable_column_el   { $$ = lappend($1, $3); }
                              14444                 :                :         ;
                              14445                 :                : 
                              14446                 :                : xmltable_column_el:
                              14447                 :                :             ColId Typename
                              14448                 :                :                 {
 1637 peter@eisentraut.org    14449                 :            136 :                     RangeTableFuncCol *fc = makeNode(RangeTableFuncCol);
                              14450                 :                : 
 3529 alvherre@alvh.no-ip.    14451                 :            136 :                     fc->colname = $1;
                              14452                 :            136 :                     fc->for_ordinality = false;
                              14453                 :            136 :                     fc->typeName = $2;
                              14454                 :            136 :                     fc->is_not_null = false;
                              14455                 :            136 :                     fc->colexpr = NULL;
                              14456                 :            136 :                     fc->coldefexpr = NULL;
                              14457                 :            136 :                     fc->location = @1;
                              14458                 :                : 
                              14459                 :            136 :                     $$ = (Node *) fc;
                              14460                 :                :                 }
                              14461                 :                :             | ColId Typename xmltable_column_option_list
                              14462                 :                :                 {
 1637 peter@eisentraut.org    14463                 :            324 :                     RangeTableFuncCol *fc = makeNode(RangeTableFuncCol);
                              14464                 :                :                     ListCell   *option;
                              14465                 :            324 :                     bool        nullability_seen = false;
                              14466                 :                : 
 3529 alvherre@alvh.no-ip.    14467                 :            324 :                     fc->colname = $1;
                              14468                 :            324 :                     fc->typeName = $2;
                              14469                 :            324 :                     fc->for_ordinality = false;
                              14470                 :            324 :                     fc->is_not_null = false;
                              14471                 :            324 :                     fc->colexpr = NULL;
                              14472                 :            324 :                     fc->coldefexpr = NULL;
                              14473                 :            324 :                     fc->location = @1;
                              14474                 :                : 
                              14475   [ +  -  +  +  :            722 :                     foreach(option, $3)
                                              +  + ]
                              14476                 :                :                     {
                              14477                 :            398 :                         DefElem   *defel = (DefElem *) lfirst(option);
                              14478                 :                : 
                              14479         [ +  + ]:            398 :                         if (strcmp(defel->defname, "default") == 0)
                              14480                 :                :                         {
                              14481         [ -  + ]:             37 :                             if (fc->coldefexpr != NULL)
 3529 alvherre@alvh.no-ip.    14482         [ #  # ]:UBC           0 :                                 ereport(ERROR,
                              14483                 :                :                                         (errcode(ERRCODE_SYNTAX_ERROR),
                              14484                 :                :                                          errmsg("only one DEFAULT value is allowed"),
                              14485                 :                :                                          parser_errposition(defel->location)));
 3529 alvherre@alvh.no-ip.    14486                 :CBC          37 :                             fc->coldefexpr = defel->arg;
                              14487                 :                :                         }
                              14488         [ +  + ]:            361 :                         else if (strcmp(defel->defname, "path") == 0)
                              14489                 :                :                         {
                              14490         [ -  + ]:            324 :                             if (fc->colexpr != NULL)
 3529 alvherre@alvh.no-ip.    14491         [ #  # ]:UBC           0 :                                 ereport(ERROR,
                              14492                 :                :                                         (errcode(ERRCODE_SYNTAX_ERROR),
                              14493                 :                :                                          errmsg("only one PATH value per column is allowed"),
                              14494                 :                :                                          parser_errposition(defel->location)));
 3529 alvherre@alvh.no-ip.    14495                 :CBC         324 :                             fc->colexpr = defel->arg;
                              14496                 :                :                         }
  539 rguo@postgresql.org     14497         [ +  - ]:             37 :                         else if (strcmp(defel->defname, "__pg__is_not_null") == 0)
                              14498                 :                :                         {
 3529 alvherre@alvh.no-ip.    14499         [ -  + ]:             37 :                             if (nullability_seen)
 3529 alvherre@alvh.no-ip.    14500         [ #  # ]:UBC           0 :                                 ereport(ERROR,
                              14501                 :                :                                         (errcode(ERRCODE_SYNTAX_ERROR),
                              14502                 :                :                                          errmsg("conflicting or redundant NULL / NOT NULL declarations for column \"%s\"", fc->colname),
                              14503                 :                :                                          parser_errposition(defel->location)));
 1756 peter@eisentraut.org    14504                 :CBC          37 :                             fc->is_not_null = boolVal(defel->arg);
 3529 alvherre@alvh.no-ip.    14505                 :             37 :                             nullability_seen = true;
                              14506                 :                :                         }
                              14507                 :                :                         else
                              14508                 :                :                         {
 3529 alvherre@alvh.no-ip.    14509         [ #  # ]:UBC           0 :                             ereport(ERROR,
                              14510                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              14511                 :                :                                      errmsg("unrecognized column option \"%s\"",
                              14512                 :                :                                             defel->defname),
                              14513                 :                :                                      parser_errposition(defel->location)));
                              14514                 :                :                         }
                              14515                 :                :                     }
 3529 alvherre@alvh.no-ip.    14516                 :CBC         324 :                     $$ = (Node *) fc;
                              14517                 :                :                 }
                              14518                 :                :             | ColId FOR ORDINALITY
                              14519                 :                :                 {
 1637 peter@eisentraut.org    14520                 :             41 :                     RangeTableFuncCol *fc = makeNode(RangeTableFuncCol);
                              14521                 :                : 
 3529 alvherre@alvh.no-ip.    14522                 :             41 :                     fc->colname = $1;
                              14523                 :             41 :                     fc->for_ordinality = true;
                              14524                 :                :                     /* other fields are ignored, initialized by makeNode */
                              14525                 :             41 :                     fc->location = @1;
                              14526                 :                : 
                              14527                 :             41 :                     $$ = (Node *) fc;
                              14528                 :                :                 }
                              14529                 :                :         ;
                              14530                 :                : 
                              14531                 :                : xmltable_column_option_list:
                              14532                 :                :             xmltable_column_option_el
                              14533                 :            324 :                 { $$ = list_make1($1); }
                              14534                 :                :             | xmltable_column_option_list xmltable_column_option_el
                              14535                 :             74 :                 { $$ = lappend($1, $2); }
                              14536                 :                :         ;
                              14537                 :                : 
                              14538                 :                : xmltable_column_option_el:
                              14539                 :                :             IDENT b_expr
                              14540                 :                :                 {
  539 rguo@postgresql.org     14541         [ +  - ]:              4 :                     if (strcmp($1, "__pg__is_not_null") == 0)
                              14542         [ +  - ]:              4 :                         ereport(ERROR,
                              14543                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                              14544                 :                :                                  errmsg("option name \"%s\" cannot be used in XMLTABLE", $1),
                              14545                 :                :                                  parser_errposition(@1)));
  539 rguo@postgresql.org     14546                 :UBC           0 :                     $$ = makeDefElem($1, $2, @1);
                              14547                 :                :                 }
                              14548                 :                :             | DEFAULT b_expr
 3529 alvherre@alvh.no-ip.    14549                 :CBC          37 :                 { $$ = makeDefElem("default", $2, @1); }
                              14550                 :                :             | NOT NULL_P
  539 rguo@postgresql.org     14551                 :             37 :                 { $$ = makeDefElem("__pg__is_not_null", (Node *) makeBoolean(true), @1); }
                              14552                 :                :             | NULL_P
  539 rguo@postgresql.org     14553                 :UBC           0 :                 { $$ = makeDefElem("__pg__is_not_null", (Node *) makeBoolean(false), @1); }
                              14554                 :                :             | PATH b_expr
  945 amitlan@postgresql.o    14555                 :CBC         324 :                 { $$ = makeDefElem("path", $2, @1); }
                              14556                 :                :         ;
                              14557                 :                : 
                              14558                 :                : xml_namespace_list:
                              14559                 :                :             xml_namespace_el
 3529 alvherre@alvh.no-ip.    14560                 :             13 :                 { $$ = list_make1($1); }
                              14561                 :                :             | xml_namespace_list ',' xml_namespace_el
 3529 alvherre@alvh.no-ip.    14562                 :UBC           0 :                 { $$ = lappend($1, $3); }
                              14563                 :                :         ;
                              14564                 :                : 
                              14565                 :                : xml_namespace_el:
                              14566                 :                :             b_expr AS ColLabel
                              14567                 :                :                 {
 3529 alvherre@alvh.no-ip.    14568                 :CBC           9 :                     $$ = makeNode(ResTarget);
                              14569                 :              9 :                     $$->name = $3;
                              14570                 :              9 :                     $$->indirection = NIL;
                              14571                 :              9 :                     $$->val = $1;
                              14572                 :              9 :                     $$->location = @1;
                              14573                 :                :                 }
                              14574                 :                :             | DEFAULT b_expr
                              14575                 :                :                 {
                              14576                 :              4 :                     $$ = makeNode(ResTarget);
                              14577                 :              4 :                     $$->name = NULL;
                              14578                 :              4 :                     $$->indirection = NIL;
                              14579                 :              4 :                     $$->val = $2;
                              14580                 :              4 :                     $$->location = @1;
                              14581                 :                :                 }
                              14582                 :                :         ;
                              14583                 :                : 
                              14584                 :                : json_table:
                              14585                 :                :             JSON_TABLE '('
                              14586                 :                :                 json_value_expr ',' a_expr json_table_path_name_opt
                              14587                 :                :                 json_passing_clause_opt
                              14588                 :                :                 COLUMNS '(' json_table_column_definition_list ')'
                              14589                 :                :                 json_table_plan_clause_opt
                              14590                 :                :                 json_on_error_clause_opt
                              14591                 :                :             ')'
                              14592                 :                :                 {
  945 amitlan@postgresql.o    14593                 :            572 :                     JsonTable *n = makeNode(JsonTable);
                              14594                 :                :                     char      *pathstring;
                              14595                 :                : 
                              14596                 :            572 :                     n->context_item = (JsonValueExpr *) $3;
                              14597         [ +  + ]:            572 :                     if (!IsA($5, A_Const) ||
                              14598         [ -  + ]:            568 :                         castNode(A_Const, $5)->val.node.type != T_String)
                              14599         [ +  - ]:              4 :                         ereport(ERROR,
                              14600                 :                :                                 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              14601                 :                :                                 errmsg("only string constants are supported in"
                              14602                 :                :                                        " JSON_TABLE path specification"),
                              14603                 :                :                                 parser_errposition(@5));
                              14604                 :            568 :                     pathstring = castNode(A_Const, $5)->val.sval.sval;
                              14605                 :            568 :                     n->pathspec = makeJsonTablePathSpec(pathstring, $6, @5, @6);
                              14606                 :            568 :                     n->passing = $7;
                              14607                 :            568 :                     n->columns = $10;
  119 akorotkov@postgresql    14608                 :GNC         568 :                     n->planspec = (JsonTablePlanSpec *) $12;
                              14609                 :            568 :                     n->on_error = (JsonBehavior *) $13;
  945 amitlan@postgresql.o    14610                 :CBC         568 :                     n->location = @1;
                              14611                 :            568 :                     $$ = (Node *) n;
                              14612                 :                :                 }
                              14613                 :                :         ;
                              14614                 :                : 
                              14615                 :                : json_table_path_name_opt:
                              14616                 :            158 :             AS name         { $$ = $2; }
                              14617                 :            422 :             | /* empty */   { $$ = NULL; }
                              14618                 :                :         ;
                              14619                 :                : 
                              14620                 :                : json_table_column_definition_list:
                              14621                 :                :             json_table_column_definition
                              14622                 :           1154 :                 { $$ = list_make1($1); }
                              14623                 :                :             | json_table_column_definition_list ',' json_table_column_definition
                              14624                 :            750 :                 { $$ = lappend($1, $3); }
                              14625                 :                :         ;
                              14626                 :                : 
                              14627                 :                : json_table_column_definition:
                              14628                 :                :             ColId FOR ORDINALITY
                              14629                 :                :                 {
                              14630                 :            101 :                     JsonTableColumn *n = makeNode(JsonTableColumn);
                              14631                 :                : 
                              14632                 :            101 :                     n->coltype = JTC_FOR_ORDINALITY;
                              14633                 :            101 :                     n->name = $1;
                              14634                 :            101 :                     n->location = @1;
                              14635                 :            101 :                     $$ = (Node *) n;
                              14636                 :                :                 }
                              14637                 :                :             | ColId Typename
                              14638                 :                :                 json_table_column_path_clause_opt
                              14639                 :                :                 json_wrapper_behavior
                              14640                 :                :                 json_quotes_clause_opt
                              14641                 :                :                 json_behavior_clause_opt
                              14642                 :                :                 {
                              14643                 :           1002 :                     JsonTableColumn *n = makeNode(JsonTableColumn);
                              14644                 :                : 
                              14645                 :           1002 :                     n->coltype = JTC_REGULAR;
                              14646                 :           1002 :                     n->name = $1;
                              14647                 :           1002 :                     n->typeName = $2;
                              14648                 :           1002 :                     n->format = makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1);
                              14649                 :           1002 :                     n->pathspec = (JsonTablePathSpec *) $3;
                              14650                 :           1002 :                     n->wrapper = $4;
                              14651                 :           1002 :                     n->quotes = $5;
                              14652                 :           1002 :                     n->on_empty = (JsonBehavior *) linitial($6);
                              14653                 :           1002 :                     n->on_error = (JsonBehavior *) lsecond($6);
                              14654                 :           1002 :                     n->location = @1;
                              14655                 :           1002 :                     $$ = (Node *) n;
                              14656                 :                :                 }
                              14657                 :                :             | ColId Typename json_format_clause
                              14658                 :                :                 json_table_column_path_clause_opt
                              14659                 :                :                 json_wrapper_behavior
                              14660                 :                :                 json_quotes_clause_opt
                              14661                 :                :                 json_behavior_clause_opt
                              14662                 :                :                 {
                              14663                 :            102 :                     JsonTableColumn *n = makeNode(JsonTableColumn);
                              14664                 :                : 
                              14665                 :            102 :                     n->coltype = JTC_FORMATTED;
                              14666                 :            102 :                     n->name = $1;
                              14667                 :            102 :                     n->typeName = $2;
                              14668                 :            102 :                     n->format = (JsonFormat *) $3;
                              14669                 :            102 :                     n->pathspec = (JsonTablePathSpec *) $4;
                              14670                 :            102 :                     n->wrapper = $5;
                              14671                 :            102 :                     n->quotes = $6;
                              14672                 :            102 :                     n->on_empty = (JsonBehavior *) linitial($7);
                              14673                 :            102 :                     n->on_error = (JsonBehavior *) lsecond($7);
                              14674                 :            102 :                     n->location = @1;
                              14675                 :            102 :                     $$ = (Node *) n;
                              14676                 :                :                 }
                              14677                 :                :             | ColId Typename
                              14678                 :                :                 EXISTS json_table_column_path_clause_opt
                              14679                 :                :                 json_on_error_clause_opt
                              14680                 :                :                 {
                              14681                 :            117 :                     JsonTableColumn *n = makeNode(JsonTableColumn);
                              14682                 :                : 
                              14683                 :            117 :                     n->coltype = JTC_EXISTS;
                              14684                 :            117 :                     n->name = $1;
                              14685                 :            117 :                     n->typeName = $2;
                              14686                 :            117 :                     n->format = makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1);
                              14687                 :            117 :                     n->wrapper = JSW_NONE;
                              14688                 :            117 :                     n->quotes = JS_QUOTES_UNSPEC;
                              14689                 :            117 :                     n->pathspec = (JsonTablePathSpec *) $4;
  860                         14690                 :            117 :                     n->on_empty = NULL;
                              14691                 :            117 :                     n->on_error = (JsonBehavior *) $5;
  945                         14692                 :            117 :                     n->location = @1;
                              14693                 :            117 :                     $$ = (Node *) n;
                              14694                 :                :                 }
                              14695                 :                :             | NESTED path_opt Sconst
                              14696                 :                :                 COLUMNS '(' json_table_column_definition_list ')'
                              14697                 :                :                 {
  941                         14698                 :            118 :                     JsonTableColumn *n = makeNode(JsonTableColumn);
                              14699                 :                : 
                              14700                 :            118 :                     n->coltype = JTC_NESTED;
  119 akorotkov@postgresql    14701                 :GNC         118 :                     n->pathspec = makeJsonTablePathSpec($3, NULL, @3, -1);
  941 amitlan@postgresql.o    14702                 :CBC         118 :                     n->columns = $6;
                              14703                 :            118 :                     n->location = @1;
                              14704                 :            118 :                     $$ = (Node *) n;
                              14705                 :                :                 }
                              14706                 :                :             | NESTED path_opt Sconst AS name
                              14707                 :                :                 COLUMNS '(' json_table_column_definition_list ')'
                              14708                 :                :                 {
                              14709                 :            464 :                     JsonTableColumn *n = makeNode(JsonTableColumn);
                              14710                 :                : 
                              14711                 :            464 :                     n->coltype = JTC_NESTED;
  119 akorotkov@postgresql    14712                 :GNC         464 :                     n->pathspec = makeJsonTablePathSpec($3, $5, @3, @5);
  941 amitlan@postgresql.o    14713                 :CBC         464 :                     n->columns = $8;
                              14714                 :            464 :                     n->location = @1;
                              14715                 :            464 :                     $$ = (Node *) n;
                              14716                 :                :                 }
                              14717                 :                :         ;
                              14718                 :                : 
                              14719                 :                : path_opt:
                              14720                 :                :             PATH
                              14721                 :                :             | /* EMPTY */
                              14722                 :                :         ;
                              14723                 :                : 
                              14724                 :                : json_table_column_path_clause_opt:
                              14725                 :                :             PATH Sconst
  945                         14726                 :            989 :                 { $$ = (Node *) makeJsonTablePathSpec($2, NULL, @2, -1); }
                              14727                 :                :             | /* EMPTY */
                              14728                 :            236 :                 { $$ = NULL; }
                              14729                 :                :         ;
                              14730                 :                : 
                              14731                 :                : json_table_plan_clause_opt:
                              14732                 :                :             PLAN '(' json_table_plan ')'
  119 akorotkov@postgresql    14733                 :GNC          92 :                 { $$ = $3; }
                              14734                 :                :             | PLAN DEFAULT '(' json_table_default_plan_choices ')'
                              14735                 :             28 :                 { $$ = makeJsonTableDefaultPlan($4, @1); }
                              14736                 :                :             | /* EMPTY */
                              14737                 :            452 :                 { $$ = NULL; }
                              14738                 :                :         ;
                              14739                 :                : 
                              14740                 :                : json_table_plan:
                              14741                 :                :             json_table_plan_simple
                              14742                 :                :             | json_table_plan_outer
                              14743                 :                :             | json_table_plan_inner
                              14744                 :                :             | json_table_plan_union
                              14745                 :                :             | json_table_plan_cross
                              14746                 :                :         ;
                              14747                 :                : 
                              14748                 :                : json_table_plan_simple:
                              14749                 :                :             name
                              14750                 :            298 :                 { $$ = makeJsonTableSimplePlan($1, @1); }
                              14751                 :                :         ;
                              14752                 :                : 
                              14753                 :                : json_table_plan_outer:
                              14754                 :                :             json_table_plan_simple OUTER_P json_table_plan_primary
                              14755                 :             73 :                 { $$ = makeJsonTableJoinedPlan(JSTP_JOIN_OUTER, $1, $3, @1); }
                              14756                 :                :         ;
                              14757                 :                : 
                              14758                 :                : json_table_plan_inner:
                              14759                 :                :             json_table_plan_simple INNER_P json_table_plan_primary
                              14760                 :             42 :                 { $$ = makeJsonTableJoinedPlan(JSTP_JOIN_INNER, $1, $3, @1); }
                              14761                 :                :         ;
                              14762                 :                : 
                              14763                 :                : json_table_plan_union:
                              14764                 :                :             json_table_plan_primary UNION json_table_plan_primary
                              14765                 :             31 :                 { $$ = makeJsonTableJoinedPlan(JSTP_JOIN_UNION, $1, $3, @1); }
                              14766                 :                :             | json_table_plan_union UNION json_table_plan_primary
                              14767                 :              5 :                 { $$ = makeJsonTableJoinedPlan(JSTP_JOIN_UNION, $1, $3, @1); }
                              14768                 :                :         ;
                              14769                 :                : 
                              14770                 :                : json_table_plan_cross:
                              14771                 :                :             json_table_plan_primary CROSS json_table_plan_primary
                              14772                 :             54 :                 { $$ = makeJsonTableJoinedPlan(JSTP_JOIN_CROSS, $1, $3, @1); }
                              14773                 :                :             | json_table_plan_cross CROSS json_table_plan_primary
                              14774                 :              1 :                 { $$ = makeJsonTableJoinedPlan(JSTP_JOIN_CROSS, $1, $3, @1); }
                              14775                 :                :         ;
                              14776                 :                : 
                              14777                 :                : json_table_plan_primary:
                              14778                 :                :             json_table_plan_simple
                              14779                 :            170 :                 { $$ = $1; }
                              14780                 :                :             | '(' json_table_plan ')'
                              14781                 :                :                 {
                              14782                 :            121 :                     castNode(JsonTablePlanSpec, $2)->location = @1;
                              14783                 :            121 :                     $$ = $2;
                              14784                 :                :                 }
                              14785                 :                :         ;
                              14786                 :                : 
                              14787                 :                : json_table_default_plan_choices:
                              14788                 :                :             json_table_default_plan_inner_outer
                              14789                 :              5 :                 { $$ = $1 | JSTP_JOIN_UNION; }
                              14790                 :                :             | json_table_default_plan_union_cross
                              14791                 :              9 :                 { $$ = $1 | JSTP_JOIN_OUTER; }
                              14792                 :                :             | json_table_default_plan_inner_outer ',' json_table_default_plan_union_cross
                              14793                 :              9 :                 { $$ = $1 | $3; }
                              14794                 :                :             | json_table_default_plan_union_cross ',' json_table_default_plan_inner_outer
                              14795                 :              5 :                 { $$ = $1 | $3; }
                              14796                 :                :         ;
                              14797                 :                : 
                              14798                 :                : json_table_default_plan_inner_outer:
                              14799                 :             11 :             INNER_P                     { $$ = JSTP_JOIN_INNER; }
                              14800                 :              8 :             | OUTER_P                   { $$ = JSTP_JOIN_OUTER; }
                              14801                 :                :         ;
                              14802                 :                : 
                              14803                 :                : json_table_default_plan_union_cross:
                              14804                 :             13 :             UNION                       { $$ = JSTP_JOIN_UNION; }
                              14805                 :             10 :             | CROSS                     { $$ = JSTP_JOIN_CROSS; }
                              14806                 :                :         ;
                              14807                 :                : 
                              14808                 :                : /*****************************************************************************
                              14809                 :                :  *
                              14810                 :                :  *  Type syntax
                              14811                 :                :  *      SQL introduces a large amount of type-specific syntax.
                              14812                 :                :  *      Define individual clauses to handle these cases, and use
                              14813                 :                :  *       the generic case to handle regular type-extensible Postgres syntax.
                              14814                 :                :  *      - thomas 1997-10-10
                              14815                 :                :  *
                              14816                 :                :  *****************************************************************************/
                              14817                 :                : 
                              14818                 :                : Typename:   SimpleTypename opt_array_bounds
                              14819                 :                :                 {
10603 lockhart@fourpalms.o    14820                 :CBC      307545 :                     $$ = $1;
                              14821                 :         307545 :                     $$->arrayBounds = $2;
                              14822                 :                :                 }
                              14823                 :                :             | SETOF SimpleTypename opt_array_bounds
                              14824                 :                :                 {
                              14825                 :           1120 :                     $$ = $2;
 8674 tgl@sss.pgh.pa.us       14826                 :           1120 :                     $$->arrayBounds = $3;
 3368 peter_e@gmx.net         14827                 :           1120 :                     $$->setof = true;
                              14828                 :                :                 }
                              14829                 :                :             /* SQL standard syntax, currently only one-dimensional */
                              14830                 :                :             | SimpleTypename ARRAY '[' Iconst ']'
                              14831                 :                :                 {
 8612 tgl@sss.pgh.pa.us       14832                 :              4 :                     $$ = $1;
 8194 neilc@samurai.com       14833                 :              4 :                     $$->arrayBounds = list_make1(makeInteger($4));
                              14834                 :                :                 }
                              14835                 :                :             | SETOF SimpleTypename ARRAY '[' Iconst ']'
                              14836                 :                :                 {
 8612 tgl@sss.pgh.pa.us       14837                 :UBC           0 :                     $$ = $2;
 8194 neilc@samurai.com       14838                 :              0 :                     $$->arrayBounds = list_make1(makeInteger($5));
 3368 peter_e@gmx.net         14839                 :              0 :                     $$->setof = true;
                              14840                 :                :                 }
                              14841                 :                :             | SimpleTypename ARRAY
                              14842                 :                :                 {
 6581                         14843                 :              0 :                     $$ = $1;
                              14844                 :              0 :                     $$->arrayBounds = list_make1(makeInteger(-1));
                              14845                 :                :                 }
                              14846                 :                :             | SETOF SimpleTypename ARRAY
                              14847                 :                :                 {
                              14848                 :              0 :                     $$ = $2;
                              14849                 :              0 :                     $$->arrayBounds = list_make1(makeInteger(-1));
 3368                         14850                 :              0 :                     $$->setof = true;
                              14851                 :                :                 }
                              14852                 :                :         ;
                              14853                 :                : 
                              14854                 :                : opt_array_bounds:
                              14855                 :                :             opt_array_bounds '[' ']'
 8907 bruce@momjian.us        14856                 :CBC        8692 :                     {  $$ = lappend($1, makeInteger(-1)); }
                              14857                 :                :             | opt_array_bounds '[' Iconst ']'
                              14858                 :             33 :                     {  $$ = lappend($1, makeInteger($3)); }
                              14859                 :                :             | /*EMPTY*/
                              14860                 :         308665 :                     {  $$ = NIL; }
                              14861                 :                :         ;
                              14862                 :                : 
                              14863                 :                : SimpleTypename:
 8859 lockhart@fourpalms.o    14864                 :         241227 :             GenericType                             { $$ = $1; }
                              14865                 :          57930 :             | Numeric                               { $$ = $1; }
                              14866                 :           1285 :             | Bit                                   { $$ = $1; }
                              14867                 :           1911 :             | Character                             { $$ = $1; }
                              14868                 :           3099 :             | ConstDatetime                         { $$ = $1; }
                              14869                 :                :             | ConstInterval opt_interval
                              14870                 :                :                 {
 9149                         14871                 :           2307 :                     $$ = $1;
 6629 tgl@sss.pgh.pa.us       14872                 :           2307 :                     $$->typmods = $2;
                              14873                 :                :                 }
                              14874                 :                :             | ConstInterval '(' Iconst ')'
                              14875                 :                :                 {
 9149 lockhart@fourpalms.o    14876                 :UBC           0 :                     $$ = $1;
 4401 bruce@momjian.us        14877                 :              0 :                     $$->typmods = list_make2(makeIntConst(INTERVAL_FULL_RANGE, -1),
                              14878                 :                :                                              makeIntConst($3, @3));
                              14879                 :                :                 }
 1204 amitlan@postgresql.o    14880                 :CBC        1197 :             | JsonType                              { $$ = $1; }
                              14881                 :                :         ;
                              14882                 :                : 
                              14883                 :                : /* We have a separate ConstTypename to allow defaulting fixed-length
                              14884                 :                :  * types such as CHAR() and BIT() to an unspecified length.
                              14885                 :                :  * SQL9x requires that these default to a length of one, but this
                              14886                 :                :  * makes no sense for constructs like CHAR 'hi' and BIT '0101',
                              14887                 :                :  * where there is an obvious better choice to make.
                              14888                 :                :  * Note that ConstInterval is not included here since it must
                              14889                 :                :  * be pushed up higher in the rules to accommodate the postfix
                              14890                 :                :  * options (e.g. INTERVAL '1' YEAR). Likewise, we have to handle
                              14891                 :                :  * the generic-type-name case in AexprConst to avoid premature
                              14892                 :                :  * reduce/reduce conflicts against function names.
                              14893                 :                :  */
                              14894                 :                : ConstTypename:
 7250 tgl@sss.pgh.pa.us       14895                 :             53 :             Numeric                                 { $$ = $1; }
 8859 lockhart@fourpalms.o    14896                 :UBC           0 :             | ConstBit                              { $$ = $1; }
 8859 lockhart@fourpalms.o    14897                 :CBC          21 :             | ConstCharacter                        { $$ = $1; }
                              14898                 :           1793 :             | ConstDatetime                         { $$ = $1; }
 1204 amitlan@postgresql.o    14899                 :            176 :             | JsonType                              { $$ = $1; }
                              14900                 :                :         ;
                              14901                 :                : 
                              14902                 :                : /*
                              14903                 :                :  * GenericType covers all type names that don't have special syntax mandated
                              14904                 :                :  * by the standard, including qualified names.  We also allow type modifiers.
                              14905                 :                :  * To avoid parsing conflicts against function invocations, the modifiers
                              14906                 :                :  * have to be shown as expr_list here, but parse analysis will only accept
                              14907                 :                :  * constants for them.
                              14908                 :                :  */
                              14909                 :                : GenericType:
                              14910                 :                :             type_function_name opt_type_modifiers
                              14911                 :                :                 {
 8952 tgl@sss.pgh.pa.us       14912                 :         171797 :                     $$ = makeTypeName($1);
 7250                         14913                 :         171796 :                     $$->typmods = $2;
                              14914                 :         171796 :                     $$->location = @1;
                              14915                 :                :                 }
                              14916                 :                :             | type_function_name attrs opt_type_modifiers
                              14917                 :                :                 {
                              14918                 :          69430 :                     $$ = makeTypeNameFromNameList(lcons(makeString($1), $2));
                              14919                 :          69430 :                     $$->typmods = $3;
 7541                         14920                 :          69430 :                     $$->location = @1;
                              14921                 :                :                 }
                              14922                 :                :         ;
                              14923                 :                : 
 7250                         14924                 :            815 : opt_type_modifiers: '(' expr_list ')'               { $$ = $2; }
                              14925                 :         244346 :                     | /* EMPTY */                   { $$ = NIL; }
                              14926                 :                :         ;
                              14927                 :                : 
                              14928                 :                : /*
                              14929                 :                :  * SQL numeric data types
                              14930                 :                :  */
                              14931                 :                : Numeric:    INT_P
                              14932                 :                :                 {
 8952                         14933                 :          26877 :                     $$ = SystemTypeName("int4");
 7250                         14934                 :          26876 :                     $$->location = @1;
                              14935                 :                :                 }
                              14936                 :                :             | INTEGER
                              14937                 :                :                 {
 8952                         14938                 :          13990 :                     $$ = SystemTypeName("int4");
 7250                         14939                 :          13990 :                     $$->location = @1;
                              14940                 :                :                 }
                              14941                 :                :             | SMALLINT
                              14942                 :                :                 {
 8952                         14943                 :            760 :                     $$ = SystemTypeName("int2");
 7250                         14944                 :            760 :                     $$->location = @1;
                              14945                 :                :                 }
                              14946                 :                :             | BIGINT
                              14947                 :                :                 {
 8952                         14948                 :           2880 :                     $$ = SystemTypeName("int8");
 7250                         14949                 :           2880 :                     $$->location = @1;
                              14950                 :                :                 }
                              14951                 :                :             | REAL
                              14952                 :                :                 {
 8952                         14953                 :           4110 :                     $$ = SystemTypeName("float4");
 7250                         14954                 :           4110 :                     $$->location = @1;
                              14955                 :                :                 }
                              14956                 :                :             | FLOAT_P opt_float
                              14957                 :                :                 {
 8952                         14958                 :            344 :                     $$ = $2;
 7250                         14959                 :            344 :                     $$->location = @1;
                              14960                 :                :                 }
                              14961                 :                :             | DOUBLE_P PRECISION
                              14962                 :                :                 {
 8952                         14963                 :            479 :                     $$ = SystemTypeName("float8");
 7250                         14964                 :            479 :                     $$->location = @1;
                              14965                 :                :                 }
                              14966                 :                :             | DECIMAL_P opt_type_modifiers
                              14967                 :                :                 {
 8952                         14968                 :             18 :                     $$ = SystemTypeName("numeric");
 7250                         14969                 :             18 :                     $$->typmods = $2;
                              14970                 :             18 :                     $$->location = @1;
                              14971                 :                :                 }
                              14972                 :                :             | DEC opt_type_modifiers
                              14973                 :                :                 {
 8952 tgl@sss.pgh.pa.us       14974                 :UBC           0 :                     $$ = SystemTypeName("numeric");
 7250                         14975                 :              0 :                     $$->typmods = $2;
                              14976                 :              0 :                     $$->location = @1;
                              14977                 :                :                 }
                              14978                 :                :             | NUMERIC opt_type_modifiers
                              14979                 :                :                 {
 8952 tgl@sss.pgh.pa.us       14980                 :CBC        3916 :                     $$ = SystemTypeName("numeric");
 7250                         14981                 :           3916 :                     $$->typmods = $2;
                              14982                 :           3916 :                     $$->location = @1;
                              14983                 :                :                 }
                              14984                 :                :             | BOOLEAN_P
                              14985                 :                :                 {
 8952                         14986                 :           4609 :                     $$ = SystemTypeName("bool");
 7250                         14987                 :           4609 :                     $$->location = @1;
                              14988                 :                :                 }
                              14989                 :                :         ;
                              14990                 :                : 
                              14991                 :                : opt_float:  '(' Iconst ')'
                              14992                 :                :                 {
                              14993                 :                :                     /*
                              14994                 :                :                      * Check FLOAT() precision limits assuming IEEE floating
                              14995                 :                :                      * types - thomas 1997-09-18
                              14996                 :                :                      */
10603 lockhart@fourpalms.o    14997         [ -  + ]:              1 :                     if ($2 < 1)
 8510 tgl@sss.pgh.pa.us       14998         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              14999                 :                :                                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                              15000                 :                :                                  errmsg("precision for type float must be at least 1 bit"),
                              15001                 :                :                                  parser_errposition(@2)));
 8542 tgl@sss.pgh.pa.us       15002         [ +  - ]:CBC           1 :                     else if ($2 <= 24)
 8952                         15003                 :              1 :                         $$ = SystemTypeName("float4");
 8542 tgl@sss.pgh.pa.us       15004         [ #  # ]:UBC           0 :                     else if ($2 <= 53)
 8952                         15005                 :              0 :                         $$ = SystemTypeName("float8");
                              15006                 :                :                     else
 8510                         15007         [ #  # ]:              0 :                         ereport(ERROR,
                              15008                 :                :                                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                              15009                 :                :                                  errmsg("precision for type float must be less than 54 bits"),
                              15010                 :                :                                  parser_errposition(@2)));
                              15011                 :                :                 }
                              15012                 :                :             | /*EMPTY*/
                              15013                 :                :                 {
 8952 tgl@sss.pgh.pa.us       15014                 :CBC         343 :                     $$ = SystemTypeName("float8");
                              15015                 :                :                 }
                              15016                 :                :         ;
                              15017                 :                : 
                              15018                 :                : /*
                              15019                 :                :  * SQL bit-field data types
                              15020                 :                :  * The following implements BIT() and BIT VARYING().
                              15021                 :                :  */
                              15022                 :                : Bit:        BitWithLength
                              15023                 :                :                 {
 8859 lockhart@fourpalms.o    15024                 :           1154 :                     $$ = $1;
                              15025                 :                :                 }
                              15026                 :                :             | BitWithoutLength
                              15027                 :                :                 {
                              15028                 :            131 :                     $$ = $1;
                              15029                 :                :                 }
                              15030                 :                :         ;
                              15031                 :                : 
                              15032                 :                : /* ConstBit is like Bit except "BIT" defaults to unspecified length */
                              15033                 :                : /* See notes for ConstCharacter, which addresses same issue for "CHAR" */
                              15034                 :                : ConstBit:   BitWithLength
                              15035                 :                :                 {
 8859 lockhart@fourpalms.o    15036                 :UBC           0 :                     $$ = $1;
                              15037                 :                :                 }
                              15038                 :                :             | BitWithoutLength
                              15039                 :                :                 {
                              15040                 :              0 :                     $$ = $1;
 7250 tgl@sss.pgh.pa.us       15041                 :              0 :                     $$->typmods = NIL;
                              15042                 :                :                 }
                              15043                 :                :         ;
                              15044                 :                : 
                              15045                 :                : BitWithLength:
                              15046                 :                :             BIT opt_varying '(' expr_list ')'
                              15047                 :                :                 {
                              15048                 :                :                     char *typname;
                              15049                 :                : 
 8952 tgl@sss.pgh.pa.us       15050         [ +  + ]:CBC        1154 :                     typname = $2 ? "varbit" : "bit";
                              15051                 :           1154 :                     $$ = SystemTypeName(typname);
 7250                         15052                 :           1154 :                     $$->typmods = $4;
                              15053                 :           1154 :                     $$->location = @1;
                              15054                 :                :                 }
                              15055                 :                :         ;
                              15056                 :                : 
                              15057                 :                : BitWithoutLength:
                              15058                 :                :             BIT opt_varying
                              15059                 :                :                 {
                              15060                 :                :                     /* bit defaults to bit(1), varbit to no limit */
 8952                         15061         [ +  + ]:            131 :                     if ($2)
                              15062                 :                :                     {
                              15063                 :             10 :                         $$ = SystemTypeName("varbit");
                              15064                 :                :                     }
                              15065                 :                :                     else
                              15066                 :                :                     {
                              15067                 :            121 :                         $$ = SystemTypeName("bit");
 6643                         15068                 :            121 :                         $$->typmods = list_make1(makeIntConst(1, -1));
                              15069                 :                :                     }
 7250                         15070                 :            131 :                     $$->location = @1;
                              15071                 :                :                 }
                              15072                 :                :         ;
                              15073                 :                : 
                              15074                 :                : 
                              15075                 :                : /*
                              15076                 :                :  * SQL character data types
                              15077                 :                :  * The following implements CHAR() and VARCHAR().
                              15078                 :                :  */
                              15079                 :                : Character:  CharacterWithLength
                              15080                 :                :                 {
 8859 lockhart@fourpalms.o    15081                 :           1083 :                     $$ = $1;
                              15082                 :                :                 }
                              15083                 :                :             | CharacterWithoutLength
                              15084                 :                :                 {
                              15085                 :            828 :                     $$ = $1;
                              15086                 :                :                 }
                              15087                 :                :         ;
                              15088                 :                : 
                              15089                 :                : ConstCharacter:  CharacterWithLength
                              15090                 :                :                 {
                              15091                 :              8 :                     $$ = $1;
                              15092                 :                :                 }
                              15093                 :                :             | CharacterWithoutLength
                              15094                 :                :                 {
                              15095                 :                :                     /* Length was not specified so allow to be unrestricted.
                              15096                 :                :                      * This handles problems with fixed-length (bpchar) strings
                              15097                 :                :                      * which in column definitions must default to a length
                              15098                 :                :                      * of one, but should not be constrained if the length
                              15099                 :                :                      * was not specified.
                              15100                 :                :                      */
                              15101                 :             13 :                     $$ = $1;
 7250 tgl@sss.pgh.pa.us       15102                 :             13 :                     $$->typmods = NIL;
                              15103                 :                :                 }
                              15104                 :                :         ;
                              15105                 :                : 
                              15106                 :                : CharacterWithLength:  character '(' Iconst ')'
                              15107                 :                :                 {
 8952                         15108                 :           1091 :                     $$ = SystemTypeName($1);
 6643                         15109                 :           1091 :                     $$->typmods = list_make1(makeIntConst($3, @3));
 7250                         15110                 :           1091 :                     $$->location = @1;
                              15111                 :                :                 }
                              15112                 :                :         ;
                              15113                 :                : 
                              15114                 :                : CharacterWithoutLength:  character
                              15115                 :                :                 {
 8952                         15116                 :            841 :                     $$ = SystemTypeName($1);
                              15117                 :                :                     /* char defaults to char(1), varchar to no limit */
 9124                         15118         [ +  + ]:            841 :                     if (strcmp($1, "bpchar") == 0)
 6643                         15119                 :            153 :                         $$->typmods = list_make1(makeIntConst(1, -1));
 7250                         15120                 :            841 :                     $$->location = @1;
                              15121                 :                :                 }
                              15122                 :                :         ;
                              15123                 :                : 
                              15124                 :                : character:  CHARACTER opt_varying
 8907 bruce@momjian.us        15125         [ +  + ]:            325 :                                         { $$ = $2 ? "varchar": "bpchar"; }
                              15126                 :                :             | CHAR_P opt_varying
                              15127         [ -  + ]:            727 :                                         { $$ = $2 ? "varchar": "bpchar"; }
                              15128                 :                :             | VARCHAR
                              15129                 :            879 :                                         { $$ = "varchar"; }
                              15130                 :                :             | NATIONAL CHARACTER opt_varying
 8907 bruce@momjian.us        15131         [ #  # ]:UBC           0 :                                         { $$ = $3 ? "varchar": "bpchar"; }
                              15132                 :                :             | NATIONAL CHAR_P opt_varying
                              15133         [ #  # ]:              0 :                                         { $$ = $3 ? "varchar": "bpchar"; }
                              15134                 :                :             | NCHAR opt_varying
 8907 bruce@momjian.us        15135         [ -  + ]:CBC           1 :                                         { $$ = $2 ? "varchar": "bpchar"; }
                              15136                 :                :         ;
                              15137                 :                : 
                              15138                 :                : opt_varying:
 3368 peter_e@gmx.net         15139                 :            272 :             VARYING                                 { $$ = true; }
                              15140                 :           2066 :             | /*EMPTY*/                             { $$ = false; }
                              15141                 :                :         ;
                              15142                 :                : 
                              15143                 :                : /*
                              15144                 :                :  * SQL date/time types
                              15145                 :                :  */
                              15146                 :                : ConstDatetime:
                              15147                 :                :             TIMESTAMP '(' Iconst ')' opt_timezone
                              15148                 :                :                 {
 9164 lockhart@fourpalms.o    15149         [ +  + ]:             81 :                     if ($5)
 8952 tgl@sss.pgh.pa.us       15150                 :             66 :                         $$ = SystemTypeName("timestamptz");
                              15151                 :                :                     else
                              15152                 :             15 :                         $$ = SystemTypeName("timestamp");
 6643                         15153                 :             81 :                     $$->typmods = list_make1(makeIntConst($3, @3));
 7250                         15154                 :             81 :                     $$->location = @1;
                              15155                 :                :                 }
                              15156                 :                :             | TIMESTAMP opt_timezone
                              15157                 :                :                 {
 9169 lockhart@fourpalms.o    15158         [ +  + ]:           3240 :                     if ($2)
 8952 tgl@sss.pgh.pa.us       15159                 :            782 :                         $$ = SystemTypeName("timestamptz");
                              15160                 :                :                     else
                              15161                 :           2458 :                         $$ = SystemTypeName("timestamp");
 7250                         15162                 :           3240 :                     $$->location = @1;
                              15163                 :                :                 }
                              15164                 :                :             | TIME '(' Iconst ')' opt_timezone
                              15165                 :                :                 {
 9164 lockhart@fourpalms.o    15166         [ +  + ]:             14 :                     if ($5)
 8952 tgl@sss.pgh.pa.us       15167                 :              5 :                         $$ = SystemTypeName("timetz");
                              15168                 :                :                     else
                              15169                 :              9 :                         $$ = SystemTypeName("time");
 6643                         15170                 :             14 :                     $$->typmods = list_make1(makeIntConst($3, @3));
 7250                         15171                 :             14 :                     $$->location = @1;
                              15172                 :                :                 }
                              15173                 :                :             | TIME opt_timezone
                              15174                 :                :                 {
 9732 lockhart@fourpalms.o    15175         [ +  + ]:           1557 :                     if ($2)
 8952 tgl@sss.pgh.pa.us       15176                 :            226 :                         $$ = SystemTypeName("timetz");
                              15177                 :                :                     else
                              15178                 :           1331 :                         $$ = SystemTypeName("time");
 7250                         15179                 :           1557 :                     $$->location = @1;
                              15180                 :                :                 }
                              15181                 :                :         ;
                              15182                 :                : 
                              15183                 :                : ConstInterval:
                              15184                 :                :             INTERVAL
                              15185                 :                :                 {
                              15186                 :           4511 :                     $$ = SystemTypeName("interval");
                              15187                 :           4511 :                     $$->location = @1;
                              15188                 :                :                 }
                              15189                 :                :         ;
                              15190                 :                : 
                              15191                 :                : opt_timezone:
 3368 peter_e@gmx.net         15192                 :           1079 :             WITH_LA TIME ZONE                       { $$ = true; }
 1311 alvherre@alvh.no-ip.    15193                 :            375 :             | WITHOUT_LA TIME ZONE                  { $$ = false; }
 3368 peter_e@gmx.net         15194                 :           3438 :             | /*EMPTY*/                             { $$ = false; }
                              15195                 :                :         ;
                              15196                 :                : 
                              15197                 :                : opt_interval:
                              15198                 :                :             YEAR_P
 6629 tgl@sss.pgh.pa.us       15199                 :              8 :                 { $$ = list_make1(makeIntConst(INTERVAL_MASK(YEAR), @1)); }
                              15200                 :                :             | MONTH_P
                              15201                 :             12 :                 { $$ = list_make1(makeIntConst(INTERVAL_MASK(MONTH), @1)); }
                              15202                 :                :             | DAY_P
                              15203                 :             12 :                 { $$ = list_make1(makeIntConst(INTERVAL_MASK(DAY), @1)); }
                              15204                 :                :             | HOUR_P
                              15205                 :              8 :                 { $$ = list_make1(makeIntConst(INTERVAL_MASK(HOUR), @1)); }
                              15206                 :                :             | MINUTE_P
                              15207                 :              8 :                 { $$ = list_make1(makeIntConst(INTERVAL_MASK(MINUTE), @1)); }
                              15208                 :                :             | interval_second
                              15209                 :             24 :                 { $$ = $1; }
                              15210                 :                :             | YEAR_P TO MONTH_P
                              15211                 :                :                 {
                              15212                 :             12 :                     $$ = list_make1(makeIntConst(INTERVAL_MASK(YEAR) |
                              15213                 :                :                                                  INTERVAL_MASK(MONTH), @1));
                              15214                 :                :                 }
                              15215                 :                :             | DAY_P TO HOUR_P
                              15216                 :                :                 {
                              15217                 :             16 :                     $$ = list_make1(makeIntConst(INTERVAL_MASK(DAY) |
                              15218                 :                :                                                  INTERVAL_MASK(HOUR), @1));
                              15219                 :                :                 }
                              15220                 :                :             | DAY_P TO MINUTE_P
                              15221                 :                :                 {
                              15222                 :             16 :                     $$ = list_make1(makeIntConst(INTERVAL_MASK(DAY) |
                              15223                 :                :                                                  INTERVAL_MASK(HOUR) |
                              15224                 :                :                                                  INTERVAL_MASK(MINUTE), @1));
                              15225                 :                :                 }
                              15226                 :                :             | DAY_P TO interval_second
                              15227                 :                :                 {
                              15228                 :             32 :                     $$ = $3;
                              15229                 :             32 :                     linitial($$) = makeIntConst(INTERVAL_MASK(DAY) |
                              15230                 :                :                                                 INTERVAL_MASK(HOUR) |
                              15231                 :                :                                                 INTERVAL_MASK(MINUTE) |
                              15232                 :             32 :                                                 INTERVAL_MASK(SECOND), @1);
                              15233                 :                :                 }
                              15234                 :                :             | HOUR_P TO MINUTE_P
                              15235                 :                :                 {
                              15236                 :             12 :                     $$ = list_make1(makeIntConst(INTERVAL_MASK(HOUR) |
                              15237                 :                :                                                  INTERVAL_MASK(MINUTE), @1));
                              15238                 :                :                 }
                              15239                 :                :             | HOUR_P TO interval_second
                              15240                 :                :                 {
                              15241                 :             24 :                     $$ = $3;
                              15242                 :             24 :                     linitial($$) = makeIntConst(INTERVAL_MASK(HOUR) |
                              15243                 :                :                                                 INTERVAL_MASK(MINUTE) |
                              15244                 :             24 :                                                 INTERVAL_MASK(SECOND), @1);
                              15245                 :                :                 }
                              15246                 :                :             | MINUTE_P TO interval_second
                              15247                 :                :                 {
                              15248                 :             44 :                     $$ = $3;
                              15249                 :             44 :                     linitial($$) = makeIntConst(INTERVAL_MASK(MINUTE) |
                              15250                 :             44 :                                                 INTERVAL_MASK(SECOND), @1);
                              15251                 :                :                 }
                              15252                 :                :             | /*EMPTY*/
                              15253                 :           4275 :                 { $$ = NIL; }
                              15254                 :                :         ;
                              15255                 :                : 
                              15256                 :                : interval_second:
                              15257                 :                :             SECOND_P
                              15258                 :                :                 {
                              15259                 :             68 :                     $$ = list_make1(makeIntConst(INTERVAL_MASK(SECOND), @1));
                              15260                 :                :                 }
                              15261                 :                :             | SECOND_P '(' Iconst ')'
                              15262                 :                :                 {
                              15263                 :             56 :                     $$ = list_make2(makeIntConst(INTERVAL_MASK(SECOND), @1),
                              15264                 :                :                                     makeIntConst($3, @3));
                              15265                 :                :                 }
                              15266                 :                :         ;
                              15267                 :                : 
                              15268                 :                : JsonType:
                              15269                 :                :             JSON
                              15270                 :                :                 {
 1204 amitlan@postgresql.o    15271                 :           1373 :                     $$ = SystemTypeName("json");
                              15272                 :           1373 :                     $$->location = @1;
                              15273                 :                :                 }
                              15274                 :                :         ;
                              15275                 :                : 
                              15276                 :                : /*****************************************************************************
                              15277                 :                :  *
                              15278                 :                :  *  expression grammar
                              15279                 :                :  *
                              15280                 :                :  *****************************************************************************/
                              15281                 :                : 
                              15282                 :                : /*
                              15283                 :                :  * General expressions
                              15284                 :                :  * This is the heart of the expression syntax.
                              15285                 :                :  *
                              15286                 :                :  * We have two expression types: a_expr is the unrestricted kind, and
                              15287                 :                :  * b_expr is a subset that must be used in some places to avoid shift/reduce
                              15288                 :                :  * conflicts.  For example, we can't do BETWEEN as "BETWEEN a_expr AND a_expr"
                              15289                 :                :  * because that use of AND conflicts with AND as a boolean operator.  So,
                              15290                 :                :  * b_expr is used in BETWEEN and we remove boolean keywords from b_expr.
                              15291                 :                :  *
                              15292                 :                :  * Note that '(' a_expr ')' is a b_expr, so an unrestricted expression can
                              15293                 :                :  * always be used by surrounding it with parens.
                              15294                 :                :  *
                              15295                 :                :  * c_expr is all the productions that are common to a_expr and b_expr;
                              15296                 :                :  * it's factored out just to eliminate redundant coding.
                              15297                 :                :  *
                              15298                 :                :  * Be careful of productions involving more than one terminal token.
                              15299                 :                :  * By default, bison will assign such productions the precedence of their
                              15300                 :                :  * last terminal, but in nearly all cases you want it to be the precedence
                              15301                 :                :  * of the first terminal instead; otherwise you will not get the behavior
                              15302                 :                :  * you expect!  So we use %prec annotations freely to set precedences.
                              15303                 :                :  */
 8907 bruce@momjian.us        15304                 :        2391078 : a_expr:     c_expr                                  { $$ = $1; }
                              15305                 :                :             | a_expr TYPECAST Typename
 6643 tgl@sss.pgh.pa.us       15306                 :         146328 :                     { $$ = makeTypeCast($1, $3, @2); }
                              15307                 :                :             | a_expr COLLATE any_name
                              15308                 :                :                 {
 5720                         15309                 :           6661 :                     CollateClause *n = makeNode(CollateClause);
                              15310                 :                : 
 5718                         15311                 :           6661 :                     n->arg = $1;
                              15312                 :           6661 :                     n->collname = $3;
 5720                         15313                 :           6661 :                     n->location = @2;
                              15314                 :           6661 :                     $$ = (Node *) n;
                              15315                 :                :                 }
                              15316                 :                :             | a_expr AT TIME ZONE a_expr            %prec AT
                              15317                 :                :                 {
 4875 rhaas@postgresql.org    15318                 :            272 :                     $$ = (Node *) makeFuncCall(SystemFuncName("timezone"),
                              15319                 :            272 :                                                list_make2($5, $1),
                              15320                 :                :                                                COERCE_SQL_SYNTAX,
                              15321                 :            272 :                                                @2);
                              15322                 :                :                 }
                              15323                 :                :             | a_expr AT LOCAL                       %prec AT
                              15324                 :                :                 {
 1119 michael@paquier.xyz     15325                 :             28 :                     $$ = (Node *) makeFuncCall(SystemFuncName("timezone"),
                              15326                 :             28 :                                                list_make1($1),
                              15327                 :                :                                                COERCE_SQL_SYNTAX,
                              15328                 :                :                                                -1);
                              15329                 :                :                 }
                              15330                 :                :         /*
                              15331                 :                :          * These operators must be called out explicitly in order to make use
                              15332                 :                :          * of bison's automatic operator-precedence handling.  All other
                              15333                 :                :          * operator names are handled by the generic productions using "Op",
                              15334                 :                :          * below; and all those operators will have the same precedence.
                              15335                 :                :          *
                              15336                 :                :          * If you add more explicitly-known operators, be sure to add them
                              15337                 :                :          * also to b_expr and to the MathOp list below.
                              15338                 :                :          */
                              15339                 :                :             | '+' a_expr                    %prec UMINUS
 7541 tgl@sss.pgh.pa.us       15340                 :              8 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", NULL, $2, @1); }
                              15341                 :                :             | '-' a_expr                    %prec UMINUS
                              15342                 :           6413 :                 { $$ = doNegate($2, @1); }
                              15343                 :                :             | a_expr '+' a_expr
                              15344                 :           9859 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", $1, $3, @2); }
                              15345                 :                :             | a_expr '-' a_expr
                              15346                 :           2909 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "-", $1, $3, @2); }
                              15347                 :                :             | a_expr '*' a_expr
                              15348                 :           4305 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "*", $1, $3, @2); }
                              15349                 :                :             | a_expr '/' a_expr
                              15350                 :           2294 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "/", $1, $3, @2); }
                              15351                 :                :             | a_expr '%' a_expr
                              15352                 :           2107 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "%", $1, $3, @2); }
                              15353                 :                :             | a_expr '^' a_expr
                              15354                 :            314 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "^", $1, $3, @2); }
                              15355                 :                :             | a_expr '<' a_expr
                              15356                 :           7060 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $3, @2); }
                              15357                 :                :             | a_expr '>' a_expr
                              15358                 :          11048 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $3, @2); }
                              15359                 :                :             | a_expr '=' a_expr
                              15360                 :         259886 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "=", $1, $3, @2); }
                              15361                 :                :             | a_expr LESS_EQUALS a_expr
 4257                         15362                 :           3115 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $3, @2); }
                              15363                 :                :             | a_expr GREATER_EQUALS a_expr
                              15364                 :           7487 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $3, @2); }
                              15365                 :                :             | a_expr NOT_EQUALS a_expr
                              15366                 :          24064 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<>", $1, $3, @2); }
                              15367                 :                : 
                              15368                 :                :             | a_expr qual_Op a_expr             %prec Op
 7541                         15369                 :          37634 :                 { $$ = (Node *) makeA_Expr(AEXPR_OP, $2, $1, $3, @2); }
                              15370                 :                :             | qual_Op a_expr                    %prec Op
                              15371                 :            157 :                 { $$ = (Node *) makeA_Expr(AEXPR_OP, $1, NULL, $2, @1); }
                              15372                 :                : 
                              15373                 :                :             | a_expr AND a_expr
 4525                         15374                 :         155577 :                 { $$ = makeAndExpr($1, $3, @2); }
                              15375                 :                :             | a_expr OR a_expr
                              15376                 :          14007 :                 { $$ = makeOrExpr($1, $3, @2); }
                              15377                 :                :             | NOT a_expr
                              15378                 :          17006 :                 { $$ = makeNotExpr($2, @1); }
                              15379                 :                :             | NOT_LA a_expr                     %prec NOT
 4257 tgl@sss.pgh.pa.us       15380                 :UBC           0 :                 { $$ = makeNotExpr($2, @1); }
                              15381                 :                : 
                              15382                 :                :             | a_expr LIKE a_expr
                              15383                 :                :                 {
 4273 tgl@sss.pgh.pa.us       15384                 :CBC        1347 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_LIKE, "~~",
                              15385                 :           1347 :                                                    $1, $3, @2);
                              15386                 :                :                 }
                              15387                 :                :             | a_expr LIKE a_expr ESCAPE a_expr                  %prec LIKE
                              15388                 :                :                 {
 1637 peter@eisentraut.org    15389                 :             80 :                     FuncCall   *n = makeFuncCall(SystemFuncName("like_escape"),
                              15390                 :             80 :                                                  list_make2($3, $5),
                              15391                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15392                 :             80 :                                                  @2);
 4273 tgl@sss.pgh.pa.us       15393                 :             80 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_LIKE, "~~",
                              15394                 :             80 :                                                    $1, (Node *) n, @2);
                              15395                 :                :                 }
                              15396                 :                :             | a_expr NOT_LA LIKE a_expr                         %prec NOT_LA
                              15397                 :                :                 {
                              15398                 :            133 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_LIKE, "!~~",
                              15399                 :            133 :                                                    $1, $4, @2);
                              15400                 :                :                 }
                              15401                 :                :             | a_expr NOT_LA LIKE a_expr ESCAPE a_expr           %prec NOT_LA
                              15402                 :                :                 {
 1637 peter@eisentraut.org    15403                 :             64 :                     FuncCall   *n = makeFuncCall(SystemFuncName("like_escape"),
                              15404                 :             64 :                                                  list_make2($4, $6),
                              15405                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15406                 :             64 :                                                  @2);
 4273 tgl@sss.pgh.pa.us       15407                 :             64 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_LIKE, "!~~",
                              15408                 :             64 :                                                    $1, (Node *) n, @2);
                              15409                 :                :                 }
                              15410                 :                :             | a_expr ILIKE a_expr
                              15411                 :                :                 {
                              15412                 :            116 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_ILIKE, "~~*",
                              15413                 :            116 :                                                    $1, $3, @2);
                              15414                 :                :                 }
                              15415                 :                :             | a_expr ILIKE a_expr ESCAPE a_expr                 %prec ILIKE
                              15416                 :                :                 {
 1637 peter@eisentraut.org    15417                 :UBC           0 :                     FuncCall   *n = makeFuncCall(SystemFuncName("like_escape"),
                              15418                 :              0 :                                                  list_make2($3, $5),
                              15419                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15420                 :              0 :                                                  @2);
 4273 tgl@sss.pgh.pa.us       15421                 :              0 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_ILIKE, "~~*",
                              15422                 :              0 :                                                    $1, (Node *) n, @2);
                              15423                 :                :                 }
                              15424                 :                :             | a_expr NOT_LA ILIKE a_expr                        %prec NOT_LA
                              15425                 :                :                 {
 4273 tgl@sss.pgh.pa.us       15426                 :CBC          20 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_ILIKE, "!~~*",
                              15427                 :             20 :                                                    $1, $4, @2);
                              15428                 :                :                 }
                              15429                 :                :             | a_expr NOT_LA ILIKE a_expr ESCAPE a_expr          %prec NOT_LA
                              15430                 :                :                 {
 1637 peter@eisentraut.org    15431                 :UBC           0 :                     FuncCall   *n = makeFuncCall(SystemFuncName("like_escape"),
                              15432                 :              0 :                                                  list_make2($4, $6),
                              15433                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15434                 :              0 :                                                  @2);
 4273 tgl@sss.pgh.pa.us       15435                 :              0 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_ILIKE, "!~~*",
                              15436                 :              0 :                                                    $1, (Node *) n, @2);
                              15437                 :                :                 }
                              15438                 :                : 
                              15439                 :                :             | a_expr SIMILAR TO a_expr                          %prec SIMILAR
                              15440                 :                :                 {
 1637 peter@eisentraut.org    15441                 :CBC          58 :                     FuncCall   *n = makeFuncCall(SystemFuncName("similar_to_escape"),
                              15442                 :             58 :                                                  list_make1($4),
                              15443                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15444                 :             58 :                                                  @2);
 4273 tgl@sss.pgh.pa.us       15445                 :             58 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_SIMILAR, "~",
                              15446                 :             58 :                                                    $1, (Node *) n, @2);
                              15447                 :                :                 }
                              15448                 :                :             | a_expr SIMILAR TO a_expr ESCAPE a_expr            %prec SIMILAR
                              15449                 :                :                 {
 1637 peter@eisentraut.org    15450                 :             24 :                     FuncCall   *n = makeFuncCall(SystemFuncName("similar_to_escape"),
                              15451                 :             24 :                                                  list_make2($4, $6),
                              15452                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15453                 :             24 :                                                  @2);
 4273 tgl@sss.pgh.pa.us       15454                 :             24 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_SIMILAR, "~",
                              15455                 :             24 :                                                    $1, (Node *) n, @2);
                              15456                 :                :                 }
                              15457                 :                :             | a_expr NOT_LA SIMILAR TO a_expr                   %prec NOT_LA
                              15458                 :                :                 {
 1637 peter@eisentraut.org    15459                 :UBC           0 :                     FuncCall   *n = makeFuncCall(SystemFuncName("similar_to_escape"),
                              15460                 :              0 :                                                  list_make1($5),
                              15461                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15462                 :              0 :                                                  @2);
 4273 tgl@sss.pgh.pa.us       15463                 :              0 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_SIMILAR, "!~",
                              15464                 :              0 :                                                    $1, (Node *) n, @2);
                              15465                 :                :                 }
                              15466                 :                :             | a_expr NOT_LA SIMILAR TO a_expr ESCAPE a_expr     %prec NOT_LA
                              15467                 :                :                 {
 1637 peter@eisentraut.org    15468                 :              0 :                     FuncCall   *n = makeFuncCall(SystemFuncName("similar_to_escape"),
                              15469                 :              0 :                                                  list_make2($5, $7),
                              15470                 :                :                                                  COERCE_EXPLICIT_CALL,
                              15471                 :              0 :                                                  @2);
 4273 tgl@sss.pgh.pa.us       15472                 :              0 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_SIMILAR, "!~",
                              15473                 :              0 :                                                    $1, (Node *) n, @2);
                              15474                 :                :                 }
                              15475                 :                : 
                              15476                 :                :             /* NullTest clause
                              15477                 :                :              * Define SQL-style Null test clause.
                              15478                 :                :              * Allow two forms described in the standard:
                              15479                 :                :              *  a IS NULL
                              15480                 :                :              *  a IS NOT NULL
                              15481                 :                :              * Allow two SQL extensions
                              15482                 :                :              *  a ISNULL
                              15483                 :                :              *  a NOTNULL
                              15484                 :                :              */
                              15485                 :                :             | a_expr IS NULL_P                          %prec IS
                              15486                 :                :                 {
 1637 peter@eisentraut.org    15487                 :CBC        3892 :                     NullTest   *n = makeNode(NullTest);
                              15488                 :                : 
 7343 tgl@sss.pgh.pa.us       15489                 :           3892 :                     n->arg = (Expr *) $1;
                              15490                 :           3892 :                     n->nulltesttype = IS_NULL;
 4274                         15491                 :           3892 :                     n->location = @2;
 1637 peter@eisentraut.org    15492                 :           3892 :                     $$ = (Node *) n;
                              15493                 :                :                 }
                              15494                 :                :             | a_expr ISNULL
                              15495                 :                :                 {
                              15496                 :             70 :                     NullTest   *n = makeNode(NullTest);
                              15497                 :                : 
 7343 tgl@sss.pgh.pa.us       15498                 :             70 :                     n->arg = (Expr *) $1;
                              15499                 :             70 :                     n->nulltesttype = IS_NULL;
 4274                         15500                 :             70 :                     n->location = @2;
 1637 peter@eisentraut.org    15501                 :             70 :                     $$ = (Node *) n;
                              15502                 :                :                 }
                              15503                 :                :             | a_expr IS NOT NULL_P                      %prec IS
                              15504                 :                :                 {
                              15505                 :           8336 :                     NullTest   *n = makeNode(NullTest);
                              15506                 :                : 
 7343 tgl@sss.pgh.pa.us       15507                 :           8336 :                     n->arg = (Expr *) $1;
                              15508                 :           8336 :                     n->nulltesttype = IS_NOT_NULL;
 4274                         15509                 :           8336 :                     n->location = @2;
 1637 peter@eisentraut.org    15510                 :           8336 :                     $$ = (Node *) n;
                              15511                 :                :                 }
                              15512                 :                :             | a_expr NOTNULL
                              15513                 :                :                 {
                              15514                 :              4 :                     NullTest   *n = makeNode(NullTest);
                              15515                 :                : 
 7343 tgl@sss.pgh.pa.us       15516                 :              4 :                     n->arg = (Expr *) $1;
                              15517                 :              4 :                     n->nulltesttype = IS_NOT_NULL;
 4274                         15518                 :              4 :                     n->location = @2;
 1637 peter@eisentraut.org    15519                 :              4 :                     $$ = (Node *) n;
                              15520                 :                :                 }
                              15521                 :                :             | row OVERLAPS row
                              15522                 :                :                 {
 4643 tgl@sss.pgh.pa.us       15523         [ -  + ]:            581 :                     if (list_length($1) != 2)
 4643 tgl@sss.pgh.pa.us       15524         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              15525                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                              15526                 :                :                                  errmsg("wrong number of parameters on left side of OVERLAPS expression"),
                              15527                 :                :                                  parser_errposition(@1)));
 4643 tgl@sss.pgh.pa.us       15528         [ -  + ]:CBC         581 :                     if (list_length($3) != 2)
 4643 tgl@sss.pgh.pa.us       15529         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              15530                 :                :                                 (errcode(ERRCODE_SYNTAX_ERROR),
                              15531                 :                :                                  errmsg("wrong number of parameters on right side of OVERLAPS expression"),
                              15532                 :                :                                  parser_errposition(@3)));
 4643 tgl@sss.pgh.pa.us       15533                 :CBC         581 :                     $$ = (Node *) makeFuncCall(SystemFuncName("overlaps"),
                              15534                 :            581 :                                                list_concat($1, $3),
                              15535                 :                :                                                COERCE_SQL_SYNTAX,
                              15536                 :            581 :                                                @2);
                              15537                 :                :                 }
                              15538                 :                :             | a_expr IS TRUE_P                          %prec IS
                              15539                 :                :                 {
 9270                         15540                 :            264 :                     BooleanTest *b = makeNode(BooleanTest);
                              15541                 :                : 
 8729                         15542                 :            264 :                     b->arg = (Expr *) $1;
 9270                         15543                 :            264 :                     b->booltesttype = IS_TRUE;
 4274                         15544                 :            264 :                     b->location = @2;
 1637 peter@eisentraut.org    15545                 :            264 :                     $$ = (Node *) b;
                              15546                 :                :                 }
                              15547                 :                :             | a_expr IS NOT TRUE_P                      %prec IS
                              15548                 :                :                 {
 9270 tgl@sss.pgh.pa.us       15549                 :            100 :                     BooleanTest *b = makeNode(BooleanTest);
                              15550                 :                : 
 8729                         15551                 :            100 :                     b->arg = (Expr *) $1;
 9270                         15552                 :            100 :                     b->booltesttype = IS_NOT_TRUE;
 4274                         15553                 :            100 :                     b->location = @2;
 1637 peter@eisentraut.org    15554                 :            100 :                     $$ = (Node *) b;
                              15555                 :                :                 }
                              15556                 :                :             | a_expr IS FALSE_P                         %prec IS
                              15557                 :                :                 {
 9270 tgl@sss.pgh.pa.us       15558                 :            159 :                     BooleanTest *b = makeNode(BooleanTest);
                              15559                 :                : 
 8729                         15560                 :            159 :                     b->arg = (Expr *) $1;
 9270                         15561                 :            159 :                     b->booltesttype = IS_FALSE;
 4274                         15562                 :            159 :                     b->location = @2;
 1637 peter@eisentraut.org    15563                 :            159 :                     $$ = (Node *) b;
                              15564                 :                :                 }
                              15565                 :                :             | a_expr IS NOT FALSE_P                     %prec IS
                              15566                 :                :                 {
 9270 tgl@sss.pgh.pa.us       15567                 :             70 :                     BooleanTest *b = makeNode(BooleanTest);
                              15568                 :                : 
 8729                         15569                 :             70 :                     b->arg = (Expr *) $1;
 9270                         15570                 :             70 :                     b->booltesttype = IS_NOT_FALSE;
 4274                         15571                 :             70 :                     b->location = @2;
 1637 peter@eisentraut.org    15572                 :             70 :                     $$ = (Node *) b;
                              15573                 :                :                 }
                              15574                 :                :             | a_expr IS UNKNOWN                         %prec IS
                              15575                 :                :                 {
 9270 tgl@sss.pgh.pa.us       15576                 :             50 :                     BooleanTest *b = makeNode(BooleanTest);
                              15577                 :                : 
 8729                         15578                 :             50 :                     b->arg = (Expr *) $1;
 9270                         15579                 :             50 :                     b->booltesttype = IS_UNKNOWN;
 4274                         15580                 :             50 :                     b->location = @2;
 1637 peter@eisentraut.org    15581                 :             50 :                     $$ = (Node *) b;
                              15582                 :                :                 }
                              15583                 :                :             | a_expr IS NOT UNKNOWN                     %prec IS
                              15584                 :                :                 {
 9270 tgl@sss.pgh.pa.us       15585                 :             40 :                     BooleanTest *b = makeNode(BooleanTest);
                              15586                 :                : 
 8729                         15587                 :             40 :                     b->arg = (Expr *) $1;
 9270                         15588                 :             40 :                     b->booltesttype = IS_NOT_UNKNOWN;
 4274                         15589                 :             40 :                     b->location = @2;
 1637 peter@eisentraut.org    15590                 :             40 :                     $$ = (Node *) b;
                              15591                 :                :                 }
                              15592                 :                :             | a_expr IS DISTINCT FROM a_expr            %prec IS
                              15593                 :                :                 {
 7541 tgl@sss.pgh.pa.us       15594                 :            656 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", $1, $5, @2);
                              15595                 :                :                 }
                              15596                 :                :             | a_expr IS NOT DISTINCT FROM a_expr        %prec IS
                              15597                 :                :                 {
 3752                         15598                 :             84 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_NOT_DISTINCT, "=", $1, $6, @2);
                              15599                 :                :                 }
                              15600                 :                :             | a_expr BETWEEN opt_asymmetric b_expr AND a_expr       %prec BETWEEN
                              15601                 :                :                 {
 4274                         15602                 :            316 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_BETWEEN,
                              15603                 :                :                                                    "BETWEEN",
                              15604                 :            316 :                                                    $1,
                              15605                 :            316 :                                                    (Node *) list_make2($4, $6),
                              15606                 :            316 :                                                    @2);
                              15607                 :                :                 }
                              15608                 :                :             | a_expr NOT_LA BETWEEN opt_asymmetric b_expr AND a_expr %prec NOT_LA
                              15609                 :                :                 {
                              15610                 :              8 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_NOT_BETWEEN,
                              15611                 :                :                                                    "NOT BETWEEN",
                              15612                 :              8 :                                                    $1,
                              15613                 :              8 :                                                    (Node *) list_make2($5, $7),
                              15614                 :              8 :                                                    @2);
                              15615                 :                :                 }
                              15616                 :                :             | a_expr BETWEEN SYMMETRIC b_expr AND a_expr            %prec BETWEEN
                              15617                 :                :                 {
                              15618                 :              8 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_BETWEEN_SYM,
                              15619                 :                :                                                    "BETWEEN SYMMETRIC",
                              15620                 :              8 :                                                    $1,
                              15621                 :              8 :                                                    (Node *) list_make2($4, $6),
                              15622                 :              8 :                                                    @2);
                              15623                 :                :                 }
                              15624                 :                :             | a_expr NOT_LA BETWEEN SYMMETRIC b_expr AND a_expr     %prec NOT_LA
                              15625                 :                :                 {
                              15626                 :              8 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_NOT_BETWEEN_SYM,
                              15627                 :                :                                                    "NOT BETWEEN SYMMETRIC",
                              15628                 :              8 :                                                    $1,
                              15629                 :              8 :                                                    (Node *) list_make2($5, $7),
                              15630                 :              8 :                                                    @2);
                              15631                 :                :                 }
                              15632                 :                :             | a_expr IN_P select_with_parens
                              15633                 :                :                 {
                              15634                 :                :                     /* generate foo = ANY (subquery) */
  511 alvherre@kurilemu.de    15635                 :           3762 :                     SubLink    *n = makeNode(SubLink);
                              15636                 :                : 
                              15637                 :           3762 :                     n->subselect = $3;
                              15638                 :           3762 :                     n->subLinkType = ANY_SUBLINK;
                              15639                 :           3762 :                     n->subLinkId = 0;
                              15640                 :           3762 :                     n->testexpr = $1;
                              15641                 :           3762 :                     n->operName = NIL;       /* show it's IN not = ANY */
                              15642                 :           3762 :                     n->location = @2;
                              15643                 :           3762 :                     $$ = (Node *) n;
                              15644                 :                :                 }
                              15645                 :                :             | a_expr IN_P '(' expr_list ')'
                              15646                 :                :                 {
                              15647                 :                :                     /* generate scalar IN expression */
                              15648                 :          10935 :                     A_Expr *n = makeSimpleA_Expr(AEXPR_IN, "=", $1, (Node *) $4, @2);
                              15649                 :                : 
                              15650                 :          10935 :                     n->rexpr_list_start = @3;
                              15651                 :          10935 :                     n->rexpr_list_end = @5;
                              15652                 :          10935 :                     $$ = (Node *) n;
                              15653                 :                :                 }
                              15654                 :                :             | a_expr NOT_LA IN_P select_with_parens         %prec NOT_LA
                              15655                 :                :                 {
                              15656                 :                :                     /* generate NOT (foo = ANY (subquery)) */
                              15657                 :            204 :                     SubLink    *n = makeNode(SubLink);
                              15658                 :                : 
                              15659                 :            204 :                     n->subselect = $4;
                              15660                 :            204 :                     n->subLinkType = ANY_SUBLINK;
                              15661                 :            204 :                     n->subLinkId = 0;
                              15662                 :            204 :                     n->testexpr = $1;
                              15663                 :            204 :                     n->operName = NIL;       /* show it's IN not = ANY */
                              15664                 :            204 :                     n->location = @2;
                              15665                 :                :                     /* Stick a NOT on top; must have same parse location */
                              15666                 :            204 :                     $$ = makeNotExpr((Node *) n, @2);
                              15667                 :                :                 }
                              15668                 :                :             | a_expr NOT_LA IN_P '(' expr_list ')'
                              15669                 :                :                 {
                              15670                 :                :                     /* generate scalar NOT IN expression */
                              15671                 :           1699 :                     A_Expr *n = makeSimpleA_Expr(AEXPR_IN, "<>", $1, (Node *) $5, @2);
                              15672                 :                : 
                              15673                 :           1699 :                     n->rexpr_list_start = @4;
                              15674                 :           1699 :                     n->rexpr_list_end = @6;
                              15675                 :           1699 :                     $$ = (Node *) n;
                              15676                 :                :                 }
                              15677                 :                :             | a_expr subquery_Op sub_type select_with_parens    %prec Op
                              15678                 :                :                 {
 1637 peter@eisentraut.org    15679                 :            140 :                     SubLink    *n = makeNode(SubLink);
                              15680                 :                : 
 9852 tgl@sss.pgh.pa.us       15681                 :            140 :                     n->subLinkType = $3;
 4523                         15682                 :            140 :                     n->subLinkId = 0;
 7617                         15683                 :            140 :                     n->testexpr = $1;
 8700                         15684                 :            140 :                     n->operName = $2;
 9425                         15685                 :            140 :                     n->subselect = $4;
 6643                         15686                 :            140 :                     n->location = @2;
 1637 peter@eisentraut.org    15687                 :            140 :                     $$ = (Node *) n;
                              15688                 :                :                 }
                              15689                 :                :             | a_expr subquery_Op sub_type '(' a_expr ')'        %prec Op
                              15690                 :                :                 {
 8530 tgl@sss.pgh.pa.us       15691         [ +  + ]:          11141 :                     if ($3 == ANY_SUBLINK)
 7541                         15692                 :          10936 :                         $$ = (Node *) makeA_Expr(AEXPR_OP_ANY, $2, $1, $5, @2);
                              15693                 :                :                     else
                              15694                 :            205 :                         $$ = (Node *) makeA_Expr(AEXPR_OP_ALL, $2, $1, $5, @2);
                              15695                 :                :                 }
                              15696                 :                :             | UNIQUE opt_unique_null_treatment select_with_parens
                              15697                 :                :                 {
                              15698                 :                :                     /* Not sure how to get rid of the parentheses
                              15699                 :                :                      * but there are lots of shift/reduce errors without them.
                              15700                 :                :                      *
                              15701                 :                :                      * Should be able to implement this by plopping the entire
                              15702                 :                :                      * select into a node, then transforming the target expressions
                              15703                 :                :                      * from whatever they are into count(*), and testing the
                              15704                 :                :                      * entire result equal to one.
                              15705                 :                :                      * But, will probably implement a separate node in the executor.
                              15706                 :                :                      */
 8510 tgl@sss.pgh.pa.us       15707         [ #  # ]:UBC           0 :                     ereport(ERROR,
                              15708                 :                :                             (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              15709                 :                :                              errmsg("UNIQUE predicate is not yet implemented"),
                              15710                 :                :                              parser_errposition(@1)));
                              15711                 :                :                 }
                              15712                 :                :             | a_expr IS DOCUMENT_P                  %prec IS
                              15713                 :                :                 {
 6643 tgl@sss.pgh.pa.us       15714                 :CBC          28 :                     $$ = makeXmlExpr(IS_DOCUMENT, NULL, NIL,
                              15715                 :             28 :                                      list_make1($1), @2);
                              15716                 :                :                 }
                              15717                 :                :             | a_expr IS NOT DOCUMENT_P              %prec IS
                              15718                 :                :                 {
 4525                         15719                 :             12 :                     $$ = makeNotExpr(makeXmlExpr(IS_DOCUMENT, NULL, NIL,
                              15720                 :             12 :                                                  list_make1($1), @2),
                              15721                 :             12 :                                      @2);
                              15722                 :                :                 }
                              15723                 :                :             | a_expr IS NORMALIZED                              %prec IS
                              15724                 :                :                 {
 2192                         15725                 :             12 :                     $$ = (Node *) makeFuncCall(SystemFuncName("is_normalized"),
                              15726                 :             12 :                                                list_make1($1),
                              15727                 :                :                                                COERCE_SQL_SYNTAX,
                              15728                 :             12 :                                                @2);
                              15729                 :                :                 }
                              15730                 :                :             | a_expr IS unicode_normal_form NORMALIZED          %prec IS
                              15731                 :                :                 {
                              15732                 :             48 :                     $$ = (Node *) makeFuncCall(SystemFuncName("is_normalized"),
                              15733                 :             24 :                                                list_make2($1, makeStringConst($3, @3)),
                              15734                 :                :                                                COERCE_SQL_SYNTAX,
                              15735                 :             24 :                                                @2);
                              15736                 :                :                 }
                              15737                 :                :             | a_expr IS NOT NORMALIZED                          %prec IS
                              15738                 :                :                 {
 2192 tgl@sss.pgh.pa.us       15739                 :UBC           0 :                     $$ = makeNotExpr((Node *) makeFuncCall(SystemFuncName("is_normalized"),
                              15740                 :              0 :                                                            list_make1($1),
                              15741                 :                :                                                            COERCE_SQL_SYNTAX,
                              15742                 :              0 :                                                            @2),
                              15743                 :              0 :                                      @2);
                              15744                 :                :                 }
                              15745                 :                :             | a_expr IS NOT unicode_normal_form NORMALIZED      %prec IS
                              15746                 :                :                 {
                              15747                 :              0 :                     $$ = makeNotExpr((Node *) makeFuncCall(SystemFuncName("is_normalized"),
                              15748                 :              0 :                                                            list_make2($1, makeStringConst($4, @4)),
                              15749                 :                :                                                            COERCE_SQL_SYNTAX,
                              15750                 :              0 :                                                            @2),
                              15751                 :              0 :                                      @2);
                              15752                 :                :                 }
                              15753                 :                :             | a_expr IS json_predicate_type_constraint
                              15754                 :                :                     json_key_uniqueness_constraint_opt      %prec IS
                              15755                 :                :                 {
 1315 alvherre@alvh.no-ip.    15756                 :CBC         246 :                     JsonFormat *format = makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1);
                              15757                 :                : 
  237 andrew@dunslane.net     15758                 :            246 :                     $$ = makeJsonIsPredicate($1, format, $3, $4, InvalidOid, @1);
                              15759                 :                :                 }
                              15760                 :                :             /*
                              15761                 :                :              * Required by SQL/JSON, but there are conflicts
                              15762                 :                :             | a_expr
                              15763                 :                :                 json_format_clause
                              15764                 :                :                 IS  json_predicate_type_constraint
                              15765                 :                :                     json_key_uniqueness_constraint_opt      %prec IS
                              15766                 :                :                 {
                              15767                 :                :                     $$ = makeJsonIsPredicate($1, $2, $4, $5, InvalidOid, @1);
                              15768                 :                :                 }
                              15769                 :                :             */
                              15770                 :                :             | a_expr IS NOT
                              15771                 :                :                     json_predicate_type_constraint
                              15772                 :                :                     json_key_uniqueness_constraint_opt      %prec IS
                              15773                 :                :                 {
 1315 alvherre@alvh.no-ip.    15774                 :             34 :                     JsonFormat *format = makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1);
                              15775                 :                : 
  237 andrew@dunslane.net     15776                 :             34 :                     $$ = makeNotExpr(makeJsonIsPredicate($1, format, $4, $5, InvalidOid, @1), @1);
                              15777                 :                :                 }
                              15778                 :                :             /*
                              15779                 :                :              * Required by SQL/JSON, but there are conflicts
                              15780                 :                :             | a_expr
                              15781                 :                :                 json_format_clause
                              15782                 :                :                 IS NOT
                              15783                 :                :                     json_predicate_type_constraint
                              15784                 :                :                     json_key_uniqueness_constraint_opt      %prec IS
                              15785                 :                :                 {
                              15786                 :                :                     $$ = makeNotExpr(makeJsonIsPredicate($1, $2, $5, $6, InvalidOid, @1), @1);
                              15787                 :                :                 }
                              15788                 :                :             */
                              15789                 :                :             | DEFAULT
                              15790                 :                :                 {
                              15791                 :                :                     /*
                              15792                 :                :                      * The SQL spec only allows DEFAULT in "contextually typed
                              15793                 :                :                      * expressions", but for us, it's easier to allow it in
                              15794                 :                :                      * any a_expr and then throw error during parse analysis
                              15795                 :                :                      * if it's in an inappropriate context.  This way also
                              15796                 :                :                      * lets us say something smarter than "syntax error".
                              15797                 :                :                      */
 3635 tgl@sss.pgh.pa.us       15798                 :           1026 :                     SetToDefault *n = makeNode(SetToDefault);
                              15799                 :                : 
                              15800                 :                :                     /* parse analysis will fill in the rest */
                              15801                 :           1025 :                     n->location = @1;
 1637 peter@eisentraut.org    15802                 :           1025 :                     $$ = (Node *) n;
                              15803                 :                :                 }
                              15804                 :                :         ;
                              15805                 :                : 
                              15806                 :                : /*
                              15807                 :                :  * Restricted expressions
                              15808                 :                :  *
                              15809                 :                :  * b_expr is a subset of the complete expression syntax defined by a_expr.
                              15810                 :                :  *
                              15811                 :                :  * Presently, AND, NOT, IS, and IN are the a_expr keywords that would
                              15812                 :                :  * cause trouble in the places where b_expr is used.  For simplicity, we
                              15813                 :                :  * just eliminate all the boolean-keyword-operator productions from b_expr.
                              15814                 :                :  */
                              15815                 :                : b_expr:     c_expr
 8907 bruce@momjian.us        15816                 :           2542 :                 { $$ = $1; }
                              15817                 :                :             | b_expr TYPECAST Typename
 6643 tgl@sss.pgh.pa.us       15818                 :            152 :                 { $$ = makeTypeCast($1, $3, @2); }
                              15819                 :                :             | '+' b_expr                    %prec UMINUS
 7541 tgl@sss.pgh.pa.us       15820                 :UBC           0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", NULL, $2, @1); }
                              15821                 :                :             | '-' b_expr                    %prec UMINUS
 7541 tgl@sss.pgh.pa.us       15822                 :CBC          44 :                 { $$ = doNegate($2, @1); }
                              15823                 :                :             | b_expr '+' b_expr
                              15824                 :             24 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", $1, $3, @2); }
                              15825                 :                :             | b_expr '-' b_expr
                              15826                 :             10 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "-", $1, $3, @2); }
                              15827                 :                :             | b_expr '*' b_expr
                              15828                 :              8 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "*", $1, $3, @2); }
                              15829                 :                :             | b_expr '/' b_expr
 7541 tgl@sss.pgh.pa.us       15830                 :UBC           0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "/", $1, $3, @2); }
                              15831                 :                :             | b_expr '%' b_expr
                              15832                 :              0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "%", $1, $3, @2); }
                              15833                 :                :             | b_expr '^' b_expr
 7541 tgl@sss.pgh.pa.us       15834                 :CBC           4 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "^", $1, $3, @2); }
                              15835                 :                :             | b_expr '<' b_expr
 7541 tgl@sss.pgh.pa.us       15836                 :UBC           0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $3, @2); }
                              15837                 :                :             | b_expr '>' b_expr
                              15838                 :              0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $3, @2); }
                              15839                 :                :             | b_expr '=' b_expr
                              15840                 :              0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "=", $1, $3, @2); }
                              15841                 :                :             | b_expr LESS_EQUALS b_expr
 4257                         15842                 :              0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $3, @2); }
                              15843                 :                :             | b_expr GREATER_EQUALS b_expr
                              15844                 :              0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $3, @2); }
                              15845                 :                :             | b_expr NOT_EQUALS b_expr
                              15846                 :              0 :                 { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<>", $1, $3, @2); }
                              15847                 :                :             | b_expr qual_Op b_expr             %prec Op
 7541 tgl@sss.pgh.pa.us       15848                 :CBC           8 :                 { $$ = (Node *) makeA_Expr(AEXPR_OP, $2, $1, $3, @2); }
                              15849                 :                :             | qual_Op b_expr                    %prec Op
 7541 tgl@sss.pgh.pa.us       15850                 :UBC           0 :                 { $$ = (Node *) makeA_Expr(AEXPR_OP, $1, NULL, $2, @1); }
                              15851                 :                :             | b_expr IS DISTINCT FROM b_expr        %prec IS
                              15852                 :                :                 {
                              15853                 :              0 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", $1, $5, @2);
                              15854                 :                :                 }
                              15855                 :                :             | b_expr IS NOT DISTINCT FROM b_expr    %prec IS
                              15856                 :                :                 {
 3752                         15857                 :              0 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_NOT_DISTINCT, "=", $1, $6, @2);
                              15858                 :                :                 }
                              15859                 :                :             | b_expr IS DOCUMENT_P                  %prec IS
                              15860                 :                :                 {
 6643                         15861                 :              0 :                     $$ = makeXmlExpr(IS_DOCUMENT, NULL, NIL,
                              15862                 :              0 :                                      list_make1($1), @2);
                              15863                 :                :                 }
                              15864                 :                :             | b_expr IS NOT DOCUMENT_P              %prec IS
                              15865                 :                :                 {
 4525                         15866                 :              0 :                     $$ = makeNotExpr(makeXmlExpr(IS_DOCUMENT, NULL, NIL,
                              15867                 :              0 :                                                  list_make1($1), @2),
                              15868                 :              0 :                                      @2);
                              15869                 :                :                 }
                              15870                 :                :         ;
                              15871                 :                : 
                              15872                 :                : /*
                              15873                 :                :  * Productions that can be used in both a_expr and b_expr.
                              15874                 :                :  *
                              15875                 :                :  * Note: productions that refer recursively to a_expr or b_expr mostly
                              15876                 :                :  * cannot appear here.  However, it's OK to refer to a_exprs that occur
                              15877                 :                :  * inside parentheses, such as function arguments; that cannot introduce
                              15878                 :                :  * ambiguity to the b_expr syntax.
                              15879                 :                :  */
 8184 tgl@sss.pgh.pa.us       15880                 :CBC     1165972 : c_expr:     columnref                               { $$ = $1; }
 8907 bruce@momjian.us        15881                 :         819243 :             | AexprConst                            { $$ = $1; }
                              15882                 :                :             | PARAM opt_indirection
                              15883                 :                :                 {
 1637 peter@eisentraut.org    15884                 :          25522 :                     ParamRef   *p = makeNode(ParamRef);
                              15885                 :                : 
 8184 tgl@sss.pgh.pa.us       15886                 :          25522 :                     p->number = $1;
 6643                         15887                 :          25522 :                     p->location = @1;
 8184                         15888         [ +  + ]:          25522 :                     if ($2)
                              15889                 :                :                     {
                              15890                 :            757 :                         A_Indirection *n = makeNode(A_Indirection);
                              15891                 :                : 
                              15892                 :            757 :                         n->arg = (Node *) p;
 6324                         15893                 :            757 :                         n->indirection = check_indirection($2, yyscanner);
 8184                         15894                 :            757 :                         $$ = (Node *) n;
                              15895                 :                :                     }
                              15896                 :                :                     else
                              15897                 :          24765 :                         $$ = (Node *) p;
                              15898                 :                :                 }
                              15899                 :                :             | '(' a_expr ')' opt_indirection
                              15900                 :                :                 {
 8612                         15901         [ +  + ]:          60669 :                     if ($4)
                              15902                 :                :                     {
 8184                         15903                 :           9321 :                         A_Indirection *n = makeNode(A_Indirection);
                              15904                 :                : 
 8612                         15905                 :           9321 :                         n->arg = $2;
 6324                         15906                 :           9321 :                         n->indirection = check_indirection($4, yyscanner);
 1637 peter@eisentraut.org    15907                 :           9321 :                         $$ = (Node *) n;
                              15908                 :                :                     }
                              15909                 :                :                     else
 8612 tgl@sss.pgh.pa.us       15910                 :          51348 :                         $$ = $2;
                              15911                 :                :                 }
                              15912                 :                :             | case_expr
 8907 bruce@momjian.us        15913                 :          25494 :                 { $$ = $1; }
                              15914                 :                :             | func_expr
 8072 tgl@sss.pgh.pa.us       15915                 :         256386 :                 { $$ = $1; }
                              15916                 :                :             | select_with_parens            %prec UMINUS
                              15917                 :                :                 {
 1637 peter@eisentraut.org    15918                 :          17053 :                     SubLink    *n = makeNode(SubLink);
                              15919                 :                : 
 8072 tgl@sss.pgh.pa.us       15920                 :          17053 :                     n->subLinkType = EXPR_SUBLINK;
 4523                         15921                 :          17053 :                     n->subLinkId = 0;
 7617                         15922                 :          17053 :                     n->testexpr = NULL;
 8072                         15923                 :          17053 :                     n->operName = NIL;
                              15924                 :          17053 :                     n->subselect = $1;
 6643                         15925                 :          17053 :                     n->location = @1;
 1637 peter@eisentraut.org    15926                 :          17053 :                     $$ = (Node *) n;
                              15927                 :                :                 }
                              15928                 :                :             | select_with_parens indirection
                              15929                 :                :                 {
                              15930                 :                :                     /*
                              15931                 :                :                      * Because the select_with_parens nonterminal is designed
                              15932                 :                :                      * to "eat" as many levels of parens as possible, the
                              15933                 :                :                      * '(' a_expr ')' opt_indirection production above will
                              15934                 :                :                      * fail to match a sub-SELECT with indirection decoration;
                              15935                 :                :                      * the sub-SELECT won't be regarded as an a_expr as long
                              15936                 :                :                      * as there are parens around it.  To support applying
                              15937                 :                :                      * subscripting or field selection to a sub-SELECT result,
                              15938                 :                :                      * we need this redundant-looking production.
                              15939                 :                :                      */
                              15940                 :             12 :                     SubLink    *n = makeNode(SubLink);
 5027 tgl@sss.pgh.pa.us       15941                 :             12 :                     A_Indirection *a = makeNode(A_Indirection);
                              15942                 :                : 
                              15943                 :             12 :                     n->subLinkType = EXPR_SUBLINK;
 4523                         15944                 :             12 :                     n->subLinkId = 0;
 5027                         15945                 :             12 :                     n->testexpr = NULL;
                              15946                 :             12 :                     n->operName = NIL;
                              15947                 :             12 :                     n->subselect = $1;
                              15948                 :             12 :                     n->location = @1;
 1637 peter@eisentraut.org    15949                 :             12 :                     a->arg = (Node *) n;
 5027 tgl@sss.pgh.pa.us       15950                 :             12 :                     a->indirection = check_indirection($2, yyscanner);
 1637 peter@eisentraut.org    15951                 :             12 :                     $$ = (Node *) a;
                              15952                 :                :                 }
                              15953                 :                :             | EXISTS select_with_parens
                              15954                 :                :                 {
                              15955                 :           8202 :                     SubLink    *n = makeNode(SubLink);
                              15956                 :                : 
 8072 tgl@sss.pgh.pa.us       15957                 :           8202 :                     n->subLinkType = EXISTS_SUBLINK;
 4523                         15958                 :           8202 :                     n->subLinkId = 0;
 7617                         15959                 :           8202 :                     n->testexpr = NULL;
 8072                         15960                 :           8202 :                     n->operName = NIL;
                              15961                 :           8202 :                     n->subselect = $2;
 6643                         15962                 :           8202 :                     n->location = @1;
 1637 peter@eisentraut.org    15963                 :           8202 :                     $$ = (Node *) n;
                              15964                 :                :                 }
                              15965                 :                :             | ARRAY select_with_parens
                              15966                 :                :                 {
                              15967                 :           5346 :                     SubLink    *n = makeNode(SubLink);
                              15968                 :                : 
 8072 tgl@sss.pgh.pa.us       15969                 :           5346 :                     n->subLinkType = ARRAY_SUBLINK;
 4523                         15970                 :           5346 :                     n->subLinkId = 0;
 7617                         15971                 :           5346 :                     n->testexpr = NULL;
 8072                         15972                 :           5346 :                     n->operName = NIL;
                              15973                 :           5346 :                     n->subselect = $2;
 6643                         15974                 :           5346 :                     n->location = @1;
 1637 peter@eisentraut.org    15975                 :           5346 :                     $$ = (Node *) n;
                              15976                 :                :                 }
                              15977                 :                :             | ARRAY array_expr
                              15978                 :                :                 {
 3544 peter_e@gmx.net         15979                 :           5463 :                     A_ArrayExpr *n = castNode(A_ArrayExpr, $2);
                              15980                 :                : 
                              15981                 :                :                     /* point outermost A_ArrayExpr to the ARRAY keyword */
 6643 tgl@sss.pgh.pa.us       15982                 :           5463 :                     n->location = @1;
 1637 peter@eisentraut.org    15983                 :           5463 :                     $$ = (Node *) n;
                              15984                 :                :                 }
                              15985                 :                :             | explicit_row
                              15986                 :                :                 {
                              15987                 :           2725 :                     RowExpr    *r = makeNode(RowExpr);
                              15988                 :                : 
 4191 andres@anarazel.de      15989                 :           2725 :                     r->args = $1;
                              15990                 :           2725 :                     r->row_typeid = InvalidOid;  /* not analyzed yet */
                              15991                 :           2725 :                     r->colnames = NIL;   /* to be filled in during analysis */
                              15992                 :           2725 :                     r->row_format = COERCE_EXPLICIT_CALL; /* abuse */
                              15993                 :           2725 :                     r->location = @1;
 1637 peter@eisentraut.org    15994                 :           2725 :                     $$ = (Node *) r;
                              15995                 :                :                 }
                              15996                 :                :             | implicit_row
                              15997                 :                :                 {
                              15998                 :           1836 :                     RowExpr    *r = makeNode(RowExpr);
                              15999                 :                : 
 8072 tgl@sss.pgh.pa.us       16000                 :           1836 :                     r->args = $1;
                              16001                 :           1836 :                     r->row_typeid = InvalidOid;  /* not analyzed yet */
 5378                         16002                 :           1836 :                     r->colnames = NIL;   /* to be filled in during analysis */
 4191 andres@anarazel.de      16003                 :           1836 :                     r->row_format = COERCE_IMPLICIT_CAST; /* abuse */
 6643 tgl@sss.pgh.pa.us       16004                 :           1836 :                     r->location = @1;
 1637 peter@eisentraut.org    16005                 :           1836 :                     $$ = (Node *) r;
                              16006                 :                :                 }
                              16007                 :                :             | GROUPING '(' expr_list ')'
                              16008                 :                :               {
 4191 andres@anarazel.de      16009                 :            256 :                   GroupingFunc *g = makeNode(GroupingFunc);
                              16010                 :                : 
                              16011                 :            256 :                   g->args = $3;
                              16012                 :            256 :                   g->location = @1;
 1637 peter@eisentraut.org    16013                 :            256 :                   $$ = (Node *) g;
                              16014                 :                :               }
                              16015                 :                :         ;
                              16016                 :                : 
                              16017                 :                : func_application: func_name '(' ')'
                              16018                 :                :                 {
 2192 tgl@sss.pgh.pa.us       16019                 :          20058 :                     $$ = (Node *) makeFuncCall($1, NIL,
                              16020                 :                :                                                COERCE_EXPLICIT_CALL,
                              16021                 :          20059 :                                                @1);
                              16022                 :                :                 }
                              16023                 :                :             | func_name '(' func_arg_list opt_sort_clause ')'
                              16024                 :                :                 {
 1637 peter@eisentraut.org    16025                 :         207403 :                     FuncCall   *n = makeFuncCall($1, $3,
                              16026                 :                :                                                  COERCE_EXPLICIT_CALL,
                              16027                 :         207403 :                                                  @1);
                              16028                 :                : 
 4700 tgl@sss.pgh.pa.us       16029                 :         207402 :                     n->agg_order = $4;
 1637 peter@eisentraut.org    16030                 :         207402 :                     $$ = (Node *) n;
                              16031                 :                :                 }
                              16032                 :                :             | func_name '(' VARIADIC func_arg_expr opt_sort_clause ')'
                              16033                 :                :                 {
                              16034                 :            389 :                     FuncCall   *n = makeFuncCall($1, list_make1($4),
                              16035                 :                :                                                  COERCE_EXPLICIT_CALL,
                              16036                 :            389 :                                                  @1);
                              16037                 :                : 
 3368 peter_e@gmx.net         16038                 :            389 :                     n->func_variadic = true;
 4700 tgl@sss.pgh.pa.us       16039                 :            389 :                     n->agg_order = $5;
 1637 peter@eisentraut.org    16040                 :            389 :                     $$ = (Node *) n;
                              16041                 :                :                 }
                              16042                 :                :             | func_name '(' func_arg_list ',' VARIADIC func_arg_expr opt_sort_clause ')'
                              16043                 :                :                 {
                              16044                 :            116 :                     FuncCall   *n = makeFuncCall($1, lappend($3, $6),
                              16045                 :                :                                                  COERCE_EXPLICIT_CALL,
                              16046                 :            116 :                                                  @1);
                              16047                 :                : 
 3368 peter_e@gmx.net         16048                 :            116 :                     n->func_variadic = true;
 4700 tgl@sss.pgh.pa.us       16049                 :            116 :                     n->agg_order = $7;
 1637 peter@eisentraut.org    16050                 :            116 :                     $$ = (Node *) n;
                              16051                 :                :                 }
                              16052                 :                :             | func_name '(' ALL func_arg_list opt_sort_clause ')'
                              16053                 :                :                 {
 1637 peter@eisentraut.org    16054                 :UBC           0 :                     FuncCall   *n = makeFuncCall($1, $4,
                              16055                 :                :                                                  COERCE_EXPLICIT_CALL,
                              16056                 :              0 :                                                  @1);
                              16057                 :                : 
 6169 tgl@sss.pgh.pa.us       16058                 :              0 :                     n->agg_order = $5;
                              16059                 :                :                     /* Ideally we'd mark the FuncCall node to indicate
                              16060                 :                :                      * "must be an aggregate", but there's no provision
                              16061                 :                :                      * for that in FuncCall at the moment.
                              16062                 :                :                      */
 1637 peter@eisentraut.org    16063                 :              0 :                     $$ = (Node *) n;
                              16064                 :                :                 }
                              16065                 :                :             | func_name '(' DISTINCT func_arg_list opt_sort_clause ')'
                              16066                 :                :                 {
 1637 peter@eisentraut.org    16067                 :CBC         398 :                     FuncCall   *n = makeFuncCall($1, $4,
                              16068                 :                :                                                  COERCE_EXPLICIT_CALL,
                              16069                 :            398 :                                                  @1);
                              16070                 :                : 
 6169 tgl@sss.pgh.pa.us       16071                 :            398 :                     n->agg_order = $5;
 3368 peter_e@gmx.net         16072                 :            398 :                     n->agg_distinct = true;
 1637 peter@eisentraut.org    16073                 :            398 :                     $$ = (Node *) n;
                              16074                 :                :                 }
                              16075                 :                :             | func_name '(' '*' ')'
                              16076                 :                :                 {
                              16077                 :                :                     /*
                              16078                 :                :                      * We consider AGGREGATE(*) to invoke a parameterless
                              16079                 :                :                      * aggregate.  This does the right thing for COUNT(*),
                              16080                 :                :                      * and there are no other aggregates in SQL that accept
                              16081                 :                :                      * '*' as parameter.
                              16082                 :                :                      *
                              16083                 :                :                      * The FuncCall node is also marked agg_star = true,
                              16084                 :                :                      * so that later processing can detect what the argument
                              16085                 :                :                      * really was.
                              16086                 :                :                      */
                              16087                 :          12061 :                     FuncCall   *n = makeFuncCall($1, NIL,
                              16088                 :                :                                                  COERCE_EXPLICIT_CALL,
                              16089                 :          12061 :                                                  @1);
                              16090                 :                : 
 3368 peter_e@gmx.net         16091                 :          12061 :                     n->agg_star = true;
 1637 peter@eisentraut.org    16092                 :          12061 :                     $$ = (Node *) n;
                              16093                 :                :                 }
                              16094                 :                :         ;
                              16095                 :                : 
                              16096                 :                : 
                              16097                 :                : /*
                              16098                 :                :  * func_expr and its cousin func_expr_windowless are split out from c_expr just
                              16099                 :                :  * so that we have classifications for "everything that is a function call or
                              16100                 :                :  * looks like one".  This isn't very important, but it saves us having to
                              16101                 :                :  * document which variants are legal in places like "FROM function()" or the
                              16102                 :                :  * backwards-compatible functional-index syntax for CREATE INDEX.
                              16103                 :                :  * (Note that many of the special SQL functions wouldn't actually make any
                              16104                 :                :  * sense as functional index entries, but we ignore that consideration here.)
                              16105                 :                :  */
                              16106                 :                : func_expr: func_application within_group_clause filter_clause null_treatment over_clause
                              16107                 :                :                 {
                              16108                 :         209224 :                     FuncCall   *n = (FuncCall *) $1;
                              16109                 :                : 
                              16110                 :                :                     /*
                              16111                 :                :                      * The order clause for WITHIN GROUP and the one for
                              16112                 :                :                      * plain-aggregate ORDER BY share a field, so we have to
                              16113                 :                :                      * check here that at most one is present.  We also check
                              16114                 :                :                      * for DISTINCT and VARIADIC here to give a better error
                              16115                 :                :                      * location.  Other consistency checks are deferred to
                              16116                 :                :                      * parse analysis.
                              16117                 :                :                      */
 4700 tgl@sss.pgh.pa.us       16118         [ +  + ]:         209224 :                     if ($2 != NIL)
                              16119                 :                :                     {
                              16120         [ +  + ]:            228 :                         if (n->agg_order != NIL)
                              16121         [ +  - ]:              4 :                             ereport(ERROR,
                              16122                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              16123                 :                :                                      errmsg("cannot use multiple ORDER BY clauses with WITHIN GROUP"),
                              16124                 :                :                                      parser_errposition(@2)));
                              16125         [ -  + ]:            224 :                         if (n->agg_distinct)
 4700 tgl@sss.pgh.pa.us       16126         [ #  # ]:UBC           0 :                             ereport(ERROR,
                              16127                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              16128                 :                :                                      errmsg("cannot use DISTINCT with WITHIN GROUP"),
                              16129                 :                :                                      parser_errposition(@2)));
 4700 tgl@sss.pgh.pa.us       16130         [ -  + ]:CBC         224 :                         if (n->func_variadic)
 4700 tgl@sss.pgh.pa.us       16131         [ #  # ]:UBC           0 :                             ereport(ERROR,
                              16132                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              16133                 :                :                                      errmsg("cannot use VARIADIC with WITHIN GROUP"),
                              16134                 :                :                                      parser_errposition(@2)));
 4700 tgl@sss.pgh.pa.us       16135                 :CBC         224 :                         n->agg_order = $2;
 3368 peter_e@gmx.net         16136                 :            224 :                         n->agg_within_group = true;
                              16137                 :                :                     }
 4700 tgl@sss.pgh.pa.us       16138                 :         209220 :                     n->agg_filter = $3;
  398 ishii@postgresql.org    16139                 :         209220 :                     n->ignore_nulls = $4;
                              16140                 :         209220 :                     n->over = $5;
 4700 tgl@sss.pgh.pa.us       16141                 :         209220 :                     $$ = (Node *) n;
                              16142                 :                :                 }
                              16143                 :                :             | json_aggregate_func filter_clause over_clause
                              16144                 :                :                 {
 1317 alvherre@alvh.no-ip.    16145                 :            610 :                     JsonAggConstructor *n = IsA($1, JsonObjectAgg) ?
                              16146         [ +  + ]:            305 :                         ((JsonObjectAgg *) $1)->constructor :
                              16147                 :            147 :                         ((JsonArrayAgg *) $1)->constructor;
                              16148                 :                : 
                              16149                 :            305 :                     n->agg_filter = $2;
                              16150                 :            305 :                     n->over = $3;
                              16151                 :            305 :                     $$ = (Node *) $1;
                              16152                 :                :                 }
                              16153                 :                :             | func_expr_common_subexpr
 4878 rhaas@postgresql.org    16154                 :          46861 :                 { $$ = $1; }
                              16155                 :                :         ;
                              16156                 :                : 
                              16157                 :                : /*
                              16158                 :                :  * Like func_expr but does not accept WINDOW functions directly
                              16159                 :                :  * (but they can still be contained in arguments for functions etc).
                              16160                 :                :  * Use this when window expressions are not allowed, where needed to
                              16161                 :                :  * disambiguate the grammar (e.g. in CREATE INDEX).
                              16162                 :                :  */
                              16163                 :                : func_expr_windowless:
                              16164                 :          30834 :             func_application                        { $$ = $1; }
 4743 peter_e@gmx.net         16165                 :            408 :             | func_expr_common_subexpr              { $$ = $1; }
 1317 alvherre@alvh.no-ip.    16166                 :             16 :             | json_aggregate_func                   { $$ = $1; }
                              16167                 :                :         ;
                              16168                 :                : 
                              16169                 :                : /*
                              16170                 :                :  * Special expressions that are considered to be functions.
                              16171                 :                :  */
                              16172                 :                : func_expr_common_subexpr:
                              16173                 :                :             COLLATION FOR '(' a_expr ')'
                              16174                 :                :                 {
 4875 rhaas@postgresql.org    16175                 :             20 :                     $$ = (Node *) makeFuncCall(SystemFuncName("pg_collation_for"),
                              16176                 :             20 :                                                list_make1($4),
                              16177                 :                :                                                COERCE_SQL_SYNTAX,
                              16178                 :             20 :                                                @1);
                              16179                 :                :                 }
                              16180                 :                :             | CURRENT_DATE
                              16181                 :                :                 {
 1268 michael@paquier.xyz     16182                 :            191 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_DATE, -1, @1);
                              16183                 :                :                 }
                              16184                 :                :             | CURRENT_TIME
                              16185                 :                :                 {
                              16186                 :             16 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_TIME, -1, @1);
                              16187                 :                :                 }
                              16188                 :                :             | CURRENT_TIME '(' Iconst ')'
                              16189                 :                :                 {
                              16190                 :             16 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_TIME_N, $3, @1);
                              16191                 :                :                 }
                              16192                 :                :             | CURRENT_TIMESTAMP
                              16193                 :                :                 {
                              16194                 :            153 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_TIMESTAMP, -1, @1);
                              16195                 :                :                 }
                              16196                 :                :             | CURRENT_TIMESTAMP '(' Iconst ')'
                              16197                 :                :                 {
                              16198                 :            109 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_TIMESTAMP_N, $3, @1);
                              16199                 :                :                 }
                              16200                 :                :             | LOCALTIME
                              16201                 :                :                 {
                              16202                 :             16 :                     $$ = makeSQLValueFunction(SVFOP_LOCALTIME, -1, @1);
                              16203                 :                :                 }
                              16204                 :                :             | LOCALTIME '(' Iconst ')'
                              16205                 :                :                 {
                              16206                 :             16 :                     $$ = makeSQLValueFunction(SVFOP_LOCALTIME_N, $3, @1);
                              16207                 :                :                 }
                              16208                 :                :             | LOCALTIMESTAMP
                              16209                 :                :                 {
                              16210                 :             24 :                     $$ = makeSQLValueFunction(SVFOP_LOCALTIMESTAMP, -1, @1);
                              16211                 :                :                 }
                              16212                 :                :             | LOCALTIMESTAMP '(' Iconst ')'
                              16213                 :                :                 {
                              16214                 :             16 :                     $$ = makeSQLValueFunction(SVFOP_LOCALTIMESTAMP_N, $3, @1);
                              16215                 :                :                 }
                              16216                 :                :             | CURRENT_ROLE
                              16217                 :                :                 {
                              16218                 :             44 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_ROLE, -1, @1);
                              16219                 :                :                 }
                              16220                 :                :             | CURRENT_USER
                              16221                 :                :                 {
                              16222                 :            661 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_USER, -1, @1);
                              16223                 :                :                 }
                              16224                 :                :             | SESSION_USER
                              16225                 :                :                 {
                              16226                 :            323 :                     $$ = makeSQLValueFunction(SVFOP_SESSION_USER, -1, @1);
                              16227                 :                :                 }
                              16228                 :                :             | SYSTEM_USER
                              16229                 :                :                 {
 1498                         16230                 :             12 :                     $$ = (Node *) makeFuncCall(SystemFuncName("system_user"),
                              16231                 :                :                                                NIL,
                              16232                 :                :                                                COERCE_SQL_SYNTAX,
                              16233                 :                :                                                @1);
                              16234                 :                :                 }
                              16235                 :                :             | USER
                              16236                 :                :                 {
 1268                         16237                 :             16 :                     $$ = makeSQLValueFunction(SVFOP_USER, -1, @1);
                              16238                 :                :                 }
                              16239                 :                :             | CURRENT_CATALOG
                              16240                 :                :                 {
                              16241                 :             35 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_CATALOG, -1, @1);
                              16242                 :                :                 }
                              16243                 :                :             | CURRENT_SCHEMA
                              16244                 :                :                 {
                              16245                 :             20 :                     $$ = makeSQLValueFunction(SVFOP_CURRENT_SCHEMA, -1, @1);
                              16246                 :                :                 }
                              16247                 :                :             | CAST '(' a_expr AS Typename ')'
 6643 tgl@sss.pgh.pa.us       16248                 :          37204 :                 { $$ = makeTypeCast($3, $5, @1); }
                              16249                 :                :             | EXTRACT '(' extract_list ')'
                              16250                 :                :                 {
 2039 peter@eisentraut.org    16251                 :            892 :                     $$ = (Node *) makeFuncCall(SystemFuncName("extract"),
 2192 tgl@sss.pgh.pa.us       16252                 :            892 :                                                $3,
                              16253                 :                :                                                COERCE_SQL_SYNTAX,
                              16254                 :            892 :                                                @1);
                              16255                 :                :                 }
                              16256                 :                :             | NORMALIZE '(' a_expr ')'
                              16257                 :                :                 {
                              16258                 :             12 :                     $$ = (Node *) makeFuncCall(SystemFuncName("normalize"),
                              16259                 :             12 :                                                list_make1($3),
                              16260                 :                :                                                COERCE_SQL_SYNTAX,
                              16261                 :             12 :                                                @1);
                              16262                 :                :                 }
                              16263                 :                :             | NORMALIZE '(' a_expr ',' unicode_normal_form ')'
                              16264                 :                :                 {
                              16265                 :            152 :                     $$ = (Node *) makeFuncCall(SystemFuncName("normalize"),
                              16266                 :             76 :                                                list_make2($3, makeStringConst($5, @5)),
                              16267                 :                :                                                COERCE_SQL_SYNTAX,
                              16268                 :             76 :                                                @1);
                              16269                 :                :                 }
                              16270                 :                :             | OVERLAY '(' overlay_list ')'
                              16271                 :                :                 {
                              16272                 :             54 :                     $$ = (Node *) makeFuncCall(SystemFuncName("overlay"),
                              16273                 :             54 :                                                $3,
                              16274                 :                :                                                COERCE_SQL_SYNTAX,
                              16275                 :             54 :                                                @1);
                              16276                 :                :                 }
                              16277                 :                :             | OVERLAY '(' func_arg_list_opt ')'
                              16278                 :                :                 {
                              16279                 :                :                     /*
                              16280                 :                :                      * allow functions named overlay() to be called without
                              16281                 :                :                      * special syntax
                              16282                 :                :                      */
 2192 tgl@sss.pgh.pa.us       16283                 :UBC           0 :                     $$ = (Node *) makeFuncCall(list_make1(makeString("overlay")),
                              16284                 :              0 :                                                $3,
                              16285                 :                :                                                COERCE_EXPLICIT_CALL,
                              16286                 :              0 :                                                @1);
                              16287                 :                :                 }
                              16288                 :                :             | POSITION '(' position_list ')'
                              16289                 :                :                 {
                              16290                 :                :                     /*
                              16291                 :                :                      * position(A in B) is converted to position(B, A)
                              16292                 :                :                      *
                              16293                 :                :                      * We deliberately don't offer a "plain syntax" option
                              16294                 :                :                      * for position(), because the reversal of the arguments
                              16295                 :                :                      * creates too much risk of confusion.
                              16296                 :                :                      */
 2192 tgl@sss.pgh.pa.us       16297                 :CBC         279 :                     $$ = (Node *) makeFuncCall(SystemFuncName("position"),
                              16298                 :            279 :                                                $3,
                              16299                 :                :                                                COERCE_SQL_SYNTAX,
                              16300                 :            279 :                                                @1);
                              16301                 :                :                 }
                              16302                 :                :             | SUBSTRING '(' substr_list ')'
                              16303                 :                :                 {
                              16304                 :                :                     /* substring(A from B for C) is converted to
                              16305                 :                :                      * substring(A, B, C) - thomas 2000-11-28
                              16306                 :                :                      */
                              16307                 :            479 :                     $$ = (Node *) makeFuncCall(SystemFuncName("substring"),
                              16308                 :            479 :                                                $3,
                              16309                 :                :                                                COERCE_SQL_SYNTAX,
                              16310                 :            479 :                                                @1);
                              16311                 :                :                 }
                              16312                 :                :             | SUBSTRING '(' func_arg_list_opt ')'
                              16313                 :                :                 {
                              16314                 :                :                     /*
                              16315                 :                :                      * allow functions named substring() to be called without
                              16316                 :                :                      * special syntax
                              16317                 :                :                      */
                              16318                 :            200 :                     $$ = (Node *) makeFuncCall(list_make1(makeString("substring")),
                              16319                 :            200 :                                                $3,
                              16320                 :                :                                                COERCE_EXPLICIT_CALL,
                              16321                 :            200 :                                                @1);
                              16322                 :                :                 }
                              16323                 :                :             | TREAT '(' a_expr AS Typename ')'
                              16324                 :                :                 {
                              16325                 :                :                     /* TREAT(expr AS target) converts expr of a particular type to target,
                              16326                 :                :                      * which is defined to be a subtype of the original expression.
                              16327                 :                :                      * In SQL99, this is intended for use with structured UDTs,
                              16328                 :                :                      * but let's make this a generally useful form allowing stronger
                              16329                 :                :                      * coercions than are handled by implicit casting.
                              16330                 :                :                      *
                              16331                 :                :                      * Convert SystemTypeName() to SystemFuncName() even though
                              16332                 :                :                      * at the moment they result in the same thing.
                              16333                 :                :                      */
 2163 peter@eisentraut.org    16334                 :UBC           0 :                     $$ = (Node *) makeFuncCall(SystemFuncName(strVal(llast($5->names))),
 2192 tgl@sss.pgh.pa.us       16335                 :              0 :                                                list_make1($3),
                              16336                 :                :                                                COERCE_EXPLICIT_CALL,
                              16337                 :              0 :                                                @1);
                              16338                 :                :                 }
                              16339                 :                :             | TRIM '(' BOTH trim_list ')'
                              16340                 :                :                 {
                              16341                 :                :                     /* various trim expressions are defined in SQL
                              16342                 :                :                      * - thomas 1997-07-19
                              16343                 :                :                      */
 2192 tgl@sss.pgh.pa.us       16344                 :CBC           8 :                     $$ = (Node *) makeFuncCall(SystemFuncName("btrim"),
                              16345                 :              8 :                                                $4,
                              16346                 :                :                                                COERCE_SQL_SYNTAX,
                              16347                 :              8 :                                                @1);
                              16348                 :                :                 }
                              16349                 :                :             | TRIM '(' LEADING trim_list ')'
                              16350                 :                :                 {
                              16351                 :             16 :                     $$ = (Node *) makeFuncCall(SystemFuncName("ltrim"),
                              16352                 :             16 :                                                $4,
                              16353                 :                :                                                COERCE_SQL_SYNTAX,
                              16354                 :             16 :                                                @1);
                              16355                 :                :                 }
                              16356                 :                :             | TRIM '(' TRAILING trim_list ')'
                              16357                 :                :                 {
                              16358                 :            380 :                     $$ = (Node *) makeFuncCall(SystemFuncName("rtrim"),
                              16359                 :            380 :                                                $4,
                              16360                 :                :                                                COERCE_SQL_SYNTAX,
                              16361                 :            380 :                                                @1);
                              16362                 :                :                 }
                              16363                 :                :             | TRIM '(' trim_list ')'
                              16364                 :                :                 {
                              16365                 :             64 :                     $$ = (Node *) makeFuncCall(SystemFuncName("btrim"),
                              16366                 :             64 :                                                $3,
                              16367                 :                :                                                COERCE_SQL_SYNTAX,
                              16368                 :             64 :                                                @1);
                              16369                 :                :                 }
                              16370                 :                :             | NULLIF '(' a_expr ',' a_expr ')'
                              16371                 :                :                 {
 7541                         16372                 :            351 :                     $$ = (Node *) makeSimpleA_Expr(AEXPR_NULLIF, "=", $3, $5, @1);
                              16373                 :                :                 }
                              16374                 :                :             | COALESCE '(' expr_list ')'
                              16375                 :                :                 {
 8071                         16376                 :           2160 :                     CoalesceExpr *c = makeNode(CoalesceExpr);
                              16377                 :                : 
                              16378                 :           2160 :                     c->args = $3;
 6643                         16379                 :           2160 :                     c->location = @1;
 1637 peter@eisentraut.org    16380                 :           2160 :                     $$ = (Node *) c;
                              16381                 :                :                 }
                              16382                 :                :             | GREATEST '(' expr_list ')'
                              16383                 :                :                 {
 7802 tgl@sss.pgh.pa.us       16384                 :            106 :                     MinMaxExpr *v = makeNode(MinMaxExpr);
                              16385                 :                : 
                              16386                 :            106 :                     v->args = $3;
                              16387                 :            106 :                     v->op = IS_GREATEST;
 6643                         16388                 :            106 :                     v->location = @1;
 1637 peter@eisentraut.org    16389                 :            106 :                     $$ = (Node *) v;
                              16390                 :                :                 }
                              16391                 :                :             | LEAST '(' expr_list ')'
                              16392                 :                :                 {
 7802 tgl@sss.pgh.pa.us       16393                 :            100 :                     MinMaxExpr *v = makeNode(MinMaxExpr);
                              16394                 :                : 
                              16395                 :            100 :                     v->args = $3;
                              16396                 :            100 :                     v->op = IS_LEAST;
 6643                         16397                 :            100 :                     v->location = @1;
 1637 peter@eisentraut.org    16398                 :            100 :                     $$ = (Node *) v;
                              16399                 :                :                 }
                              16400                 :                :             | XMLCONCAT '(' expr_list ')'
                              16401                 :                :                 {
 6643 tgl@sss.pgh.pa.us       16402                 :             41 :                     $$ = makeXmlExpr(IS_XMLCONCAT, NULL, NIL, $3, @1);
                              16403                 :                :                 }
                              16404                 :                :             | XMLELEMENT '(' NAME_P ColLabel ')'
                              16405                 :                :                 {
                              16406                 :              4 :                     $$ = makeXmlExpr(IS_XMLELEMENT, $4, NIL, NIL, @1);
                              16407                 :                :                 }
                              16408                 :                :             | XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ')'
                              16409                 :                :                 {
                              16410                 :             24 :                     $$ = makeXmlExpr(IS_XMLELEMENT, $4, $6, NIL, @1);
                              16411                 :                :                 }
                              16412                 :                :             | XMLELEMENT '(' NAME_P ColLabel ',' expr_list ')'
                              16413                 :                :                 {
                              16414                 :             77 :                     $$ = makeXmlExpr(IS_XMLELEMENT, $4, NIL, $6, @1);
                              16415                 :                :                 }
                              16416                 :                :             | XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ',' expr_list ')'
                              16417                 :                :                 {
                              16418                 :             13 :                     $$ = makeXmlExpr(IS_XMLELEMENT, $4, $6, $8, @1);
                              16419                 :                :                 }
                              16420                 :                :             | XMLEXISTS '(' c_expr xmlexists_argument ')'
                              16421                 :                :                 {
                              16422                 :                :                     /* xmlexists(A PASSING [BY REF] B [BY REF]) is
                              16423                 :                :                      * converted to xmlexists(A, B)*/
 2192                         16424                 :             36 :                     $$ = (Node *) makeFuncCall(SystemFuncName("xmlexists"),
                              16425                 :             36 :                                                list_make2($3, $4),
                              16426                 :                :                                                COERCE_SQL_SYNTAX,
                              16427                 :             36 :                                                @1);
                              16428                 :                :                 }
                              16429                 :                :             | XMLFOREST '(' labeled_expr_list ')'
                              16430                 :                :                 {
 6643                         16431                 :             21 :                     $$ = makeXmlExpr(IS_XMLFOREST, NULL, $3, NIL, @1);
                              16432                 :                :                 }
                              16433                 :                :             | XMLPARSE '(' document_or_content a_expr xml_whitespace_option ')'
                              16434                 :                :                 {
                              16435                 :                :                     XmlExpr *x = (XmlExpr *)
                              16436                 :            234 :                         makeXmlExpr(IS_XMLPARSE, NULL, NIL,
                              16437                 :            117 :                                     list_make2($4, makeBoolAConst($5, -1)),
                              16438                 :            117 :                                     @1);
                              16439                 :                : 
 7215 peter_e@gmx.net         16440                 :            117 :                     x->xmloption = $3;
 1637 peter@eisentraut.org    16441                 :            117 :                     $$ = (Node *) x;
                              16442                 :                :                 }
                              16443                 :                :             | XMLPI '(' NAME_P ColLabel ')'
                              16444                 :                :                 {
 6643 tgl@sss.pgh.pa.us       16445                 :             20 :                     $$ = makeXmlExpr(IS_XMLPI, $4, NULL, NIL, @1);
                              16446                 :                :                 }
                              16447                 :                :             | XMLPI '(' NAME_P ColLabel ',' a_expr ')'
                              16448                 :                :                 {
                              16449                 :             33 :                     $$ = makeXmlExpr(IS_XMLPI, $4, NULL, list_make1($6), @1);
                              16450                 :                :                 }
                              16451                 :                :             | XMLROOT '(' a_expr ',' xml_root_version opt_xml_root_standalone ')'
                              16452                 :                :                 {
 7256                         16453                 :             45 :                     $$ = makeXmlExpr(IS_XMLROOT, NULL, NIL,
 6643                         16454                 :             45 :                                      list_make3($3, $5, $6), @1);
                              16455                 :                :                 }
                              16456                 :                :             | XMLSERIALIZE '(' document_or_content a_expr AS SimpleTypename xml_indent_option ')'
                              16457                 :                :                 {
 7215 peter_e@gmx.net         16458                 :            168 :                     XmlSerialize *n = makeNode(XmlSerialize);
                              16459                 :                : 
                              16460                 :            168 :                     n->xmloption = $3;
                              16461                 :            168 :                     n->expr = $4;
 6321                         16462                 :            168 :                     n->typeName = $6;
 1331 tgl@sss.pgh.pa.us       16463                 :            168 :                     n->indent = $7;
 6643                         16464                 :            168 :                     n->location = @1;
 1637 peter@eisentraut.org    16465                 :            168 :                     $$ = (Node *) n;
                              16466                 :                :                 }
                              16467                 :                :             | JSON_OBJECT '(' func_arg_list ')'
                              16468                 :                :                 {
                              16469                 :                :                     /* Support for legacy (non-standard) json_object() */
 1317 alvherre@alvh.no-ip.    16470                 :             60 :                     $$ = (Node *) makeFuncCall(SystemFuncName("json_object"),
                              16471                 :             60 :                                                $3, COERCE_EXPLICIT_CALL, @1);
                              16472                 :                :                 }
                              16473                 :                :             | JSON_OBJECT '(' json_name_and_value_list
                              16474                 :                :                 json_object_constructor_null_clause_opt
                              16475                 :                :                 json_key_uniqueness_constraint_opt
                              16476                 :                :                 json_returning_clause_opt ')'
                              16477                 :                :                 {
                              16478                 :            347 :                     JsonObjectConstructor *n = makeNode(JsonObjectConstructor);
                              16479                 :                : 
                              16480                 :            347 :                     n->exprs = $3;
                              16481                 :            347 :                     n->absent_on_null = $4;
                              16482                 :            347 :                     n->unique = $5;
                              16483                 :            347 :                     n->output = (JsonOutput *) $6;
                              16484                 :            347 :                     n->location = @1;
                              16485                 :            347 :                     $$ = (Node *) n;
                              16486                 :                :                 }
                              16487                 :                :             | JSON_OBJECT '(' json_returning_clause_opt ')'
                              16488                 :                :                 {
                              16489                 :             59 :                     JsonObjectConstructor *n = makeNode(JsonObjectConstructor);
                              16490                 :                : 
                              16491                 :             59 :                     n->exprs = NULL;
                              16492                 :             59 :                     n->absent_on_null = false;
                              16493                 :             59 :                     n->unique = false;
                              16494                 :             59 :                     n->output = (JsonOutput *) $3;
                              16495                 :             59 :                     n->location = @1;
                              16496                 :             59 :                     $$ = (Node *) n;
                              16497                 :                :                 }
                              16498                 :                :             | JSON_ARRAY '('
                              16499                 :                :                 json_value_expr_list
                              16500                 :                :                 json_array_constructor_null_clause_opt
                              16501                 :                :                 json_returning_clause_opt
                              16502                 :                :             ')'
                              16503                 :                :                 {
                              16504                 :            174 :                     JsonArrayConstructor *n = makeNode(JsonArrayConstructor);
                              16505                 :                : 
                              16506                 :            174 :                     n->exprs = $3;
                              16507                 :            174 :                     n->absent_on_null = $4;
                              16508                 :            174 :                     n->output = (JsonOutput *) $5;
                              16509                 :            174 :                     n->location = @1;
                              16510                 :            174 :                     $$ = (Node *) n;
                              16511                 :                :                 }
                              16512                 :                :             | JSON_ARRAY '('
                              16513                 :                :                 select_no_parens
                              16514                 :                :                 json_format_clause_opt
                              16515                 :                :                 /* json_array_constructor_null_clause_opt */
                              16516                 :                :                 json_returning_clause_opt
                              16517                 :                :             ')'
                              16518                 :                :                 {
                              16519                 :             99 :                     JsonArrayQueryConstructor *n = makeNode(JsonArrayQueryConstructor);
                              16520                 :                : 
                              16521                 :             99 :                     n->query = $3;
                              16522                 :             99 :                     n->format = (JsonFormat *) $4;
                              16523                 :             99 :                     n->absent_on_null = true;    /* XXX */
                              16524                 :             99 :                     n->output = (JsonOutput *) $5;
                              16525                 :             99 :                     n->location = @1;
                              16526                 :             99 :                     $$ = (Node *) n;
                              16527                 :                :                 }
                              16528                 :                :             | JSON_ARRAY '('
                              16529                 :                :                 json_returning_clause_opt
                              16530                 :                :             ')'
                              16531                 :                :                 {
                              16532                 :             55 :                     JsonArrayConstructor *n = makeNode(JsonArrayConstructor);
                              16533                 :                : 
                              16534                 :             55 :                     n->exprs = NIL;
                              16535                 :             55 :                     n->absent_on_null = true;
                              16536                 :             55 :                     n->output = (JsonOutput *) $3;
                              16537                 :             55 :                     n->location = @1;
                              16538                 :             55 :                     $$ = (Node *) n;
                              16539                 :                :                 }
                              16540                 :                :             | JSON '(' json_value_expr json_key_uniqueness_constraint_opt ')'
                              16541                 :                :                 {
 1204 amitlan@postgresql.o    16542                 :            103 :                     JsonParseExpr *n = makeNode(JsonParseExpr);
                              16543                 :                : 
                              16544                 :            103 :                     n->expr = (JsonValueExpr *) $3;
                              16545                 :            103 :                     n->unique_keys = $4;
                              16546                 :            103 :                     n->output = NULL;
                              16547                 :            103 :                     n->location = @1;
                              16548                 :            103 :                     $$ = (Node *) n;
                              16549                 :                :                 }
                              16550                 :                :             | JSON_SCALAR '(' a_expr ')'
                              16551                 :                :                 {
                              16552                 :             64 :                     JsonScalarExpr *n = makeNode(JsonScalarExpr);
                              16553                 :                : 
                              16554                 :             64 :                     n->expr = (Expr *) $3;
                              16555                 :             64 :                     n->output = NULL;
                              16556                 :             64 :                     n->location = @1;
                              16557                 :             64 :                     $$ = (Node *) n;
                              16558                 :                :                 }
                              16559                 :                :             | JSON_SERIALIZE '(' json_value_expr json_returning_clause_opt ')'
                              16560                 :                :                 {
                              16561                 :             65 :                     JsonSerializeExpr *n = makeNode(JsonSerializeExpr);
                              16562                 :                : 
                              16563                 :             65 :                     n->expr = (JsonValueExpr *) $3;
                              16564                 :             65 :                     n->output = (JsonOutput *) $4;
                              16565                 :             65 :                     n->location = @1;
                              16566                 :             65 :                     $$ = (Node *) n;
                              16567                 :                :                 }
                              16568                 :                :             | MERGE_ACTION '(' ')'
                              16569                 :                :                 {
  963 dean.a.rasheed@gmail    16570                 :            152 :                     MergeSupportFunc *m = makeNode(MergeSupportFunc);
                              16571                 :                : 
                              16572                 :            152 :                     m->msftype = TEXTOID;
                              16573                 :            152 :                     m->location = @1;
                              16574                 :            152 :                     $$ = (Node *) m;
                              16575                 :                :                 }
                              16576                 :                :             | JSON_QUERY '('
                              16577                 :                :                 json_value_expr ',' a_expr json_passing_clause_opt
                              16578                 :                :                 json_returning_clause_opt
                              16579                 :                :                 json_wrapper_behavior
                              16580                 :                :                 json_quotes_clause_opt
                              16581                 :                :                 json_behavior_clause_opt
                              16582                 :                :             ')'
                              16583                 :                :                 {
  959 amitlan@postgresql.o    16584                 :            764 :                     JsonFuncExpr *n = makeNode(JsonFuncExpr);
                              16585                 :                : 
                              16586                 :            764 :                     n->op = JSON_QUERY_OP;
                              16587                 :            764 :                     n->context_item = (JsonValueExpr *) $3;
                              16588                 :            764 :                     n->pathspec = $5;
                              16589                 :            764 :                     n->passing = $6;
                              16590                 :            764 :                     n->output = (JsonOutput *) $7;
                              16591                 :            764 :                     n->wrapper = $8;
                              16592                 :            764 :                     n->quotes = $9;
                              16593                 :            764 :                     n->on_empty = (JsonBehavior *) linitial($10);
                              16594                 :            764 :                     n->on_error = (JsonBehavior *) lsecond($10);
                              16595                 :            764 :                     n->location = @1;
                              16596                 :            764 :                     $$ = (Node *) n;
                              16597                 :                :                 }
                              16598                 :                :             | JSON_EXISTS '('
                              16599                 :                :                 json_value_expr ',' a_expr json_passing_clause_opt
                              16600                 :                :                 json_on_error_clause_opt
                              16601                 :                :             ')'
                              16602                 :                :                 {
                              16603                 :            127 :                     JsonFuncExpr *n = makeNode(JsonFuncExpr);
                              16604                 :                : 
                              16605                 :            127 :                     n->op = JSON_EXISTS_OP;
                              16606                 :            127 :                     n->context_item = (JsonValueExpr *) $3;
                              16607                 :            127 :                     n->pathspec = $5;
                              16608                 :            127 :                     n->passing = $6;
                              16609                 :            127 :                     n->output = NULL;
                              16610                 :            127 :                     n->on_error = (JsonBehavior *) $7;
                              16611                 :            127 :                     n->location = @1;
                              16612                 :            127 :                     $$ = (Node *) n;
                              16613                 :                :                 }
                              16614                 :                :             | JSON_VALUE '('
                              16615                 :                :                 json_value_expr ',' a_expr json_passing_clause_opt
                              16616                 :                :                 json_returning_clause_opt
                              16617                 :                :                 json_behavior_clause_opt
                              16618                 :                :             ')'
                              16619                 :                :                 {
                              16620                 :            532 :                     JsonFuncExpr *n = makeNode(JsonFuncExpr);
                              16621                 :                : 
                              16622                 :            532 :                     n->op = JSON_VALUE_OP;
                              16623                 :            532 :                     n->context_item = (JsonValueExpr *) $3;
                              16624                 :            532 :                     n->pathspec = $5;
                              16625                 :            532 :                     n->passing = $6;
                              16626                 :            532 :                     n->output = (JsonOutput *) $7;
                              16627                 :            532 :                     n->on_empty = (JsonBehavior *) linitial($8);
                              16628                 :            532 :                     n->on_error = (JsonBehavior *) lsecond($8);
                              16629                 :            532 :                     n->location = @1;
                              16630                 :            532 :                     $$ = (Node *) n;
                              16631                 :                :                 }
                              16632                 :                :             ;
                              16633                 :                : 
                              16634                 :                : 
                              16635                 :                : /*
                              16636                 :                :  * SQL/XML support
                              16637                 :                :  */
                              16638                 :                : xml_root_version: VERSION_P a_expr
 7256 tgl@sss.pgh.pa.us       16639                 :             16 :                 { $$ = $2; }
                              16640                 :                :             | VERSION_P NO VALUE_P
 6643                         16641                 :             29 :                 { $$ = makeNullAConst(-1); }
                              16642                 :                :         ;
                              16643                 :                : 
                              16644                 :                : opt_xml_root_standalone: ',' STANDALONE_P YES_P
                              16645                 :             17 :                 { $$ = makeIntConst(XML_STANDALONE_YES, -1); }
                              16646                 :                :             | ',' STANDALONE_P NO
                              16647                 :              8 :                 { $$ = makeIntConst(XML_STANDALONE_NO, -1); }
                              16648                 :                :             | ',' STANDALONE_P NO VALUE_P
                              16649                 :              8 :                 { $$ = makeIntConst(XML_STANDALONE_NO_VALUE, -1); }
                              16650                 :                :             | /*EMPTY*/
                              16651                 :             12 :                 { $$ = makeIntConst(XML_STANDALONE_OMITTED, -1); }
                              16652                 :                :         ;
                              16653                 :                : 
  240 peter@eisentraut.org    16654                 :             37 : xml_attributes: XMLATTRIBUTES '(' labeled_expr_list ')' { $$ = $3; }
                              16655                 :                :         ;
                              16656                 :                : 
                              16657                 :             58 : labeled_expr_list:  labeled_expr                    { $$ = list_make1($1); }
                              16658                 :             95 :             | labeled_expr_list ',' labeled_expr    { $$ = lappend($1, $3); }
                              16659                 :                :         ;
                              16660                 :                : 
                              16661                 :                : labeled_expr: a_expr AS ColLabel
                              16662                 :                :                 {
 7259 peter_e@gmx.net         16663                 :             69 :                     $$ = makeNode(ResTarget);
                              16664                 :             69 :                     $$->name = $3;
 6641 tgl@sss.pgh.pa.us       16665                 :             69 :                     $$->indirection = NIL;
 7259 peter_e@gmx.net         16666                 :             69 :                     $$->val = (Node *) $1;
 7256 tgl@sss.pgh.pa.us       16667                 :             69 :                     $$->location = @1;
                              16668                 :                :                 }
                              16669                 :                :             | a_expr
                              16670                 :                :                 {
 7259 peter_e@gmx.net         16671                 :             84 :                     $$ = makeNode(ResTarget);
                              16672                 :             84 :                     $$->name = NULL;
 6641 tgl@sss.pgh.pa.us       16673                 :             84 :                     $$->indirection = NIL;
 7250                         16674                 :             84 :                     $$->val = (Node *) $1;
 7256                         16675                 :             84 :                     $$->location = @1;
                              16676                 :                :                 }
                              16677                 :                :         ;
                              16678                 :                : 
 7215 peter_e@gmx.net         16679                 :            123 : document_or_content: DOCUMENT_P                     { $$ = XMLOPTION_DOCUMENT; }
                              16680                 :            172 :             | CONTENT_P                             { $$ = XMLOPTION_CONTENT; }
                              16681                 :                :         ;
                              16682                 :                : 
 1331 tgl@sss.pgh.pa.us       16683                 :            117 : xml_indent_option: INDENT                           { $$ = true; }
                              16684                 :             23 :             | NO INDENT                             { $$ = false; }
                              16685                 :             28 :             | /*EMPTY*/                             { $$ = false; }
                              16686                 :                :         ;
                              16687                 :                : 
 3368 peter_e@gmx.net         16688                 :UBC           0 : xml_whitespace_option: PRESERVE WHITESPACE_P        { $$ = true; }
 3368 peter_e@gmx.net         16689                 :CBC           1 :             | STRIP_P WHITESPACE_P                  { $$ = false; }
                              16690                 :            116 :             | /*EMPTY*/                             { $$ = false; }
                              16691                 :                :         ;
                              16692                 :                : 
                              16693                 :                : /* We allow several variants for SQL and other compatibility. */
                              16694                 :                : xmlexists_argument:
                              16695                 :                :             PASSING c_expr
                              16696                 :                :                 {
 5936                         16697                 :            158 :                     $$ = $2;
                              16698                 :                :                 }
                              16699                 :                :             | PASSING c_expr xml_passing_mech
                              16700                 :                :                 {
 5936 peter_e@gmx.net         16701                 :UBC           0 :                     $$ = $2;
                              16702                 :                :                 }
                              16703                 :                :             | PASSING xml_passing_mech c_expr
                              16704                 :                :                 {
 2800 alvherre@alvh.no-ip.    16705                 :CBC          28 :                     $$ = $3;
                              16706                 :                :                 }
                              16707                 :                :             | PASSING xml_passing_mech c_expr xml_passing_mech
                              16708                 :                :                 {
                              16709                 :              4 :                     $$ = $3;
                              16710                 :                :                 }
                              16711                 :                :         ;
                              16712                 :                : 
                              16713                 :                : xml_passing_mech:
                              16714                 :                :             BY REF_P
                              16715                 :                :             | BY VALUE_P
                              16716                 :                :         ;
                              16717                 :                : 
                              16718                 :                : /*****************************************************************************
                              16719                 :                :  *
                              16720                 :                :  * WAIT FOR LSN
                              16721                 :                :  *
                              16722                 :                :  *****************************************************************************/
                              16723                 :                : 
                              16724                 :                : WaitStmt:
                              16725                 :                :             WAIT FOR LSN_P Sconst opt_wait_with_clause
                              16726                 :                :                 {
  365 akorotkov@postgresql    16727                 :            298 :                     WaitStmt *n = makeNode(WaitStmt);
                              16728                 :            298 :                     n->lsn_literal = $4;
                              16729                 :            298 :                     n->options = $5;
   64 michael@paquier.xyz     16730                 :            298 :                     n->lsn_location = @4;
  365 akorotkov@postgresql    16731                 :            298 :                     $$ = (Node *) n;
                              16732                 :                :                 }
                              16733                 :                :             ;
                              16734                 :                : 
                              16735                 :                : opt_wait_with_clause:
                              16736                 :            282 :             WITH '(' utility_option_list ')'        { $$ = $3; }
                              16737                 :             16 :             | /*EMPTY*/                             { $$ = NIL; }
                              16738                 :                :             ;
                              16739                 :                : 
                              16740                 :                : /*
                              16741                 :                :  * Aggregate decoration clauses
                              16742                 :                :  */
                              16743                 :                : within_group_clause:
 4700 tgl@sss.pgh.pa.us       16744                 :            228 :             WITHIN GROUP_P '(' sort_clause ')'      { $$ = $4; }
                              16745                 :         209000 :             | /*EMPTY*/                             { $$ = NIL; }
                              16746                 :                :         ;
                              16747                 :                : 
                              16748                 :                : filter_clause:
                              16749                 :            506 :             FILTER '(' WHERE a_expr ')'             { $$ = $4; }
                              16750                 :         209027 :             | /*EMPTY*/                             { $$ = NULL; }
                              16751                 :                :         ;
                              16752                 :                : 
                              16753                 :                : 
                              16754                 :                : /*
                              16755                 :                :  * Window Definitions
                              16756                 :                :  */
                              16757                 :                : null_treatment:
  398 ishii@postgresql.org    16758                 :            156 :             IGNORE_P NULLS_P                        { $$ = PARSER_IGNORE_NULLS; }
                              16759                 :             64 :             | RESPECT_P NULLS_P                     { $$ = PARSER_RESPECT_NULLS; }
                              16760                 :         209008 :             | /*EMPTY*/                             { $$ = NO_NULLTREATMENT; }
                              16761                 :                :         ;
                              16762                 :                : 
                              16763                 :                : window_clause:
 6521 tgl@sss.pgh.pa.us       16764                 :            406 :             WINDOW window_definition_list           { $$ = $2; }
                              16765                 :         314708 :             | /*EMPTY*/                             { $$ = NIL; }
                              16766                 :                :         ;
                              16767                 :                : 
                              16768                 :                : window_definition_list:
                              16769                 :            406 :             window_definition                       { $$ = list_make1($1); }
                              16770                 :                :             | window_definition_list ',' window_definition
                              16771                 :             20 :                                                     { $$ = lappend($1, $3); }
                              16772                 :                :         ;
                              16773                 :                : 
                              16774                 :                : window_definition:
                              16775                 :                :             ColId AS window_specification
                              16776                 :                :                 {
 1637 peter@eisentraut.org    16777                 :            426 :                     WindowDef  *n = $3;
                              16778                 :                : 
 6521 tgl@sss.pgh.pa.us       16779                 :            426 :                     n->name = $1;
                              16780                 :            426 :                     $$ = n;
                              16781                 :                :                 }
                              16782                 :                :         ;
                              16783                 :                : 
                              16784                 :                : over_clause: OVER window_specification
                              16785                 :           2046 :                 { $$ = $2; }
                              16786                 :                :             | OVER ColId
                              16787                 :                :                 {
 1637 peter@eisentraut.org    16788                 :            790 :                     WindowDef  *n = makeNode(WindowDef);
                              16789                 :                : 
 6518 tgl@sss.pgh.pa.us       16790                 :            790 :                     n->name = $2;
                              16791                 :            790 :                     n->refname = NULL;
 6521                         16792                 :            790 :                     n->partitionClause = NIL;
                              16793                 :            790 :                     n->orderClause = NIL;
 6518                         16794                 :            790 :                     n->frameOptions = FRAMEOPTION_DEFAULTS;
 6110                         16795                 :            790 :                     n->startOffset = NULL;
                              16796                 :            790 :                     n->endOffset = NULL;
 6521                         16797                 :            790 :                     n->location = @2;
                              16798                 :            790 :                     $$ = n;
                              16799                 :                :                 }
                              16800                 :                :             | /*EMPTY*/
                              16801                 :         206693 :                 { $$ = NULL; }
                              16802                 :                :         ;
                              16803                 :                : 
                              16804                 :                : window_specification: '(' opt_existing_window_name opt_partition_clause
                              16805                 :                :                         opt_sort_clause opt_frame_clause ')'
                              16806                 :                :                 {
 1637 peter@eisentraut.org    16807                 :           2472 :                     WindowDef  *n = makeNode(WindowDef);
                              16808                 :                : 
 6521 tgl@sss.pgh.pa.us       16809                 :           2472 :                     n->name = NULL;
                              16810                 :           2472 :                     n->refname = $2;
                              16811                 :           2472 :                     n->partitionClause = $3;
                              16812                 :           2472 :                     n->orderClause = $4;
                              16813                 :                :                     /* copy relevant fields of opt_frame_clause */
 6110                         16814                 :           2472 :                     n->frameOptions = $5->frameOptions;
                              16815                 :           2472 :                     n->startOffset = $5->startOffset;
                              16816                 :           2472 :                     n->endOffset = $5->endOffset;
 6521                         16817                 :           2472 :                     n->location = @1;
                              16818                 :           2472 :                     $$ = n;
                              16819                 :                :                 }
                              16820                 :                :         ;
                              16821                 :                : 
                              16822                 :                : /*
                              16823                 :                :  * If we see PARTITION, RANGE, ROWS or GROUPS as the first token after the '('
                              16824                 :                :  * of a window_specification, we want the assumption to be that there is
                              16825                 :                :  * no existing_window_name; but those keywords are unreserved and so could
                              16826                 :                :  * be ColIds.  We fix this by making them have the same precedence as IDENT
                              16827                 :                :  * and giving the empty production here a slightly higher precedence, so
                              16828                 :                :  * that the shift/reduce conflict is resolved in favor of reducing the rule.
                              16829                 :                :  * These keywords are thus precluded from being an existing_window_name but
                              16830                 :                :  * are not reserved for any other purpose.
                              16831                 :                :  */
                              16832                 :             36 : opt_existing_window_name: ColId                     { $$ = $1; }
                              16833                 :           2440 :             | /*EMPTY*/             %prec Op        { $$ = NULL; }
                              16834                 :                :         ;
                              16835                 :                : 
                              16836                 :            632 : opt_partition_clause: PARTITION BY expr_list        { $$ = $3; }
                              16837                 :           1840 :             | /*EMPTY*/                             { $$ = NIL; }
                              16838                 :                :         ;
                              16839                 :                : 
                              16840                 :                : /*
                              16841                 :                :  * For frame clauses, we return a WindowDef, but only some fields are used:
                              16842                 :                :  * frameOptions, startOffset, and endOffset.
                              16843                 :                :  */
                              16844                 :                : opt_frame_clause:
                              16845                 :                :             RANGE frame_extent opt_window_exclusion_clause
                              16846                 :                :                 {
 1637 peter@eisentraut.org    16847                 :            546 :                     WindowDef  *n = $2;
                              16848                 :                : 
 6110 tgl@sss.pgh.pa.us       16849                 :            546 :                     n->frameOptions |= FRAMEOPTION_NONDEFAULT | FRAMEOPTION_RANGE;
 3193                         16850                 :            546 :                     n->frameOptions |= $3;
 6110                         16851                 :            546 :                     $$ = n;
                              16852                 :                :                 }
                              16853                 :                :             | ROWS frame_extent opt_window_exclusion_clause
                              16854                 :                :                 {
 1637 peter@eisentraut.org    16855                 :            510 :                     WindowDef  *n = $2;
                              16856                 :                : 
 6110 tgl@sss.pgh.pa.us       16857                 :            510 :                     n->frameOptions |= FRAMEOPTION_NONDEFAULT | FRAMEOPTION_ROWS;
 3193                         16858                 :            510 :                     n->frameOptions |= $3;
                              16859                 :            510 :                     $$ = n;
                              16860                 :                :                 }
                              16861                 :                :             | GROUPS frame_extent opt_window_exclusion_clause
                              16862                 :                :                 {
 1637 peter@eisentraut.org    16863                 :            156 :                     WindowDef  *n = $2;
                              16864                 :                : 
 3193 tgl@sss.pgh.pa.us       16865                 :            156 :                     n->frameOptions |= FRAMEOPTION_NONDEFAULT | FRAMEOPTION_GROUPS;
                              16866                 :            156 :                     n->frameOptions |= $3;
 6110                         16867                 :            156 :                     $$ = n;
                              16868                 :                :                 }
                              16869                 :                :             | /*EMPTY*/
                              16870                 :                :                 {
 1637 peter@eisentraut.org    16871                 :           1260 :                     WindowDef  *n = makeNode(WindowDef);
                              16872                 :                : 
 6110 tgl@sss.pgh.pa.us       16873                 :           1260 :                     n->frameOptions = FRAMEOPTION_DEFAULTS;
                              16874                 :           1260 :                     n->startOffset = NULL;
                              16875                 :           1260 :                     n->endOffset = NULL;
                              16876                 :           1260 :                     $$ = n;
                              16877                 :                :                 }
                              16878                 :                :         ;
                              16879                 :                : 
                              16880                 :                : frame_extent: frame_bound
                              16881                 :                :                 {
 1637 peter@eisentraut.org    16882                 :              8 :                     WindowDef  *n = $1;
                              16883                 :                : 
                              16884                 :                :                     /* reject invalid cases */
 6110 tgl@sss.pgh.pa.us       16885         [ -  + ]:              8 :                     if (n->frameOptions & FRAMEOPTION_START_UNBOUNDED_FOLLOWING)
 6518 tgl@sss.pgh.pa.us       16886         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              16887                 :                :                                 (errcode(ERRCODE_WINDOWING_ERROR),
                              16888                 :                :                                  errmsg("frame start cannot be UNBOUNDED FOLLOWING"),
                              16889                 :                :                                  parser_errposition(@1)));
 3193 tgl@sss.pgh.pa.us       16890         [ -  + ]:CBC           8 :                     if (n->frameOptions & FRAMEOPTION_START_OFFSET_FOLLOWING)
 6518 tgl@sss.pgh.pa.us       16891         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              16892                 :                :                                 (errcode(ERRCODE_WINDOWING_ERROR),
                              16893                 :                :                                  errmsg("frame starting from following row cannot end with current row"),
                              16894                 :                :                                  parser_errposition(@1)));
 6110 tgl@sss.pgh.pa.us       16895                 :CBC           8 :                     n->frameOptions |= FRAMEOPTION_END_CURRENT_ROW;
                              16896                 :              8 :                     $$ = n;
                              16897                 :                :                 }
                              16898                 :                :             | BETWEEN frame_bound AND frame_bound
                              16899                 :                :                 {
 1637 peter@eisentraut.org    16900                 :           1204 :                     WindowDef  *n1 = $2;
                              16901                 :           1204 :                     WindowDef  *n2 = $4;
                              16902                 :                : 
                              16903                 :                :                     /* form merged options */
 6110 tgl@sss.pgh.pa.us       16904                 :           1204 :                     int     frameOptions = n1->frameOptions;
                              16905                 :                :                     /* shift converts START_ options to END_ options */
                              16906                 :           1204 :                     frameOptions |= n2->frameOptions << 1;
                              16907                 :           1204 :                     frameOptions |= FRAMEOPTION_BETWEEN;
                              16908                 :                :                     /* reject invalid cases */
                              16909         [ -  + ]:           1204 :                     if (frameOptions & FRAMEOPTION_START_UNBOUNDED_FOLLOWING)
 6518 tgl@sss.pgh.pa.us       16910         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              16911                 :                :                                 (errcode(ERRCODE_WINDOWING_ERROR),
                              16912                 :                :                                  errmsg("frame start cannot be UNBOUNDED FOLLOWING"),
                              16913                 :                :                                  parser_errposition(@2)));
 6110 tgl@sss.pgh.pa.us       16914         [ -  + ]:CBC        1204 :                     if (frameOptions & FRAMEOPTION_END_UNBOUNDED_PRECEDING)
 6518 tgl@sss.pgh.pa.us       16915         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              16916                 :                :                                 (errcode(ERRCODE_WINDOWING_ERROR),
                              16917                 :                :                                  errmsg("frame end cannot be UNBOUNDED PRECEDING"),
                              16918                 :                :                                  parser_errposition(@4)));
 6110 tgl@sss.pgh.pa.us       16919         [ +  + ]:CBC        1204 :                     if ((frameOptions & FRAMEOPTION_START_CURRENT_ROW) &&
 3193                         16920         [ -  + ]:            336 :                         (frameOptions & FRAMEOPTION_END_OFFSET_PRECEDING))
 6110 tgl@sss.pgh.pa.us       16921         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              16922                 :                :                                 (errcode(ERRCODE_WINDOWING_ERROR),
                              16923                 :                :                                  errmsg("frame starting from current row cannot have preceding rows"),
                              16924                 :                :                                  parser_errposition(@4)));
 3193 tgl@sss.pgh.pa.us       16925         [ +  + ]:CBC        1204 :                     if ((frameOptions & FRAMEOPTION_START_OFFSET_FOLLOWING) &&
                              16926         [ -  + ]:            120 :                         (frameOptions & (FRAMEOPTION_END_OFFSET_PRECEDING |
                              16927                 :                :                                          FRAMEOPTION_END_CURRENT_ROW)))
 6110 tgl@sss.pgh.pa.us       16928         [ #  # ]:UBC           0 :                         ereport(ERROR,
                              16929                 :                :                                 (errcode(ERRCODE_WINDOWING_ERROR),
                              16930                 :                :                                  errmsg("frame starting from following row cannot have preceding rows"),
                              16931                 :                :                                  parser_errposition(@4)));
 6110 tgl@sss.pgh.pa.us       16932                 :CBC        1204 :                     n1->frameOptions = frameOptions;
                              16933                 :           1204 :                     n1->endOffset = n2->startOffset;
                              16934                 :           1204 :                     $$ = n1;
                              16935                 :                :                 }
                              16936                 :                :         ;
                              16937                 :                : 
                              16938                 :                : /*
                              16939                 :                :  * This is used for both frame start and frame end, with output set up on
                              16940                 :                :  * the assumption it's frame start; the frame_extent productions must reject
                              16941                 :                :  * invalid cases.
                              16942                 :                :  */
                              16943                 :                : frame_bound:
                              16944                 :                :             UNBOUNDED PRECEDING
                              16945                 :                :                 {
 1637 peter@eisentraut.org    16946                 :            192 :                     WindowDef  *n = makeNode(WindowDef);
                              16947                 :                : 
 6110 tgl@sss.pgh.pa.us       16948                 :            192 :                     n->frameOptions = FRAMEOPTION_START_UNBOUNDED_PRECEDING;
                              16949                 :            192 :                     n->startOffset = NULL;
                              16950                 :            192 :                     n->endOffset = NULL;
                              16951                 :            192 :                     $$ = n;
                              16952                 :                :                 }
                              16953                 :                :             | UNBOUNDED FOLLOWING
                              16954                 :                :                 {
 1637 peter@eisentraut.org    16955                 :            266 :                     WindowDef  *n = makeNode(WindowDef);
                              16956                 :                : 
 6110 tgl@sss.pgh.pa.us       16957                 :            266 :                     n->frameOptions = FRAMEOPTION_START_UNBOUNDED_FOLLOWING;
                              16958                 :            266 :                     n->startOffset = NULL;
                              16959                 :            266 :                     n->endOffset = NULL;
                              16960                 :            266 :                     $$ = n;
                              16961                 :                :                 }
                              16962                 :                :             | CURRENT_P ROW
                              16963                 :                :                 {
 1637 peter@eisentraut.org    16964                 :            464 :                     WindowDef  *n = makeNode(WindowDef);
                              16965                 :                : 
 6110 tgl@sss.pgh.pa.us       16966                 :            464 :                     n->frameOptions = FRAMEOPTION_START_CURRENT_ROW;
                              16967                 :            464 :                     n->startOffset = NULL;
                              16968                 :            464 :                     n->endOffset = NULL;
                              16969                 :            464 :                     $$ = n;
                              16970                 :                :                 }
                              16971                 :                :             | a_expr PRECEDING
                              16972                 :                :                 {
 1637 peter@eisentraut.org    16973                 :            664 :                     WindowDef  *n = makeNode(WindowDef);
                              16974                 :                : 
 3193 tgl@sss.pgh.pa.us       16975                 :            664 :                     n->frameOptions = FRAMEOPTION_START_OFFSET_PRECEDING;
 6110                         16976                 :            664 :                     n->startOffset = $1;
                              16977                 :            664 :                     n->endOffset = NULL;
                              16978                 :            664 :                     $$ = n;
                              16979                 :                :                 }
                              16980                 :                :             | a_expr FOLLOWING
                              16981                 :                :                 {
 1637 peter@eisentraut.org    16982                 :            830 :                     WindowDef  *n = makeNode(WindowDef);
                              16983                 :                : 
 3193 tgl@sss.pgh.pa.us       16984                 :            830 :                     n->frameOptions = FRAMEOPTION_START_OFFSET_FOLLOWING;
 6110                         16985                 :            830 :                     n->startOffset = $1;
                              16986                 :            830 :                     n->endOffset = NULL;
                              16987                 :            830 :                     $$ = n;
                              16988                 :                :                 }
                              16989                 :                :         ;
                              16990                 :                : 
                              16991                 :                : opt_window_exclusion_clause:
 3193                         16992                 :             92 :             EXCLUDE CURRENT_P ROW   { $$ = FRAMEOPTION_EXCLUDE_CURRENT_ROW; }
                              16993                 :             72 :             | EXCLUDE GROUP_P       { $$ = FRAMEOPTION_EXCLUDE_GROUP; }
                              16994                 :            108 :             | EXCLUDE TIES          { $$ = FRAMEOPTION_EXCLUDE_TIES; }
                              16995                 :             12 :             | EXCLUDE NO OTHERS     { $$ = 0; }
                              16996                 :            928 :             | /*EMPTY*/             { $$ = 0; }
                              16997                 :                :         ;
                              16998                 :                : 
                              16999                 :                : 
                              17000                 :                : /*
                              17001                 :                :  * Supporting nonterminals for expressions.
                              17002                 :                :  */
                              17003                 :                : 
                              17004                 :                : /* Explicit row production.
                              17005                 :                :  *
                              17006                 :                :  * SQL99 allows an optional ROW keyword, so we can now do single-element rows
                              17007                 :                :  * without conflicting with the parenthesized a_expr production.  Without the
                              17008                 :                :  * ROW keyword, there must be more than one a_expr inside the parens.
                              17009                 :                :  */
 8214 tgl@sss.pgh.pa.us       17010                 :UBC           0 : row:        ROW '(' expr_list ')'                   { $$ = $3; }
                              17011                 :              0 :             | ROW '(' ')'                           { $$ = NIL; }
 8214 tgl@sss.pgh.pa.us       17012                 :CBC        1162 :             | '(' expr_list ',' a_expr ')'          { $$ = lappend($2, $4); }
                              17013                 :                :         ;
                              17014                 :                : 
 4191 andres@anarazel.de      17015                 :           2701 : explicit_row:   ROW '(' expr_list ')'               { $$ = $3; }
                              17016                 :             24 :             | ROW '(' ')'                           { $$ = NIL; }
                              17017                 :                :         ;
                              17018                 :                : 
                              17019                 :           1836 : implicit_row:   '(' expr_list ',' a_expr ')'        { $$ = lappend($2, $4); }
                              17020                 :                :         ;
                              17021                 :                : 
 8214 tgl@sss.pgh.pa.us       17022                 :          11048 : sub_type:   ANY                                     { $$ = ANY_SUBLINK; }
 8214 tgl@sss.pgh.pa.us       17023                 :UBC           0 :             | SOME                                  { $$ = ANY_SUBLINK; }
 8214 tgl@sss.pgh.pa.us       17024                 :CBC         233 :             | ALL                                   { $$ = ALL_SUBLINK; }
                              17025                 :                :         ;
                              17026                 :                : 
                              17027                 :           7652 : all_Op:     Op                                      { $$ = $1; }
                              17028                 :          17733 :             | MathOp                                { $$ = $1; }
                              17029                 :                :         ;
                              17030                 :                : 
                              17031                 :             25 : MathOp:      '+'                                    { $$ = "+"; }
                              17032                 :             34 :             | '-'                                   { $$ = "-"; }
                              17033                 :             94 :             | '*'                                   { $$ = "*"; }
 8214 tgl@sss.pgh.pa.us       17034                 :UBC           0 :             | '/'                                   { $$ = "/"; }
 8214 tgl@sss.pgh.pa.us       17035                 :CBC           4 :             | '%'                                   { $$ = "%"; }
 8214 tgl@sss.pgh.pa.us       17036                 :UBC           0 :             | '^'                                   { $$ = "^"; }
 8214 tgl@sss.pgh.pa.us       17037                 :CBC         589 :             | '<'                                    { $$ = "<"; }
                              17038                 :            514 :             | '>'                                    { $$ = ">"; }
                              17039                 :          15071 :             | '='                                   { $$ = "="; }
 4257                         17040                 :            482 :             | LESS_EQUALS                           { $$ = "<="; }
                              17041                 :            476 :             | GREATER_EQUALS                        { $$ = ">="; }
                              17042                 :            444 :             | NOT_EQUALS                            { $$ = "<>"; }
                              17043                 :                :         ;
                              17044                 :                : 
                              17045                 :                : qual_Op:    Op
 8194 neilc@samurai.com       17046                 :          28219 :                     { $$ = list_make1(makeString($1)); }
                              17047                 :                :             | OPERATOR '(' any_operator ')'
 8214 tgl@sss.pgh.pa.us       17048                 :           9584 :                     { $$ = $3; }
                              17049                 :                :         ;
                              17050                 :                : 
                              17051                 :                : qual_all_Op:
                              17052                 :                :             all_Op
 8194 neilc@samurai.com       17053                 :            791 :                     { $$ = list_make1(makeString($1)); }
                              17054                 :                :             | OPERATOR '(' any_operator ')'
 8214 tgl@sss.pgh.pa.us       17055                 :             17 :                     { $$ = $3; }
                              17056                 :                :         ;
                              17057                 :                : 
                              17058                 :                : subquery_Op:
                              17059                 :                :             all_Op
 8194 neilc@samurai.com       17060                 :          11102 :                     { $$ = list_make1(makeString($1)); }
                              17061                 :                :             | OPERATOR '(' any_operator ')'
 8214 tgl@sss.pgh.pa.us       17062                 :            157 :                     { $$ = $3; }
                              17063                 :                :             | LIKE
 8194 neilc@samurai.com       17064                 :             16 :                     { $$ = list_make1(makeString("~~")); }
                              17065                 :                :             | NOT_LA LIKE
                              17066                 :              8 :                     { $$ = list_make1(makeString("!~~")); }
                              17067                 :                :             | ILIKE
                              17068                 :              8 :                     { $$ = list_make1(makeString("~~*")); }
                              17069                 :                :             | NOT_LA ILIKE
 8194 neilc@samurai.com       17070                 :UBC           0 :                     { $$ = list_make1(makeString("!~~*")); }
                              17071                 :                : /* cannot put SIMILAR TO here, because SIMILAR TO is a hack.
                              17072                 :                :  * the regular expression is preprocessed by a function (similar_to_escape),
                              17073                 :                :  * and the ~ operator for posix regular expressions is used.
                              17074                 :                :  *        x SIMILAR TO y     ->    x ~ similar_to_escape(y)
                              17075                 :                :  * this transformation is made on the fly by the parser upwards.
                              17076                 :                :  * however the SubLink structure which handles any/some/all stuff
                              17077                 :                :  * is not ready for such a thing.
                              17078                 :                :  */
                              17079                 :                :             ;
                              17080                 :                : 
                              17081                 :                : expr_list:  a_expr
                              17082                 :                :                 {
 8192 tgl@sss.pgh.pa.us       17083                 :CBC      106941 :                     $$ = list_make1($1);
                              17084                 :                :                 }
                              17085                 :                :             | expr_list ',' a_expr
                              17086                 :                :                 {
                              17087                 :          96129 :                     $$ = lappend($1, $3);
                              17088                 :                :                 }
                              17089                 :                :         ;
                              17090                 :                : 
                              17091                 :                : /* function arguments can have names */
                              17092                 :                : func_arg_list:  func_arg_expr
                              17093                 :                :                 {
 6237                         17094                 :         208177 :                     $$ = list_make1($1);
                              17095                 :                :                 }
                              17096                 :                :             | func_arg_list ',' func_arg_expr
                              17097                 :                :                 {
                              17098                 :         182425 :                     $$ = lappend($1, $3);
                              17099                 :                :                 }
                              17100                 :                :         ;
                              17101                 :                : 
                              17102                 :                : func_arg_expr:  a_expr
                              17103                 :                :                 {
                              17104                 :         364531 :                     $$ = $1;
                              17105                 :                :                 }
                              17106                 :                :             | param_name COLON_EQUALS a_expr
                              17107                 :                :                 {
                              17108                 :          24924 :                     NamedArgExpr *na = makeNode(NamedArgExpr);
                              17109                 :                : 
 6003                         17110                 :          24924 :                     na->name = $1;
                              17111                 :          24924 :                     na->arg = (Expr *) $3;
 6237                         17112                 :          24924 :                     na->argnumber = -1;      /* until determined */
 6003                         17113                 :          24924 :                     na->location = @1;
 6237                         17114                 :          24924 :                     $$ = (Node *) na;
                              17115                 :                :                 }
                              17116                 :                :             | param_name EQUALS_GREATER a_expr
                              17117                 :                :                 {
 4258 rhaas@postgresql.org    17118                 :           1652 :                     NamedArgExpr *na = makeNode(NamedArgExpr);
                              17119                 :                : 
                              17120                 :           1652 :                     na->name = $1;
                              17121                 :           1652 :                     na->arg = (Expr *) $3;
                              17122                 :           1652 :                     na->argnumber = -1;      /* until determined */
                              17123                 :           1652 :                     na->location = @1;
                              17124                 :           1652 :                     $$ = (Node *) na;
                              17125                 :                :                 }
                              17126                 :                :         ;
                              17127                 :                : 
 2192 tgl@sss.pgh.pa.us       17128                 :            200 : func_arg_list_opt:  func_arg_list                   { $$ = $1; }
 2192 tgl@sss.pgh.pa.us       17129                 :UBC           0 :             | /*EMPTY*/                             { $$ = NIL; }
                              17130                 :                :         ;
                              17131                 :                : 
 7226 tgl@sss.pgh.pa.us       17132                 :CBC        1102 : type_list:  Typename                                { $$ = list_make1($1); }
                              17133                 :            318 :             | type_list ',' Typename                { $$ = lappend($1, $3); }
                              17134                 :                :         ;
                              17135                 :                : 
                              17136                 :                : array_expr: '[' expr_list ']'
                              17137                 :                :                 {
  511 alvherre@kurilemu.de    17138                 :           5597 :                     $$ = makeAArrayExpr($2, @1, @3);
                              17139                 :                :                 }
                              17140                 :                :             | '[' array_expr_list ']'
                              17141                 :                :                 {
                              17142                 :            255 :                     $$ = makeAArrayExpr($2, @1, @3);
                              17143                 :                :                 }
                              17144                 :                :             | '[' ']'
                              17145                 :                :                 {
                              17146                 :             74 :                     $$ = makeAArrayExpr(NIL, @1, @2);
                              17147                 :                :                 }
                              17148                 :                :         ;
                              17149                 :                : 
 6804 tgl@sss.pgh.pa.us       17150                 :            255 : array_expr_list: array_expr                         { $$ = list_make1($1); }
                              17151                 :            208 :             | array_expr_list ',' array_expr        { $$ = lappend($1, $3); }
                              17152                 :                :         ;
                              17153                 :                : 
                              17154                 :                : 
                              17155                 :                : extract_list:
                              17156                 :                :             extract_arg FROM a_expr
                              17157                 :                :                 {
 6643                         17158                 :            892 :                     $$ = list_make2(makeStringConst($1, @1), $3);
                              17159                 :                :                 }
                              17160                 :                :         ;
                              17161                 :                : 
                              17162                 :                : /* Allow delimited string Sconst in extract_arg as an SQL extension.
                              17163                 :                :  * - thomas 2001-04-12
                              17164                 :                :  */
                              17165                 :                : extract_arg:
 8907 bruce@momjian.us        17166                 :            720 :             IDENT                                   { $$ = $1; }
                              17167                 :             48 :             | YEAR_P                                { $$ = "year"; }
                              17168                 :             28 :             | MONTH_P                               { $$ = "month"; }
                              17169                 :             36 :             | DAY_P                                 { $$ = "day"; }
                              17170                 :             20 :             | HOUR_P                                { $$ = "hour"; }
                              17171                 :             20 :             | MINUTE_P                              { $$ = "minute"; }
                              17172                 :             20 :             | SECOND_P                              { $$ = "second"; }
 6567 meskes@postgresql.or    17173                 :UBC           0 :             | Sconst                                { $$ = $1; }
                              17174                 :                :         ;
                              17175                 :                : 
                              17176                 :                : unicode_normal_form:
 2192 tgl@sss.pgh.pa.us       17177                 :CBC          52 :             NFC                                     { $$ = "NFC"; }
                              17178                 :             24 :             | NFD                                   { $$ = "NFD"; }
                              17179                 :             12 :             | NFKC                                  { $$ = "NFKC"; }
                              17180                 :             12 :             | NFKD                                  { $$ = "NFKD"; }
                              17181                 :                :         ;
                              17182                 :                : 
                              17183                 :                : /* OVERLAY() arguments */
                              17184                 :                : overlay_list:
                              17185                 :                :             a_expr PLACING a_expr FROM a_expr FOR a_expr
                              17186                 :                :                 {
                              17187                 :                :                     /* overlay(A PLACING B FROM C FOR D) is converted to overlay(A, B, C, D) */
 2320 peter@eisentraut.org    17188                 :             22 :                     $$ = list_make4($1, $3, $5, $7);
                              17189                 :                :                 }
                              17190                 :                :             | a_expr PLACING a_expr FROM a_expr
                              17191                 :                :                 {
                              17192                 :                :                     /* overlay(A PLACING B FROM C) is converted to overlay(A, B, C) */
                              17193                 :             32 :                     $$ = list_make3($1, $3, $5);
                              17194                 :                :                 }
                              17195                 :                :         ;
                              17196                 :                : 
                              17197                 :                : /* position_list uses b_expr not a_expr to avoid conflict with general IN */
                              17198                 :                : position_list:
 8194 neilc@samurai.com       17199                 :            279 :             b_expr IN_P b_expr                      { $$ = list_make2($3, $1); }
                              17200                 :                :         ;
                              17201                 :                : 
                              17202                 :                : /*
                              17203                 :                :  * SUBSTRING() arguments
                              17204                 :                :  *
                              17205                 :                :  * Note that SQL:1999 has both
                              17206                 :                :  *     text FROM int FOR int
                              17207                 :                :  * and
                              17208                 :                :  *     text FROM pattern FOR escape
                              17209                 :                :  *
                              17210                 :                :  * In the parser we map them both to a call to the substring() function and
                              17211                 :                :  * rely on type resolution to pick the right one.
                              17212                 :                :  *
                              17213                 :                :  * In SQL:2003, the second variant was changed to
                              17214                 :                :  *     text SIMILAR pattern ESCAPE escape
                              17215                 :                :  * We could in theory map that to a different function internally, but
                              17216                 :                :  * since we still support the SQL:1999 version, we don't.  However,
                              17217                 :                :  * ruleutils.c will reverse-list the call in the newer style.
                              17218                 :                :  */
                              17219                 :                : substr_list:
                              17220                 :                :             a_expr FROM a_expr FOR a_expr
                              17221                 :                :                 {
 2320 peter@eisentraut.org    17222                 :            101 :                     $$ = list_make3($1, $3, $5);
                              17223                 :                :                 }
                              17224                 :                :             | a_expr FOR a_expr FROM a_expr
                              17225                 :                :                 {
                              17226                 :                :                     /* not legal per SQL, but might as well allow it */
 2320 peter@eisentraut.org    17227                 :UBC           0 :                     $$ = list_make3($1, $5, $3);
                              17228                 :                :                 }
                              17229                 :                :             | a_expr FROM a_expr
                              17230                 :                :                 {
                              17231                 :                :                     /*
                              17232                 :                :                      * Because we aren't restricting data types here, this
                              17233                 :                :                      * syntax can end up resolving to textregexsubstr().
                              17234                 :                :                      * We've historically allowed that to happen, so continue
                              17235                 :                :                      * to accept it.  However, ruleutils.c will reverse-list
                              17236                 :                :                      * such a call in regular function call syntax.
                              17237                 :                :                      */
 2320 peter@eisentraut.org    17238                 :CBC         225 :                     $$ = list_make2($1, $3);
                              17239                 :                :                 }
                              17240                 :                :             | a_expr FOR a_expr
                              17241                 :                :                 {
                              17242                 :                :                     /* not legal per SQL */
                              17243                 :                : 
                              17244                 :                :                     /*
                              17245                 :                :                      * Since there are no cases where this syntax allows
                              17246                 :                :                      * a textual FOR value, we forcibly cast the argument
                              17247                 :                :                      * to int4.  The possible matches in pg_proc are
                              17248                 :                :                      * substring(text,int4) and substring(text,text),
                              17249                 :                :                      * and we don't want the parser to choose the latter,
                              17250                 :                :                      * which it is likely to do if the second argument
                              17251                 :                :                      * is unknown or doesn't have an implicit cast to int4.
                              17252                 :                :                      */
 6643 tgl@sss.pgh.pa.us       17253                 :             35 :                     $$ = list_make3($1, makeIntConst(1, -1),
                              17254                 :                :                                     makeTypeCast($3,
                              17255                 :                :                                                  SystemTypeName("int4"), -1));
                              17256                 :                :                 }
                              17257                 :                :             | a_expr SIMILAR a_expr ESCAPE a_expr
                              17258                 :                :                 {
 2320 peter@eisentraut.org    17259                 :            118 :                     $$ = list_make3($1, $3, $5);
                              17260                 :                :                 }
                              17261                 :                :         ;
                              17262                 :                : 
 8907 bruce@momjian.us        17263                 :            396 : trim_list:  a_expr FROM expr_list                   { $$ = lappend($3, $1); }
                              17264                 :             16 :             | FROM expr_list                        { $$ = $2; }
                              17265                 :             56 :             | expr_list                             { $$ = $1; }
                              17266                 :                :         ;
                              17267                 :                : 
                              17268                 :                : /*
                              17269                 :                :  * Define SQL-style CASE clause.
                              17270                 :                :  * - Full specification
                              17271                 :                :  *  CASE WHEN a = b THEN c ... ELSE d END
                              17272                 :                :  * - Implicit argument
                              17273                 :                :  *  CASE a WHEN b THEN c ... ELSE d END
                              17274                 :                :  */
                              17275                 :                : case_expr:  CASE case_arg when_clause_list case_default END_P
                              17276                 :                :                 {
 1637 peter@eisentraut.org    17277                 :          25494 :                     CaseExpr   *c = makeNode(CaseExpr);
                              17278                 :                : 
 8268 tgl@sss.pgh.pa.us       17279                 :          25494 :                     c->casetype = InvalidOid; /* not analyzed yet */
 8729                         17280                 :          25494 :                     c->arg = (Expr *) $2;
10198 lockhart@fourpalms.o    17281                 :          25494 :                     c->args = $3;
 8729 tgl@sss.pgh.pa.us       17282                 :          25494 :                     c->defresult = (Expr *) $4;
 6643                         17283                 :          25494 :                     c->location = @1;
 1637 peter@eisentraut.org    17284                 :          25494 :                     $$ = (Node *) c;
                              17285                 :                :                 }
                              17286                 :                :         ;
                              17287                 :                : 
                              17288                 :                : when_clause_list:
                              17289                 :                :             /* There must be at least one */
 8194 neilc@samurai.com       17290                 :          25494 :             when_clause                             { $$ = list_make1($1); }
 8906 bruce@momjian.us        17291                 :          19873 :             | when_clause_list when_clause          { $$ = lappend($1, $2); }
                              17292                 :                :         ;
                              17293                 :                : 
                              17294                 :                : when_clause:
                              17295                 :                :             WHEN a_expr THEN a_expr
                              17296                 :                :                 {
 1637 peter@eisentraut.org    17297                 :          45367 :                     CaseWhen   *w = makeNode(CaseWhen);
                              17298                 :                : 
 8729 tgl@sss.pgh.pa.us       17299                 :          45367 :                     w->expr = (Expr *) $2;
                              17300                 :          45367 :                     w->result = (Expr *) $4;
 6643                         17301                 :          45367 :                     w->location = @1;
 1637 peter@eisentraut.org    17302                 :          45367 :                     $$ = (Node *) w;
                              17303                 :                :                 }
                              17304                 :                :         ;
                              17305                 :                : 
                              17306                 :                : case_default:
 8907 bruce@momjian.us        17307                 :          18962 :             ELSE a_expr                             { $$ = $2; }
                              17308                 :           6532 :             | /*EMPTY*/                             { $$ = NULL; }
                              17309                 :                :         ;
                              17310                 :                : 
                              17311                 :           5042 : case_arg:   a_expr                                  { $$ = $1; }
                              17312                 :          20452 :             | /*EMPTY*/                             { $$ = NULL; }
                              17313                 :                :         ;
                              17314                 :                : 
                              17315                 :                : columnref:  ColId
                              17316                 :                :                 {
 6324 tgl@sss.pgh.pa.us       17317                 :         464973 :                     $$ = makeColumnRef($1, NIL, @1, yyscanner);
                              17318                 :                :                 }
                              17319                 :                :             | ColId indirection
                              17320                 :                :                 {
                              17321                 :         700999 :                     $$ = makeColumnRef($1, $2, @1, yyscanner);
                              17322                 :                :                 }
                              17323                 :                :         ;
                              17324                 :                : 
                              17325                 :                : indirection_el:
                              17326                 :                :             '.' attr_name
                              17327                 :                :                 {
 8184                         17328                 :         950583 :                     $$ = (Node *) makeString($2);
                              17329                 :                :                 }
                              17330                 :                :             | '.' '*'
                              17331                 :                :                 {
 6641                         17332                 :           4739 :                     $$ = (Node *) makeNode(A_Star);
                              17333                 :                :                 }
                              17334                 :                :             | '[' a_expr ']'
                              17335                 :                :                 {
 8184                         17336                 :           8662 :                     A_Indices *ai = makeNode(A_Indices);
                              17337                 :                : 
 3971                         17338                 :           8662 :                     ai->is_slice = false;
 8184                         17339                 :           8662 :                     ai->lidx = NULL;
                              17340                 :           8662 :                     ai->uidx = $2;
                              17341                 :           8662 :                     $$ = (Node *) ai;
                              17342                 :                :                 }
                              17343                 :                :             | '[' opt_slice_bound ':' opt_slice_bound ']'
                              17344                 :                :                 {
                              17345                 :            405 :                     A_Indices *ai = makeNode(A_Indices);
                              17346                 :                : 
 3971                         17347                 :            405 :                     ai->is_slice = true;
 8184                         17348                 :            405 :                     ai->lidx = $2;
                              17349                 :            405 :                     ai->uidx = $4;
                              17350                 :            405 :                     $$ = (Node *) ai;
                              17351                 :                :                 }
                              17352                 :                :         ;
                              17353                 :                : 
                              17354                 :                : opt_slice_bound:
 3971                         17355                 :            690 :             a_expr                                  { $$ = $1; }
                              17356                 :            120 :             | /*EMPTY*/                             { $$ = NULL; }
                              17357                 :                :         ;
                              17358                 :                : 
                              17359                 :                : indirection:
 8184                         17360                 :         949382 :             indirection_el                          { $$ = list_make1($1); }
                              17361                 :           2078 :             | indirection indirection_el            { $$ = lappend($1, $2); }
                              17362                 :                :         ;
                              17363                 :                : 
                              17364                 :                : opt_indirection:
                              17365                 :         121834 :             /*EMPTY*/                               { $$ = NIL; }
                              17366                 :          12929 :             | opt_indirection indirection_el        { $$ = lappend($1, $2); }
                              17367                 :                :         ;
                              17368                 :                : 
                              17369                 :                : opt_asymmetric: ASYMMETRIC
                              17370                 :                :             | /*EMPTY*/
                              17371                 :                :         ;
                              17372                 :                : 
                              17373                 :                : /* SQL/JSON support */
                              17374                 :                : json_passing_clause_opt:
  959 amitlan@postgresql.o    17375                 :            254 :             PASSING json_arguments                  { $$ = $2; }
                              17376                 :           1749 :             | /*EMPTY*/                             { $$ = NIL; }
                              17377                 :                :         ;
                              17378                 :                : 
                              17379                 :                : json_arguments:
                              17380                 :            254 :             json_argument                           { $$ = list_make1($1); }
                              17381                 :            105 :             | json_arguments ',' json_argument      { $$ = lappend($1, $3); }
                              17382                 :                :         ;
                              17383                 :                : 
                              17384                 :                : json_argument:
                              17385                 :                :             json_value_expr AS ColLabel
                              17386                 :                :             {
                              17387                 :            359 :                 JsonArgument *n = makeNode(JsonArgument);
                              17388                 :                : 
                              17389                 :            359 :                 n->val = (JsonValueExpr *) $1;
                              17390                 :            359 :                 n->name = $3;
                              17391                 :            359 :                 $$ = (Node *) n;
                              17392                 :                :             }
                              17393                 :                :         ;
                              17394                 :                : 
                              17395                 :                : /* ARRAY is a noise word */
                              17396                 :                : json_wrapper_behavior:
                              17397                 :             29 :               WITHOUT WRAPPER                   { $$ = JSW_NONE; }
  959 amitlan@postgresql.o    17398                 :GBC           1 :             | WITHOUT ARRAY WRAPPER             { $$ = JSW_NONE; }
  959 amitlan@postgresql.o    17399                 :CBC          58 :             | WITH WRAPPER                      { $$ = JSW_UNCONDITIONAL; }
                              17400                 :              9 :             | WITH ARRAY WRAPPER                { $$ = JSW_UNCONDITIONAL; }
  959 amitlan@postgresql.o    17401                 :GBC           1 :             | WITH CONDITIONAL ARRAY WRAPPER    { $$ = JSW_CONDITIONAL; }
  959 amitlan@postgresql.o    17402                 :CBC           9 :             | WITH UNCONDITIONAL ARRAY WRAPPER  { $$ = JSW_UNCONDITIONAL; }
                              17403                 :             25 :             | WITH CONDITIONAL WRAPPER          { $$ = JSW_CONDITIONAL; }
                              17404                 :              9 :             | WITH UNCONDITIONAL WRAPPER        { $$ = JSW_UNCONDITIONAL; }
                              17405                 :           1727 :             | /* empty */                       { $$ = JSW_UNSPEC; }
                              17406                 :                :         ;
                              17407                 :                : 
                              17408                 :                : json_behavior:
                              17409                 :                :             DEFAULT a_expr
                              17410                 :            447 :                 { $$ = (Node *) makeJsonBehavior(JSON_BEHAVIOR_DEFAULT, $2, @1); }
                              17411                 :                :             | json_behavior_type
                              17412                 :            530 :                 { $$ = (Node *) makeJsonBehavior($1, NULL, @1); }
                              17413                 :                :         ;
                              17414                 :                : 
                              17415                 :                : json_behavior_type:
                              17416                 :            352 :             ERROR_P     { $$ = JSON_BEHAVIOR_ERROR; }
                              17417                 :             26 :             | NULL_P    { $$ = JSON_BEHAVIOR_NULL; }
                              17418                 :             30 :             | TRUE_P    { $$ = JSON_BEHAVIOR_TRUE; }
                              17419                 :             10 :             | FALSE_P   { $$ = JSON_BEHAVIOR_FALSE; }
                              17420                 :             14 :             | UNKNOWN   { $$ = JSON_BEHAVIOR_UNKNOWN; }
                              17421                 :             26 :             | EMPTY_P ARRAY { $$ = JSON_BEHAVIOR_EMPTY_ARRAY; }
                              17422                 :             53 :             | EMPTY_P OBJECT_P  { $$ = JSON_BEHAVIOR_EMPTY_OBJECT; }
                              17423                 :                :             /* non-standard, for Oracle compatibility only */
                              17424                 :             19 :             | EMPTY_P   { $$ = JSON_BEHAVIOR_EMPTY_ARRAY; }
                              17425                 :                :         ;
                              17426                 :                : 
                              17427                 :                : json_behavior_clause_opt:
                              17428                 :                :             json_behavior ON EMPTY_P
                              17429                 :            263 :                 { $$ = list_make2($1, NULL); }
                              17430                 :                :             | json_behavior ON ERROR_P
                              17431                 :            429 :                 { $$ = list_make2(NULL, $1); }
                              17432                 :                :             | json_behavior ON EMPTY_P json_behavior ON ERROR_P
                              17433                 :             75 :                 { $$ = list_make2($1, $4); }
                              17434                 :                :             | /* EMPTY */
                              17435                 :           1633 :                 { $$ = list_make2(NULL, NULL); }
                              17436                 :                :         ;
                              17437                 :                : 
                              17438                 :                : json_on_error_clause_opt:
                              17439                 :                :             json_behavior ON ERROR_P
                              17440                 :            131 :                 { $$ = $1; }
                              17441                 :                :             | /* EMPTY */
                              17442                 :            685 :                 { $$ = NULL; }
                              17443                 :                :         ;
                              17444                 :                : 
                              17445                 :                : json_value_expr:
                              17446                 :                :             a_expr json_format_clause_opt
                              17447                 :                :             {
                              17448                 :                :                 /* formatted_expr will be set during parse-analysis. */
 1203                         17449                 :           3630 :                 $$ = (Node *) makeJsonValueExpr((Expr *) $1, NULL,
                              17450                 :           3630 :                                                 castNode(JsonFormat, $2));
                              17451                 :                :             }
                              17452                 :                :         ;
                              17453                 :                : 
                              17454                 :                : json_format_clause:
                              17455                 :                :             FORMAT_LA JSON ENCODING name
                              17456                 :                :                 {
                              17457                 :                :                     int     encoding;
                              17458                 :                : 
 1060 alvherre@alvh.no-ip.    17459         [ +  + ]:             70 :                     if (!pg_strcasecmp($4, "utf8"))
                              17460                 :             44 :                         encoding = JS_ENC_UTF8;
                              17461         [ +  + ]:             26 :                     else if (!pg_strcasecmp($4, "utf16"))
                              17462                 :              9 :                         encoding = JS_ENC_UTF16;
                              17463         [ +  + ]:             17 :                     else if (!pg_strcasecmp($4, "utf32"))
                              17464                 :              9 :                         encoding = JS_ENC_UTF32;
                              17465                 :                :                     else
                              17466         [ +  - ]:              8 :                         ereport(ERROR,
                              17467                 :                :                                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                              17468                 :                :                                  errmsg("unrecognized JSON encoding: %s", $4),
                              17469                 :                :                                  parser_errposition(@4)));
                              17470                 :                : 
                              17471                 :             62 :                     $$ = (Node *) makeJsonFormat(JS_FORMAT_JSON, encoding, @1);
                              17472                 :                :                 }
                              17473                 :                :             | FORMAT_LA JSON
                              17474                 :                :                 {
                              17475                 :            308 :                     $$ = (Node *) makeJsonFormat(JS_FORMAT_JSON, JS_ENC_DEFAULT, @1);
                              17476                 :                :                 }
                              17477                 :                :         ;
                              17478                 :                : 
                              17479                 :                : json_format_clause_opt:
                              17480                 :                :             json_format_clause
                              17481                 :                :                 {
                              17482                 :            268 :                     $$ = $1;
                              17483                 :                :                 }
                              17484                 :                :             | /* EMPTY */
                              17485                 :                :                 {
 1317                         17486                 :           4891 :                     $$ = (Node *) makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1);
                              17487                 :                :                 }
                              17488                 :                :         ;
                              17489                 :                : 
                              17490                 :                : json_quotes_clause_opt:
  959 amitlan@postgresql.o    17491                 :              9 :             KEEP QUOTES ON SCALAR STRING_P      { $$ = JS_QUOTES_KEEP; }
                              17492                 :             69 :             | KEEP QUOTES                       { $$ = JS_QUOTES_KEEP; }
                              17493                 :              9 :             | OMIT QUOTES ON SCALAR STRING_P    { $$ = JS_QUOTES_OMIT; }
                              17494                 :            122 :             | OMIT QUOTES                       { $$ = JS_QUOTES_OMIT; }
                              17495                 :           1659 :             | /* EMPTY */                       { $$ = JS_QUOTES_UNSPEC; }
                              17496                 :                :         ;
                              17497                 :                : 
                              17498                 :                : json_returning_clause_opt:
                              17499                 :                :             RETURNING Typename json_format_clause_opt
                              17500                 :                :                 {
 1317 alvherre@alvh.no-ip.    17501                 :           1430 :                     JsonOutput *n = makeNode(JsonOutput);
                              17502                 :                : 
                              17503                 :           1430 :                     n->typeName = $2;
                              17504                 :           1430 :                     n->returning = makeNode(JsonReturning);
                              17505                 :           1430 :                     n->returning->format = (JsonFormat *) $3;
                              17506                 :           1430 :                     $$ = (Node *) n;
                              17507                 :                :                 }
                              17508                 :            986 :             | /* EMPTY */                           { $$ = NULL; }
                              17509                 :                :         ;
                              17510                 :                : 
                              17511                 :                : /*
                              17512                 :                :  * We must assign the only-JSON production a precedence less than IDENT in
                              17513                 :                :  * order to favor shifting over reduction when JSON is followed by VALUE_P,
                              17514                 :                :  * OBJECT_P, or SCALAR.  (ARRAY doesn't need that treatment, because it's a
                              17515                 :                :  * fully reserved word.)  Because json_predicate_type_constraint is always
                              17516                 :                :  * followed by json_key_uniqueness_constraint_opt, we also need the only-JSON
                              17517                 :                :  * production to have precedence less than WITH and WITHOUT.  UNBOUNDED isn't
                              17518                 :                :  * really related to this syntax, but it's a convenient choice because it
                              17519                 :                :  * already has a precedence less than IDENT for other reasons.
                              17520                 :                :  */
                              17521                 :                : json_predicate_type_constraint:
 1073 tgl@sss.pgh.pa.us       17522                 :            184 :             JSON                    %prec UNBOUNDED { $$ = JS_TYPE_ANY; }
 1315 alvherre@alvh.no-ip.    17523                 :             18 :             | JSON VALUE_P                          { $$ = JS_TYPE_ANY; }
                              17524                 :             26 :             | JSON ARRAY                            { $$ = JS_TYPE_ARRAY; }
                              17525                 :             26 :             | JSON OBJECT_P                         { $$ = JS_TYPE_OBJECT; }
                              17526                 :             26 :             | JSON SCALAR                           { $$ = JS_TYPE_SCALAR; }
                              17527                 :                :         ;
                              17528                 :                : 
                              17529                 :                : /*
                              17530                 :                :  * KEYS is a noise word here.  To avoid shift/reduce conflicts, assign the
                              17531                 :                :  * KEYS-less productions a precedence less than IDENT (i.e., less than KEYS).
                              17532                 :                :  * This prevents reducing them when the next token is KEYS.
                              17533                 :                :  */
                              17534                 :                : json_key_uniqueness_constraint_opt:
                              17535                 :            103 :             WITH UNIQUE KEYS                            { $$ = true; }
 1073 tgl@sss.pgh.pa.us       17536                 :             74 :             | WITH UNIQUE               %prec UNBOUNDED { $$ = true; }
 1311 alvherre@alvh.no-ip.    17537                 :             28 :             | WITHOUT UNIQUE KEYS                       { $$ = false; }
 1073 tgl@sss.pgh.pa.us       17538                 :             10 :             | WITHOUT UNIQUE            %prec UNBOUNDED { $$ = false; }
                              17539                 :            681 :             | /* EMPTY */               %prec UNBOUNDED { $$ = false; }
                              17540                 :                :         ;
                              17541                 :                : 
                              17542                 :                : json_name_and_value_list:
                              17543                 :                :             json_name_and_value
 1317 alvherre@alvh.no-ip.    17544                 :            347 :                 { $$ = list_make1($1); }
                              17545                 :                :             | json_name_and_value_list ',' json_name_and_value
                              17546                 :            165 :                 { $$ = lappend($1, $3); }
                              17547                 :                :         ;
                              17548                 :                : 
                              17549                 :                : json_name_and_value:
                              17550                 :                : /* Supporting this syntax seems to require major surgery
                              17551                 :                :             KEY c_expr VALUE_P json_value_expr
                              17552                 :                :                 { $$ = makeJsonKeyValue($2, $4); }
                              17553                 :                :             |
                              17554                 :                : */
                              17555                 :                :             c_expr VALUE_P json_value_expr
                              17556                 :            122 :                 { $$ = makeJsonKeyValue($1, $3); }
                              17557                 :                :             |
                              17558                 :                :             a_expr ':' json_value_expr
                              17559                 :            556 :                 { $$ = makeJsonKeyValue($1, $3); }
                              17560                 :                :         ;
                              17561                 :                : 
                              17562                 :                : /* empty means false for objects, true for arrays */
                              17563                 :                : json_object_constructor_null_clause_opt:
                              17564                 :             21 :             NULL_P ON NULL_P                    { $$ = false; }
                              17565                 :             88 :             | ABSENT ON NULL_P                  { $$ = true; }
                              17566                 :            404 :             | /* EMPTY */                       { $$ = false; }
                              17567                 :                :         ;
                              17568                 :                : 
                              17569                 :                : json_array_constructor_null_clause_opt:
                              17570                 :             58 :             NULL_P ON NULL_P                        { $$ = false; }
                              17571                 :             25 :             | ABSENT ON NULL_P                      { $$ = true; }
                              17572                 :            246 :             | /* EMPTY */                           { $$ = true; }
                              17573                 :                :         ;
                              17574                 :                : 
                              17575                 :                : json_value_expr_list:
                              17576                 :            174 :             json_value_expr                             { $$ = list_make1($1); }
                              17577                 :             93 :             | json_value_expr_list ',' json_value_expr  { $$ = lappend($1, $3);}
                              17578                 :                :         ;
                              17579                 :                : 
                              17580                 :                : json_aggregate_func:
                              17581                 :                :             JSON_OBJECTAGG '('
                              17582                 :                :                 json_name_and_value
                              17583                 :                :                 json_object_constructor_null_clause_opt
                              17584                 :                :                 json_key_uniqueness_constraint_opt
                              17585                 :                :                 json_returning_clause_opt
                              17586                 :                :             ')'
                              17587                 :                :                 {
                              17588                 :            166 :                     JsonObjectAgg *n = makeNode(JsonObjectAgg);
                              17589                 :                : 
                              17590                 :            166 :                     n->arg = (JsonKeyValue *) $3;
                              17591                 :            166 :                     n->absent_on_null = $4;
                              17592                 :            166 :                     n->unique = $5;
                              17593                 :            166 :                     n->constructor = makeNode(JsonAggConstructor);
                              17594                 :            166 :                     n->constructor->output = (JsonOutput *) $6;
                              17595                 :            166 :                     n->constructor->agg_order = NULL;
                              17596                 :            166 :                     n->constructor->location = @1;
                              17597                 :            166 :                     $$ = (Node *) n;
                              17598                 :                :                 }
                              17599                 :                :             | JSON_ARRAYAGG '('
                              17600                 :                :                 json_value_expr
                              17601                 :                :                 json_array_aggregate_order_by_clause_opt
                              17602                 :                :                 json_array_constructor_null_clause_opt
                              17603                 :                :                 json_returning_clause_opt
                              17604                 :                :             ')'
                              17605                 :                :                 {
                              17606                 :            155 :                     JsonArrayAgg *n = makeNode(JsonArrayAgg);
                              17607                 :                : 
                              17608                 :            155 :                     n->arg = (JsonValueExpr *) $3;
                              17609                 :            155 :                     n->absent_on_null = $5;
                              17610                 :            155 :                     n->constructor = makeNode(JsonAggConstructor);
                              17611                 :            155 :                     n->constructor->agg_order = $4;
                              17612                 :            155 :                     n->constructor->output = (JsonOutput *) $6;
                              17613                 :            155 :                     n->constructor->location = @1;
                              17614                 :            155 :                     $$ = (Node *) n;
                              17615                 :                :                 }
                              17616                 :                :         ;
                              17617                 :                : 
                              17618                 :                : json_array_aggregate_order_by_clause_opt:
                              17619                 :             38 :             ORDER BY sortby_list                    { $$ = $3; }
                              17620                 :            117 :             | /* EMPTY */                           { $$ = NIL; }
                              17621                 :                :         ;
                              17622                 :                : 
                              17623                 :                : /*****************************************************************************
                              17624                 :                :  *
                              17625                 :                :  *  target list for SELECT
                              17626                 :                :  *
                              17627                 :                :  *****************************************************************************/
                              17628                 :                : 
 4709 tgl@sss.pgh.pa.us       17629                 :         312207 : opt_target_list: target_list                        { $$ = $1; }
                              17630                 :            430 :             | /* EMPTY */                           { $$ = NIL; }
                              17631                 :                :         ;
                              17632                 :                : 
                              17633                 :                : target_list:
 8194 neilc@samurai.com       17634                 :         317147 :             target_el                               { $$ = list_make1($1); }
 8906 bruce@momjian.us        17635                 :         416964 :             | target_list ',' target_el             { $$ = lappend($1, $3); }
                              17636                 :                :         ;
                              17637                 :                : 
                              17638                 :                : target_el:  a_expr AS ColLabel
                              17639                 :                :                 {
10650                         17640                 :         147156 :                     $$ = makeNode(ResTarget);
                              17641                 :         147156 :                     $$->name = $3;
 8995 tgl@sss.pgh.pa.us       17642                 :         147156 :                     $$->indirection = NIL;
 1637 peter@eisentraut.org    17643                 :         147156 :                     $$->val = (Node *) $1;
 7532 tgl@sss.pgh.pa.us       17644                 :         147156 :                     $$->location = @1;
                              17645                 :                :                 }
                              17646                 :                :             | a_expr BareColLabel
                              17647                 :                :                 {
 6838                         17648                 :           2294 :                     $$ = makeNode(ResTarget);
                              17649                 :           2294 :                     $$->name = $2;
                              17650                 :           2294 :                     $$->indirection = NIL;
 1637 peter@eisentraut.org    17651                 :           2294 :                     $$->val = (Node *) $1;
 6838 tgl@sss.pgh.pa.us       17652                 :           2294 :                     $$->location = @1;
                              17653                 :                :                 }
                              17654                 :                :             | a_expr
                              17655                 :                :                 {
10650 bruce@momjian.us        17656                 :         544299 :                     $$ = makeNode(ResTarget);
                              17657                 :         544298 :                     $$->name = NULL;
 8995 tgl@sss.pgh.pa.us       17658                 :         544298 :                     $$->indirection = NIL;
 1637 peter@eisentraut.org    17659                 :         544298 :                     $$->val = (Node *) $1;
 7532 tgl@sss.pgh.pa.us       17660                 :         544298 :                     $$->location = @1;
                              17661                 :                :                 }
                              17662                 :                :             | '*'
                              17663                 :                :                 {
 1637 peter@eisentraut.org    17664                 :          40362 :                     ColumnRef  *n = makeNode(ColumnRef);
                              17665                 :                : 
 6641 tgl@sss.pgh.pa.us       17666                 :          40362 :                     n->fields = list_make1(makeNode(A_Star));
 7541                         17667                 :          40362 :                     n->location = @1;
                              17668                 :                : 
10650 bruce@momjian.us        17669                 :          40362 :                     $$ = makeNode(ResTarget);
                              17670                 :          40362 :                     $$->name = NULL;
 8995 tgl@sss.pgh.pa.us       17671                 :          40362 :                     $$->indirection = NIL;
 1637 peter@eisentraut.org    17672                 :          40362 :                     $$->val = (Node *) n;
 7532 tgl@sss.pgh.pa.us       17673                 :          40362 :                     $$->location = @1;
                              17674                 :                :                 }
                              17675                 :                :         ;
                              17676                 :                : 
                              17677                 :                : 
                              17678                 :                : /*****************************************************************************
                              17679                 :                :  *
                              17680                 :                :  *  Names and constants
                              17681                 :                :  *
                              17682                 :                :  *****************************************************************************/
                              17683                 :                : 
                              17684                 :                : qualified_name_list:
 8194 neilc@samurai.com       17685                 :           9976 :             qualified_name                          { $$ = list_make1($1); }
 8907 bruce@momjian.us        17686                 :            319 :             | qualified_name_list ',' qualified_name { $$ = lappend($1, $3); }
                              17687                 :                :         ;
                              17688                 :                : 
                              17689                 :                : /*
                              17690                 :                :  * The production for a qualified relation name has to exactly match the
                              17691                 :                :  * production for a qualified func_name, because in a FROM clause we cannot
                              17692                 :                :  * tell which we are parsing until we see what comes after it ('(' for a
                              17693                 :                :  * func_name, something else for a relation). Therefore we allow 'indirection'
                              17694                 :                :  * which may contain subscripts, and reject that case in the C code.
                              17695                 :                :  */
                              17696                 :                : qualified_name:
                              17697                 :                :             ColId
                              17698                 :                :                 {
 5806 rhaas@postgresql.org    17699                 :         273996 :                     $$ = makeRangeVar(NULL, $1, @1);
                              17700                 :                :                 }
                              17701                 :                :             | ColId indirection
                              17702                 :                :                 {
 1835 akapila@postgresql.o    17703                 :         160593 :                     $$ = makeRangeVarFromQualifiedName($1, $2, @1, yyscanner);
                              17704                 :                :                 }
                              17705                 :                :         ;
                              17706                 :                : 
                              17707                 :                : name_list:  name
 8194 neilc@samurai.com       17708                 :          18874 :                     { $$ = list_make1(makeString($1)); }
                              17709                 :                :             | name_list ',' name
 8906 bruce@momjian.us        17710                 :          38795 :                     { $$ = lappend($1, makeString($3)); }
                              17711                 :                :         ;
                              17712                 :                : 
                              17713                 :                : 
 8907                         17714                 :         110098 : name:       ColId                                   { $$ = $1; };
                              17715                 :                : 
 8108 tgl@sss.pgh.pa.us       17716                 :        1026135 : attr_name:  ColLabel                                { $$ = $1; };
                              17717                 :                : 
 8907 bruce@momjian.us        17718                 :             50 : file_name:  Sconst                                  { $$ = $1; };
                              17719                 :                : 
                              17720                 :                : /*
                              17721                 :                :  * The production for a qualified func_name has to exactly match the
                              17722                 :                :  * production for a qualified columnref, because we cannot tell which we
                              17723                 :                :  * are parsing until we see what comes after it ('(' or Sconst for a func_name,
                              17724                 :                :  * anything else for a columnref).  Therefore we allow 'indirection' which
                              17725                 :                :  * may contain subscripts, and reject that case in the C code.  (If we
                              17726                 :                :  * ever implement SQL99-like methods, such syntax may actually become legal!)
                              17727                 :                :  */
                              17728                 :                : func_name:  type_function_name
 8194 neilc@samurai.com       17729                 :         181398 :                     { $$ = list_make1(makeString($1)); }
                              17730                 :                :             | ColId indirection
                              17731                 :                :                     {
 6324 tgl@sss.pgh.pa.us       17732                 :          87743 :                         $$ = check_func_name(lcons(makeString($1), $2),
                              17733                 :                :                                              yyscanner);
                              17734                 :                :                     }
                              17735                 :                :         ;
                              17736                 :                : 
                              17737                 :                : 
                              17738                 :                : /*
                              17739                 :                :  * Constants
                              17740                 :                :  */
                              17741                 :                : AexprConst: Iconst
                              17742                 :                :                 {
 6643                         17743                 :         264414 :                     $$ = makeIntConst($1, @1);
                              17744                 :                :                 }
                              17745                 :                :             | FCONST
                              17746                 :                :                 {
                              17747                 :           7974 :                     $$ = makeFloatConst($1, @1);
                              17748                 :                :                 }
                              17749                 :                :             | Sconst
                              17750                 :                :                 {
                              17751                 :         449778 :                     $$ = makeStringConst($1, @1);
                              17752                 :                :                 }
                              17753                 :                :             | BCONST
                              17754                 :                :                 {
                              17755                 :            509 :                     $$ = makeBitStringConst($1, @1);
                              17756                 :                :                 }
                              17757                 :                :             | XCONST
                              17758                 :                :                 {
                              17759                 :                :                     /* This is a bit constant per SQL99:
                              17760                 :                :                      * Without Feature F511, "BIT data type",
                              17761                 :                :                      * a <general literal> shall not be a
                              17762                 :                :                      * <bit string literal> or a <hex string literal>.
                              17763                 :                :                      */
                              17764                 :           2216 :                     $$ = makeBitStringConst($1, @1);
                              17765                 :                :                 }
                              17766                 :                :             | func_name Sconst
                              17767                 :                :                 {
                              17768                 :                :                     /* generic type 'literal' syntax */
 1637 peter@eisentraut.org    17769                 :           6510 :                     TypeName   *t = makeTypeNameFromNameList($1);
                              17770                 :                : 
 6764 alvherre@alvh.no-ip.    17771                 :           6510 :                     t->location = @1;
 6643 tgl@sss.pgh.pa.us       17772                 :           6510 :                     $$ = makeStringConstCast($2, @2, t);
                              17773                 :                :                 }
                              17774                 :                :             | func_name '(' func_arg_list opt_sort_clause ')' Sconst
                              17775                 :                :                 {
                              17776                 :                :                     /* generic syntax with a type modifier */
 1637 peter@eisentraut.org    17777                 :UBC           0 :                     TypeName   *t = makeTypeNameFromNameList($1);
                              17778                 :                :                     ListCell   *lc;
                              17779                 :                : 
                              17780                 :                :                     /*
                              17781                 :                :                      * We must use func_arg_list and opt_sort_clause in the
                              17782                 :                :                      * production to avoid reduce/reduce conflicts, but we
                              17783                 :                :                      * don't actually wish to allow NamedArgExpr in this
                              17784                 :                :                      * context, nor ORDER BY.
                              17785                 :                :                      */
 6237 tgl@sss.pgh.pa.us       17786   [ #  #  #  #  :              0 :                     foreach(lc, $3)
                                              #  # ]
                              17787                 :                :                     {
                              17788                 :              0 :                         NamedArgExpr *arg = (NamedArgExpr *) lfirst(lc);
                              17789                 :                : 
                              17790         [ #  # ]:              0 :                         if (IsA(arg, NamedArgExpr))
                              17791         [ #  # ]:              0 :                             ereport(ERROR,
                              17792                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              17793                 :                :                                      errmsg("type modifier cannot have parameter name"),
                              17794                 :                :                                      parser_errposition(arg->location)));
                              17795                 :                :                     }
 4700                         17796         [ #  # ]:              0 :                     if ($4 != NIL)
                              17797         [ #  # ]:              0 :                             ereport(ERROR,
                              17798                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              17799                 :                :                                      errmsg("type modifier cannot have ORDER BY"),
                              17800                 :                :                                      parser_errposition(@4)));
                              17801                 :                : 
 6764 alvherre@alvh.no-ip.    17802                 :              0 :                     t->typmods = $3;
                              17803                 :              0 :                     t->location = @1;
 4700 tgl@sss.pgh.pa.us       17804                 :              0 :                     $$ = makeStringConstCast($6, @6, t);
                              17805                 :                :                 }
                              17806                 :                :             | ConstTypename Sconst
                              17807                 :                :                 {
 6643 tgl@sss.pgh.pa.us       17808                 :CBC        2043 :                     $$ = makeStringConstCast($2, @2, $1);
                              17809                 :                :                 }
                              17810                 :                :             | ConstInterval Sconst opt_interval
                              17811                 :                :                 {
 1637 peter@eisentraut.org    17812                 :           2196 :                     TypeName   *t = $1;
                              17813                 :                : 
 6629 tgl@sss.pgh.pa.us       17814                 :           2196 :                     t->typmods = $3;
 6643                         17815                 :           2196 :                     $$ = makeStringConstCast($2, @2, t);
                              17816                 :                :                 }
                              17817                 :                :             | ConstInterval '(' Iconst ')' Sconst
                              17818                 :                :                 {
 1637 peter@eisentraut.org    17819                 :              8 :                     TypeName   *t = $1;
                              17820                 :                : 
 4401 bruce@momjian.us        17821                 :              8 :                     t->typmods = list_make2(makeIntConst(INTERVAL_FULL_RANGE, -1),
                              17822                 :                :                                             makeIntConst($3, @3));
 6643 tgl@sss.pgh.pa.us       17823                 :              8 :                     $$ = makeStringConstCast($5, @5, t);
                              17824                 :                :                 }
                              17825                 :                :             | TRUE_P
                              17826                 :                :                 {
 3368 peter_e@gmx.net         17827                 :          20197 :                     $$ = makeBoolAConst(true, @1);
                              17828                 :                :                 }
                              17829                 :                :             | FALSE_P
                              17830                 :                :                 {
                              17831                 :          20366 :                     $$ = makeBoolAConst(false, @1);
                              17832                 :                :                 }
                              17833                 :                :             | NULL_P
                              17834                 :                :                 {
 6643 tgl@sss.pgh.pa.us       17835                 :          43120 :                     $$ = makeNullAConst(@1);
                              17836                 :                :                 }
                              17837                 :                :         ;
                              17838                 :                : 
 8907 bruce@momjian.us        17839                 :         280391 : Iconst:     ICONST                                  { $$ = $1; };
                              17840                 :         494859 : Sconst:     SCONST                                  { $$ = $1; };
                              17841                 :                : 
 6567 meskes@postgresql.or    17842                 :           9676 : SignedIconst: Iconst                                { $$ = $1; }
 6567 meskes@postgresql.or    17843                 :UBC           0 :             | '+' Iconst                            { $$ = + $2; }
 6567 meskes@postgresql.or    17844                 :CBC         188 :             | '-' Iconst                            { $$ = - $2; }
                              17845                 :                :         ;
                              17846                 :                : 
                              17847                 :                : /* Role specifications */
                              17848                 :                : RoleId:     RoleSpec
                              17849                 :                :                 {
 1637 peter@eisentraut.org    17850                 :           1334 :                     RoleSpec   *spc = (RoleSpec *) $1;
                              17851                 :                : 
 4259 alvherre@alvh.no-ip.    17852   [ +  +  +  +  :           1334 :                     switch (spc->roletype)
                                              +  - ]
                              17853                 :                :                     {
                              17854                 :           1329 :                         case ROLESPEC_CSTRING:
                              17855                 :           1329 :                             $$ = spc->rolename;
                              17856                 :           1329 :                             break;
                              17857                 :              2 :                         case ROLESPEC_PUBLIC:
                              17858         [ +  - ]:              2 :                             ereport(ERROR,
                              17859                 :                :                                     (errcode(ERRCODE_RESERVED_NAME),
                              17860                 :                :                                      errmsg("role name \"%s\" is reserved",
                              17861                 :                :                                             "public"),
                              17862                 :                :                                      parser_errposition(@1)));
                              17863                 :                :                             break;
                              17864                 :              1 :                         case ROLESPEC_SESSION_USER:
                              17865         [ +  - ]:              1 :                             ereport(ERROR,
                              17866                 :                :                                     (errcode(ERRCODE_RESERVED_NAME),
                              17867                 :                :                                      errmsg("%s cannot be used as a role name here",
                              17868                 :                :                                             "SESSION_USER"),
                              17869                 :                :                                      parser_errposition(@1)));
                              17870                 :                :                             break;
                              17871                 :              1 :                         case ROLESPEC_CURRENT_USER:
                              17872         [ +  - ]:              1 :                             ereport(ERROR,
                              17873                 :                :                                     (errcode(ERRCODE_RESERVED_NAME),
                              17874                 :                :                                      errmsg("%s cannot be used as a role name here",
                              17875                 :                :                                             "CURRENT_USER"),
                              17876                 :                :                                      parser_errposition(@1)));
                              17877                 :                :                             break;
 2240 peter@eisentraut.org    17878                 :              1 :                         case ROLESPEC_CURRENT_ROLE:
                              17879         [ +  - ]:              1 :                             ereport(ERROR,
                              17880                 :                :                                     (errcode(ERRCODE_RESERVED_NAME),
                              17881                 :                :                                      errmsg("%s cannot be used as a role name here",
                              17882                 :                :                                             "CURRENT_ROLE"),
                              17883                 :                :                                      parser_errposition(@1)));
                              17884                 :                :                             break;
                              17885                 :                :                     }
                              17886                 :                :                 }
                              17887                 :                :             ;
                              17888                 :                : 
                              17889                 :                : RoleSpec:   NonReservedWord
                              17890                 :                :                 {
                              17891                 :                :                     /*
                              17892                 :                :                      * "public" and "none" are not keywords, but they must
                              17893                 :                :                      * be treated specially here.
                              17894                 :                :                      */
                              17895                 :                :                     RoleSpec   *n;
                              17896                 :                : 
 1637                         17897         [ +  + ]:          15366 :                     if (strcmp($1, "public") == 0)
                              17898                 :                :                     {
                              17899                 :           6703 :                         n = (RoleSpec *) makeRoleSpec(ROLESPEC_PUBLIC, @1);
                              17900                 :           6703 :                         n->roletype = ROLESPEC_PUBLIC;
                              17901                 :                :                     }
                              17902         [ +  + ]:           8663 :                     else if (strcmp($1, "none") == 0)
                              17903                 :                :                     {
                              17904         [ +  - ]:             13 :                         ereport(ERROR,
                              17905                 :                :                                 (errcode(ERRCODE_RESERVED_NAME),
                              17906                 :                :                                  errmsg("role name \"%s\" is reserved",
                              17907                 :                :                                         "none"),
                              17908                 :                :                                  parser_errposition(@1)));
                              17909                 :                :                     }
                              17910                 :                :                     else
                              17911                 :                :                     {
                              17912                 :           8650 :                         n = makeRoleSpec(ROLESPEC_CSTRING, @1);
                              17913                 :           8650 :                         n->rolename = pstrdup($1);
                              17914                 :                :                     }
                              17915                 :          15353 :                     $$ = n;
                              17916                 :                :                 }
                              17917                 :                :             | CURRENT_ROLE
                              17918                 :                :                 {
                              17919                 :             80 :                     $$ = makeRoleSpec(ROLESPEC_CURRENT_ROLE, @1);
                              17920                 :                :                 }
                              17921                 :                :             | CURRENT_USER
                              17922                 :                :                 {
                              17923                 :            149 :                     $$ = makeRoleSpec(ROLESPEC_CURRENT_USER, @1);
                              17924                 :                :                 }
                              17925                 :                :             | SESSION_USER
                              17926                 :                :                 {
                              17927                 :             18 :                     $$ = makeRoleSpec(ROLESPEC_SESSION_USER, @1);
                              17928                 :                :                 }
                              17929                 :                :         ;
                              17930                 :                : 
                              17931                 :                : role_list:  RoleSpec
                              17932                 :           2083 :                 { $$ = list_make1($1); }
                              17933                 :                :             | role_list ',' RoleSpec
                              17934                 :            189 :                 { $$ = lappend($1, $3); }
                              17935                 :                :         ;
                              17936                 :                : 
                              17937                 :                : 
                              17938                 :                : /*****************************************************************************
                              17939                 :                :  *
                              17940                 :                :  * PL/pgSQL extensions
                              17941                 :                :  *
                              17942                 :                :  * You'd think a PL/pgSQL "expression" should be just an a_expr, but
                              17943                 :                :  * historically it can include just about anything that can follow SELECT.
                              17944                 :                :  * Therefore the returned struct is a SelectStmt.
                              17945                 :                :  *****************************************************************************/
                              17946                 :                : 
                              17947                 :                : PLpgSQL_Expr: opt_distinct_clause opt_target_list
                              17948                 :                :             from_clause where_clause
                              17949                 :                :             group_clause having_clause window_clause
                              17950                 :                :             opt_sort_clause opt_select_limit opt_for_locking_clause
                              17951                 :                :                 {
 2131 tgl@sss.pgh.pa.us       17952                 :          24933 :                     SelectStmt *n = makeNode(SelectStmt);
                              17953                 :                : 
 2113                         17954                 :          24933 :                     n->distinctClause = $1;
                              17955                 :          24933 :                     n->targetList = $2;
                              17956                 :          24933 :                     n->fromClause = $3;
                              17957                 :          24933 :                     n->whereClause = $4;
 2058 tomas.vondra@postgre    17958                 :          24933 :                     n->groupClause = ($5)->list;
                              17959                 :          24933 :                     n->groupDistinct = ($5)->distinct;
 2113 tgl@sss.pgh.pa.us       17960                 :          24933 :                     n->havingClause = $6;
                              17961                 :          24933 :                     n->windowClause = $7;
                              17962                 :          24933 :                     n->sortClause = $8;
                              17963         [ +  + ]:          24933 :                     if ($9)
                              17964                 :                :                     {
                              17965                 :              2 :                         n->limitOffset = $9->limitOffset;
                              17966                 :              2 :                         n->limitCount = $9->limitCount;
 2131                         17967         [ +  - ]:              2 :                         if (!n->sortClause &&
 2113                         17968         [ -  + ]:              2 :                             $9->limitOption == LIMIT_OPTION_WITH_TIES)
 2131 tgl@sss.pgh.pa.us       17969         [ #  # ]:UBC           0 :                             ereport(ERROR,
                              17970                 :                :                                     (errcode(ERRCODE_SYNTAX_ERROR),
                              17971                 :                :                                      errmsg("WITH TIES cannot be specified without ORDER BY clause"),
                              17972                 :                :                                      parser_errposition($9->optionLoc)));
 2113 tgl@sss.pgh.pa.us       17973                 :CBC           2 :                         n->limitOption = $9->limitOption;
                              17974                 :                :                     }
                              17975                 :          24933 :                     n->lockingClause = $10;
 2131                         17976                 :          24933 :                     $$ = (Node *) n;
                              17977                 :                :                 }
                              17978                 :                :         ;
                              17979                 :                : 
                              17980                 :                : /*
                              17981                 :                :  * PL/pgSQL Assignment statement: name opt_indirection := PLpgSQL_Expr
                              17982                 :                :  */
                              17983                 :                : 
                              17984                 :                : PLAssignStmt: plassign_target opt_indirection plassign_equals PLpgSQL_Expr
                              17985                 :                :                 {
                              17986                 :           4258 :                     PLAssignStmt *n = makeNode(PLAssignStmt);
                              17987                 :                : 
                              17988                 :           4258 :                     n->name = $1;
                              17989                 :           4258 :                     n->indirection = check_indirection($2, yyscanner);
                              17990                 :                :                     /* nnames will be filled by calling production */
                              17991                 :           4072 :                     n->val = (SelectStmt *) $4;
                              17992                 :           4072 :                     n->location = @1;
                              17993                 :           4072 :                     $$ = (Node *) n;
                              17994                 :                :                 }
                              17995                 :                :         ;
                              17996                 :                : 
                              17997                 :           4242 : plassign_target: ColId                          { $$ = $1; }
                              17998                 :             16 :             | PARAM                             { $$ = psprintf("$%d", $1); }
                              17999                 :                :         ;
                              18000                 :                : 
                              18001                 :                : plassign_equals: COLON_EQUALS
                              18002                 :                :             | '='
                              18003                 :                :         ;
                              18004                 :                : 
                              18005                 :                : 
                              18006                 :                : /*
                              18007                 :                :  * Name classification hierarchy.
                              18008                 :                :  *
                              18009                 :                :  * IDENT is the lexeme returned by the lexer for identifiers that match
                              18010                 :                :  * no known keyword.  In most cases, we can accept certain keywords as
                              18011                 :                :  * names, not only IDENTs.  We prefer to accept as many such keywords
                              18012                 :                :  * as possible to minimize the impact of "reserved words" on programmers.
                              18013                 :                :  * So, we divide names into several possible classes.  The classification
                              18014                 :                :  * is chosen in part to make keywords acceptable as names wherever possible.
                              18015                 :                :  */
                              18016                 :                : 
                              18017                 :                : /* Column identifier --- names that can be column, table, etc names.
                              18018                 :                :  */
 8907 bruce@momjian.us        18019                 :        2182778 : ColId:      IDENT                                   { $$ = $1; }
                              18020                 :          32216 :             | unreserved_keyword                    { $$ = pstrdup($1); }
                              18021                 :           3896 :             | col_name_keyword                      { $$ = pstrdup($1); }
                              18022                 :                :         ;
                              18023                 :                : 
                              18024                 :                : /* Type/function identifier --- names that can be type or function names.
                              18025                 :                :  */
 7250 tgl@sss.pgh.pa.us       18026                 :         421623 : type_function_name: IDENT                           { $$ = $1; }
 8907 bruce@momjian.us        18027                 :          40807 :             | unreserved_keyword                    { $$ = pstrdup($1); }
 7250 tgl@sss.pgh.pa.us       18028                 :             53 :             | type_func_name_keyword                { $$ = pstrdup($1); }
                              18029                 :                :         ;
                              18030                 :                : 
                              18031                 :                : /* Any not-fully-reserved word --- these names can be, eg, role names.
                              18032                 :                :  */
 4904                         18033                 :          47807 : NonReservedWord:    IDENT                           { $$ = $1; }
                              18034                 :          21506 :             | unreserved_keyword                    { $$ = pstrdup($1); }
                              18035                 :            292 :             | col_name_keyword                      { $$ = pstrdup($1); }
                              18036                 :           3734 :             | type_func_name_keyword                { $$ = pstrdup($1); }
                              18037                 :                :         ;
                              18038                 :                : 
                              18039                 :                : /* Column label --- allowed labels in "AS" clauses.
                              18040                 :                :  * This presently includes *all* Postgres keywords.
                              18041                 :                :  */
 8907 bruce@momjian.us        18042                 :        1162149 : ColLabel:   IDENT                                   { $$ = $1; }
                              18043                 :          26035 :             | unreserved_keyword                    { $$ = pstrdup($1); }
                              18044                 :            190 :             | col_name_keyword                      { $$ = pstrdup($1); }
 7250 tgl@sss.pgh.pa.us       18045                 :            952 :             | type_func_name_keyword                { $$ = pstrdup($1); }
 8907 bruce@momjian.us        18046                 :           5083 :             | reserved_keyword                      { $$ = pstrdup($1); }
                              18047                 :                :         ;
                              18048                 :                : 
                              18049                 :                : /* Bare column label --- names that can be column labels without writing "AS".
                              18050                 :                :  * This classification is orthogonal to the other keyword categories.
                              18051                 :                :  */
 2239 tgl@sss.pgh.pa.us       18052                 :           2286 : BareColLabel:   IDENT                               { $$ = $1; }
                              18053                 :              8 :             | bare_label_keyword                    { $$ = pstrdup($1); }
                              18054                 :                :         ;
                              18055                 :                : 
                              18056                 :                : 
                              18057                 :                : /*
                              18058                 :                :  * Keyword category lists.  Generally, every keyword present in
                              18059                 :                :  * the Postgres grammar should appear in exactly one of these lists.
                              18060                 :                :  *
                              18061                 :                :  * Put a new keyword into the first list that it can go into without causing
                              18062                 :                :  * shift or reduce conflicts.  The earlier lists define "less reserved"
                              18063                 :                :  * categories of keywords.
                              18064                 :                :  *
                              18065                 :                :  * Make sure that each keyword's category in kwlist.h matches where
                              18066                 :                :  * it is listed here.  (Someday we may be able to generate these lists and
                              18067                 :                :  * kwlist.h's table from one source of truth.)
                              18068                 :                :  */
                              18069                 :                : 
                              18070                 :                : /* "Unreserved" keywords --- available for use as any kind of name.
                              18071                 :                :  */
                              18072                 :                : unreserved_keyword:
                              18073                 :                :               ABORT_P
                              18074                 :                :             | ABSENT
                              18075                 :                :             | ABSOLUTE_P
                              18076                 :                :             | ACCESS
                              18077                 :                :             | ACTION
                              18078                 :                :             | ADD_P
                              18079                 :                :             | ADMIN
                              18080                 :                :             | AFTER
                              18081                 :                :             | AGGREGATE
                              18082                 :                :             | ALSO
                              18083                 :                :             | ALTER
                              18084                 :                :             | ALWAYS
                              18085                 :                :             | ASENSITIVE
                              18086                 :                :             | ASSERTION
                              18087                 :                :             | ASSIGNMENT
                              18088                 :                :             | AT
                              18089                 :                :             | ATOMIC
                              18090                 :                :             | ATTACH
                              18091                 :                :             | ATTRIBUTE
                              18092                 :                :             | BACKWARD
                              18093                 :                :             | BEFORE
                              18094                 :                :             | BEGIN_P
                              18095                 :                :             | BREADTH
                              18096                 :                :             | BY
                              18097                 :                :             | CACHE
                              18098                 :                :             | CALL
                              18099                 :                :             | CALLED
                              18100                 :                :             | CASCADE
                              18101                 :                :             | CASCADED
                              18102                 :                :             | CATALOG_P
                              18103                 :                :             | CHAIN
                              18104                 :                :             | CHARACTERISTICS
                              18105                 :                :             | CHECKPOINT
                              18106                 :                :             | CLASS
                              18107                 :                :             | CLOSE
                              18108                 :                :             | CLUSTER
                              18109                 :                :             | COLUMNS
                              18110                 :                :             | COMMENT
                              18111                 :                :             | COMMENTS
                              18112                 :                :             | COMMIT
                              18113                 :                :             | COMMITTED
                              18114                 :                :             | COMPRESSION
                              18115                 :                :             | CONDITIONAL
                              18116                 :                :             | CONFIGURATION
                              18117                 :                :             | CONFLICT
                              18118                 :                :             | CONNECTION
                              18119                 :                :             | CONSTRAINTS
                              18120                 :                :             | CONTENT_P
                              18121                 :                :             | CONTINUE_P
                              18122                 :                :             | CONVERSION_P
                              18123                 :                :             | COPY
                              18124                 :                :             | COST
                              18125                 :                :             | CSV
                              18126                 :                :             | CUBE
                              18127                 :                :             | CURRENT_P
                              18128                 :                :             | CURSOR
                              18129                 :                :             | CYCLE
                              18130                 :                :             | DATA_P
                              18131                 :                :             | DATABASE
                              18132                 :                :             | DAY_P
                              18133                 :                :             | DEALLOCATE
                              18134                 :                :             | DECLARE
                              18135                 :                :             | DEFAULTS
                              18136                 :                :             | DEFERRED
                              18137                 :                :             | DEFINER
                              18138                 :                :             | DELETE_P
                              18139                 :                :             | DELIMITER
                              18140                 :                :             | DELIMITERS
                              18141                 :                :             | DEPENDS
                              18142                 :                :             | DEPTH
                              18143                 :                :             | DETACH
                              18144                 :                :             | DICTIONARY
                              18145                 :                :             | DISABLE_P
                              18146                 :                :             | DISCARD
                              18147                 :                :             | DOCUMENT_P
                              18148                 :                :             | DOMAIN_P
                              18149                 :                :             | DOUBLE_P
                              18150                 :                :             | DROP
                              18151                 :                :             | EACH
                              18152                 :                :             | EMPTY_P
                              18153                 :                :             | ENABLE_P
                              18154                 :                :             | ENCODING
                              18155                 :                :             | ENCRYPTED
                              18156                 :                :             | ENFORCED
                              18157                 :                :             | ENUM_P
                              18158                 :                :             | ERROR_P
                              18159                 :                :             | ESCAPE
                              18160                 :                :             | EVENT
                              18161                 :                :             | EXCLUDE
                              18162                 :                :             | EXCLUDING
                              18163                 :                :             | EXCLUSIVE
                              18164                 :                :             | EXECUTE
                              18165                 :                :             | EXPLAIN
                              18166                 :                :             | EXPRESSION
                              18167                 :                :             | EXTENSION
                              18168                 :                :             | EXTERNAL
                              18169                 :                :             | FAMILY
                              18170                 :                :             | FILTER
                              18171                 :                :             | FINALIZE
                              18172                 :                :             | FIRST_P
                              18173                 :                :             | FOLLOWING
                              18174                 :                :             | FORCE
                              18175                 :                :             | FORMAT
                              18176                 :                :             | FORWARD
                              18177                 :                :             | FUNCTION
                              18178                 :                :             | FUNCTIONS
                              18179                 :                :             | GENERATED
                              18180                 :                :             | GLOBAL
                              18181                 :                :             | GRANTED
                              18182                 :                :             | GROUPS
                              18183                 :                :             | HANDLER
                              18184                 :                :             | HEADER_P
                              18185                 :                :             | HOLD
                              18186                 :                :             | HOUR_P
                              18187                 :                :             | IDENTITY_P
                              18188                 :                :             | IF_P
                              18189                 :                :             | IGNORE_P
                              18190                 :                :             | IMMEDIATE
                              18191                 :                :             | IMMUTABLE
                              18192                 :                :             | IMPLICIT_P
                              18193                 :                :             | IMPORT_P
                              18194                 :                :             | INCLUDE
                              18195                 :                :             | INCLUDING
                              18196                 :                :             | INCREMENT
                              18197                 :                :             | INDENT
                              18198                 :                :             | INDEX
                              18199                 :                :             | INDEXES
                              18200                 :                :             | INHERIT
                              18201                 :                :             | INHERITS
                              18202                 :                :             | INLINE_P
                              18203                 :                :             | INPUT_P
                              18204                 :                :             | INSENSITIVE
                              18205                 :                :             | INSERT
                              18206                 :                :             | INSTEAD
                              18207                 :                :             | INVOKER
                              18208                 :                :             | ISOLATION
                              18209                 :                :             | KEEP
                              18210                 :                :             | KEY
                              18211                 :                :             | KEYS
                              18212                 :                :             | LABEL
                              18213                 :                :             | LANGUAGE
                              18214                 :                :             | LARGE_P
                              18215                 :                :             | LAST_P
                              18216                 :                :             | LEAKPROOF
                              18217                 :                :             | LEVEL
                              18218                 :                :             | LISTEN
                              18219                 :                :             | LOAD
                              18220                 :                :             | LOCAL
                              18221                 :                :             | LOCATION
                              18222                 :                :             | LOCK_P
                              18223                 :                :             | LOCKED
                              18224                 :                :             | LOGGED
                              18225                 :                :             | LSN_P
                              18226                 :                :             | MAPPING
                              18227                 :                :             | MATCH
                              18228                 :                :             | MATCHED
                              18229                 :                :             | MATERIALIZED
                              18230                 :                :             | MAXVALUE
                              18231                 :                :             | MERGE
                              18232                 :                :             | METHOD
                              18233                 :                :             | MINUTE_P
                              18234                 :                :             | MINVALUE
                              18235                 :                :             | MODE
                              18236                 :                :             | MONTH_P
                              18237                 :                :             | MOVE
                              18238                 :                :             | NAME_P
                              18239                 :                :             | NAMES
                              18240                 :                :             | NESTED
                              18241                 :                :             | NEW
                              18242                 :                :             | NEXT
                              18243                 :                :             | NFC
                              18244                 :                :             | NFD
                              18245                 :                :             | NFKC
                              18246                 :                :             | NFKD
                              18247                 :                :             | NO
                              18248                 :                :             | NORMALIZED
                              18249                 :                :             | NOTHING
                              18250                 :                :             | NOTIFY
                              18251                 :                :             | NOWAIT
                              18252                 :                :             | NULLS_P
                              18253                 :                :             | OBJECT_P
                              18254                 :                :             | OBJECTS_P
                              18255                 :                :             | OF
                              18256                 :                :             | OFF
                              18257                 :                :             | OIDS
                              18258                 :                :             | OLD
                              18259                 :                :             | OMIT
                              18260                 :                :             | OPERATOR
                              18261                 :                :             | OPTION
                              18262                 :                :             | OPTIONS
                              18263                 :                :             | ORDINALITY
                              18264                 :                :             | OTHERS
                              18265                 :                :             | OVER
                              18266                 :                :             | OVERRIDING
                              18267                 :                :             | OWNED
                              18268                 :                :             | OWNER
                              18269                 :                :             | PARALLEL
                              18270                 :                :             | PARAMETER
                              18271                 :                :             | PARSER
                              18272                 :                :             | PARTIAL
                              18273                 :                :             | PARTITION
                              18274                 :                :             | PASSING
                              18275                 :                :             | PASSWORD
                              18276                 :                :             | PATH
                              18277                 :                :             | PERIOD
                              18278                 :                :             | PLAN
                              18279                 :                :             | PLANS
                              18280                 :                :             | POLICY
                              18281                 :                :             | PRECEDING
                              18282                 :                :             | PREPARE
                              18283                 :                :             | PREPARED
                              18284                 :                :             | PRESERVE
                              18285                 :                :             | PRIOR
                              18286                 :                :             | PRIVILEGES
                              18287                 :                :             | PROCEDURAL
                              18288                 :                :             | PROCEDURE
                              18289                 :                :             | PROCEDURES
                              18290                 :                :             | PROGRAM
                              18291                 :                :             | PUBLICATION
                              18292                 :                :             | QUOTE
                              18293                 :                :             | QUOTES
                              18294                 :                :             | RANGE
                              18295                 :                :             | READ
                              18296                 :                :             | REASSIGN
                              18297                 :                :             | RECURSIVE
                              18298                 :                :             | REF_P
                              18299                 :                :             | REFERENCING
                              18300                 :                :             | REFRESH
                              18301                 :                :             | REINDEX
                              18302                 :                :             | RELATIVE_P
                              18303                 :                :             | RELEASE
                              18304                 :                :             | RENAME
                              18305                 :                :             | REPACK
                              18306                 :                :             | REPEATABLE
                              18307                 :                :             | REPLACE
                              18308                 :                :             | REPLICA
                              18309                 :                :             | RESET
                              18310                 :                :             | RESPECT_P
                              18311                 :                :             | RESTART
                              18312                 :                :             | RESTRICT
                              18313                 :                :             | RETURN
                              18314                 :                :             | RETURNS
                              18315                 :                :             | REVOKE
                              18316                 :                :             | ROLE
                              18317                 :                :             | ROLLBACK
                              18318                 :                :             | ROLLUP
                              18319                 :                :             | ROUTINE
                              18320                 :                :             | ROUTINES
                              18321                 :                :             | ROWS
                              18322                 :                :             | RULE
                              18323                 :                :             | SAVEPOINT
                              18324                 :                :             | SCALAR
                              18325                 :                :             | SCHEMA
                              18326                 :                :             | SCHEMAS
                              18327                 :                :             | SCROLL
                              18328                 :                :             | SEARCH
                              18329                 :                :             | SECOND_P
                              18330                 :                :             | SECURITY
                              18331                 :                :             | SEQUENCE
                              18332                 :                :             | SEQUENCES
                              18333                 :                :             | SERIALIZABLE
                              18334                 :                :             | SERVER
                              18335                 :                :             | SESSION
                              18336                 :                :             | SET
                              18337                 :                :             | SETS
                              18338                 :                :             | SHARE
                              18339                 :                :             | SHOW
                              18340                 :                :             | SIMPLE
                              18341                 :                :             | SKIP
                              18342                 :                :             | SNAPSHOT
                              18343                 :                :             | SOURCE
                              18344                 :                :             | SQL_P
                              18345                 :                :             | STABLE
                              18346                 :                :             | STANDALONE_P
                              18347                 :                :             | START
                              18348                 :                :             | STATEMENT
                              18349                 :                :             | STATISTICS
                              18350                 :                :             | STDIN
                              18351                 :                :             | STDOUT
                              18352                 :                :             | STORAGE
                              18353                 :                :             | STORED
                              18354                 :                :             | STRICT_P
                              18355                 :                :             | STRING_P
                              18356                 :                :             | STRIP_P
                              18357                 :                :             | SUBSCRIPTION
                              18358                 :                :             | SUPPORT
                              18359                 :                :             | SYSID
                              18360                 :                :             | SYSTEM_P
                              18361                 :                :             | TABLES
                              18362                 :                :             | TABLESPACE
                              18363                 :                :             | TARGET
                              18364                 :                :             | TEMP
                              18365                 :                :             | TEMPLATE
                              18366                 :                :             | TEMPORARY
                              18367                 :                :             | TEXT_P
                              18368                 :                :             | TIES
                              18369                 :                :             | TRANSACTION
                              18370                 :                :             | TRANSFORM
                              18371                 :                :             | TRIGGER
                              18372                 :                :             | TRUNCATE
                              18373                 :                :             | TRUSTED
                              18374                 :                :             | TYPE_P
                              18375                 :                :             | TYPES_P
                              18376                 :                :             | UESCAPE
                              18377                 :                :             | UNBOUNDED
                              18378                 :                :             | UNCOMMITTED
                              18379                 :                :             | UNCONDITIONAL
                              18380                 :                :             | UNENCRYPTED
                              18381                 :                :             | UNKNOWN
                              18382                 :                :             | UNLISTEN
                              18383                 :                :             | UNLOGGED
                              18384                 :                :             | UNTIL
                              18385                 :                :             | UPDATE
                              18386                 :                :             | VACUUM
                              18387                 :                :             | VALID
                              18388                 :                :             | VALIDATE
                              18389                 :                :             | VALIDATOR
                              18390                 :                :             | VALUE_P
                              18391                 :                :             | VARYING
                              18392                 :                :             | VERSION_P
                              18393                 :                :             | VIEW
                              18394                 :                :             | VIEWS
                              18395                 :                :             | VIRTUAL
                              18396                 :                :             | VOLATILE
                              18397                 :                :             | WAIT
                              18398                 :                :             | WHITESPACE_P
                              18399                 :                :             | WITHIN
                              18400                 :                :             | WITHOUT
                              18401                 :                :             | WORK
                              18402                 :                :             | WRAPPER
                              18403                 :                :             | WRITE
                              18404                 :                :             | XML_P
                              18405                 :                :             | YEAR_P
                              18406                 :                :             | YES_P
                              18407                 :                :             | ZONE
                              18408                 :                :         ;
                              18409                 :                : 
                              18410                 :                : /* Column identifier --- keywords that can be column, table, etc names.
                              18411                 :                :  *
                              18412                 :                :  * Many of these keywords will in fact be recognized as type or function
                              18413                 :                :  * names too; but they have special productions for the purpose, and so
                              18414                 :                :  * can't be treated as "generic" type or function names.
                              18415                 :                :  *
                              18416                 :                :  * The type names appearing here are not usable as function names
                              18417                 :                :  * because they can be followed by '(' in typename productions, which
                              18418                 :                :  * looks too much like a function call for an LR(1) parser.
                              18419                 :                :  */
                              18420                 :                : col_name_keyword:
                              18421                 :                :               BETWEEN
                              18422                 :                :             | BIGINT
                              18423                 :                :             | BIT
                              18424                 :                :             | BOOLEAN_P
                              18425                 :                :             | CHAR_P
                              18426                 :                :             | CHARACTER
                              18427                 :                :             | COALESCE
                              18428                 :                :             | DEC
                              18429                 :                :             | DECIMAL_P
                              18430                 :                :             | EXISTS
                              18431                 :                :             | EXTRACT
                              18432                 :                :             | FLOAT_P
                              18433                 :                :             | GREATEST
                              18434                 :                :             | GROUPING
                              18435                 :                :             | INOUT
                              18436                 :                :             | INT_P
                              18437                 :                :             | INTEGER
                              18438                 :                :             | INTERVAL
                              18439                 :                :             | JSON
                              18440                 :                :             | JSON_ARRAY
                              18441                 :                :             | JSON_ARRAYAGG
                              18442                 :                :             | JSON_EXISTS
                              18443                 :                :             | JSON_OBJECT
                              18444                 :                :             | JSON_OBJECTAGG
                              18445                 :                :             | JSON_QUERY
                              18446                 :                :             | JSON_SCALAR
                              18447                 :                :             | JSON_SERIALIZE
                              18448                 :                :             | JSON_TABLE
                              18449                 :                :             | JSON_VALUE
                              18450                 :                :             | LEAST
                              18451                 :                :             | MERGE_ACTION
                              18452                 :                :             | NATIONAL
                              18453                 :                :             | NCHAR
                              18454                 :                :             | NONE
                              18455                 :                :             | NORMALIZE
                              18456                 :                :             | NULLIF
                              18457                 :                :             | NUMERIC
                              18458                 :                :             | OUT_P
                              18459                 :                :             | OVERLAY
                              18460                 :                :             | POSITION
                              18461                 :                :             | PRECISION
                              18462                 :                :             | REAL
                              18463                 :                :             | ROW
                              18464                 :                :             | SETOF
                              18465                 :                :             | SMALLINT
                              18466                 :                :             | SUBSTRING
                              18467                 :                :             | TIME
                              18468                 :                :             | TIMESTAMP
                              18469                 :                :             | TREAT
                              18470                 :                :             | TRIM
                              18471                 :                :             | VALUES
                              18472                 :                :             | VARCHAR
                              18473                 :                :             | XMLATTRIBUTES
                              18474                 :                :             | XMLCONCAT
                              18475                 :                :             | XMLELEMENT
                              18476                 :                :             | XMLEXISTS
                              18477                 :                :             | XMLFOREST
                              18478                 :                :             | XMLNAMESPACES
                              18479                 :                :             | XMLPARSE
                              18480                 :                :             | XMLPI
                              18481                 :                :             | XMLROOT
                              18482                 :                :             | XMLSERIALIZE
                              18483                 :                :             | XMLTABLE
                              18484                 :                :         ;
                              18485                 :                : 
                              18486                 :                : /* Type/function identifier --- keywords that can be type or function names.
                              18487                 :                :  *
                              18488                 :                :  * Most of these are keywords that are used as operators in expressions;
                              18489                 :                :  * in general such keywords can't be column names because they would be
                              18490                 :                :  * ambiguous with variables, but they are unambiguous as function identifiers.
                              18491                 :                :  *
                              18492                 :                :  * Do not include POSITION, SUBSTRING, etc here since they have explicit
                              18493                 :                :  * productions in a_expr to support the goofy SQL9x argument syntax.
                              18494                 :                :  * - thomas 2000-11-28
                              18495                 :                :  */
                              18496                 :                : type_func_name_keyword:
                              18497                 :                :               AUTHORIZATION
                              18498                 :                :             | BINARY
                              18499                 :                :             | COLLATION
                              18500                 :                :             | CONCURRENTLY
                              18501                 :                :             | CROSS
                              18502                 :                :             | CURRENT_SCHEMA
                              18503                 :                :             | FREEZE
                              18504                 :                :             | FULL
                              18505                 :                :             | ILIKE
                              18506                 :                :             | INNER_P
                              18507                 :                :             | IS
                              18508                 :                :             | ISNULL
                              18509                 :                :             | JOIN
                              18510                 :                :             | LEFT
                              18511                 :                :             | LIKE
                              18512                 :                :             | NATURAL
                              18513                 :                :             | NOTNULL
                              18514                 :                :             | OUTER_P
                              18515                 :                :             | OVERLAPS
                              18516                 :                :             | RIGHT
                              18517                 :                :             | SIMILAR
                              18518                 :                :             | TABLESAMPLE
                              18519                 :                :             | VERBOSE
                              18520                 :                :         ;
                              18521                 :                : 
                              18522                 :                : /* Reserved keyword --- these keywords are usable only as a ColLabel.
                              18523                 :                :  *
                              18524                 :                :  * Keywords appear here if they could not be distinguished from variable,
                              18525                 :                :  * type, or function names in some contexts.  Don't put things here unless
                              18526                 :                :  * forced to.
                              18527                 :                :  */
                              18528                 :                : reserved_keyword:
                              18529                 :                :               ALL
                              18530                 :                :             | ANALYSE
                              18531                 :                :             | ANALYZE
                              18532                 :                :             | AND
                              18533                 :                :             | ANY
                              18534                 :                :             | ARRAY
                              18535                 :                :             | AS
                              18536                 :                :             | ASC
                              18537                 :                :             | ASYMMETRIC
                              18538                 :                :             | BOTH
                              18539                 :                :             | CASE
                              18540                 :                :             | CAST
                              18541                 :                :             | CHECK
                              18542                 :                :             | COLLATE
                              18543                 :                :             | COLUMN
                              18544                 :                :             | CONSTRAINT
                              18545                 :                :             | CREATE
                              18546                 :                :             | CURRENT_CATALOG
                              18547                 :                :             | CURRENT_DATE
                              18548                 :                :             | CURRENT_ROLE
                              18549                 :                :             | CURRENT_TIME
                              18550                 :                :             | CURRENT_TIMESTAMP
                              18551                 :                :             | CURRENT_USER
                              18552                 :                :             | DEFAULT
                              18553                 :                :             | DEFERRABLE
                              18554                 :                :             | DESC
                              18555                 :                :             | DISTINCT
                              18556                 :                :             | DO
                              18557                 :                :             | ELSE
                              18558                 :                :             | END_P
                              18559                 :                :             | EXCEPT
                              18560                 :                :             | FALSE_P
                              18561                 :                :             | FETCH
                              18562                 :                :             | FOR
                              18563                 :                :             | FOREIGN
                              18564                 :                :             | FROM
                              18565                 :                :             | GRANT
                              18566                 :                :             | GROUP_P
                              18567                 :                :             | HAVING
                              18568                 :                :             | IN_P
                              18569                 :                :             | INITIALLY
                              18570                 :                :             | INTERSECT
                              18571                 :                :             | INTO
                              18572                 :                :             | LATERAL_P
                              18573                 :                :             | LEADING
                              18574                 :                :             | LIMIT
                              18575                 :                :             | LOCALTIME
                              18576                 :                :             | LOCALTIMESTAMP
                              18577                 :                :             | NOT
                              18578                 :                :             | NULL_P
                              18579                 :                :             | OFFSET
                              18580                 :                :             | ON
                              18581                 :                :             | ONLY
                              18582                 :                :             | OR
                              18583                 :                :             | ORDER
                              18584                 :                :             | PLACING
                              18585                 :                :             | PRIMARY
                              18586                 :                :             | REFERENCES
                              18587                 :                :             | RETURNING
                              18588                 :                :             | SELECT
                              18589                 :                :             | SESSION_USER
                              18590                 :                :             | SOME
                              18591                 :                :             | SYMMETRIC
                              18592                 :                :             | SYSTEM_USER
                              18593                 :                :             | TABLE
                              18594                 :                :             | THEN
                              18595                 :                :             | TO
                              18596                 :                :             | TRAILING
                              18597                 :                :             | TRUE_P
                              18598                 :                :             | UNION
                              18599                 :                :             | UNIQUE
                              18600                 :                :             | USER
                              18601                 :                :             | USING
                              18602                 :                :             | VARIADIC
                              18603                 :                :             | WHEN
                              18604                 :                :             | WHERE
                              18605                 :                :             | WINDOW
                              18606                 :                :             | WITH
                              18607                 :                :         ;
                              18608                 :                : 
                              18609                 :                : /*
                              18610                 :                :  * While all keywords can be used as column labels when preceded by AS,
                              18611                 :                :  * not all of them can be used as a "bare" column label without AS.
                              18612                 :                :  * Those that can be used as a bare label must be listed here,
                              18613                 :                :  * in addition to appearing in one of the category lists above.
                              18614                 :                :  *
                              18615                 :                :  * Always add a new keyword to this list if possible.  Mark it BARE_LABEL
                              18616                 :                :  * in kwlist.h if it is included here, or AS_LABEL if it is not.
                              18617                 :                :  */
                              18618                 :                : bare_label_keyword:
                              18619                 :                :               ABORT_P
                              18620                 :                :             | ABSENT
                              18621                 :                :             | ABSOLUTE_P
                              18622                 :                :             | ACCESS
                              18623                 :                :             | ACTION
                              18624                 :                :             | ADD_P
                              18625                 :                :             | ADMIN
                              18626                 :                :             | AFTER
                              18627                 :                :             | AGGREGATE
                              18628                 :                :             | ALL
                              18629                 :                :             | ALSO
                              18630                 :                :             | ALTER
                              18631                 :                :             | ALWAYS
                              18632                 :                :             | ANALYSE
                              18633                 :                :             | ANALYZE
                              18634                 :                :             | AND
                              18635                 :                :             | ANY
                              18636                 :                :             | ASC
                              18637                 :                :             | ASENSITIVE
                              18638                 :                :             | ASSERTION
                              18639                 :                :             | ASSIGNMENT
                              18640                 :                :             | ASYMMETRIC
                              18641                 :                :             | AT
                              18642                 :                :             | ATOMIC
                              18643                 :                :             | ATTACH
                              18644                 :                :             | ATTRIBUTE
                              18645                 :                :             | AUTHORIZATION
                              18646                 :                :             | BACKWARD
                              18647                 :                :             | BEFORE
                              18648                 :                :             | BEGIN_P
                              18649                 :                :             | BETWEEN
                              18650                 :                :             | BIGINT
                              18651                 :                :             | BINARY
                              18652                 :                :             | BIT
                              18653                 :                :             | BOOLEAN_P
                              18654                 :                :             | BOTH
                              18655                 :                :             | BREADTH
                              18656                 :                :             | BY
                              18657                 :                :             | CACHE
                              18658                 :                :             | CALL
                              18659                 :                :             | CALLED
                              18660                 :                :             | CASCADE
                              18661                 :                :             | CASCADED
                              18662                 :                :             | CASE
                              18663                 :                :             | CAST
                              18664                 :                :             | CATALOG_P
                              18665                 :                :             | CHAIN
                              18666                 :                :             | CHARACTERISTICS
                              18667                 :                :             | CHECK
                              18668                 :                :             | CHECKPOINT
                              18669                 :                :             | CLASS
                              18670                 :                :             | CLOSE
                              18671                 :                :             | CLUSTER
                              18672                 :                :             | COALESCE
                              18673                 :                :             | COLLATE
                              18674                 :                :             | COLLATION
                              18675                 :                :             | COLUMN
                              18676                 :                :             | COLUMNS
                              18677                 :                :             | COMMENT
                              18678                 :                :             | COMMENTS
                              18679                 :                :             | COMMIT
                              18680                 :                :             | COMMITTED
                              18681                 :                :             | COMPRESSION
                              18682                 :                :             | CONCURRENTLY
                              18683                 :                :             | CONDITIONAL
                              18684                 :                :             | CONFIGURATION
                              18685                 :                :             | CONFLICT
                              18686                 :                :             | CONNECTION
                              18687                 :                :             | CONSTRAINT
                              18688                 :                :             | CONSTRAINTS
                              18689                 :                :             | CONTENT_P
                              18690                 :                :             | CONTINUE_P
                              18691                 :                :             | CONVERSION_P
                              18692                 :                :             | COPY
                              18693                 :                :             | COST
                              18694                 :                :             | CROSS
                              18695                 :                :             | CSV
                              18696                 :                :             | CUBE
                              18697                 :                :             | CURRENT_P
                              18698                 :                :             | CURRENT_CATALOG
                              18699                 :                :             | CURRENT_DATE
                              18700                 :                :             | CURRENT_ROLE
                              18701                 :                :             | CURRENT_SCHEMA
                              18702                 :                :             | CURRENT_TIME
                              18703                 :                :             | CURRENT_TIMESTAMP
                              18704                 :                :             | CURRENT_USER
                              18705                 :                :             | CURSOR
                              18706                 :                :             | CYCLE
                              18707                 :                :             | DATA_P
                              18708                 :                :             | DATABASE
                              18709                 :                :             | DEALLOCATE
                              18710                 :                :             | DEC
                              18711                 :                :             | DECIMAL_P
                              18712                 :                :             | DECLARE
                              18713                 :                :             | DEFAULT
                              18714                 :                :             | DEFAULTS
                              18715                 :                :             | DEFERRABLE
                              18716                 :                :             | DEFERRED
                              18717                 :                :             | DEFINER
                              18718                 :                :             | DELETE_P
                              18719                 :                :             | DELIMITER
                              18720                 :                :             | DELIMITERS
                              18721                 :                :             | DEPENDS
                              18722                 :                :             | DEPTH
                              18723                 :                :             | DESC
                              18724                 :                :             | DETACH
                              18725                 :                :             | DICTIONARY
                              18726                 :                :             | DISABLE_P
                              18727                 :                :             | DISCARD
                              18728                 :                :             | DISTINCT
                              18729                 :                :             | DO
                              18730                 :                :             | DOCUMENT_P
                              18731                 :                :             | DOMAIN_P
                              18732                 :                :             | DOUBLE_P
                              18733                 :                :             | DROP
                              18734                 :                :             | EACH
                              18735                 :                :             | ELSE
                              18736                 :                :             | EMPTY_P
                              18737                 :                :             | ENABLE_P
                              18738                 :                :             | ENCODING
                              18739                 :                :             | ENCRYPTED
                              18740                 :                :             | END_P
                              18741                 :                :             | ENFORCED
                              18742                 :                :             | ENUM_P
                              18743                 :                :             | ERROR_P
                              18744                 :                :             | ESCAPE
                              18745                 :                :             | EVENT
                              18746                 :                :             | EXCLUDE
                              18747                 :                :             | EXCLUDING
                              18748                 :                :             | EXCLUSIVE
                              18749                 :                :             | EXECUTE
                              18750                 :                :             | EXISTS
                              18751                 :                :             | EXPLAIN
                              18752                 :                :             | EXPRESSION
                              18753                 :                :             | EXTENSION
                              18754                 :                :             | EXTERNAL
                              18755                 :                :             | EXTRACT
                              18756                 :                :             | FALSE_P
                              18757                 :                :             | FAMILY
                              18758                 :                :             | FINALIZE
                              18759                 :                :             | FIRST_P
                              18760                 :                :             | FLOAT_P
                              18761                 :                :             | FOLLOWING
                              18762                 :                :             | FORCE
                              18763                 :                :             | FOREIGN
                              18764                 :                :             | FORMAT
                              18765                 :                :             | FORWARD
                              18766                 :                :             | FREEZE
                              18767                 :                :             | FULL
                              18768                 :                :             | FUNCTION
                              18769                 :                :             | FUNCTIONS
                              18770                 :                :             | GENERATED
                              18771                 :                :             | GLOBAL
                              18772                 :                :             | GRANTED
                              18773                 :                :             | GREATEST
                              18774                 :                :             | GROUPING
                              18775                 :                :             | GROUPS
                              18776                 :                :             | HANDLER
                              18777                 :                :             | HEADER_P
                              18778                 :                :             | HOLD
                              18779                 :                :             | IDENTITY_P
                              18780                 :                :             | IF_P
                              18781                 :                :             | ILIKE
                              18782                 :                :             | IMMEDIATE
                              18783                 :                :             | IMMUTABLE
                              18784                 :                :             | IMPLICIT_P
                              18785                 :                :             | IMPORT_P
                              18786                 :                :             | IN_P
                              18787                 :                :             | INCLUDE
                              18788                 :                :             | INCLUDING
                              18789                 :                :             | INCREMENT
                              18790                 :                :             | INDENT
                              18791                 :                :             | INDEX
                              18792                 :                :             | INDEXES
                              18793                 :                :             | INHERIT
                              18794                 :                :             | INHERITS
                              18795                 :                :             | INITIALLY
                              18796                 :                :             | INLINE_P
                              18797                 :                :             | INNER_P
                              18798                 :                :             | INOUT
                              18799                 :                :             | INPUT_P
                              18800                 :                :             | INSENSITIVE
                              18801                 :                :             | INSERT
                              18802                 :                :             | INSTEAD
                              18803                 :                :             | INT_P
                              18804                 :                :             | INTEGER
                              18805                 :                :             | INTERVAL
                              18806                 :                :             | INVOKER
                              18807                 :                :             | IS
                              18808                 :                :             | ISOLATION
                              18809                 :                :             | JOIN
                              18810                 :                :             | JSON
                              18811                 :                :             | JSON_ARRAY
                              18812                 :                :             | JSON_ARRAYAGG
                              18813                 :                :             | JSON_EXISTS
                              18814                 :                :             | JSON_OBJECT
                              18815                 :                :             | JSON_OBJECTAGG
                              18816                 :                :             | JSON_QUERY
                              18817                 :                :             | JSON_SCALAR
                              18818                 :                :             | JSON_SERIALIZE
                              18819                 :                :             | JSON_TABLE
                              18820                 :                :             | JSON_VALUE
                              18821                 :                :             | KEEP
                              18822                 :                :             | KEY
                              18823                 :                :             | KEYS
                              18824                 :                :             | LABEL
                              18825                 :                :             | LANGUAGE
                              18826                 :                :             | LARGE_P
                              18827                 :                :             | LAST_P
                              18828                 :                :             | LATERAL_P
                              18829                 :                :             | LEADING
                              18830                 :                :             | LEAKPROOF
                              18831                 :                :             | LEAST
                              18832                 :                :             | LEFT
                              18833                 :                :             | LEVEL
                              18834                 :                :             | LIKE
                              18835                 :                :             | LISTEN
                              18836                 :                :             | LOAD
                              18837                 :                :             | LOCAL
                              18838                 :                :             | LOCALTIME
                              18839                 :                :             | LOCALTIMESTAMP
                              18840                 :                :             | LOCATION
                              18841                 :                :             | LOCK_P
                              18842                 :                :             | LOCKED
                              18843                 :                :             | LOGGED
                              18844                 :                :             | LSN_P
                              18845                 :                :             | MAPPING
                              18846                 :                :             | MATCH
                              18847                 :                :             | MATCHED
                              18848                 :                :             | MATERIALIZED
                              18849                 :                :             | MAXVALUE
                              18850                 :                :             | MERGE
                              18851                 :                :             | MERGE_ACTION
                              18852                 :                :             | METHOD
                              18853                 :                :             | MINVALUE
                              18854                 :                :             | MODE
                              18855                 :                :             | MOVE
                              18856                 :                :             | NAME_P
                              18857                 :                :             | NAMES
                              18858                 :                :             | NATIONAL
                              18859                 :                :             | NATURAL
                              18860                 :                :             | NCHAR
                              18861                 :                :             | NESTED
                              18862                 :                :             | NEW
                              18863                 :                :             | NEXT
                              18864                 :                :             | NFC
                              18865                 :                :             | NFD
                              18866                 :                :             | NFKC
                              18867                 :                :             | NFKD
                              18868                 :                :             | NO
                              18869                 :                :             | NONE
                              18870                 :                :             | NORMALIZE
                              18871                 :                :             | NORMALIZED
                              18872                 :                :             | NOT
                              18873                 :                :             | NOTHING
                              18874                 :                :             | NOTIFY
                              18875                 :                :             | NOWAIT
                              18876                 :                :             | NULL_P
                              18877                 :                :             | NULLIF
                              18878                 :                :             | NULLS_P
                              18879                 :                :             | NUMERIC
                              18880                 :                :             | OBJECT_P
                              18881                 :                :             | OBJECTS_P
                              18882                 :                :             | OF
                              18883                 :                :             | OFF
                              18884                 :                :             | OIDS
                              18885                 :                :             | OLD
                              18886                 :                :             | OMIT
                              18887                 :                :             | ONLY
                              18888                 :                :             | OPERATOR
                              18889                 :                :             | OPTION
                              18890                 :                :             | OPTIONS
                              18891                 :                :             | OR
                              18892                 :                :             | ORDINALITY
                              18893                 :                :             | OTHERS
                              18894                 :                :             | OUT_P
                              18895                 :                :             | OUTER_P
                              18896                 :                :             | OVERLAY
                              18897                 :                :             | OVERRIDING
                              18898                 :                :             | OWNED
                              18899                 :                :             | OWNER
                              18900                 :                :             | PARALLEL
                              18901                 :                :             | PARAMETER
                              18902                 :                :             | PARSER
                              18903                 :                :             | PARTIAL
                              18904                 :                :             | PARTITION
                              18905                 :                :             | PASSING
                              18906                 :                :             | PASSWORD
                              18907                 :                :             | PATH
                              18908                 :                :             | PERIOD
                              18909                 :                :             | PLACING
                              18910                 :                :             | PLAN
                              18911                 :                :             | PLANS
                              18912                 :                :             | POLICY
                              18913                 :                :             | POSITION
                              18914                 :                :             | PRECEDING
                              18915                 :                :             | PREPARE
                              18916                 :                :             | PREPARED
                              18917                 :                :             | PRESERVE
                              18918                 :                :             | PRIMARY
                              18919                 :                :             | PRIOR
                              18920                 :                :             | PRIVILEGES
                              18921                 :                :             | PROCEDURAL
                              18922                 :                :             | PROCEDURE
                              18923                 :                :             | PROCEDURES
                              18924                 :                :             | PROGRAM
                              18925                 :                :             | PUBLICATION
                              18926                 :                :             | QUOTE
                              18927                 :                :             | QUOTES
                              18928                 :                :             | RANGE
                              18929                 :                :             | READ
                              18930                 :                :             | REAL
                              18931                 :                :             | REASSIGN
                              18932                 :                :             | RECURSIVE
                              18933                 :                :             | REF_P
                              18934                 :                :             | REFERENCES
                              18935                 :                :             | REFERENCING
                              18936                 :                :             | REFRESH
                              18937                 :                :             | REINDEX
                              18938                 :                :             | RELATIVE_P
                              18939                 :                :             | RELEASE
                              18940                 :                :             | RENAME
                              18941                 :                :             | REPACK
                              18942                 :                :             | REPEATABLE
                              18943                 :                :             | REPLACE
                              18944                 :                :             | REPLICA
                              18945                 :                :             | RESET
                              18946                 :                :             | RESTART
                              18947                 :                :             | RESTRICT
                              18948                 :                :             | RETURN
                              18949                 :                :             | RETURNS
                              18950                 :                :             | REVOKE
                              18951                 :                :             | RIGHT
                              18952                 :                :             | ROLE
                              18953                 :                :             | ROLLBACK
                              18954                 :                :             | ROLLUP
                              18955                 :                :             | ROUTINE
                              18956                 :                :             | ROUTINES
                              18957                 :                :             | ROW
                              18958                 :                :             | ROWS
                              18959                 :                :             | RULE
                              18960                 :                :             | SAVEPOINT
                              18961                 :                :             | SCALAR
                              18962                 :                :             | SCHEMA
                              18963                 :                :             | SCHEMAS
                              18964                 :                :             | SCROLL
                              18965                 :                :             | SEARCH
                              18966                 :                :             | SECURITY
                              18967                 :                :             | SELECT
                              18968                 :                :             | SEQUENCE
                              18969                 :                :             | SEQUENCES
                              18970                 :                :             | SERIALIZABLE
                              18971                 :                :             | SERVER
                              18972                 :                :             | SESSION
                              18973                 :                :             | SESSION_USER
                              18974                 :                :             | SET
                              18975                 :                :             | SETOF
                              18976                 :                :             | SETS
                              18977                 :                :             | SHARE
                              18978                 :                :             | SHOW
                              18979                 :                :             | SIMILAR
                              18980                 :                :             | SIMPLE
                              18981                 :                :             | SKIP
                              18982                 :                :             | SMALLINT
                              18983                 :                :             | SNAPSHOT
                              18984                 :                :             | SOME
                              18985                 :                :             | SOURCE
                              18986                 :                :             | SQL_P
                              18987                 :                :             | STABLE
                              18988                 :                :             | STANDALONE_P
                              18989                 :                :             | START
                              18990                 :                :             | STATEMENT
                              18991                 :                :             | STATISTICS
                              18992                 :                :             | STDIN
                              18993                 :                :             | STDOUT
                              18994                 :                :             | STORAGE
                              18995                 :                :             | STORED
                              18996                 :                :             | STRICT_P
                              18997                 :                :             | STRING_P
                              18998                 :                :             | STRIP_P
                              18999                 :                :             | SUBSCRIPTION
                              19000                 :                :             | SUBSTRING
                              19001                 :                :             | SUPPORT
                              19002                 :                :             | SYMMETRIC
                              19003                 :                :             | SYSID
                              19004                 :                :             | SYSTEM_P
                              19005                 :                :             | SYSTEM_USER
                              19006                 :                :             | TABLE
                              19007                 :                :             | TABLES
                              19008                 :                :             | TABLESAMPLE
                              19009                 :                :             | TABLESPACE
                              19010                 :                :             | TARGET
                              19011                 :                :             | TEMP
                              19012                 :                :             | TEMPLATE
                              19013                 :                :             | TEMPORARY
                              19014                 :                :             | TEXT_P
                              19015                 :                :             | THEN
                              19016                 :                :             | TIES
                              19017                 :                :             | TIME
                              19018                 :                :             | TIMESTAMP
                              19019                 :                :             | TRAILING
                              19020                 :                :             | TRANSACTION
                              19021                 :                :             | TRANSFORM
                              19022                 :                :             | TREAT
                              19023                 :                :             | TRIGGER
                              19024                 :                :             | TRIM
                              19025                 :                :             | TRUE_P
                              19026                 :                :             | TRUNCATE
                              19027                 :                :             | TRUSTED
                              19028                 :                :             | TYPE_P
                              19029                 :                :             | TYPES_P
                              19030                 :                :             | UESCAPE
                              19031                 :                :             | UNBOUNDED
                              19032                 :                :             | UNCOMMITTED
                              19033                 :                :             | UNCONDITIONAL
                              19034                 :                :             | UNENCRYPTED
                              19035                 :                :             | UNIQUE
                              19036                 :                :             | UNKNOWN
                              19037                 :                :             | UNLISTEN
                              19038                 :                :             | UNLOGGED
                              19039                 :                :             | UNTIL
                              19040                 :                :             | UPDATE
                              19041                 :                :             | USER
                              19042                 :                :             | USING
                              19043                 :                :             | VACUUM
                              19044                 :                :             | VALID
                              19045                 :                :             | VALIDATE
                              19046                 :                :             | VALIDATOR
                              19047                 :                :             | VALUE_P
                              19048                 :                :             | VALUES
                              19049                 :                :             | VARCHAR
                              19050                 :                :             | VARIADIC
                              19051                 :                :             | VERBOSE
                              19052                 :                :             | VERSION_P
                              19053                 :                :             | VIEW
                              19054                 :                :             | VIEWS
                              19055                 :                :             | VIRTUAL
                              19056                 :                :             | VOLATILE
                              19057                 :                :             | WAIT
                              19058                 :                :             | WHEN
                              19059                 :                :             | WHITESPACE_P
                              19060                 :                :             | WORK
                              19061                 :                :             | WRAPPER
                              19062                 :                :             | WRITE
                              19063                 :                :             | XML_P
                              19064                 :                :             | XMLATTRIBUTES
                              19065                 :                :             | XMLCONCAT
                              19066                 :                :             | XMLELEMENT
                              19067                 :                :             | XMLEXISTS
                              19068                 :                :             | XMLFOREST
                              19069                 :                :             | XMLNAMESPACES
                              19070                 :                :             | XMLPARSE
                              19071                 :                :             | XMLPI
                              19072                 :                :             | XMLROOT
                              19073                 :                :             | XMLSERIALIZE
                              19074                 :                :             | XMLTABLE
                              19075                 :                :             | YES_P
                              19076                 :                :             | ZONE
                              19077                 :                :         ;
                              19078                 :                : 
                              19079                 :                : %%
                              19080                 :                : 
                              19081                 :                : /*
                              19082                 :                :  * The signature of this function is required by bison.  However, we
                              19083                 :                :  * ignore the passed yylloc and instead use the last token position
                              19084                 :                :  * available from the scanner.
                              19085                 :                :  */
                              19086                 :                : static void
 6205                         19087                 :            463 : base_yyerror(YYLTYPE *yylloc, core_yyscan_t yyscanner, const char *msg)
                              19088                 :                : {
 6324                         19089                 :            463 :     parser_yyerror(msg);
                              19090                 :                : }
                              19091                 :                : 
                              19092                 :                : static RawStmt *
 3582                         19093                 :         517832 : makeRawStmt(Node *stmt, int stmt_location)
                              19094                 :                : {
                              19095                 :         517832 :     RawStmt    *rs = makeNode(RawStmt);
                              19096                 :                : 
                              19097                 :         517832 :     rs->stmt = stmt;
                              19098                 :         517832 :     rs->stmt_location = stmt_location;
                              19099                 :         517832 :     rs->stmt_len = 0;            /* might get changed later */
                              19100                 :         517832 :     return rs;
                              19101                 :                : }
                              19102                 :                : 
                              19103                 :                : /* Adjust a RawStmt to reflect that it doesn't run to the end of the string */
                              19104                 :                : static void
                              19105                 :         389601 : updateRawStmtEnd(RawStmt *rs, int end_location)
                              19106                 :                : {
                              19107                 :                :     /*
                              19108                 :                :      * If we already set the length, don't change it.  This is for situations
                              19109                 :                :      * like "select foo ;; select bar" where the same statement will be last
                              19110                 :                :      * in the string for more than one semicolon.
                              19111                 :                :      */
                              19112         [ +  + ]:         389601 :     if (rs->stmt_len > 0)
                              19113                 :            337 :         return;
                              19114                 :                : 
                              19115                 :                :     /* OK, update length of RawStmt */
                              19116                 :         389264 :     rs->stmt_len = end_location - rs->stmt_location;
                              19117                 :                : }
                              19118                 :                : 
                              19119                 :                : static Node *
 6324                         19120                 :        1165981 : makeColumnRef(char *colname, List *indirection,
                              19121                 :                :               int location, core_yyscan_t yyscanner)
                              19122                 :                : {
                              19123                 :                :     /*
                              19124                 :                :      * Generate a ColumnRef node, with an A_Indirection node added if there is
                              19125                 :                :      * any subscripting in the specified indirection list.  However, any field
                              19126                 :                :      * selection at the start of the indirection list must be transposed into
                              19127                 :                :      * the "fields" part of the ColumnRef node.
                              19128                 :                :      */
 8184                         19129                 :        1165981 :     ColumnRef  *c = makeNode(ColumnRef);
 1637 peter@eisentraut.org    19130                 :        1165981 :     int         nfields = 0;
                              19131                 :                :     ListCell   *l;
                              19132                 :                : 
 7541 tgl@sss.pgh.pa.us       19133                 :        1165981 :     c->location = location;
 8184                         19134   [ +  +  +  +  :        1862427 :     foreach(l, indirection)
                                              +  + ]
                              19135                 :                :     {
                              19136         [ +  + ]:         702872 :         if (IsA(lfirst(l), A_Indices))
                              19137                 :                :         {
                              19138                 :           6426 :             A_Indirection *i = makeNode(A_Indirection);
                              19139                 :                : 
                              19140         [ +  + ]:           6426 :             if (nfields == 0)
                              19141                 :                :             {
                              19142                 :                :                 /* easy case - all indirection goes to A_Indirection */
 6641                         19143                 :           4608 :                 c->fields = list_make1(makeString(colname));
 6324                         19144                 :           4608 :                 i->indirection = check_indirection(indirection, yyscanner);
                              19145                 :                :             }
                              19146                 :                :             else
                              19147                 :                :             {
                              19148                 :                :                 /* got to split the list in two */
 6641                         19149                 :           1818 :                 i->indirection = check_indirection(list_copy_tail(indirection,
                              19150                 :                :                                                                   nfields),
                              19151                 :                :                                                    yyscanner);
 8184                         19152                 :           1818 :                 indirection = list_truncate(indirection, nfields);
 6641                         19153                 :           1818 :                 c->fields = lcons(makeString(colname), indirection);
                              19154                 :                :             }
 8184                         19155                 :           6426 :             i->arg = (Node *) c;
                              19156                 :           6426 :             return (Node *) i;
                              19157                 :                :         }
 6641                         19158         [ +  + ]:         696446 :         else if (IsA(lfirst(l), A_Star))
                              19159                 :                :         {
                              19160                 :                :             /* We only allow '*' at the end of a ColumnRef */
 2670                         19161         [ -  + ]:           3816 :             if (lnext(indirection, l) != NULL)
 6324 tgl@sss.pgh.pa.us       19162                 :UBC           0 :                 parser_yyerror("improper use of \"*\"");
                              19163                 :                :         }
 8184 tgl@sss.pgh.pa.us       19164                 :CBC      696446 :         nfields++;
                              19165                 :                :     }
                              19166                 :                :     /* No subscripting, so all indirection gets added to field list */
 6641                         19167                 :        1159555 :     c->fields = lcons(makeString(colname), indirection);
 8184                         19168                 :        1159555 :     return (Node *) c;
                              19169                 :                : }
                              19170                 :                : 
                              19171                 :                : static Node *
 6643                         19172                 :         194476 : makeTypeCast(Node *arg, TypeName *typename, int location)
                              19173                 :                : {
 1637 peter@eisentraut.org    19174                 :         194476 :     TypeCast   *n = makeNode(TypeCast);
                              19175                 :                : 
 8888 bruce@momjian.us        19176                 :         194476 :     n->arg = arg;
 6321 peter_e@gmx.net         19177                 :         194476 :     n->typeName = typename;
 6643 tgl@sss.pgh.pa.us       19178                 :         194476 :     n->location = location;
 8888 bruce@momjian.us        19179                 :         194476 :     return (Node *) n;
                              19180                 :                : }
                              19181                 :                : 
                              19182                 :                : static Node *
 6643 tgl@sss.pgh.pa.us       19183                 :          10757 : makeStringConstCast(char *str, int location, TypeName *typename)
                              19184                 :                : {
 1637 peter@eisentraut.org    19185                 :          10757 :     Node       *s = makeStringConst(str, location);
                              19186                 :                : 
 6643 tgl@sss.pgh.pa.us       19187                 :          10757 :     return makeTypeCast(s, typename, -1);
                              19188                 :                : }
                              19189                 :                : 
                              19190                 :                : static Node *
                              19191                 :         270298 : makeIntConst(int val, int location)
                              19192                 :                : {
  680 peter@eisentraut.org    19193                 :         270298 :     A_Const    *n = makeNode(A_Const);
                              19194                 :                : 
 1883                         19195                 :         270298 :     n->val.ival.type = T_Integer;
 1756                         19196                 :         270298 :     n->val.ival.ival = val;
 6643 tgl@sss.pgh.pa.us       19197                 :         270298 :     n->location = location;
                              19198                 :                : 
  680 peter@eisentraut.org    19199                 :         270298 :     return (Node *) n;
                              19200                 :                : }
                              19201                 :                : 
                              19202                 :                : static Node *
 6643 tgl@sss.pgh.pa.us       19203                 :           8114 : makeFloatConst(char *str, int location)
                              19204                 :                : {
  680 peter@eisentraut.org    19205                 :           8114 :     A_Const    *n = makeNode(A_Const);
                              19206                 :                : 
 1883                         19207                 :           8114 :     n->val.fval.type = T_Float;
 1756                         19208                 :           8114 :     n->val.fval.fval = str;
 6643 tgl@sss.pgh.pa.us       19209                 :           8114 :     n->location = location;
                              19210                 :                : 
  680 peter@eisentraut.org    19211                 :           8114 :     return (Node *) n;
                              19212                 :                : }
                              19213                 :                : 
                              19214                 :                : static Node *
 1756                         19215                 :          40760 : makeBoolAConst(bool state, int location)
                              19216                 :                : {
  680                         19217                 :          40760 :     A_Const    *n = makeNode(A_Const);
                              19218                 :                : 
 1756                         19219                 :          40760 :     n->val.boolval.type = T_Boolean;
                              19220                 :          40760 :     n->val.boolval.boolval = state;
                              19221                 :          40760 :     n->location = location;
                              19222                 :                : 
  680                         19223                 :          40760 :     return (Node *) n;
                              19224                 :                : }
                              19225                 :                : 
                              19226                 :                : static Node *
 6643 tgl@sss.pgh.pa.us       19227                 :           2725 : makeBitStringConst(char *str, int location)
                              19228                 :                : {
  680 peter@eisentraut.org    19229                 :           2725 :     A_Const    *n = makeNode(A_Const);
                              19230                 :                : 
 1883                         19231                 :           2725 :     n->val.bsval.type = T_BitString;
 1756                         19232                 :           2725 :     n->val.bsval.bsval = str;
 6643 tgl@sss.pgh.pa.us       19233                 :           2725 :     n->location = location;
                              19234                 :                : 
  680 peter@eisentraut.org    19235                 :           2725 :     return (Node *) n;
                              19236                 :                : }
                              19237                 :                : 
                              19238                 :                : static Node *
 6643 tgl@sss.pgh.pa.us       19239                 :          43167 : makeNullAConst(int location)
                              19240                 :                : {
  680 peter@eisentraut.org    19241                 :          43167 :     A_Const    *n = makeNode(A_Const);
                              19242                 :                : 
 1883                         19243                 :          43167 :     n->isnull = true;
 6643 tgl@sss.pgh.pa.us       19244                 :          43167 :     n->location = location;
                              19245                 :                : 
 1637 peter@eisentraut.org    19246                 :          43167 :     return (Node *) n;
                              19247                 :                : }
                              19248                 :                : 
                              19249                 :                : static Node *
 1883                         19250                 :           3195 : makeAConst(Node *v, int location)
                              19251                 :                : {
                              19252                 :                :     Node       *n;
                              19253                 :                : 
 8964 lockhart@fourpalms.o    19254      [ +  +  - ]:           3195 :     switch (v->type)
                              19255                 :                :     {
                              19256                 :            140 :         case T_Float:
 1756 peter@eisentraut.org    19257                 :            140 :             n = makeFloatConst(castNode(Float, v)->fval, location);
 8964 lockhart@fourpalms.o    19258                 :            140 :             break;
                              19259                 :                : 
                              19260                 :           3055 :         case T_Integer:
 1756 peter@eisentraut.org    19261                 :           3055 :             n = makeIntConst(castNode(Integer, v)->ival, location);
 8964 lockhart@fourpalms.o    19262                 :           3055 :             break;
                              19263                 :                : 
 8964 lockhart@fourpalms.o    19264                 :UBC           0 :         default:
                              19265                 :                :             /* currently not used */
 1756 peter@eisentraut.org    19266                 :              0 :             Assert(false);
                              19267                 :                :             n = NULL;
                              19268                 :                :     }
                              19269                 :                : 
 8964 lockhart@fourpalms.o    19270                 :CBC        3195 :     return n;
                              19271                 :                : }
                              19272                 :                : 
                              19273                 :                : /* makeRoleSpec
                              19274                 :                :  * Create a RoleSpec with the given type
                              19275                 :                :  */
                              19276                 :                : static RoleSpec *
 4259 alvherre@alvh.no-ip.    19277                 :          16083 : makeRoleSpec(RoleSpecType type, int location)
                              19278                 :                : {
 1637 peter@eisentraut.org    19279                 :          16083 :     RoleSpec   *spec = makeNode(RoleSpec);
                              19280                 :                : 
 4259 alvherre@alvh.no-ip.    19281                 :          16083 :     spec->roletype = type;
                              19282                 :          16083 :     spec->location = location;
                              19283                 :                : 
 3599 peter_e@gmx.net         19284                 :          16083 :     return spec;
                              19285                 :                : }
                              19286                 :                : 
                              19287                 :                : /* check_qualified_name --- check the result of qualified_name production
                              19288                 :                :  *
                              19289                 :                :  * It's easiest to let the grammar production for qualified_name allow
                              19290                 :                :  * subscripts and '*', which we then must reject here.
                              19291                 :                :  */
                              19292                 :                : static void
 6205 tgl@sss.pgh.pa.us       19293                 :         160614 : check_qualified_name(List *names, core_yyscan_t yyscanner)
                              19294                 :                : {
                              19295                 :                :     ListCell   *i;
                              19296                 :                : 
 8032                         19297   [ +  -  +  +  :         321228 :     foreach(i, names)
                                              +  + ]
                              19298                 :                :     {
                              19299         [ -  + ]:         160614 :         if (!IsA(lfirst(i), String))
 6324 tgl@sss.pgh.pa.us       19300                 :UBC           0 :             parser_yyerror("syntax error");
                              19301                 :                :     }
 8032 tgl@sss.pgh.pa.us       19302                 :CBC      160614 : }
                              19303                 :                : 
                              19304                 :                : /* check_func_name --- check the result of func_name production
                              19305                 :                :  *
                              19306                 :                :  * It's easiest to let the grammar production for func_name allow subscripts
                              19307                 :                :  * and '*', which we then must reject here.
                              19308                 :                :  */
                              19309                 :                : static List *
 6205                         19310                 :          87757 : check_func_name(List *names, core_yyscan_t yyscanner)
                              19311                 :                : {
                              19312                 :                :     ListCell   *i;
                              19313                 :                : 
 8184                         19314   [ +  -  +  +  :         263271 :     foreach(i, names)
                                              +  + ]
                              19315                 :                :     {
                              19316         [ -  + ]:         175514 :         if (!IsA(lfirst(i), String))
 6324 tgl@sss.pgh.pa.us       19317                 :UBC           0 :             parser_yyerror("syntax error");
                              19318                 :                :     }
 8184 tgl@sss.pgh.pa.us       19319                 :CBC       87757 :     return names;
                              19320                 :                : }
                              19321                 :                : 
                              19322                 :                : /* check_indirection --- check the result of indirection production
                              19323                 :                :  *
                              19324                 :                :  * We only allow '*' at the end of the list, but it's hard to enforce that
                              19325                 :                :  * in the grammar, so do it here.
                              19326                 :                :  */
                              19327                 :                : static List *
 6205                         19328                 :          52159 : check_indirection(List *indirection, core_yyscan_t yyscanner)
                              19329                 :                : {
                              19330                 :                :     ListCell   *l;
                              19331                 :                : 
 6641                         19332   [ +  +  +  +  :          71731 :     foreach(l, indirection)
                                              +  + ]
                              19333                 :                :     {
                              19334         [ +  + ]:          19572 :         if (IsA(lfirst(l), A_Star))
                              19335                 :                :         {
 2670                         19336         [ -  + ]:            923 :             if (lnext(indirection, l) != NULL)
 6324 tgl@sss.pgh.pa.us       19337                 :UBC           0 :                 parser_yyerror("improper use of \"*\"");
                              19338                 :                :         }
                              19339                 :                :     }
 6641 tgl@sss.pgh.pa.us       19340                 :CBC       52159 :     return indirection;
                              19341                 :                : }
                              19342                 :                : 
                              19343                 :                : /* extractArgTypes()
                              19344                 :                :  * Given a list of FunctionParameter nodes, extract a list of just the
                              19345                 :                :  * argument types (TypeNames) for input parameters only.  This is what
                              19346                 :                :  * is needed to look up an existing function, which is what is wanted by
                              19347                 :                :  * the productions that use this call.
                              19348                 :                :  */
                              19349                 :                : static List *
 1974                         19350                 :           5634 : extractArgTypes(List *parameters)
                              19351                 :                : {
 8339                         19352                 :           5634 :     List       *result = NIL;
                              19353                 :                :     ListCell   *i;
                              19354                 :                : 
                              19355   [ +  +  +  +  :          14012 :     foreach(i, parameters)
                                              +  + ]
                              19356                 :                :     {
                              19357                 :           8378 :         FunctionParameter *p = (FunctionParameter *) lfirst(i);
                              19358                 :                : 
 1974                         19359   [ +  +  +  - ]:           8378 :         if (p->mode != FUNC_PARAM_OUT && p->mode != FUNC_PARAM_TABLE)
 7891                         19360                 :           8285 :             result = lappend(result, p->argType);
                              19361                 :                :     }
 8339                         19362                 :           5634 :     return result;
                              19363                 :                : }
                              19364                 :                : 
                              19365                 :                : /* extractAggrArgTypes()
                              19366                 :                :  * As above, but work from the output of the aggr_args production.
                              19367                 :                :  */
                              19368                 :                : static List *
 4700                         19369                 :            220 : extractAggrArgTypes(List *aggrargs)
                              19370                 :                : {
                              19371         [ -  + ]:            220 :     Assert(list_length(aggrargs) == 2);
 1974                         19372                 :            220 :     return extractArgTypes((List *) linitial(aggrargs));
                              19373                 :                : }
                              19374                 :                : 
                              19375                 :                : /* makeOrderedSetArgs()
                              19376                 :                :  * Build the result of the aggr_args production (which see the comments for).
                              19377                 :                :  * This handles only the case where both given lists are nonempty, so that
                              19378                 :                :  * we have to deal with multiple VARIADIC arguments.
                              19379                 :                :  */
                              19380                 :                : static List *
 4700                         19381                 :             20 : makeOrderedSetArgs(List *directargs, List *orderedargs,
                              19382                 :                :                    core_yyscan_t yyscanner)
                              19383                 :                : {
                              19384                 :             20 :     FunctionParameter *lastd = (FunctionParameter *) llast(directargs);
                              19385                 :                :     Integer    *ndirectargs;
                              19386                 :                : 
                              19387                 :                :     /* No restriction unless last direct arg is VARIADIC */
                              19388         [ +  + ]:             20 :     if (lastd->mode == FUNC_PARAM_VARIADIC)
                              19389                 :                :     {
                              19390                 :             10 :         FunctionParameter *firsto = (FunctionParameter *) linitial(orderedargs);
                              19391                 :                : 
                              19392                 :                :         /*
                              19393                 :                :          * We ignore the names, though the aggr_arg production allows them; it
                              19394                 :                :          * doesn't allow default values, so those need not be checked.
                              19395                 :                :          */
                              19396         [ +  - ]:             10 :         if (list_length(orderedargs) != 1 ||
                              19397         [ +  - ]:             10 :             firsto->mode != FUNC_PARAM_VARIADIC ||
                              19398         [ -  + ]:             10 :             !equal(lastd->argType, firsto->argType))
 4700 tgl@sss.pgh.pa.us       19399         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19400                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19401                 :                :                      errmsg("an ordered-set aggregate with a VARIADIC direct argument must have one VARIADIC aggregated argument of the same data type"),
                              19402                 :                :                      parser_errposition(firsto->location)));
                              19403                 :                : 
                              19404                 :                :         /* OK, drop the duplicate VARIADIC argument from the internal form */
 4700 tgl@sss.pgh.pa.us       19405                 :CBC          10 :         orderedargs = NIL;
                              19406                 :                :     }
                              19407                 :                : 
                              19408                 :                :     /* don't merge into the next line, as list_concat changes directargs */
 2220                         19409                 :             20 :     ndirectargs = makeInteger(list_length(directargs));
                              19410                 :                : 
 4700                         19411                 :             20 :     return list_make2(list_concat(directargs, orderedargs),
                              19412                 :                :                       ndirectargs);
                              19413                 :                : }
                              19414                 :                : 
                              19415                 :                : /* insertSelectOptions()
                              19416                 :                :  * Insert ORDER BY, etc into an already-constructed SelectStmt.
                              19417                 :                :  *
                              19418                 :                :  * This routine is just to avoid duplicating code in SelectStmt productions.
                              19419                 :                :  */
                              19420                 :                : static void
 9496                         19421                 :          58010 : insertSelectOptions(SelectStmt *stmt,
                              19422                 :                :                     List *sortClause, List *lockingClause,
                              19423                 :                :                     SelectLimit *limitClause,
                              19424                 :                :                     WithClause *withClause,
                              19425                 :                :                     core_yyscan_t yyscanner)
                              19426                 :                : {
 6606                         19427         [ -  + ]:          58010 :     Assert(IsA(stmt, SelectStmt));
                              19428                 :                : 
                              19429                 :                :     /*
                              19430                 :                :      * Tests here are to reject constructs like
                              19431                 :                :      *  (SELECT foo ORDER BY bar) ORDER BY baz
                              19432                 :                :      */
 9496                         19433         [ +  + ]:          58010 :     if (sortClause)
                              19434                 :                :     {
                              19435         [ -  + ]:          49888 :         if (stmt->sortClause)
 8510 tgl@sss.pgh.pa.us       19436         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19437                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19438                 :                :                      errmsg("multiple ORDER BY clauses not allowed"),
                              19439                 :                :                      parser_errposition(exprLocation((Node *) sortClause))));
 9496 tgl@sss.pgh.pa.us       19440                 :CBC       49888 :         stmt->sortClause = sortClause;
                              19441                 :                :     }
                              19442                 :                :     /* We can handle multiple locking clauses, though */
 7494                         19443                 :          58010 :     stmt->lockingClause = list_concat(stmt->lockingClause, lockingClause);
 2403 alvherre@alvh.no-ip.    19444   [ +  +  +  + ]:          58010 :     if (limitClause && limitClause->limitOffset)
                              19445                 :                :     {
 9496 tgl@sss.pgh.pa.us       19446         [ -  + ]:            675 :         if (stmt->limitOffset)
 8510 tgl@sss.pgh.pa.us       19447         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19448                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19449                 :                :                      errmsg("multiple OFFSET clauses not allowed"),
                              19450                 :                :                      parser_errposition(limitClause->offsetLoc)));
 2403 alvherre@alvh.no-ip.    19451                 :CBC         675 :         stmt->limitOffset = limitClause->limitOffset;
                              19452                 :                :     }
                              19453   [ +  +  +  + ]:          58010 :     if (limitClause && limitClause->limitCount)
                              19454                 :                :     {
 9496 tgl@sss.pgh.pa.us       19455         [ -  + ]:           2917 :         if (stmt->limitCount)
 8510 tgl@sss.pgh.pa.us       19456         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19457                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19458                 :                :                      errmsg("multiple LIMIT clauses not allowed"),
                              19459                 :                :                      parser_errposition(limitClause->countLoc)));
 2403 alvherre@alvh.no-ip.    19460                 :CBC        2917 :         stmt->limitCount = limitClause->limitCount;
                              19461                 :                :     }
 1055                         19462         [ +  + ]:          58010 :     if (limitClause)
                              19463                 :                :     {
                              19464                 :                :         /* If there was a conflict, we must have detected it above */
  735 tgl@sss.pgh.pa.us       19465         [ -  + ]:           3380 :         Assert(!stmt->limitOption);
 2403 alvherre@alvh.no-ip.    19466   [ +  +  +  + ]:           3380 :         if (!stmt->sortClause && limitClause->limitOption == LIMIT_OPTION_WITH_TIES)
                              19467         [ +  - ]:              4 :             ereport(ERROR,
                              19468                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19469                 :                :                      errmsg("WITH TIES cannot be specified without ORDER BY clause"),
                              19470                 :                :                      parser_errposition(limitClause->optionLoc)));
 1861                         19471   [ +  +  +  + ]:           3376 :         if (limitClause->limitOption == LIMIT_OPTION_WITH_TIES && stmt->lockingClause)
                              19472                 :                :         {
                              19473                 :                :             ListCell   *lc;
                              19474                 :                : 
                              19475   [ +  -  +  -  :              4 :             foreach(lc, stmt->lockingClause)
                                              +  - ]
                              19476                 :                :             {
                              19477                 :              4 :                 LockingClause *lock = lfirst_node(LockingClause, lc);
                              19478                 :                : 
                              19479         [ +  - ]:              4 :                 if (lock->waitPolicy == LockWaitSkip)
                              19480         [ +  - ]:              4 :                     ereport(ERROR,
                              19481                 :                :                             (errcode(ERRCODE_SYNTAX_ERROR),
                              19482                 :                :                              errmsg("%s and %s options cannot be used together",
                              19483                 :                :                                     "SKIP LOCKED", "WITH TIES"),
                              19484                 :                :                              parser_errposition(limitClause->optionLoc)));
                              19485                 :                :             }
                              19486                 :                :         }
 2403                         19487                 :           3372 :         stmt->limitOption = limitClause->limitOption;
                              19488                 :                :     }
 6606 tgl@sss.pgh.pa.us       19489         [ +  + ]:          58002 :     if (withClause)
                              19490                 :                :     {
                              19491         [ -  + ]:           2058 :         if (stmt->withClause)
 6606 tgl@sss.pgh.pa.us       19492         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19493                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19494                 :                :                      errmsg("multiple WITH clauses not allowed"),
                              19495                 :                :                      parser_errposition(exprLocation((Node *) withClause))));
 6606 tgl@sss.pgh.pa.us       19496                 :CBC        2058 :         stmt->withClause = withClause;
                              19497                 :                :     }
 9496                         19498                 :          58002 : }
                              19499                 :                : 
                              19500                 :                : static Node *
  511 michael@paquier.xyz     19501                 :          13166 : makeSetOp(SetOperation op, bool all, Node *larg, Node *rarg)
                              19502                 :                : {
 9496 tgl@sss.pgh.pa.us       19503                 :          13166 :     SelectStmt *n = makeNode(SelectStmt);
                              19504                 :                : 
                              19505                 :          13166 :     n->op = op;
                              19506                 :          13166 :     n->all = all;
                              19507                 :          13166 :     n->larg = (SelectStmt *) larg;
                              19508                 :          13166 :     n->rarg = (SelectStmt *) rarg;
                              19509                 :          13166 :     return (Node *) n;
                              19510                 :                : }
                              19511                 :                : 
                              19512                 :                : /* SystemFuncName()
                              19513                 :                :  * Build a properly-qualified reference to a built-in function.
                              19514                 :                :  */
                              19515                 :                : List *
 8976                         19516                 :          13067 : SystemFuncName(char *name)
                              19517                 :                : {
 8194 neilc@samurai.com       19518                 :          13067 :     return list_make2(makeString("pg_catalog"), makeString(name));
                              19519                 :                : }
                              19520                 :                : 
                              19521                 :                : /* SystemTypeName()
                              19522                 :                :  * Build a properly-qualified reference to a built-in type.
                              19523                 :                :  *
                              19524                 :                :  * typmod is defaulted, but may be changed afterwards by caller.
                              19525                 :                :  * Likewise for the location.
                              19526                 :                :  */
                              19527                 :                : TypeName *
 8952 tgl@sss.pgh.pa.us       19528                 :          72673 : SystemTypeName(char *name)
                              19529                 :                : {
 7250                         19530                 :          72673 :     return makeTypeNameFromNameList(list_make2(makeString("pg_catalog"),
                              19531                 :                :                                                makeString(name)));
                              19532                 :                : }
                              19533                 :                : 
                              19534                 :                : /* doNegate()
                              19535                 :                :  * Handle negation of a numeric constant.
                              19536                 :                :  *
                              19537                 :                :  * Formerly, we did this here because the optimizer couldn't cope with
                              19538                 :                :  * indexquals that looked like "var = -4" --- it wants "var = const"
                              19539                 :                :  * and a unary minus operator applied to a constant didn't qualify.
                              19540                 :                :  * As of Postgres 7.0, that problem doesn't exist anymore because there
                              19541                 :                :  * is a constant-subexpression simplifier in the optimizer.  However,
                              19542                 :                :  * there's still a good reason for doing this here, which is that we can
                              19543                 :                :  * postpone committing to a particular internal representation for simple
                              19544                 :                :  * negative constants.  It's better to leave "-123.456" in string form
                              19545                 :                :  * until we know what the desired type is.
                              19546                 :                :  */
                              19547                 :                : static Node *
 7541                         19548                 :           6457 : doNegate(Node *n, int location)
                              19549                 :                : {
10094 bruce@momjian.us        19550         [ +  + ]:           6457 :     if (IsA(n, A_Const))
                              19551                 :                :     {
  680 peter@eisentraut.org    19552                 :           5773 :         A_Const    *con = (A_Const *) n;
                              19553                 :                : 
                              19554                 :                :         /* report the constant's location as that of the '-' sign */
 6643 tgl@sss.pgh.pa.us       19555                 :           5773 :         con->location = location;
                              19556                 :                : 
 1883 peter@eisentraut.org    19557         [ +  + ]:           5773 :         if (IsA(&con->val, Integer))
                              19558                 :                :         {
 1756                         19559                 :           5117 :             con->val.ival.ival = -con->val.ival.ival;
10094 bruce@momjian.us        19560                 :           5117 :             return n;
                              19561                 :                :         }
 1883 peter@eisentraut.org    19562         [ +  - ]:            656 :         if (IsA(&con->val, Float))
                              19563                 :                :         {
                              19564                 :            656 :             doNegateFloat(&con->val.fval);
10094 bruce@momjian.us        19565                 :            656 :             return n;
                              19566                 :                :         }
                              19567                 :                :     }
                              19568                 :                : 
 7541 tgl@sss.pgh.pa.us       19569                 :            684 :     return (Node *) makeSimpleA_Expr(AEXPR_OP, "-", NULL, n, location);
                              19570                 :                : }
                              19571                 :                : 
                              19572                 :                : static void
 1883 peter@eisentraut.org    19573                 :            669 : doNegateFloat(Float *v)
                              19574                 :                : {
 1637                         19575                 :            669 :     char       *oldval = v->fval;
                              19576                 :                : 
 9754 tgl@sss.pgh.pa.us       19577         [ -  + ]:            669 :     if (*oldval == '+')
 9754 tgl@sss.pgh.pa.us       19578                 :UBC           0 :         oldval++;
 9754 tgl@sss.pgh.pa.us       19579         [ -  + ]:CBC         669 :     if (*oldval == '-')
  680 peter@eisentraut.org    19580                 :UBC           0 :         v->fval = oldval + 1;    /* just strip the '-' */
                              19581                 :                :     else
 1756 peter@eisentraut.org    19582                 :CBC         669 :         v->fval = psprintf("-%s", oldval);
 9754 tgl@sss.pgh.pa.us       19583                 :            669 : }
                              19584                 :                : 
                              19585                 :                : static Node *
 4525                         19586                 :         155577 : makeAndExpr(Node *lexpr, Node *rexpr, int location)
                              19587                 :                : {
                              19588                 :                :     /* Flatten "a AND b AND c ..." to a single BoolExpr on sight */
 2158                         19589         [ +  + ]:         155577 :     if (IsA(lexpr, BoolExpr))
                              19590                 :                :     {
 1637 peter@eisentraut.org    19591                 :          73185 :         BoolExpr   *blexpr = (BoolExpr *) lexpr;
                              19592                 :                : 
 4525 tgl@sss.pgh.pa.us       19593         [ +  + ]:          73185 :         if (blexpr->boolop == AND_EXPR)
                              19594                 :                :         {
                              19595                 :          69595 :             blexpr->args = lappend(blexpr->args, rexpr);
                              19596                 :          69595 :             return (Node *) blexpr;
                              19597                 :                :         }
                              19598                 :                :     }
                              19599                 :          85982 :     return (Node *) makeBoolExpr(AND_EXPR, list_make2(lexpr, rexpr), location);
                              19600                 :                : }
                              19601                 :                : 
                              19602                 :                : static Node *
                              19603                 :          14007 : makeOrExpr(Node *lexpr, Node *rexpr, int location)
                              19604                 :                : {
                              19605                 :                :     /* Flatten "a OR b OR c ..." to a single BoolExpr on sight */
 2158                         19606         [ +  + ]:          14007 :     if (IsA(lexpr, BoolExpr))
                              19607                 :                :     {
 1637 peter@eisentraut.org    19608                 :           3598 :         BoolExpr   *blexpr = (BoolExpr *) lexpr;
                              19609                 :                : 
 4525 tgl@sss.pgh.pa.us       19610         [ +  + ]:           3598 :         if (blexpr->boolop == OR_EXPR)
                              19611                 :                :         {
                              19612                 :           2606 :             blexpr->args = lappend(blexpr->args, rexpr);
                              19613                 :           2606 :             return (Node *) blexpr;
                              19614                 :                :         }
                              19615                 :                :     }
                              19616                 :          11401 :     return (Node *) makeBoolExpr(OR_EXPR, list_make2(lexpr, rexpr), location);
                              19617                 :                : }
                              19618                 :                : 
                              19619                 :                : static Node *
                              19620                 :          17256 : makeNotExpr(Node *expr, int location)
                              19621                 :                : {
                              19622                 :          17256 :     return (Node *) makeBoolExpr(NOT_EXPR, list_make1(expr), location);
                              19623                 :                : }
                              19624                 :                : 
                              19625                 :                : static Node *
  511 alvherre@kurilemu.de    19626                 :           5926 : makeAArrayExpr(List *elements, int location, int location_end)
                              19627                 :                : {
 6804 tgl@sss.pgh.pa.us       19628                 :           5926 :     A_ArrayExpr *n = makeNode(A_ArrayExpr);
                              19629                 :                : 
                              19630                 :           5926 :     n->elements = elements;
 6643                         19631                 :           5926 :     n->location = location;
  511 alvherre@kurilemu.de    19632                 :           5926 :     n->list_start = location;
                              19633                 :           5926 :     n->list_end = location_end;
 6804 tgl@sss.pgh.pa.us       19634                 :           5926 :     return (Node *) n;
                              19635                 :                : }
                              19636                 :                : 
                              19637                 :                : static Node *
 1268 michael@paquier.xyz     19638                 :           1656 : makeSQLValueFunction(SQLValueFunctionOp op, int32 typmod, int location)
                              19639                 :                : {
                              19640                 :           1656 :     SQLValueFunction *svf = makeNode(SQLValueFunction);
                              19641                 :                : 
                              19642                 :           1656 :     svf->op = op;
                              19643                 :                :     /* svf->type will be filled during parse analysis */
                              19644                 :           1656 :     svf->typmod = typmod;
                              19645                 :           1656 :     svf->location = location;
                              19646                 :           1656 :     return (Node *) svf;
                              19647                 :                : }
                              19648                 :                : 
                              19649                 :                : static Node *
 6643 tgl@sss.pgh.pa.us       19650                 :            435 : makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args,
                              19651                 :                :             int location)
                              19652                 :                : {
  680 peter@eisentraut.org    19653                 :            435 :     XmlExpr    *x = makeNode(XmlExpr);
                              19654                 :                : 
 7259 peter_e@gmx.net         19655                 :            435 :     x->op = op;
                              19656                 :            435 :     x->name = name;
                              19657                 :                : 
                              19658                 :                :     /*
                              19659                 :                :      * named_args is a list of ResTarget; it'll be split apart into separate
                              19660                 :                :      * expression and name lists in transformXmlExpr().
                              19661                 :                :      */
                              19662                 :            435 :     x->named_args = named_args;
 7256 tgl@sss.pgh.pa.us       19663                 :            435 :     x->arg_names = NIL;
 7259 peter_e@gmx.net         19664                 :            435 :     x->args = args;
                              19665                 :                :     /* xmloption, if relevant, must be filled in by caller */
                              19666                 :                :     /* type and typmod will be filled in during parse analysis */
  680 peter@eisentraut.org    19667                 :            435 :     x->type = InvalidOid;        /* marks the node as not analyzed */
 6643 tgl@sss.pgh.pa.us       19668                 :            435 :     x->location = location;
 7259 peter_e@gmx.net         19669                 :            435 :     return (Node *) x;
                              19670                 :                : }
                              19671                 :                : 
                              19672                 :                : /*
                              19673                 :                :  * Merge the input and output parameters of a table function.
                              19674                 :                :  */
                              19675                 :                : static List *
  735 tgl@sss.pgh.pa.us       19676                 :            141 : mergeTableFuncParameters(List *func_args, List *columns, core_yyscan_t yyscanner)
                              19677                 :                : {
                              19678                 :                :     ListCell   *lc;
                              19679                 :                : 
                              19680                 :                :     /* Explicit OUT and INOUT parameters shouldn't be used in this syntax */
 6684                         19681   [ +  +  +  +  :            303 :     foreach(lc, func_args)
                                              +  + ]
                              19682                 :                :     {
                              19683                 :            162 :         FunctionParameter *p = (FunctionParameter *) lfirst(lc);
                              19684                 :                : 
 1974                         19685         [ -  + ]:            162 :         if (p->mode != FUNC_PARAM_DEFAULT &&
 1974 tgl@sss.pgh.pa.us       19686         [ #  # ]:UBC           0 :             p->mode != FUNC_PARAM_IN &&
                              19687         [ #  # ]:              0 :             p->mode != FUNC_PARAM_VARIADIC)
 6684                         19688         [ #  # ]:              0 :             ereport(ERROR,
                              19689                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19690                 :                :                      errmsg("OUT and INOUT arguments aren't allowed in TABLE functions"),
                              19691                 :                :                      parser_errposition(p->location)));
                              19692                 :                :     }
                              19693                 :                : 
 6684 tgl@sss.pgh.pa.us       19694                 :CBC         141 :     return list_concat(func_args, columns);
                              19695                 :                : }
                              19696                 :                : 
                              19697                 :                : /*
                              19698                 :                :  * Determine return type of a TABLE function.  A single result column
                              19699                 :                :  * returns setof that column's type; otherwise return setof record.
                              19700                 :                :  */
                              19701                 :                : static TypeName *
                              19702                 :            141 : TableFuncTypeName(List *columns)
                              19703                 :                : {
                              19704                 :                :     TypeName   *result;
                              19705                 :                : 
                              19706         [ +  + ]:            141 :     if (list_length(columns) == 1)
                              19707                 :                :     {
                              19708                 :             40 :         FunctionParameter *p = (FunctionParameter *) linitial(columns);
                              19709                 :                : 
 3528 peter_e@gmx.net         19710                 :             40 :         result = copyObject(p->argType);
                              19711                 :                :     }
                              19712                 :                :     else
 6684 tgl@sss.pgh.pa.us       19713                 :            101 :         result = SystemTypeName("record");
                              19714                 :                : 
                              19715                 :            141 :     result->setof = true;
                              19716                 :                : 
                              19717                 :            141 :     return result;
                              19718                 :                : }
                              19719                 :                : 
                              19720                 :                : /*
                              19721                 :                :  * Convert a list of (dotted) names to a RangeVar (like
                              19722                 :                :  * makeRangeVarFromNameList, but with position support).  The
                              19723                 :                :  * "AnyName" refers to the any_name production in the grammar.
                              19724                 :                :  */
                              19725                 :                : static RangeVar *
 5884 peter_e@gmx.net         19726                 :           2548 : makeRangeVarFromAnyName(List *names, int position, core_yyscan_t yyscanner)
                              19727                 :                : {
 1637 peter@eisentraut.org    19728                 :           2548 :     RangeVar   *r = makeNode(RangeVar);
                              19729                 :                : 
 5884 peter_e@gmx.net         19730   [ +  +  -  - ]:           2548 :     switch (list_length(names))
                              19731                 :                :     {
                              19732                 :           2498 :         case 1:
                              19733                 :           2498 :             r->catalogname = NULL;
                              19734                 :           2498 :             r->schemaname = NULL;
                              19735                 :           2498 :             r->relname = strVal(linitial(names));
                              19736                 :           2498 :             break;
                              19737                 :             50 :         case 2:
                              19738                 :             50 :             r->catalogname = NULL;
                              19739                 :             50 :             r->schemaname = strVal(linitial(names));
                              19740                 :             50 :             r->relname = strVal(lsecond(names));
                              19741                 :             50 :             break;
 5884 peter_e@gmx.net         19742                 :UBC           0 :         case 3:
 4237 heikki.linnakangas@i    19743                 :              0 :             r->catalogname = strVal(linitial(names));
 5884 peter_e@gmx.net         19744                 :              0 :             r->schemaname = strVal(lsecond(names));
                              19745                 :              0 :             r->relname = strVal(lthird(names));
                              19746                 :              0 :             break;
                              19747                 :              0 :         default:
                              19748         [ #  # ]:              0 :             ereport(ERROR,
                              19749                 :                :                     (errcode(ERRCODE_SYNTAX_ERROR),
                              19750                 :                :                      errmsg("improper qualified name (too many dotted names): %s",
                              19751                 :                :                             NameListToString(names)),
                              19752                 :                :                      parser_errposition(position)));
                              19753                 :                :             break;
                              19754                 :                :     }
                              19755                 :                : 
 5806 rhaas@postgresql.org    19756                 :CBC        2548 :     r->relpersistence = RELPERSISTENCE_PERMANENT;
 5884 peter_e@gmx.net         19757                 :           2548 :     r->location = position;
                              19758                 :                : 
                              19759                 :           2548 :     return r;
                              19760                 :                : }
                              19761                 :                : 
                              19762                 :                : /*
                              19763                 :                :  * Convert a relation_name with name and namelist to a RangeVar using
                              19764                 :                :  * makeRangeVar.
                              19765                 :                :  */
                              19766                 :                : static RangeVar *
 1835 akapila@postgresql.o    19767                 :         160614 : makeRangeVarFromQualifiedName(char *name, List *namelist, int location,
                              19768                 :                :                               core_yyscan_t yyscanner)
                              19769                 :                : {
                              19770                 :                :     RangeVar   *r;
                              19771                 :                : 
                              19772                 :         160614 :     check_qualified_name(namelist, yyscanner);
                              19773                 :         160614 :     r = makeRangeVar(NULL, NULL, location);
                              19774                 :                : 
                              19775      [ +  -  - ]:         160614 :     switch (list_length(namelist))
                              19776                 :                :     {
                              19777                 :         160614 :         case 1:
                              19778                 :         160614 :             r->catalogname = NULL;
                              19779                 :         160614 :             r->schemaname = name;
                              19780                 :         160614 :             r->relname = strVal(linitial(namelist));
                              19781                 :         160614 :             break;
 1835 akapila@postgresql.o    19782                 :UBC           0 :         case 2:
                              19783                 :              0 :             r->catalogname = name;
                              19784                 :              0 :             r->schemaname = strVal(linitial(namelist));
                              19785                 :              0 :             r->relname = strVal(lsecond(namelist));
                              19786                 :              0 :             break;
                              19787                 :              0 :         default:
                              19788         [ #  # ]:              0 :             ereport(ERROR,
                              19789                 :                :                     errcode(ERRCODE_SYNTAX_ERROR),
                              19790                 :                :                     errmsg("improper qualified name (too many dotted names): %s",
                              19791                 :                :                            NameListToString(lcons(makeString(name), namelist))),
                              19792                 :                :                     parser_errposition(location));
                              19793                 :                :             break;
                              19794                 :                :     }
                              19795                 :                : 
 1835 akapila@postgresql.o    19796                 :CBC      160614 :     return r;
                              19797                 :                : }
                              19798                 :                : 
                              19799                 :                : /* Separate Constraint nodes from COLLATE clauses in a ColQualList */
                              19800                 :                : static void
 5720 tgl@sss.pgh.pa.us       19801                 :          45385 : SplitColQualList(List *qualList,
                              19802                 :                :                  List **constraintList, CollateClause **collClause,
                              19803                 :                :                  core_yyscan_t yyscanner)
                              19804                 :                : {
                              19805                 :                :     ListCell   *cell;
                              19806                 :                : 
                              19807                 :          45385 :     *collClause = NULL;
 2670                         19808   [ +  +  +  +  :          58559 :     foreach(cell, qualList)
                                              +  + ]
                              19809                 :                :     {
 1637 peter@eisentraut.org    19810                 :          13174 :         Node       *n = (Node *) lfirst(cell);
                              19811                 :                : 
 5720 tgl@sss.pgh.pa.us       19812         [ +  + ]:          13174 :         if (IsA(n, Constraint))
                              19813                 :                :         {
                              19814                 :                :             /* keep it in list */
                              19815                 :          12634 :             continue;
                              19816                 :                :         }
                              19817         [ +  - ]:            540 :         if (IsA(n, CollateClause))
                              19818                 :                :         {
                              19819                 :            540 :             CollateClause *c = (CollateClause *) n;
                              19820                 :                : 
                              19821         [ -  + ]:            540 :             if (*collClause)
 5720 tgl@sss.pgh.pa.us       19822         [ #  # ]:UBC           0 :                 ereport(ERROR,
                              19823                 :                :                         (errcode(ERRCODE_SYNTAX_ERROR),
                              19824                 :                :                          errmsg("multiple COLLATE clauses not allowed"),
                              19825                 :                :                          parser_errposition(c->location)));
 5720 tgl@sss.pgh.pa.us       19826                 :CBC         540 :             *collClause = c;
                              19827                 :                :         }
                              19828                 :                :         else
 5720 tgl@sss.pgh.pa.us       19829         [ #  # ]:UBC           0 :             elog(ERROR, "unexpected node type %d", (int) n->type);
                              19830                 :                :         /* remove non-Constraint nodes from qualList */
 2670 tgl@sss.pgh.pa.us       19831                 :CBC         540 :         qualList = foreach_delete_current(qualList, cell);
                              19832                 :                :     }
 5720                         19833                 :          45385 :     *constraintList = qualList;
                              19834                 :          45385 : }
                              19835                 :                : 
                              19836                 :                : /*
                              19837                 :                :  * Process result of ConstraintAttributeSpec, and set appropriate bool flags
                              19838                 :                :  * in the output command node.  Pass NULL for any flags the particular
                              19839                 :                :  * command doesn't support.
                              19840                 :                :  */
                              19841                 :                : static void
 5622                         19842                 :          11398 : processCASbits(int cas_bits, int location, const char *constrType,
                              19843                 :                :                bool *deferrable, bool *initdeferred, bool *is_enforced,
                              19844                 :                :                bool *not_valid, bool *no_inherit, core_yyscan_t yyscanner)
                              19845                 :                : {
                              19846                 :                :     /* defaults */
                              19847         [ +  + ]:          11398 :     if (deferrable)
                              19848                 :           9919 :         *deferrable = false;
                              19849         [ +  + ]:          11398 :     if (initdeferred)
                              19850                 :           9919 :         *initdeferred = false;
                              19851         [ +  + ]:          11398 :     if (not_valid)
                              19852                 :           2676 :         *not_valid = false;
  663 peter@eisentraut.org    19853         [ +  + ]:          11398 :     if (is_enforced)
                              19854                 :           2468 :         *is_enforced = true;
                              19855                 :                : 
 5622 tgl@sss.pgh.pa.us       19856         [ +  + ]:          11398 :     if (cas_bits & (CAS_DEFERRABLE | CAS_INITIALLY_DEFERRED))
                              19857                 :                :     {
                              19858         [ +  - ]:            176 :         if (deferrable)
                              19859                 :            176 :             *deferrable = true;
                              19860                 :                :         else
 5622 tgl@sss.pgh.pa.us       19861         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19862                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19863                 :                :             /* translator: %s is CHECK, UNIQUE, or similar */
                              19864                 :                :                      errmsg("%s constraints cannot be marked DEFERRABLE",
                              19865                 :                :                             constrType),
                              19866                 :                :                      parser_errposition(location)));
                              19867                 :                :     }
                              19868                 :                : 
 5622 tgl@sss.pgh.pa.us       19869         [ +  + ]:CBC       11398 :     if (cas_bits & CAS_INITIALLY_DEFERRED)
                              19870                 :                :     {
                              19871         [ +  - ]:            106 :         if (initdeferred)
                              19872                 :            106 :             *initdeferred = true;
                              19873                 :                :         else
 5622 tgl@sss.pgh.pa.us       19874         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19875                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19876                 :                :             /* translator: %s is CHECK, UNIQUE, or similar */
                              19877                 :                :                      errmsg("%s constraints cannot be marked DEFERRABLE",
                              19878                 :                :                             constrType),
                              19879                 :                :                      parser_errposition(location)));
                              19880                 :                :     }
                              19881                 :                : 
 5622 tgl@sss.pgh.pa.us       19882         [ +  + ]:CBC       11398 :     if (cas_bits & CAS_NOT_VALID)
                              19883                 :                :     {
                              19884         [ +  - ]:            432 :         if (not_valid)
                              19885                 :            432 :             *not_valid = true;
                              19886                 :                :         else
 5622 tgl@sss.pgh.pa.us       19887         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19888                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19889                 :                :             /* translator: %s is CHECK, UNIQUE, or similar */
                              19890                 :                :                      errmsg("%s constraints cannot be marked NOT VALID",
                              19891                 :                :                             constrType),
                              19892                 :                :                      parser_errposition(location)));
                              19893                 :                :     }
                              19894                 :                : 
 5217 alvherre@alvh.no-ip.    19895         [ +  + ]:CBC       11398 :     if (cas_bits & CAS_NO_INHERIT)
                              19896                 :                :     {
                              19897         [ +  - ]:            167 :         if (no_inherit)
                              19898                 :            167 :             *no_inherit = true;
                              19899                 :                :         else
 5217 alvherre@alvh.no-ip.    19900         [ #  # ]:UBC           0 :             ereport(ERROR,
                              19901                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19902                 :                :             /* translator: %s is CHECK, UNIQUE, or similar */
                              19903                 :                :                      errmsg("%s constraints cannot be marked NO INHERIT",
                              19904                 :                :                             constrType),
                              19905                 :                :                      parser_errposition(location)));
                              19906                 :                :     }
                              19907                 :                : 
  663 peter@eisentraut.org    19908         [ +  + ]:CBC       11398 :     if (cas_bits & CAS_NOT_ENFORCED)
                              19909                 :                :     {
                              19910         [ +  + ]:            195 :         if (is_enforced)
                              19911                 :            191 :             *is_enforced = false;
                              19912                 :                :         else
                              19913         [ +  - ]:              4 :             ereport(ERROR,
                              19914                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19915                 :                :                      /* translator: %s is CHECK, UNIQUE, or similar */
                              19916                 :                :                      errmsg("%s constraints cannot be marked NOT ENFORCED",
                              19917                 :                :                             constrType),
                              19918                 :                :                      parser_errposition(location)));
                              19919                 :                : 
                              19920                 :                :         /*
                              19921                 :                :          * NB: The validated status is irrelevant when the constraint is set to
                              19922                 :                :          * NOT ENFORCED, but for consistency, it should be set accordingly.
                              19923                 :                :          * This ensures that if the constraint is later changed to ENFORCED, it
                              19924                 :                :          * will automatically be in the correct NOT VALIDATED state.
                              19925                 :                :          */
                              19926         [ +  + ]:            191 :         if (not_valid)
                              19927                 :             95 :             *not_valid = true;
                              19928                 :                :     }
                              19929                 :                : 
                              19930         [ +  + ]:          11394 :     if (cas_bits & CAS_ENFORCED)
                              19931                 :                :     {
                              19932         [ +  + ]:            148 :         if (is_enforced)
                              19933                 :            144 :             *is_enforced = true;
                              19934                 :                :         else
                              19935         [ +  - ]:              4 :             ereport(ERROR,
                              19936                 :                :                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                              19937                 :                :                      /* translator: %s is CHECK, UNIQUE, or similar */
                              19938                 :                :                      errmsg("%s constraints cannot be marked ENFORCED",
                              19939                 :                :                             constrType),
                              19940                 :                :                      parser_errposition(location)));
                              19941                 :                :     }
 5622 tgl@sss.pgh.pa.us       19942                 :          11390 : }
                              19943                 :                : 
                              19944                 :                : /*
                              19945                 :                :  * Parse a user-supplied partition strategy string into parse node
                              19946                 :                :  * PartitionStrategy representation, or die trying.
                              19947                 :                :  */
                              19948                 :                : static PartitionStrategy
  735                         19949                 :           3459 : parsePartitionStrategy(char *strategy, int location, core_yyscan_t yyscanner)
                              19950                 :                : {
 1463 alvherre@alvh.no-ip.    19951         [ +  + ]:           3459 :     if (pg_strcasecmp(strategy, "list") == 0)
                              19952                 :           1645 :         return PARTITION_STRATEGY_LIST;
                              19953         [ +  + ]:           1814 :     else if (pg_strcasecmp(strategy, "range") == 0)
                              19954                 :           1639 :         return PARTITION_STRATEGY_RANGE;
                              19955         [ +  + ]:            175 :     else if (pg_strcasecmp(strategy, "hash") == 0)
                              19956                 :            171 :         return PARTITION_STRATEGY_HASH;
                              19957                 :                : 
                              19958         [ +  - ]:              4 :     ereport(ERROR,
                              19959                 :                :             (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                              19960                 :                :              errmsg("unrecognized partitioning strategy \"%s\"", strategy),
                              19961                 :                :              parser_errposition(location)));
                              19962                 :                :     return PARTITION_STRATEGY_LIST; /* keep compiler quiet */
                              19963                 :                : 
                              19964                 :                : }
                              19965                 :                : 
                              19966                 :                : /*
                              19967                 :                :  * Process all_objects_list to set all_tables and/or all_sequences.
                              19968                 :                :  * Also, checks if the pub_object_type has been specified more than once.
                              19969                 :                :  */
                              19970                 :                : static void
  246 akapila@postgresql.o    19971                 :            212 : preprocess_pub_all_objtype_list(List *all_objects_list, List **pubobjects,
                              19972                 :                :                                 bool *all_tables, bool *all_sequences,
                              19973                 :                :                                 core_yyscan_t yyscanner)
                              19974                 :                : {
  392                         19975         [ -  + ]:            212 :     if (!all_objects_list)
  392 akapila@postgresql.o    19976                 :UBC           0 :         return;
                              19977                 :                : 
  392 akapila@postgresql.o    19978                 :CBC         212 :     *all_tables = false;
                              19979                 :            212 :     *all_sequences = false;
                              19980                 :                : 
                              19981   [ +  -  +  +  :            645 :     foreach_ptr(PublicationAllObjSpec, obj, all_objects_list)
                                              +  + ]
                              19982                 :                :     {
                              19983         [ +  + ]:            237 :         if (obj->pubobjtype == PUBLICATION_ALL_TABLES)
                              19984                 :                :         {
                              19985         [ +  + ]:            187 :             if (*all_tables)
                              19986         [ +  - ]:              4 :                 ereport(ERROR,
                              19987                 :                :                         errcode(ERRCODE_SYNTAX_ERROR),
                              19988                 :                :                         errmsg("invalid publication object list"),
                              19989                 :                :                         errdetail("ALL TABLES can be specified only once."),
                              19990                 :                :                         parser_errposition(obj->location));
                              19991                 :                : 
                              19992                 :            183 :             *all_tables = true;
  246                         19993                 :            183 :             *pubobjects = list_concat(*pubobjects, obj->except_tables);
                              19994                 :                :         }
  392                         19995         [ +  - ]:             50 :         else if (obj->pubobjtype == PUBLICATION_ALL_SEQUENCES)
                              19996                 :                :         {
                              19997         [ +  + ]:             50 :             if (*all_sequences)
                              19998         [ +  - ]:              4 :                 ereport(ERROR,
                              19999                 :                :                     errcode(ERRCODE_SYNTAX_ERROR),
                              20000                 :                :                         errmsg("invalid publication object list"),
                              20001                 :                :                         errdetail("ALL SEQUENCES can be specified only once."),
                              20002                 :                :                         parser_errposition(obj->location));
                              20003                 :                : 
                              20004                 :             46 :             *all_sequences = true;
                              20005                 :                :         }
                              20006                 :                :     }
                              20007                 :                : }
                              20008                 :                : 
                              20009                 :                : /*
                              20010                 :                :  * Process pubobjspec_list to check for errors in any of the objects and
                              20011                 :                :  * convert PUBLICATIONOBJ_CONTINUATION into appropriate PublicationObjSpecType.
                              20012                 :                :  */
                              20013                 :                : static void
 1835                         20014                 :           1095 : preprocess_pubobj_list(List *pubobjspec_list, core_yyscan_t yyscanner)
                              20015                 :                : {
                              20016                 :                :     ListCell   *cell;
                              20017                 :                :     PublicationObjSpec *pubobj;
                              20018                 :           1095 :     PublicationObjSpecType prevobjtype = PUBLICATIONOBJ_CONTINUATION;
                              20019                 :                : 
                              20020         [ -  + ]:           1095 :     if (!pubobjspec_list)
 1835 akapila@postgresql.o    20021                 :UBC           0 :         return;
                              20022                 :                : 
 1835 akapila@postgresql.o    20023                 :CBC        1095 :     pubobj = (PublicationObjSpec *) linitial(pubobjspec_list);
                              20024         [ +  + ]:           1095 :     if (pubobj->pubobjtype == PUBLICATIONOBJ_CONTINUATION)
                              20025         [ +  - ]:              8 :         ereport(ERROR,
                              20026                 :                :                 errcode(ERRCODE_SYNTAX_ERROR),
                              20027                 :                :                 errmsg("invalid publication object list"),
                              20028                 :                :                 errdetail("One of TABLE or TABLES IN SCHEMA must be specified before a standalone table or schema name."),
                              20029                 :                :                 parser_errposition(pubobj->location));
                              20030                 :                : 
                              20031   [ +  -  +  +  :           2323 :     foreach(cell, pubobjspec_list)
                                              +  + ]
                              20032                 :                :     {
                              20033                 :           1252 :         pubobj = (PublicationObjSpec *) lfirst(cell);
                              20034                 :                : 
                              20035         [ +  + ]:           1252 :         if (pubobj->pubobjtype == PUBLICATIONOBJ_CONTINUATION)
                              20036                 :            112 :             pubobj->pubobjtype = prevobjtype;
                              20037                 :                : 
 1673 tomas.vondra@postgre    20038         [ +  + ]:           1252 :         if (pubobj->pubobjtype == PUBLICATIONOBJ_TABLE)
                              20039                 :                :         {
                              20040                 :                :             /* relation name or pubtable must be set for this type of object */
 1835 akapila@postgresql.o    20041   [ +  +  +  + ]:            955 :             if (!pubobj->name && !pubobj->pubtable)
                              20042         [ +  - ]:              4 :                 ereport(ERROR,
                              20043                 :                :                         errcode(ERRCODE_SYNTAX_ERROR),
                              20044                 :                :                         errmsg("invalid table name"),
                              20045                 :                :                         parser_errposition(pubobj->location));
                              20046                 :                : 
 1717                         20047         [ +  + ]:            951 :             if (pubobj->name)
                              20048                 :                :             {
                              20049                 :                :                 /* convert it to PublicationTable */
 1835                         20050                 :             37 :                 PublicationTable *pubtable = makeNode(PublicationTable);
                              20051                 :                : 
 1771 alvherre@alvh.no-ip.    20052                 :             37 :                 pubtable->relation =
                              20053                 :             37 :                     makeRangeVar(NULL, pubobj->name, pubobj->location);
 1835 akapila@postgresql.o    20054                 :             37 :                 pubobj->pubtable = pubtable;
                              20055                 :             37 :                 pubobj->name = NULL;
                              20056                 :                :             }
                              20057                 :                :         }
 1771 alvherre@alvh.no-ip.    20058         [ +  + ]:            297 :         else if (pubobj->pubobjtype == PUBLICATIONOBJ_TABLES_IN_SCHEMA ||
                              20059         [ +  - ]:             16 :                  pubobj->pubobjtype == PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA)
                              20060                 :                :         {
                              20061                 :                :             /* WHERE clause is not allowed on a schema object */
 1717 akapila@postgresql.o    20062   [ +  +  +  + ]:            297 :             if (pubobj->pubtable && pubobj->pubtable->whereClause)
                              20063         [ +  - ]:              4 :                 ereport(ERROR,
                              20064                 :                :                         errcode(ERRCODE_SYNTAX_ERROR),
                              20065                 :                :                         errmsg("WHERE clause not allowed for schema"),
                              20066                 :                :                         parser_errposition(pubobj->location));
                              20067                 :                : 
                              20068                 :                :             /* Column list is not allowed on a schema object */
 1685 tomas.vondra@postgre    20069   [ +  +  +  + ]:            293 :             if (pubobj->pubtable && pubobj->pubtable->columns)
                              20070         [ +  - ]:              4 :                 ereport(ERROR,
                              20071                 :                :                         errcode(ERRCODE_SYNTAX_ERROR),
                              20072                 :                :                         errmsg("column specification not allowed for schema"),
                              20073                 :                :                         parser_errposition(pubobj->location));
                              20074                 :                : 
                              20075                 :                :             /*
                              20076                 :                :              * We can distinguish between the different type of schema objects
                              20077                 :                :              * based on whether name and pubtable is set.
                              20078                 :                :              */
 1835 akapila@postgresql.o    20079         [ +  + ]:            289 :             if (pubobj->name)
 1771 alvherre@alvh.no-ip.    20080                 :            269 :                 pubobj->pubobjtype = PUBLICATIONOBJ_TABLES_IN_SCHEMA;
 1835 akapila@postgresql.o    20081   [ +  -  +  + ]:             20 :             else if (!pubobj->name && !pubobj->pubtable)
 1771 alvherre@alvh.no-ip.    20082                 :             16 :                 pubobj->pubobjtype = PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA;
                              20083                 :                :             else
 1835 akapila@postgresql.o    20084         [ +  - ]:              4 :                 ereport(ERROR,
                              20085                 :                :                         errcode(ERRCODE_SYNTAX_ERROR),
                              20086                 :                :                         errmsg("invalid schema name"),
                              20087                 :                :                         parser_errposition(pubobj->location));
                              20088                 :                :         }
                              20089                 :                : 
                              20090                 :           1236 :         prevobjtype = pubobj->pubobjtype;
                              20091                 :                :     }
                              20092                 :                : }
                              20093                 :                : 
                              20094                 :                : /*----------
                              20095                 :                :  * Recursive view transformation
                              20096                 :                :  *
                              20097                 :                :  * Convert
                              20098                 :                :  *
                              20099                 :                :  *     CREATE RECURSIVE VIEW relname (aliases) AS query
                              20100                 :                :  *
                              20101                 :                :  * to
                              20102                 :                :  *
                              20103                 :                :  *     CREATE VIEW relname (aliases) AS
                              20104                 :                :  *         WITH RECURSIVE relname (aliases) AS (query)
                              20105                 :                :  *         SELECT aliases FROM relname
                              20106                 :                :  *
                              20107                 :                :  * Actually, just the WITH ... part, which is then inserted into the original
                              20108                 :                :  * view definition as the query.
                              20109                 :                :  * ----------
                              20110                 :                :  */
                              20111                 :                : static Node *
 5026 peter_e@gmx.net         20112                 :              9 : makeRecursiveViewSelect(char *relname, List *aliases, Node *query)
                              20113                 :                : {
                              20114                 :              9 :     SelectStmt *s = makeNode(SelectStmt);
                              20115                 :              9 :     WithClause *w = makeNode(WithClause);
                              20116                 :              9 :     CommonTableExpr *cte = makeNode(CommonTableExpr);
                              20117                 :              9 :     List       *tl = NIL;
                              20118                 :                :     ListCell   *lc;
                              20119                 :                : 
                              20120                 :                :     /* create common table expression */
                              20121                 :              9 :     cte->ctename = relname;
                              20122                 :              9 :     cte->aliascolnames = aliases;
 2819 tgl@sss.pgh.pa.us       20123                 :              9 :     cte->ctematerialized = CTEMaterializeDefault;
 5026 peter_e@gmx.net         20124                 :              9 :     cte->ctequery = query;
                              20125                 :              9 :     cte->location = -1;
                              20126                 :                : 
                              20127                 :                :     /* create WITH clause and attach CTE */
                              20128                 :              9 :     w->recursive = true;
                              20129                 :              9 :     w->ctes = list_make1(cte);
                              20130                 :              9 :     w->location = -1;
                              20131                 :                : 
                              20132                 :                :     /*
                              20133                 :                :      * create target list for the new SELECT from the alias list of the
                              20134                 :                :      * recursive view specification
                              20135                 :                :      */
  680 peter@eisentraut.org    20136   [ +  -  +  +  :             18 :     foreach(lc, aliases)
                                              +  + ]
                              20137                 :                :     {
                              20138                 :              9 :         ResTarget  *rt = makeNode(ResTarget);
                              20139                 :                : 
 5026 peter_e@gmx.net         20140                 :              9 :         rt->name = NULL;
                              20141                 :              9 :         rt->indirection = NIL;
                              20142                 :              9 :         rt->val = makeColumnRef(strVal(lfirst(lc)), NIL, -1, 0);
                              20143                 :              9 :         rt->location = -1;
                              20144                 :                : 
                              20145                 :              9 :         tl = lappend(tl, rt);
                              20146                 :                :     }
                              20147                 :                : 
                              20148                 :                :     /*
                              20149                 :                :      * create new SELECT combining WITH clause, target list, and fake FROM
                              20150                 :                :      * clause
                              20151                 :                :      */
                              20152                 :              9 :     s->withClause = w;
                              20153                 :              9 :     s->targetList = tl;
                              20154                 :              9 :     s->fromClause = list_make1(makeRangeVar(NULL, relname, -1));
                              20155                 :                : 
                              20156                 :              9 :     return (Node *) s;
                              20157                 :                : }
                              20158                 :                : 
                              20159                 :                : /* parser_init()
                              20160                 :                :  * Initialize to parse one query string
                              20161                 :                :  */
                              20162                 :                : void
 5720 tgl@sss.pgh.pa.us       20163                 :         494003 : parser_init(base_yy_extra_type *yyext)
                              20164                 :                : {
                              20165                 :         494003 :     yyext->parsetree = NIL;      /* in case grammar forgets to set it */
                              20166                 :         494003 : }
        

Generated by: LCOV version 2.0-1