From 30ed71e423ee63b263730b86326da2a629a29f84 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 13 May 2022 07:17:29 +0200 Subject: [PATCH] Indent C code in flex and bison files In the style of pgindent, done semi-manually. Discussion: https://www.postgresql.org/message-id/flat/7d062ecc-7444-23ec-a159-acd8adf9b586%40enterprisedb.com --- contrib/cube/cubeparse.y | 8 +- contrib/seg/segparse.y | 22 +- src/backend/bootstrap/bootparse.y | 19 +- src/backend/parser/gram.y | 2492 ++++++++++++++++-------- src/backend/replication/repl_gram.y | 28 +- src/backend/replication/repl_scanner.l | 5 +- src/backend/utils/adt/jsonpath_gram.y | 41 +- src/backend/utils/adt/jsonpath_scan.l | 4 +- src/backend/utils/misc/guc-file.l | 8 +- src/bin/pgbench/exprparse.y | 4 +- src/interfaces/ecpg/preproc/pgc.l | 24 +- src/pl/plpgsql/src/pl_gram.y | 467 ++--- 12 files changed, 1955 insertions(+), 1167 deletions(-) diff --git a/contrib/cube/cubeparse.y b/contrib/cube/cubeparse.y index deb2efdc0d..7577c4515c 100644 --- a/contrib/cube/cubeparse.y +++ b/contrib/cube/cubeparse.y @@ -45,7 +45,7 @@ static NDBOX *write_point_as_box(int dim, char *str); box: O_BRACKET paren_list COMMA paren_list C_BRACKET { - int dim; + int dim; dim = item_count($2, ','); if (item_count($4, ',') != dim) @@ -72,7 +72,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET | paren_list COMMA paren_list { - int dim; + int dim; dim = item_count($1, ','); if (item_count($3, ',') != dim) @@ -99,7 +99,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET | paren_list { - int dim; + int dim; dim = item_count($1, ','); if (dim > CUBE_MAX_DIM) @@ -117,7 +117,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET | list { - int dim; + int dim; dim = item_count($1, ','); if (dim > CUBE_MAX_DIM) diff --git a/contrib/seg/segparse.y b/contrib/seg/segparse.y index 040cab3904..33e3a9f35f 100644 --- a/contrib/seg/segparse.y +++ b/contrib/seg/segparse.y @@ -38,13 +38,15 @@ static char strbuf[25] = { %expect 0 %name-prefix="seg_yy" -%union { - struct BND { - float val; - char ext; - char sigd; +%union +{ + struct BND + { + float val; + char ext; + char sigd; } bnd; - char * text; + char *text; } %token SEGFLOAT %token RANGE @@ -119,7 +121,7 @@ range: boundary PLUMIN deviation boundary: SEGFLOAT { /* temp variable avoids a gcc 3.3.x bug on Sparc64 */ - float val = seg_atof($1); + float val = seg_atof($1); $$.ext = '\0'; $$.sigd = significant_digits($1); @@ -128,7 +130,7 @@ boundary: SEGFLOAT | EXTENSION SEGFLOAT { /* temp variable avoids a gcc 3.3.x bug on Sparc64 */ - float val = seg_atof($2); + float val = seg_atof($2); $$.ext = $1[0]; $$.sigd = significant_digits($2); @@ -139,7 +141,7 @@ boundary: SEGFLOAT deviation: SEGFLOAT { /* temp variable avoids a gcc 3.3.x bug on Sparc64 */ - float val = seg_atof($1); + float val = seg_atof($1); $$.ext = '\0'; $$.sigd = significant_digits($1); @@ -153,7 +155,7 @@ deviation: SEGFLOAT static float seg_atof(const char *value) { - Datum datum; + Datum datum; datum = DirectFunctionCall1(float4in, CStringGetDatum(value)); return DatumGetFloat4(datum); diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y index 142433f63f..e5cf1b3d43 100644 --- a/src/backend/bootstrap/bootparse.y +++ b/src/backend/bootstrap/bootparse.y @@ -167,9 +167,9 @@ Boot_CreateStmt: } RPAREN { - TupleDesc tupdesc; - bool shared_relation; - bool mapped_relation; + TupleDesc tupdesc; + bool shared_relation; + bool mapped_relation; do_start(); @@ -218,7 +218,7 @@ Boot_CreateStmt: } else { - Oid id; + Oid id; id = heap_create_with_catalog($2, PG_CATALOG_NAMESPACE, @@ -269,8 +269,8 @@ Boot_InsertStmt: Boot_DeclareIndexStmt: XDECLARE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN { - IndexStmt *stmt = makeNode(IndexStmt); - Oid relationId; + IndexStmt *stmt = makeNode(IndexStmt); + Oid relationId; elog(DEBUG4, "creating index \"%s\"", $3); @@ -321,8 +321,8 @@ Boot_DeclareIndexStmt: Boot_DeclareUniqueIndexStmt: XDECLARE UNIQUE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN { - IndexStmt *stmt = makeNode(IndexStmt); - Oid relationId; + IndexStmt *stmt = makeNode(IndexStmt); + Oid relationId; elog(DEBUG4, "creating unique index \"%s\"", $4); @@ -400,7 +400,8 @@ boot_index_params: boot_index_param: boot_ident boot_ident { - IndexElem *n = makeNode(IndexElem); + IndexElem *n = makeNode(IndexElem); + n->name = $1; n->expr = NULL; n->indexcolname = NULL; diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index c9941d9cb4..989db0dbec 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -129,23 +129,23 @@ typedef struct ImportQual /* Private struct for the result of opt_select_limit production */ typedef struct SelectLimit { - Node *limitOffset; - Node *limitCount; + Node *limitOffset; + Node *limitCount; LimitOption limitOption; } SelectLimit; /* Private struct for the result of group_clause production */ typedef struct GroupClause { - bool distinct; - List *list; + bool distinct; + List *list; } GroupClause; /* Private structs for the result of key_actions and key_action productions */ typedef struct KeyAction { - char action; - List *cols; + char action; + List *cols; } KeyAction; typedef struct KeyActions @@ -233,61 +233,61 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); %union { - core_YYSTYPE core_yystype; + core_YYSTYPE core_yystype; /* these fields must match core_YYSTYPE: */ - int ival; - char *str; - const char *keyword; + int ival; + char *str; + const char *keyword; - char chr; - bool boolean; - JoinType jtype; - DropBehavior dbehavior; - OnCommitAction oncommit; - List *list; - Node *node; - ObjectType objtype; - TypeName *typnam; - FunctionParameter *fun_param; + char chr; + bool boolean; + JoinType jtype; + DropBehavior dbehavior; + OnCommitAction oncommit; + List *list; + Node *node; + ObjectType objtype; + TypeName *typnam; + FunctionParameter *fun_param; FunctionParameterMode fun_param_mode; - ObjectWithArgs *objwithargs; - DefElem *defelt; - SortBy *sortby; - WindowDef *windef; - JoinExpr *jexpr; - IndexElem *ielem; - StatsElem *selem; - Alias *alias; - RangeVar *range; - IntoClause *into; - WithClause *with; - InferClause *infer; - OnConflictClause *onconflict; - A_Indices *aind; - ResTarget *target; - struct PrivTarget *privtarget; - AccessPriv *accesspriv; - struct ImportQual *importqual; - InsertStmt *istmt; - VariableSetStmt *vsetstmt; - PartitionElem *partelem; - PartitionSpec *partspec; - PartitionBoundSpec *partboundspec; - RoleSpec *rolespec; - PublicationObjSpec *publicationobjectspec; - struct SelectLimit *selectlimit; - SetQuantifier setquantifier; - struct GroupClause *groupclause; - MergeWhenClause *mergewhen; - struct KeyActions *keyactions; - struct KeyAction *keyaction; - JsonBehavior *jsbehavior; + ObjectWithArgs *objwithargs; + DefElem *defelt; + SortBy *sortby; + WindowDef *windef; + JoinExpr *jexpr; + IndexElem *ielem; + StatsElem *selem; + Alias *alias; + RangeVar *range; + IntoClause *into; + WithClause *with; + InferClause *infer; + OnConflictClause *onconflict; + A_Indices *aind; + ResTarget *target; + struct PrivTarget *privtarget; + AccessPriv *accesspriv; + struct ImportQual *importqual; + InsertStmt *istmt; + VariableSetStmt *vsetstmt; + PartitionElem *partelem; + PartitionSpec *partspec; + PartitionBoundSpec *partboundspec; + RoleSpec *rolespec; + PublicationObjSpec *publicationobjectspec; + struct SelectLimit *selectlimit; + SetQuantifier setquantifier; + struct GroupClause *groupclause; + MergeWhenClause *mergewhen; + struct KeyActions *keyactions; + struct KeyAction *keyaction; + JsonBehavior *jsbehavior; struct { - JsonBehavior *on_empty; - JsonBehavior *on_error; - } on_behavior; - JsonQuotes js_quotes; + JsonBehavior *on_empty; + JsonBehavior *on_error; + } on_behavior; + JsonQuotes js_quotes; } %type stmt toplevel_stmt schema_stmt routine_body_stmt @@ -987,6 +987,7 @@ parse_toplevel: | MODE_PLPGSQL_ASSIGN1 PLAssignStmt { PLAssignStmt *n = (PLAssignStmt *) $2; + n->nnames = 1; pg_yyget_extra(yyscanner)->parsetree = list_make1(makeRawStmt((Node *) n, 0)); @@ -994,6 +995,7 @@ parse_toplevel: | MODE_PLPGSQL_ASSIGN2 PLAssignStmt { PLAssignStmt *n = (PLAssignStmt *) $2; + n->nnames = 2; pg_yyget_extra(yyscanner)->parsetree = list_make1(makeRawStmt((Node *) n, 0)); @@ -1001,6 +1003,7 @@ parse_toplevel: | MODE_PLPGSQL_ASSIGN3 PLAssignStmt { PLAssignStmt *n = (PLAssignStmt *) $2; + n->nnames = 3; pg_yyget_extra(yyscanner)->parsetree = list_make1(makeRawStmt((Node *) n, 0)); @@ -1184,9 +1187,10 @@ stmt: CallStmt: CALL func_application { - CallStmt *n = makeNode(CallStmt); + CallStmt *n = makeNode(CallStmt); + n->funccall = castNode(FuncCall, $2); - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -1200,10 +1204,11 @@ CreateRoleStmt: CREATE ROLE RoleId opt_with OptRoleList { CreateRoleStmt *n = makeNode(CreateRoleStmt); + n->stmt_type = ROLESTMT_ROLE; n->role = $3; n->options = $5; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -1232,7 +1237,7 @@ AlterOptRoleElem: PASSWORD Sconst { $$ = makeDefElem("password", - (Node *)makeString($2), @1); + (Node *) makeString($2), @1); } | PASSWORD NULL_P { @@ -1246,7 +1251,7 @@ AlterOptRoleElem: * ENCRYPTED PASSWORD. */ $$ = makeDefElem("password", - (Node *)makeString($3), @1); + (Node *) makeString($3), @1); } | UNENCRYPTED PASSWORD Sconst { @@ -1258,20 +1263,20 @@ AlterOptRoleElem: } | INHERIT { - $$ = makeDefElem("inherit", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("inherit", (Node *) makeBoolean(true), @1); } | CONNECTION LIMIT SignedIconst { - $$ = makeDefElem("connectionlimit", (Node *)makeInteger($3), @1); + $$ = makeDefElem("connectionlimit", (Node *) makeInteger($3), @1); } | VALID UNTIL Sconst { - $$ = makeDefElem("validUntil", (Node *)makeString($3), @1); + $$ = makeDefElem("validUntil", (Node *) makeString($3), @1); } /* Supported but not documented for roles, for use by ALTER GROUP. */ | USER role_list { - $$ = makeDefElem("rolemembers", (Node *)$2, @1); + $$ = makeDefElem("rolemembers", (Node *) $2, @1); } | IDENT { @@ -1281,36 +1286,36 @@ AlterOptRoleElem: * size of the main parser. */ if (strcmp($1, "superuser") == 0) - $$ = makeDefElem("superuser", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("superuser", (Node *) makeBoolean(true), @1); else if (strcmp($1, "nosuperuser") == 0) - $$ = makeDefElem("superuser", (Node *)makeBoolean(false), @1); + $$ = makeDefElem("superuser", (Node *) makeBoolean(false), @1); else if (strcmp($1, "createrole") == 0) - $$ = makeDefElem("createrole", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("createrole", (Node *) makeBoolean(true), @1); else if (strcmp($1, "nocreaterole") == 0) - $$ = makeDefElem("createrole", (Node *)makeBoolean(false), @1); + $$ = makeDefElem("createrole", (Node *) makeBoolean(false), @1); else if (strcmp($1, "replication") == 0) - $$ = makeDefElem("isreplication", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("isreplication", (Node *) makeBoolean(true), @1); else if (strcmp($1, "noreplication") == 0) - $$ = makeDefElem("isreplication", (Node *)makeBoolean(false), @1); + $$ = makeDefElem("isreplication", (Node *) makeBoolean(false), @1); else if (strcmp($1, "createdb") == 0) - $$ = makeDefElem("createdb", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("createdb", (Node *) makeBoolean(true), @1); else if (strcmp($1, "nocreatedb") == 0) - $$ = makeDefElem("createdb", (Node *)makeBoolean(false), @1); + $$ = makeDefElem("createdb", (Node *) makeBoolean(false), @1); else if (strcmp($1, "login") == 0) - $$ = makeDefElem("canlogin", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("canlogin", (Node *) makeBoolean(true), @1); else if (strcmp($1, "nologin") == 0) - $$ = makeDefElem("canlogin", (Node *)makeBoolean(false), @1); + $$ = makeDefElem("canlogin", (Node *) makeBoolean(false), @1); else if (strcmp($1, "bypassrls") == 0) - $$ = makeDefElem("bypassrls", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("bypassrls", (Node *) makeBoolean(true), @1); else if (strcmp($1, "nobypassrls") == 0) - $$ = makeDefElem("bypassrls", (Node *)makeBoolean(false), @1); + $$ = makeDefElem("bypassrls", (Node *) makeBoolean(false), @1); else if (strcmp($1, "noinherit") == 0) { /* * Note that INHERIT is a keyword, so it's handled by main parser, but * NOINHERIT is handled here. */ - $$ = makeDefElem("inherit", (Node *)makeBoolean(false), @1); + $$ = makeDefElem("inherit", (Node *) makeBoolean(false), @1); } else ereport(ERROR, @@ -1325,23 +1330,23 @@ CreateOptRoleElem: /* The following are not supported by ALTER ROLE/USER/GROUP */ | SYSID Iconst { - $$ = makeDefElem("sysid", (Node *)makeInteger($2), @1); + $$ = makeDefElem("sysid", (Node *) makeInteger($2), @1); } | ADMIN role_list { - $$ = makeDefElem("adminmembers", (Node *)$2, @1); + $$ = makeDefElem("adminmembers", (Node *) $2, @1); } | ROLE role_list { - $$ = makeDefElem("rolemembers", (Node *)$2, @1); + $$ = makeDefElem("rolemembers", (Node *) $2, @1); } | IN_P ROLE role_list { - $$ = makeDefElem("addroleto", (Node *)$3, @1); + $$ = makeDefElem("addroleto", (Node *) $3, @1); } | IN_P GROUP_P role_list { - $$ = makeDefElem("addroleto", (Node *)$3, @1); + $$ = makeDefElem("addroleto", (Node *) $3, @1); } ; @@ -1356,10 +1361,11 @@ CreateUserStmt: CREATE USER RoleId opt_with OptRoleList { CreateRoleStmt *n = makeNode(CreateRoleStmt); + n->stmt_type = ROLESTMT_USER; n->role = $3; n->options = $5; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -1374,18 +1380,20 @@ AlterRoleStmt: ALTER ROLE RoleSpec opt_with AlterOptRoleList { AlterRoleStmt *n = makeNode(AlterRoleStmt); + n->role = $3; n->action = +1; /* add, if there are members */ n->options = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER USER RoleSpec opt_with AlterOptRoleList { AlterRoleStmt *n = makeNode(AlterRoleStmt); + n->role = $3; n->action = +1; /* add, if there are members */ n->options = $5; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -1398,34 +1406,38 @@ AlterRoleSetStmt: ALTER ROLE RoleSpec opt_in_database SetResetClause { AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); + n->role = $3; n->database = $4; n->setstmt = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER ROLE ALL opt_in_database SetResetClause { AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); + n->role = NULL; n->database = $4; n->setstmt = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER USER RoleSpec opt_in_database SetResetClause { AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); + n->role = $3; n->database = $4; n->setstmt = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER USER ALL opt_in_database SetResetClause { AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); + n->role = NULL; n->database = $4; n->setstmt = $5; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -1443,44 +1455,50 @@ DropRoleStmt: DROP ROLE role_list { DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = false; n->roles = $3; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP ROLE IF_P EXISTS role_list { DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = true; n->roles = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP USER role_list { DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = false; n->roles = $3; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP USER IF_P EXISTS role_list { DropRoleStmt *n = makeNode(DropRoleStmt); + n->roles = $5; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP GROUP_P role_list { DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = false; n->roles = $3; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP GROUP_P IF_P EXISTS role_list { DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = true; n->roles = $5; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -1495,10 +1513,11 @@ CreateGroupStmt: CREATE GROUP_P RoleId opt_with OptRoleList { CreateRoleStmt *n = makeNode(CreateRoleStmt); + n->stmt_type = ROLESTMT_GROUP; n->role = $3; n->options = $5; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -1513,11 +1532,12 @@ AlterGroupStmt: ALTER GROUP_P RoleSpec add_drop USER role_list { AlterRoleStmt *n = makeNode(AlterRoleStmt); + n->role = $3; n->action = $4; n->options = list_make1(makeDefElem("rolemembers", - (Node *)$6, @6)); - $$ = (Node *)n; + (Node *) $6, @6)); + $$ = (Node *) n; } ; @@ -1536,26 +1556,29 @@ CreateSchemaStmt: CREATE SCHEMA OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList { CreateSchemaStmt *n = makeNode(CreateSchemaStmt); + /* One can omit the schema name or the authorization id. */ n->schemaname = $3; n->authrole = $5; n->schemaElts = $6; n->if_not_exists = false; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE SCHEMA ColId OptSchemaEltList { CreateSchemaStmt *n = makeNode(CreateSchemaStmt); + /* ...but not both */ n->schemaname = $3; n->authrole = NULL; n->schemaElts = $4; n->if_not_exists = false; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE SCHEMA IF_P NOT EXISTS OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList { CreateSchemaStmt *n = makeNode(CreateSchemaStmt); + /* schema name can be omitted here, too */ n->schemaname = $6; n->authrole = $8; @@ -1566,11 +1589,12 @@ CreateSchemaStmt: parser_errposition(@9))); n->schemaElts = $9; n->if_not_exists = true; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE SCHEMA IF_P NOT EXISTS ColId OptSchemaEltList { CreateSchemaStmt *n = makeNode(CreateSchemaStmt); + /* ...but not here */ n->schemaname = $6; n->authrole = NULL; @@ -1581,7 +1605,7 @@ CreateSchemaStmt: parser_errposition(@7))); n->schemaElts = $7; n->if_not_exists = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -1628,18 +1652,21 @@ VariableSetStmt: SET set_rest { VariableSetStmt *n = $2; + n->is_local = false; $$ = (Node *) n; } | SET LOCAL set_rest { VariableSetStmt *n = $3; + n->is_local = true; $$ = (Node *) n; } | SET SESSION set_rest { VariableSetStmt *n = $3; + n->is_local = false; $$ = (Node *) n; } @@ -1649,6 +1676,7 @@ set_rest: TRANSACTION transaction_mode_list { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_MULTI; n->name = "TRANSACTION"; n->args = $2; @@ -1657,6 +1685,7 @@ set_rest: | SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_MULTI; n->name = "SESSION CHARACTERISTICS"; n->args = $5; @@ -1669,6 +1698,7 @@ generic_set: var_name TO var_list { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; n->name = $1; n->args = $3; @@ -1677,6 +1707,7 @@ generic_set: | var_name '=' var_list { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; n->name = $1; n->args = $3; @@ -1685,6 +1716,7 @@ generic_set: | var_name TO DEFAULT { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_DEFAULT; n->name = $1; $$ = n; @@ -1692,6 +1724,7 @@ generic_set: | var_name '=' DEFAULT { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_DEFAULT; n->name = $1; $$ = n; @@ -1703,6 +1736,7 @@ set_rest_more: /* Generic SET syntaxes: */ | var_name FROM CURRENT_P { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_CURRENT; n->name = $1; $$ = n; @@ -1711,6 +1745,7 @@ set_rest_more: /* Generic SET syntaxes: */ | TIME ZONE zone_value { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; n->name = "timezone"; if ($3 != NULL) @@ -1730,6 +1765,7 @@ set_rest_more: /* Generic SET syntaxes: */ | SCHEMA Sconst { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; n->name = "search_path"; n->args = list_make1(makeStringConst($2, @2)); @@ -1738,6 +1774,7 @@ set_rest_more: /* Generic SET syntaxes: */ | NAMES opt_encoding { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; n->name = "client_encoding"; if ($2 != NULL) @@ -1749,6 +1786,7 @@ set_rest_more: /* Generic SET syntaxes: */ | ROLE NonReservedWord_or_Sconst { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; n->name = "role"; n->args = list_make1(makeStringConst($2, @2)); @@ -1757,6 +1795,7 @@ set_rest_more: /* Generic SET syntaxes: */ | SESSION AUTHORIZATION NonReservedWord_or_Sconst { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; n->name = "session_authorization"; n->args = list_make1(makeStringConst($3, @3)); @@ -1765,6 +1804,7 @@ set_rest_more: /* Generic SET syntaxes: */ | SESSION AUTHORIZATION DEFAULT { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_DEFAULT; n->name = "session_authorization"; $$ = n; @@ -1772,6 +1812,7 @@ set_rest_more: /* Generic SET syntaxes: */ | XML_P OPTION document_or_content { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; n->name = "xmloption"; n->args = list_make1(makeStringConst($3 == XMLOPTION_DOCUMENT ? "DOCUMENT" : "CONTENT", @3)); @@ -1781,6 +1822,7 @@ set_rest_more: /* Generic SET syntaxes: */ | TRANSACTION SNAPSHOT Sconst { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_MULTI; n->name = "TRANSACTION SNAPSHOT"; n->args = list_make1(makeStringConst($3, @3)); @@ -1840,10 +1882,12 @@ zone_value: } | ConstInterval Sconst opt_interval { - TypeName *t = $1; + TypeName *t = $1; + if ($3 != NIL) { - A_Const *n = (A_Const *) linitial($3); + A_Const *n = (A_Const *) linitial($3); + if ((n->val.ival.ival & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -1855,7 +1899,8 @@ zone_value: } | ConstInterval '(' Iconst ')' Sconst { - TypeName *t = $1; + TypeName *t = $1; + t->typmods = list_make2(makeIntConst(INTERVAL_FULL_RANGE, -1), makeIntConst($3, @3)); $$ = makeStringConstCast($5, @5, t); @@ -1885,6 +1930,7 @@ reset_rest: | TIME ZONE { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET; n->name = "timezone"; $$ = n; @@ -1892,6 +1938,7 @@ reset_rest: | TRANSACTION ISOLATION LEVEL { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET; n->name = "transaction_isolation"; $$ = n; @@ -1899,6 +1946,7 @@ reset_rest: | SESSION AUTHORIZATION { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET; n->name = "session_authorization"; $$ = n; @@ -1909,6 +1957,7 @@ generic_reset: var_name { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET; n->name = $1; $$ = n; @@ -1916,6 +1965,7 @@ generic_reset: | ALL { VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET_ALL; $$ = n; } @@ -1938,30 +1988,35 @@ VariableShowStmt: SHOW var_name { VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = $2; $$ = (Node *) n; } | SHOW TIME ZONE { VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "timezone"; $$ = (Node *) n; } | SHOW TRANSACTION ISOLATION LEVEL { VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "transaction_isolation"; $$ = (Node *) n; } | SHOW SESSION AUTHORIZATION { VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "session_authorization"; $$ = (Node *) n; } | SHOW ALL { VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "all"; $$ = (Node *) n; } @@ -1972,6 +2027,7 @@ ConstraintsSetStmt: SET CONSTRAINTS constraints_set_list constraints_set_mode { ConstraintsSetStmt *n = makeNode(ConstraintsSetStmt); + n->constraints = $3; n->deferred = $4; $$ = (Node *) n; @@ -1996,7 +2052,8 @@ CheckPointStmt: CHECKPOINT { CheckPointStmt *n = makeNode(CheckPointStmt); - $$ = (Node *)n; + + $$ = (Node *) n; } ; @@ -2011,30 +2068,35 @@ DiscardStmt: DISCARD ALL { DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_ALL; $$ = (Node *) n; } | DISCARD TEMP { DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_TEMP; $$ = (Node *) n; } | DISCARD TEMPORARY { DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_TEMP; $$ = (Node *) n; } | DISCARD PLANS { DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_PLANS; $$ = (Node *) n; } | DISCARD SEQUENCES { DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_SEQUENCES; $$ = (Node *) n; } @@ -2054,203 +2116,224 @@ AlterTableStmt: ALTER TABLE relation_expr alter_table_cmds { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $3; n->cmds = $4; n->objtype = OBJECT_TABLE; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE IF_P EXISTS relation_expr alter_table_cmds { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $5; n->cmds = $6; n->objtype = OBJECT_TABLE; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE relation_expr partition_cmd { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $3; n->cmds = list_make1($4); n->objtype = OBJECT_TABLE; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE IF_P EXISTS relation_expr partition_cmd { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $5; n->cmds = list_make1($6); n->objtype = OBJECT_TABLE; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait { AlterTableMoveAllStmt *n = makeNode(AlterTableMoveAllStmt); + n->orig_tablespacename = $6; n->objtype = OBJECT_TABLE; n->roles = NIL; n->new_tablespacename = $9; n->nowait = $10; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait { AlterTableMoveAllStmt *n = makeNode(AlterTableMoveAllStmt); + n->orig_tablespacename = $6; n->objtype = OBJECT_TABLE; n->roles = $9; n->new_tablespacename = $12; n->nowait = $13; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER INDEX qualified_name alter_table_cmds { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $3; n->cmds = $4; n->objtype = OBJECT_INDEX; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER INDEX IF_P EXISTS qualified_name alter_table_cmds { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $5; n->cmds = $6; n->objtype = OBJECT_INDEX; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER INDEX qualified_name index_partition_cmd { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $3; n->cmds = list_make1($4); n->objtype = OBJECT_INDEX; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER INDEX ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait { AlterTableMoveAllStmt *n = makeNode(AlterTableMoveAllStmt); + n->orig_tablespacename = $6; n->objtype = OBJECT_INDEX; n->roles = NIL; n->new_tablespacename = $9; n->nowait = $10; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER INDEX ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait { AlterTableMoveAllStmt *n = makeNode(AlterTableMoveAllStmt); + n->orig_tablespacename = $6; n->objtype = OBJECT_INDEX; n->roles = $9; n->new_tablespacename = $12; n->nowait = $13; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SEQUENCE qualified_name alter_table_cmds { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $3; n->cmds = $4; n->objtype = OBJECT_SEQUENCE; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SEQUENCE IF_P EXISTS qualified_name alter_table_cmds { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $5; n->cmds = $6; n->objtype = OBJECT_SEQUENCE; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER VIEW qualified_name alter_table_cmds { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $3; n->cmds = $4; n->objtype = OBJECT_VIEW; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER VIEW IF_P EXISTS qualified_name alter_table_cmds { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $5; n->cmds = $6; n->objtype = OBJECT_VIEW; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER MATERIALIZED VIEW qualified_name alter_table_cmds { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $4; n->cmds = $5; n->objtype = OBJECT_MATVIEW; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name alter_table_cmds { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $6; n->cmds = $7; n->objtype = OBJECT_MATVIEW; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait { AlterTableMoveAllStmt *n = makeNode(AlterTableMoveAllStmt); + n->orig_tablespacename = $7; n->objtype = OBJECT_MATVIEW; n->roles = NIL; n->new_tablespacename = $10; n->nowait = $11; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait { AlterTableMoveAllStmt *n = makeNode(AlterTableMoveAllStmt); + n->orig_tablespacename = $7; n->objtype = OBJECT_MATVIEW; n->roles = $10; n->new_tablespacename = $13; n->nowait = $14; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FOREIGN TABLE relation_expr alter_table_cmds { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $4; n->cmds = $5; n->objtype = OBJECT_FOREIGN_TABLE; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FOREIGN TABLE IF_P EXISTS relation_expr alter_table_cmds { AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $6; n->cmds = $7; n->objtype = OBJECT_FOREIGN_TABLE; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -2324,88 +2407,98 @@ alter_table_cmd: ADD_P columnDef { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddColumn; n->def = $2; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ADD IF NOT EXISTS */ | ADD_P IF_P NOT EXISTS columnDef { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddColumn; n->def = $5; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ADD COLUMN */ | ADD_P COLUMN columnDef { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddColumn; n->def = $3; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ADD COLUMN IF NOT EXISTS */ | ADD_P COLUMN IF_P NOT EXISTS columnDef { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddColumn; n->def = $6; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] {SET DEFAULT |DROP DEFAULT} */ | ALTER opt_column ColId alter_column_default { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ColumnDefault; n->name = $3; n->def = $4; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] DROP NOT NULL */ | ALTER opt_column ColId DROP NOT NULL_P { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropNotNull; n->name = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] SET NOT NULL */ | ALTER opt_column ColId SET NOT NULL_P { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetNotNull; n->name = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] DROP EXPRESSION */ | ALTER opt_column ColId DROP EXPRESSION { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropExpression; n->name = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] DROP EXPRESSION IF EXISTS */ | ALTER opt_column ColId DROP EXPRESSION IF_P EXISTS { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropExpression; n->name = $3; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] SET STATISTICS */ | ALTER opt_column ColId SET STATISTICS SignedIconst { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetStatistics; n->name = $3; n->def = (Node *) makeInteger($6); - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] SET STATISTICS */ | ALTER opt_column Iconst SET STATISTICS SignedIconst @@ -2421,43 +2514,47 @@ alter_table_cmd: n->subtype = AT_SetStatistics; n->num = (int16) $3; n->def = (Node *) makeInteger($6); - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] SET ( column_parameter = value [, ... ] ) */ | ALTER opt_column ColId SET reloptions { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetOptions; n->name = $3; n->def = (Node *) $5; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] RESET ( column_parameter [, ... ] ) */ | ALTER opt_column ColId RESET reloptions { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ResetOptions; n->name = $3; n->def = (Node *) $5; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] SET STORAGE */ | ALTER opt_column ColId SET STORAGE ColId { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetStorage; n->name = $3; n->def = (Node *) makeString($6); - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] SET COMPRESSION */ | ALTER opt_column ColId SET column_compression { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetCompression; n->name = $3; n->def = (Node *) makeString($5); - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] ADD GENERATED ... AS IDENTITY ... */ | ALTER opt_column ColId ADD_P GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList @@ -2474,54 +2571,59 @@ alter_table_cmd: n->name = $3; n->def = (Node *) c; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] SET /RESET */ | ALTER opt_column ColId alter_identity_column_option_list { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetIdentity; n->name = $3; n->def = (Node *) $4; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] DROP IDENTITY */ | ALTER opt_column ColId DROP IDENTITY_P { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropIdentity; n->name = $3; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER [COLUMN] DROP IDENTITY IF EXISTS */ | ALTER opt_column ColId DROP IDENTITY_P IF_P EXISTS { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropIdentity; n->name = $3; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE DROP [COLUMN] IF EXISTS [RESTRICT|CASCADE] */ | DROP opt_column IF_P EXISTS ColId opt_drop_behavior { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropColumn; n->name = $5; n->behavior = $6; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE DROP [COLUMN] [RESTRICT|CASCADE] */ | DROP opt_column ColId opt_drop_behavior { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropColumn; n->name = $3; n->behavior = $4; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } /* * ALTER TABLE ALTER [COLUMN] [SET DATA] TYPE @@ -2531,6 +2633,7 @@ alter_table_cmd: { AlterTableCmd *n = makeNode(AlterTableCmd); ColumnDef *def = makeNode(ColumnDef); + n->subtype = AT_AlterColumnType; n->name = $3; n->def = (Node *) def; @@ -2539,30 +2642,33 @@ alter_table_cmd: def->collClause = (CollateClause *) $7; def->raw_default = $8; def->location = @3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER FOREIGN TABLE ALTER [COLUMN] OPTIONS */ | ALTER opt_column ColId alter_generic_options { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AlterColumnGenericOptions; n->name = $3; n->def = (Node *) $4; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ADD CONSTRAINT ... */ | ADD_P TableConstraint { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddConstraint; n->def = $2; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ALTER CONSTRAINT ... */ | ALTER CONSTRAINT name ConstraintAttributeSpec { AlterTableCmd *n = makeNode(AlterTableCmd); Constraint *c = makeNode(Constraint); + n->subtype = AT_AlterConstraint; n->def = (Node *) c; c->contype = CONSTR_FOREIGN; /* others not supported, yet */ @@ -2571,279 +2677,314 @@ alter_table_cmd: &c->deferrable, &c->initdeferred, NULL, NULL, yyscanner); - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE VALIDATE CONSTRAINT ... */ | VALIDATE CONSTRAINT name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ValidateConstraint; n->name = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE DROP CONSTRAINT IF EXISTS [RESTRICT|CASCADE] */ | DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropConstraint; n->name = $5; n->behavior = $6; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE DROP CONSTRAINT [RESTRICT|CASCADE] */ | DROP CONSTRAINT name opt_drop_behavior { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropConstraint; n->name = $3; n->behavior = $4; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE SET WITHOUT OIDS, for backward compat */ | SET WITHOUT OIDS { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropOids; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE CLUSTER ON */ | CLUSTER ON name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ClusterOn; n->name = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE SET WITHOUT CLUSTER */ | SET WITHOUT CLUSTER { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropCluster; n->name = NULL; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE SET LOGGED */ | SET LOGGED { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetLogged; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE SET UNLOGGED */ | SET UNLOGGED { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetUnLogged; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ENABLE TRIGGER */ | ENABLE_P TRIGGER name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableTrig; n->name = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ENABLE ALWAYS TRIGGER */ | ENABLE_P ALWAYS TRIGGER name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableAlwaysTrig; n->name = $4; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ENABLE REPLICA TRIGGER */ | ENABLE_P REPLICA TRIGGER name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableReplicaTrig; n->name = $4; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ENABLE TRIGGER ALL */ | ENABLE_P TRIGGER ALL { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableTrigAll; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ENABLE TRIGGER USER */ | ENABLE_P TRIGGER USER { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableTrigUser; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE DISABLE TRIGGER */ | DISABLE_P TRIGGER name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableTrig; n->name = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE DISABLE TRIGGER ALL */ | DISABLE_P TRIGGER ALL { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableTrigAll; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE DISABLE TRIGGER USER */ | DISABLE_P TRIGGER USER { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableTrigUser; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ENABLE RULE */ | ENABLE_P RULE name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableRule; n->name = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ENABLE ALWAYS RULE */ | ENABLE_P ALWAYS RULE name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableAlwaysRule; n->name = $4; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ENABLE REPLICA RULE */ | ENABLE_P REPLICA RULE name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableReplicaRule; n->name = $4; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE DISABLE RULE */ | DISABLE_P RULE name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableRule; n->name = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE INHERIT */ | INHERIT qualified_name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddInherit; n->def = (Node *) $2; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE NO INHERIT */ | NO INHERIT qualified_name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropInherit; n->def = (Node *) $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE OF */ | OF any_name { AlterTableCmd *n = makeNode(AlterTableCmd); - TypeName *def = makeTypeNameFromNameList($2); + TypeName *def = makeTypeNameFromNameList($2); + def->location = @2; n->subtype = AT_AddOf; n->def = (Node *) def; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE NOT OF */ | NOT OF { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropOf; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE OWNER TO RoleSpec */ | OWNER TO RoleSpec { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ChangeOwner; n->newowner = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE SET ACCESS METHOD */ | SET ACCESS METHOD name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetAccessMethod; n->name = $4; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE SET TABLESPACE */ | SET TABLESPACE name { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetTableSpace; n->name = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE SET (...) */ | SET reloptions { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetRelOptions; - n->def = (Node *)$2; - $$ = (Node *)n; + n->def = (Node *) $2; + $$ = (Node *) n; } /* ALTER TABLE RESET (...) */ | RESET reloptions { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ResetRelOptions; - n->def = (Node *)$2; - $$ = (Node *)n; + n->def = (Node *) $2; + $$ = (Node *) n; } /* ALTER TABLE REPLICA IDENTITY */ | REPLICA IDENTITY_P replica_identity { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ReplicaIdentity; n->def = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE ENABLE ROW LEVEL SECURITY */ | ENABLE_P ROW LEVEL SECURITY { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableRowSecurity; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE DISABLE ROW LEVEL SECURITY */ | DISABLE_P ROW LEVEL SECURITY { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableRowSecurity; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE FORCE ROW LEVEL SECURITY */ | FORCE ROW LEVEL SECURITY { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ForceRowSecurity; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TABLE NO FORCE ROW LEVEL SECURITY */ | NO FORCE ROW LEVEL SECURITY { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_NoForceRowSecurity; - $$ = (Node *)n; + $$ = (Node *) n; } | alter_generic_options { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_GenericOptions; - n->def = (Node *)$1; + n->def = (Node *) $1; $$ = (Node *) n; } ; @@ -2863,6 +3004,7 @@ opt_collate_clause: COLLATE any_name { CollateClause *n = makeNode(CollateClause); + n->arg = NULL; n->collname = $2; n->location = @1; @@ -2880,6 +3022,7 @@ replica_identity: NOTHING { ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt); + n->identity_type = REPLICA_IDENTITY_NOTHING; n->name = NULL; $$ = (Node *) n; @@ -2887,6 +3030,7 @@ replica_identity: | FULL { ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt); + n->identity_type = REPLICA_IDENTITY_FULL; n->name = NULL; $$ = (Node *) n; @@ -2894,6 +3038,7 @@ replica_identity: | DEFAULT { ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt); + n->identity_type = REPLICA_IDENTITY_DEFAULT; n->name = NULL; $$ = (Node *) n; @@ -2901,6 +3046,7 @@ replica_identity: | USING INDEX name { ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt); + n->identity_type = REPLICA_IDENTITY_INDEX; n->name = $3; $$ = (Node *) n; @@ -2955,7 +3101,7 @@ alter_identity_column_option: } | RESTART opt_with NumericOnly { - $$ = makeDefElem("restart", (Node *)$3, @1); + $$ = makeDefElem("restart", (Node *) $3, @1); } | SET SeqOptElem { @@ -3070,7 +3216,7 @@ PartitionBoundSpec: hash_partbound_elem: NonReservedWord Iconst { - $$ = makeDefElem($1, (Node *)makeInteger($2), @1); + $$ = makeDefElem($1, (Node *) makeInteger($2), @1); } ; @@ -3101,7 +3247,7 @@ AlterCompositeTypeStmt: n->relation = makeRangeVarFromAnyName($3, @3, yyscanner); n->cmds = $4; n->objtype = OBJECT_TYPE; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -3115,36 +3261,40 @@ alter_type_cmd: ADD_P ATTRIBUTE TableFuncElement opt_drop_behavior { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddColumn; n->def = $3; n->behavior = $4; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TYPE DROP ATTRIBUTE IF EXISTS [RESTRICT|CASCADE] */ | DROP ATTRIBUTE IF_P EXISTS ColId opt_drop_behavior { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropColumn; n->name = $5; n->behavior = $6; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TYPE DROP ATTRIBUTE [RESTRICT|CASCADE] */ | DROP ATTRIBUTE ColId opt_drop_behavior { AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropColumn; n->name = $3; n->behavior = $4; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER TYPE ALTER ATTRIBUTE [SET DATA] TYPE [RESTRICT|CASCADE] */ | ALTER ATTRIBUTE ColId opt_set_data TYPE_P Typename opt_collate_clause opt_drop_behavior { AlterTableCmd *n = makeNode(AlterTableCmd); ColumnDef *def = makeNode(ColumnDef); + n->subtype = AT_AlterColumnType; n->name = $3; n->def = (Node *) def; @@ -3154,7 +3304,7 @@ alter_type_cmd: def->collClause = (CollateClause *) $7; def->raw_default = NULL; def->location = @3; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -3170,14 +3320,16 @@ ClosePortalStmt: CLOSE cursor_name { ClosePortalStmt *n = makeNode(ClosePortalStmt); + n->portalname = $2; - $$ = (Node *)n; + $$ = (Node *) n; } | CLOSE ALL { ClosePortalStmt *n = makeNode(ClosePortalStmt); + n->portalname = NULL; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -3211,6 +3363,7 @@ CopyStmt: COPY opt_binary qualified_name opt_column_list copy_options where_clause { CopyStmt *n = makeNode(CopyStmt); + n->relation = $3; n->query = NULL; n->attlist = $4; @@ -3239,11 +3392,12 @@ CopyStmt: COPY opt_binary qualified_name opt_column_list n->options = lappend(n->options, $8); if ($10) n->options = list_concat(n->options, $10); - $$ = (Node *)n; + $$ = (Node *) n; } | COPY '(' PreparableStmt ')' TO opt_program copy_file_name opt_with copy_options { CopyStmt *n = makeNode(CopyStmt); + n->relation = NULL; n->query = $3; n->attlist = NIL; @@ -3258,7 +3412,7 @@ CopyStmt: COPY opt_binary qualified_name opt_column_list errmsg("STDIN/STDOUT not allowed with PROGRAM"), parser_errposition(@5))); - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -3296,55 +3450,55 @@ copy_opt_list: copy_opt_item: BINARY { - $$ = makeDefElem("format", (Node *)makeString("binary"), @1); + $$ = makeDefElem("format", (Node *) makeString("binary"), @1); } | FREEZE { - $$ = makeDefElem("freeze", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("freeze", (Node *) makeBoolean(true), @1); } | DELIMITER opt_as Sconst { - $$ = makeDefElem("delimiter", (Node *)makeString($3), @1); + $$ = makeDefElem("delimiter", (Node *) makeString($3), @1); } | NULL_P opt_as Sconst { - $$ = makeDefElem("null", (Node *)makeString($3), @1); + $$ = makeDefElem("null", (Node *) makeString($3), @1); } | CSV { - $$ = makeDefElem("format", (Node *)makeString("csv"), @1); + $$ = makeDefElem("format", (Node *) makeString("csv"), @1); } | HEADER_P { - $$ = makeDefElem("header", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("header", (Node *) makeBoolean(true), @1); } | QUOTE opt_as Sconst { - $$ = makeDefElem("quote", (Node *)makeString($3), @1); + $$ = makeDefElem("quote", (Node *) makeString($3), @1); } | ESCAPE opt_as Sconst { - $$ = makeDefElem("escape", (Node *)makeString($3), @1); + $$ = makeDefElem("escape", (Node *) makeString($3), @1); } | FORCE QUOTE columnList { - $$ = makeDefElem("force_quote", (Node *)$3, @1); + $$ = makeDefElem("force_quote", (Node *) $3, @1); } | FORCE QUOTE '*' { - $$ = makeDefElem("force_quote", (Node *)makeNode(A_Star), @1); + $$ = makeDefElem("force_quote", (Node *) makeNode(A_Star), @1); } | FORCE NOT NULL_P columnList { - $$ = makeDefElem("force_not_null", (Node *)$4, @1); + $$ = makeDefElem("force_not_null", (Node *) $4, @1); } | FORCE NULL_P columnList { - $$ = makeDefElem("force_null", (Node *)$3, @1); + $$ = makeDefElem("force_null", (Node *) $3, @1); } | ENCODING Sconst { - $$ = makeDefElem("encoding", (Node *)makeString($2), @1); + $$ = makeDefElem("encoding", (Node *) makeString($2), @1); } ; @@ -3353,7 +3507,7 @@ copy_opt_item: opt_binary: BINARY { - $$ = makeDefElem("format", (Node *)makeString("binary"), @1); + $$ = makeDefElem("format", (Node *) makeString("binary"), @1); } | /*EMPTY*/ { $$ = NULL; } ; @@ -3361,7 +3515,7 @@ opt_binary: copy_delimiter: opt_using DELIMITERS Sconst { - $$ = makeDefElem("delimiter", (Node *)makeString($3), @2); + $$ = makeDefElem("delimiter", (Node *) makeString($3), @2); } | /*EMPTY*/ { $$ = NULL; } ; @@ -3427,6 +3581,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' OnCommitOption OptTableSpace { CreateStmt *n = makeNode(CreateStmt); + $4->relpersistence = $2; n->relation = $4; n->tableElts = $6; @@ -3439,13 +3594,14 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' n->oncommit = $12; n->tablespacename = $13; n->if_not_exists = false; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name '(' OptTableElementList ')' OptInherit OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace { CreateStmt *n = makeNode(CreateStmt); + $7->relpersistence = $2; n->relation = $7; n->tableElts = $9; @@ -3458,13 +3614,14 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' n->oncommit = $15; n->tablespacename = $16; n->if_not_exists = true; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE OptTemp TABLE qualified_name OF any_name OptTypedTableElementList OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace { CreateStmt *n = makeNode(CreateStmt); + $4->relpersistence = $2; n->relation = $4; n->tableElts = $7; @@ -3478,13 +3635,14 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' n->oncommit = $11; n->tablespacename = $12; n->if_not_exists = false; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name OF any_name OptTypedTableElementList OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace { CreateStmt *n = makeNode(CreateStmt); + $7->relpersistence = $2; n->relation = $7; n->tableElts = $10; @@ -3498,13 +3656,14 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' n->oncommit = $14; n->tablespacename = $15; n->if_not_exists = true; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE OptTemp TABLE qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace { CreateStmt *n = makeNode(CreateStmt); + $4->relpersistence = $2; n->relation = $4; n->tableElts = $8; @@ -3518,13 +3677,14 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' n->oncommit = $13; n->tablespacename = $14; n->if_not_exists = false; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace { CreateStmt *n = makeNode(CreateStmt); + $7->relpersistence = $2; n->relation = $7; n->tableElts = $11; @@ -3538,7 +3698,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' n->oncommit = $16; n->tablespacename = $17; n->if_not_exists = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -3621,6 +3781,7 @@ TypedTableElement: columnDef: ColId Typename opt_column_compression create_generic_options ColQualList { ColumnDef *n = makeNode(ColumnDef); + n->colname = $1; n->typeName = $2; n->compression = $3; @@ -3636,13 +3797,14 @@ columnDef: ColId Typename opt_column_compression create_generic_options ColQualL SplitColQualList($5, &n->constraints, &n->collClause, yyscanner); n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } ; columnOptions: ColId ColQualList { ColumnDef *n = makeNode(ColumnDef); + n->colname = $1; n->typeName = NULL; n->inhcount = 0; @@ -3656,11 +3818,12 @@ columnOptions: ColId ColQualList SplitColQualList($2, &n->constraints, &n->collClause, yyscanner); n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | ColId WITH OPTIONS ColQualList { ColumnDef *n = makeNode(ColumnDef); + n->colname = $1; n->typeName = NULL; n->inhcount = 0; @@ -3674,7 +3837,7 @@ columnOptions: ColId ColQualList SplitColQualList($4, &n->constraints, &n->collClause, yyscanner); n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -3697,6 +3860,7 @@ ColConstraint: CONSTRAINT name ColConstraintElem { Constraint *n = castNode(Constraint, $3); + n->conname = $2; n->location = @1; $$ = (Node *) n; @@ -3711,6 +3875,7 @@ ColConstraint: * again in SplitColQualList. */ CollateClause *n = makeNode(CollateClause); + n->arg = NULL; n->collname = $2; n->location = @1; @@ -3737,20 +3902,23 @@ ColConstraintElem: NOT NULL_P { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_NOTNULL; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | NULL_P { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_NULL; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | UNIQUE opt_unique_null_treatment opt_definition OptConsTableSpace { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_UNIQUE; n->location = @1; n->nulls_not_distinct = !$2; @@ -3758,22 +3926,24 @@ ColConstraintElem: n->options = $3; n->indexname = NULL; n->indexspace = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | PRIMARY KEY opt_definition OptConsTableSpace { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_PRIMARY; n->location = @1; n->keys = NULL; n->options = $3; n->indexname = NULL; n->indexspace = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | CHECK '(' a_expr ')' opt_no_inherit { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_CHECK; n->location = @1; n->is_no_inherit = $5; @@ -3781,29 +3951,32 @@ ColConstraintElem: n->cooked_expr = NULL; n->skip_validation = false; n->initially_valid = true; - $$ = (Node *)n; + $$ = (Node *) n; } | DEFAULT b_expr { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_DEFAULT; n->location = @1; n->raw_expr = $2; n->cooked_expr = NULL; - $$ = (Node *)n; + $$ = (Node *) n; } | GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_IDENTITY; n->generated_when = $2; n->options = $5; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | GENERATED generated_when AS '(' a_expr ')' STORED { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_GENERATED; n->generated_when = $2; n->raw_expr = $5; @@ -3822,11 +3995,12 @@ ColConstraintElem: errmsg("for a generated column, GENERATED ALWAYS must be specified"), parser_errposition(@2))); - $$ = (Node *)n; + $$ = (Node *) n; } | REFERENCES qualified_name opt_column_list key_match key_actions { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_FOREIGN; n->location = @1; n->pktable = $2; @@ -3838,7 +4012,7 @@ ColConstraintElem: n->fk_del_set_cols = ($5)->deleteAction->cols; n->skip_validation = false; n->initially_valid = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -3872,30 +4046,34 @@ ConstraintAttr: DEFERRABLE { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_ATTR_DEFERRABLE; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | NOT DEFERRABLE { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_ATTR_NOT_DEFERRABLE; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | INITIALLY DEFERRED { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_ATTR_DEFERRED; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | INITIALLY IMMEDIATE { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_ATTR_IMMEDIATE; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -3904,10 +4082,11 @@ TableLikeClause: LIKE qualified_name TableLikeOptionList { TableLikeClause *n = makeNode(TableLikeClause); + n->relation = $2; n->options = $3; n->relationOid = InvalidOid; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -3939,6 +4118,7 @@ TableConstraint: CONSTRAINT name ConstraintElem { Constraint *n = castNode(Constraint, $3); + n->conname = $2; n->location = @1; $$ = (Node *) n; @@ -3950,6 +4130,7 @@ ConstraintElem: CHECK '(' a_expr ')' ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_CHECK; n->location = @1; n->raw_expr = $3; @@ -3958,12 +4139,13 @@ ConstraintElem: NULL, NULL, &n->skip_validation, &n->is_no_inherit, yyscanner); n->initially_valid = !n->skip_validation; - $$ = (Node *)n; + $$ = (Node *) n; } | UNIQUE opt_unique_null_treatment '(' columnList ')' opt_c_include opt_definition OptConsTableSpace ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_UNIQUE; n->location = @1; n->nulls_not_distinct = !$2; @@ -3975,11 +4157,12 @@ ConstraintElem: processCASbits($9, @9, "UNIQUE", &n->deferrable, &n->initdeferred, NULL, NULL, yyscanner); - $$ = (Node *)n; + $$ = (Node *) n; } | UNIQUE ExistingIndex ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_UNIQUE; n->location = @1; n->keys = NIL; @@ -3990,12 +4173,13 @@ ConstraintElem: processCASbits($3, @3, "UNIQUE", &n->deferrable, &n->initdeferred, NULL, NULL, yyscanner); - $$ = (Node *)n; + $$ = (Node *) n; } | PRIMARY KEY '(' columnList ')' opt_c_include opt_definition OptConsTableSpace ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_PRIMARY; n->location = @1; n->keys = $4; @@ -4006,11 +4190,12 @@ ConstraintElem: processCASbits($9, @9, "PRIMARY KEY", &n->deferrable, &n->initdeferred, NULL, NULL, yyscanner); - $$ = (Node *)n; + $$ = (Node *) n; } | PRIMARY KEY ExistingIndex ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_PRIMARY; n->location = @1; n->keys = NIL; @@ -4021,13 +4206,14 @@ ConstraintElem: processCASbits($4, @4, "PRIMARY KEY", &n->deferrable, &n->initdeferred, NULL, NULL, yyscanner); - $$ = (Node *)n; + $$ = (Node *) n; } | EXCLUDE access_method_clause '(' ExclusionConstraintList ')' opt_c_include opt_definition OptConsTableSpace OptWhereClause ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_EXCLUSION; n->location = @1; n->access_method = $2; @@ -4040,12 +4226,13 @@ ConstraintElem: processCASbits($10, @10, "EXCLUDE", &n->deferrable, &n->initdeferred, NULL, NULL, yyscanner); - $$ = (Node *)n; + $$ = (Node *) n; } | FOREIGN KEY '(' columnList ')' REFERENCES qualified_name opt_column_list key_match key_actions ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); + n->contype = CONSTR_FOREIGN; n->location = @1; n->pktable = $7; @@ -4060,7 +4247,7 @@ ConstraintElem: &n->skip_validation, NULL, yyscanner); n->initially_valid = !n->skip_validation; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -4136,6 +4323,7 @@ key_actions: key_update { KeyActions *n = palloc(sizeof(KeyActions)); + n->updateAction = $1; n->deleteAction = palloc(sizeof(KeyAction)); n->deleteAction->action = FKCONSTR_ACTION_NOACTION; @@ -4145,6 +4333,7 @@ key_actions: | key_delete { KeyActions *n = palloc(sizeof(KeyActions)); + n->updateAction = palloc(sizeof(KeyAction)); n->updateAction->action = FKCONSTR_ACTION_NOACTION; n->updateAction->cols = NIL; @@ -4154,6 +4343,7 @@ key_actions: | key_update key_delete { KeyActions *n = palloc(sizeof(KeyActions)); + n->updateAction = $1; n->deleteAction = $2; $$ = n; @@ -4161,6 +4351,7 @@ key_actions: | key_delete key_update { KeyActions *n = palloc(sizeof(KeyActions)); + n->updateAction = $2; n->deleteAction = $1; $$ = n; @@ -4168,6 +4359,7 @@ key_actions: | /*EMPTY*/ { KeyActions *n = palloc(sizeof(KeyActions)); + n->updateAction = palloc(sizeof(KeyAction)); n->updateAction->action = FKCONSTR_ACTION_NOACTION; n->updateAction->cols = NIL; @@ -4200,6 +4392,7 @@ key_action: NO ACTION { KeyAction *n = palloc(sizeof(KeyAction)); + n->action = FKCONSTR_ACTION_NOACTION; n->cols = NIL; $$ = n; @@ -4207,6 +4400,7 @@ key_action: | RESTRICT { KeyAction *n = palloc(sizeof(KeyAction)); + n->action = FKCONSTR_ACTION_RESTRICT; n->cols = NIL; $$ = n; @@ -4214,6 +4408,7 @@ key_action: | CASCADE { KeyAction *n = palloc(sizeof(KeyAction)); + n->action = FKCONSTR_ACTION_CASCADE; n->cols = NIL; $$ = n; @@ -4221,6 +4416,7 @@ key_action: | SET NULL_P opt_column_list { KeyAction *n = palloc(sizeof(KeyAction)); + n->action = FKCONSTR_ACTION_SETNULL; n->cols = $3; $$ = n; @@ -4228,6 +4424,7 @@ key_action: | SET DEFAULT opt_column_list { KeyAction *n = palloc(sizeof(KeyAction)); + n->action = FKCONSTR_ACTION_SETDEFAULT; n->cols = $3; $$ = n; @@ -4342,25 +4539,27 @@ CreateStatsStmt: opt_name_list ON stats_params FROM from_list { CreateStatsStmt *n = makeNode(CreateStatsStmt); + n->defnames = $3; n->stat_types = $4; n->exprs = $6; n->relations = $8; n->stxcomment = NULL; n->if_not_exists = false; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE STATISTICS IF_P NOT EXISTS any_name opt_name_list ON stats_params FROM from_list { CreateStatsStmt *n = makeNode(CreateStatsStmt); + n->defnames = $6; n->stat_types = $7; n->exprs = $9; n->relations = $11; n->stxcomment = NULL; n->if_not_exists = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -4407,18 +4606,20 @@ AlterStatsStmt: ALTER STATISTICS any_name SET STATISTICS SignedIconst { AlterStatsStmt *n = makeNode(AlterStatsStmt); + n->defnames = $3; n->missing_ok = false; n->stxstattarget = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER STATISTICS IF_P EXISTS any_name SET STATISTICS SignedIconst { AlterStatsStmt *n = makeNode(AlterStatsStmt); + n->defnames = $5; n->missing_ok = true; n->stxstattarget = $8; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -4436,6 +4637,7 @@ CreateAsStmt: CREATE OptTemp TABLE create_as_target AS SelectStmt opt_with_data { CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt); + ctas->query = $6; ctas->into = $4; ctas->objtype = OBJECT_TABLE; @@ -4449,6 +4651,7 @@ CreateAsStmt: | CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS SelectStmt opt_with_data { CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt); + ctas->query = $9; ctas->into = $7; ctas->objtype = OBJECT_TABLE; @@ -4495,6 +4698,7 @@ CreateMatViewStmt: CREATE OptNoLog MATERIALIZED VIEW create_mv_target AS SelectStmt opt_with_data { CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt); + ctas->query = $7; ctas->into = $5; ctas->objtype = OBJECT_MATVIEW; @@ -4508,6 +4712,7 @@ CreateMatViewStmt: | CREATE OptNoLog MATERIALIZED VIEW IF_P NOT EXISTS create_mv_target AS SelectStmt opt_with_data { CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt); + ctas->query = $10; ctas->into = $8; ctas->objtype = OBJECT_MATVIEW; @@ -4551,6 +4756,7 @@ RefreshMatViewStmt: REFRESH MATERIALIZED VIEW opt_concurrently qualified_name opt_with_data { RefreshMatViewStmt *n = makeNode(RefreshMatViewStmt); + n->concurrent = $4; n->relation = $5; n->skipData = !($6); @@ -4571,22 +4777,24 @@ CreateSeqStmt: CREATE OptTemp SEQUENCE qualified_name OptSeqOptList { CreateSeqStmt *n = makeNode(CreateSeqStmt); + $4->relpersistence = $2; n->sequence = $4; n->options = $5; n->ownerId = InvalidOid; n->if_not_exists = false; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE OptTemp SEQUENCE IF_P NOT EXISTS qualified_name OptSeqOptList { CreateSeqStmt *n = makeNode(CreateSeqStmt); + $7->relpersistence = $2; n->sequence = $7; n->options = $8; n->ownerId = InvalidOid; n->if_not_exists = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -4594,18 +4802,20 @@ AlterSeqStmt: ALTER SEQUENCE qualified_name SeqOptList { AlterSeqStmt *n = makeNode(AlterSeqStmt); + n->sequence = $3; n->options = $4; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SEQUENCE IF_P EXISTS qualified_name SeqOptList { AlterSeqStmt *n = makeNode(AlterSeqStmt); + n->sequence = $5; n->options = $6; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -4624,31 +4834,31 @@ SeqOptList: SeqOptElem { $$ = list_make1($1); } SeqOptElem: AS SimpleTypename { - $$ = makeDefElem("as", (Node *)$2, @1); + $$ = makeDefElem("as", (Node *) $2, @1); } | CACHE NumericOnly { - $$ = makeDefElem("cache", (Node *)$2, @1); + $$ = makeDefElem("cache", (Node *) $2, @1); } | CYCLE { - $$ = makeDefElem("cycle", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("cycle", (Node *) makeBoolean(true), @1); } | NO CYCLE { - $$ = makeDefElem("cycle", (Node *)makeBoolean(false), @1); + $$ = makeDefElem("cycle", (Node *) makeBoolean(false), @1); } | INCREMENT opt_by NumericOnly { - $$ = makeDefElem("increment", (Node *)$3, @1); + $$ = makeDefElem("increment", (Node *) $3, @1); } | MAXVALUE NumericOnly { - $$ = makeDefElem("maxvalue", (Node *)$2, @1); + $$ = makeDefElem("maxvalue", (Node *) $2, @1); } | MINVALUE NumericOnly { - $$ = makeDefElem("minvalue", (Node *)$2, @1); + $$ = makeDefElem("minvalue", (Node *) $2, @1); } | NO MAXVALUE { @@ -4660,16 +4870,16 @@ SeqOptElem: AS SimpleTypename } | OWNED BY any_name { - $$ = makeDefElem("owned_by", (Node *)$3, @1); + $$ = makeDefElem("owned_by", (Node *) $3, @1); } | SEQUENCE NAME_P any_name { /* not documented, only used by pg_dump */ - $$ = makeDefElem("sequence_name", (Node *)$3, @1); + $$ = makeDefElem("sequence_name", (Node *) $3, @1); } | START opt_with NumericOnly { - $$ = makeDefElem("start", (Node *)$3, @1); + $$ = makeDefElem("start", (Node *) $3, @1); } | RESTART { @@ -4677,7 +4887,7 @@ SeqOptElem: AS SimpleTypename } | RESTART opt_with NumericOnly { - $$ = makeDefElem("restart", (Node *)$3, @1); + $$ = makeDefElem("restart", (Node *) $3, @1); } ; @@ -4690,7 +4900,8 @@ NumericOnly: | '+' FCONST { $$ = (Node *) makeFloat($2); } | '-' FCONST { - Float *f = makeFloat($2); + Float *f = makeFloat($2); + doNegateFloat(f); $$ = (Node *) f; } @@ -4720,22 +4931,24 @@ CreatePLangStmt: * ignore TRUSTED, as the previous code would have too. */ CreateExtensionStmt *n = makeNode(CreateExtensionStmt); + n->if_not_exists = $2; n->extname = $6; n->options = NIL; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE name HANDLER handler_name opt_inline_handler opt_validator { CreatePLangStmt *n = makeNode(CreatePLangStmt); + n->replace = $2; n->plname = $6; n->plhandler = $8; n->plinline = $9; n->plvalidator = $10; n->pltrusted = $3; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -4783,6 +4996,7 @@ opt_procedural: CreateTableSpaceStmt: CREATE TABLESPACE name OptTableSpaceOwner LOCATION Sconst opt_reloptions { CreateTableSpaceStmt *n = makeNode(CreateTableSpaceStmt); + n->tablespacename = $3; n->owner = $4; n->location = $6; @@ -4808,6 +5022,7 @@ OptTableSpaceOwner: OWNER RoleSpec { $$ = $2; } DropTableSpaceStmt: DROP TABLESPACE name { DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt); + n->tablespacename = $3; n->missing_ok = false; $$ = (Node *) n; @@ -4815,6 +5030,7 @@ DropTableSpaceStmt: DROP TABLESPACE name | DROP TABLESPACE IF_P EXISTS name { DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt); + n->tablespacename = $5; n->missing_ok = true; $$ = (Node *) n; @@ -4832,6 +5048,7 @@ DropTableSpaceStmt: DROP TABLESPACE name CreateExtensionStmt: CREATE EXTENSION name opt_with create_extension_opt_list { CreateExtensionStmt *n = makeNode(CreateExtensionStmt); + n->extname = $3; n->if_not_exists = false; n->options = $5; @@ -4840,6 +5057,7 @@ CreateExtensionStmt: CREATE EXTENSION name opt_with create_extension_opt_list | CREATE EXTENSION IF_P NOT EXISTS name opt_with create_extension_opt_list { CreateExtensionStmt *n = makeNode(CreateExtensionStmt); + n->extname = $6; n->if_not_exists = true; n->options = $8; @@ -4857,11 +5075,11 @@ create_extension_opt_list: create_extension_opt_item: SCHEMA name { - $$ = makeDefElem("schema", (Node *)makeString($2), @1); + $$ = makeDefElem("schema", (Node *) makeString($2), @1); } | VERSION_P NonReservedWord_or_Sconst { - $$ = makeDefElem("new_version", (Node *)makeString($2), @1); + $$ = makeDefElem("new_version", (Node *) makeString($2), @1); } | FROM NonReservedWord_or_Sconst { @@ -4872,7 +5090,7 @@ create_extension_opt_item: } | CASCADE { - $$ = makeDefElem("cascade", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("cascade", (Node *) makeBoolean(true), @1); } ; @@ -4885,6 +5103,7 @@ create_extension_opt_item: AlterExtensionStmt: ALTER EXTENSION name UPDATE alter_extension_opt_list { AlterExtensionStmt *n = makeNode(AlterExtensionStmt); + n->extname = $3; n->options = $5; $$ = (Node *) n; @@ -4901,7 +5120,7 @@ alter_extension_opt_list: alter_extension_opt_item: TO NonReservedWord_or_Sconst { - $$ = makeDefElem("new_version", (Node *)makeString($2), @1); + $$ = makeDefElem("new_version", (Node *) makeString($2), @1); } ; @@ -4915,33 +5134,37 @@ AlterExtensionContentsStmt: ALTER EXTENSION name add_drop object_type_name name { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = $5; n->object = (Node *) makeString($6); - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EXTENSION name add_drop object_type_any_name any_name { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = $5; n->object = (Node *) $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = OBJECT_AGGREGATE; n->object = (Node *) $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')' { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = OBJECT_CAST; @@ -4951,83 +5174,92 @@ AlterExtensionContentsStmt: | ALTER EXTENSION name add_drop DOMAIN_P Typename { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = OBJECT_DOMAIN; n->object = (Node *) $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EXTENSION name add_drop FUNCTION function_with_argtypes { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = OBJECT_FUNCTION; n->object = (Node *) $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = OBJECT_OPERATOR; n->object = (Node *) $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING name { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = OBJECT_OPCLASS; n->object = (Node *) lcons(makeString($9), $7); - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING name { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = OBJECT_OPFAMILY; n->object = (Node *) lcons(makeString($9), $7); - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EXTENSION name add_drop PROCEDURE function_with_argtypes { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = OBJECT_PROCEDURE; n->object = (Node *) $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EXTENSION name add_drop ROUTINE function_with_argtypes { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = OBJECT_ROUTINE; n->object = (Node *) $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EXTENSION name add_drop TRANSFORM FOR Typename LANGUAGE name { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = OBJECT_TRANSFORM; n->object = (Node *) list_make2($7, makeString($9)); - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EXTENSION name add_drop TYPE_P Typename { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); + n->extname = $3; n->action = $4; n->objtype = OBJECT_TYPE; n->object = (Node *) $6; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -5041,6 +5273,7 @@ AlterExtensionContentsStmt: CreateFdwStmt: CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic_options { CreateFdwStmt *n = makeNode(CreateFdwStmt); + n->fdwname = $5; n->func_options = $6; n->options = $7; @@ -5049,9 +5282,9 @@ CreateFdwStmt: CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic ; fdw_option: - HANDLER handler_name { $$ = makeDefElem("handler", (Node *)$2, @1); } + HANDLER handler_name { $$ = makeDefElem("handler", (Node *) $2, @1); } | NO HANDLER { $$ = makeDefElem("handler", NULL, @1); } - | VALIDATOR handler_name { $$ = makeDefElem("validator", (Node *)$2, @1); } + | VALIDATOR handler_name { $$ = makeDefElem("validator", (Node *) $2, @1); } | NO VALIDATOR { $$ = makeDefElem("validator", NULL, @1); } ; @@ -5075,6 +5308,7 @@ opt_fdw_options: AlterFdwStmt: ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_options { AlterFdwStmt *n = makeNode(AlterFdwStmt); + n->fdwname = $5; n->func_options = $6; n->options = $7; @@ -5083,6 +5317,7 @@ AlterFdwStmt: ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_op | ALTER FOREIGN DATA_P WRAPPER name fdw_options { AlterFdwStmt *n = makeNode(AlterFdwStmt); + n->fdwname = $5; n->func_options = $6; n->options = NIL; @@ -5171,6 +5406,7 @@ CreateForeignServerStmt: CREATE SERVER name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options { CreateForeignServerStmt *n = makeNode(CreateForeignServerStmt); + n->servername = $3; n->servertype = $4; n->version = $5; @@ -5183,6 +5419,7 @@ CreateForeignServerStmt: CREATE SERVER name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options { CreateForeignServerStmt *n = makeNode(CreateForeignServerStmt); + n->servername = $6; n->servertype = $7; n->version = $8; @@ -5219,6 +5456,7 @@ opt_foreign_server_version: AlterForeignServerStmt: ALTER SERVER name foreign_server_version alter_generic_options { AlterForeignServerStmt *n = makeNode(AlterForeignServerStmt); + n->servername = $3; n->version = $4; n->options = $5; @@ -5228,6 +5466,7 @@ AlterForeignServerStmt: ALTER SERVER name foreign_server_version alter_generic_o | ALTER SERVER name foreign_server_version { AlterForeignServerStmt *n = makeNode(AlterForeignServerStmt); + n->servername = $3; n->version = $4; n->has_version = true; @@ -5236,6 +5475,7 @@ AlterForeignServerStmt: ALTER SERVER name foreign_server_version alter_generic_o | ALTER SERVER name alter_generic_options { AlterForeignServerStmt *n = makeNode(AlterForeignServerStmt); + n->servername = $3; n->options = $4; $$ = (Node *) n; @@ -5255,6 +5495,7 @@ CreateForeignTableStmt: OptInherit SERVER name create_generic_options { CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt); + $4->relpersistence = RELPERSISTENCE_PERMANENT; n->base.relation = $4; n->base.tableElts = $6; @@ -5275,6 +5516,7 @@ CreateForeignTableStmt: OptInherit SERVER name create_generic_options { CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt); + $7->relpersistence = RELPERSISTENCE_PERMANENT; n->base.relation = $7; n->base.tableElts = $9; @@ -5295,6 +5537,7 @@ CreateForeignTableStmt: SERVER name create_generic_options { CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt); + $4->relpersistence = RELPERSISTENCE_PERMANENT; n->base.relation = $4; n->base.inhRelations = list_make1($7); @@ -5316,6 +5559,7 @@ CreateForeignTableStmt: SERVER name create_generic_options { CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt); + $7->relpersistence = RELPERSISTENCE_PERMANENT; n->base.relation = $7; n->base.inhRelations = list_make1($10); @@ -5348,6 +5592,7 @@ ImportForeignSchemaStmt: FROM SERVER name INTO name create_generic_options { ImportForeignSchemaStmt *n = makeNode(ImportForeignSchemaStmt); + n->server_name = $8; n->remote_schema = $4; n->local_schema = $10; @@ -5367,6 +5612,7 @@ import_qualification: import_qualification_type '(' relation_expr_list ')' { ImportQual *n = (ImportQual *) palloc(sizeof(ImportQual)); + n->type = $1; n->table_names = $3; $$ = n; @@ -5390,6 +5636,7 @@ import_qualification: CreateUserMappingStmt: CREATE USER MAPPING FOR auth_ident SERVER name create_generic_options { CreateUserMappingStmt *n = makeNode(CreateUserMappingStmt); + n->user = $5; n->servername = $7; n->options = $8; @@ -5399,6 +5646,7 @@ CreateUserMappingStmt: CREATE USER MAPPING FOR auth_ident SERVER name create_gen | CREATE USER MAPPING IF_P NOT EXISTS FOR auth_ident SERVER name create_generic_options { CreateUserMappingStmt *n = makeNode(CreateUserMappingStmt); + n->user = $8; n->servername = $10; n->options = $11; @@ -5424,6 +5672,7 @@ auth_ident: RoleSpec { $$ = $1; } DropUserMappingStmt: DROP USER MAPPING FOR auth_ident SERVER name { DropUserMappingStmt *n = makeNode(DropUserMappingStmt); + n->user = $5; n->servername = $7; n->missing_ok = false; @@ -5432,6 +5681,7 @@ DropUserMappingStmt: DROP USER MAPPING FOR auth_ident SERVER name | DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name { DropUserMappingStmt *n = makeNode(DropUserMappingStmt); + n->user = $7; n->servername = $9; n->missing_ok = true; @@ -5449,6 +5699,7 @@ DropUserMappingStmt: DROP USER MAPPING FOR auth_ident SERVER name AlterUserMappingStmt: ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options { AlterUserMappingStmt *n = makeNode(AlterUserMappingStmt); + n->user = $5; n->servername = $7; n->options = $8; @@ -5475,6 +5726,7 @@ CreatePolicyStmt: RowSecurityOptionalExpr RowSecurityOptionalWithCheck { CreatePolicyStmt *n = makeNode(CreatePolicyStmt); + n->policy_name = $3; n->table = $5; n->permissive = $6; @@ -5491,6 +5743,7 @@ AlterPolicyStmt: RowSecurityOptionalExpr RowSecurityOptionalWithCheck { AlterPolicyStmt *n = makeNode(AlterPolicyStmt); + n->policy_name = $3; n->table = $5; n->roles = $6; @@ -5530,9 +5783,9 @@ RowSecurityDefaultPermissive: else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("unrecognized row security option \"%s\"", $2), + errmsg("unrecognized row security option \"%s\"", $2), errhint("Only PERMISSIVE or RESTRICTIVE policies are supported currently."), - parser_errposition(@2))); + parser_errposition(@2))); } | /* EMPTY */ { $$ = true; } @@ -5561,6 +5814,7 @@ row_security_cmd: CreateAmStmt: CREATE ACCESS METHOD name TYPE_P am_type HANDLER handler_name { CreateAmStmt *n = makeNode(CreateAmStmt); + n->amname = $4; n->handler_name = $8; n->amtype = $6; @@ -5586,6 +5840,7 @@ CreateTrigStmt: EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')' { CreateTrigStmt *n = makeNode(CreateTrigStmt); + n->replace = $2; n->isconstraint = false; n->trigname = $4; @@ -5601,7 +5856,7 @@ CreateTrigStmt: n->deferrable = false; n->initdeferred = false; n->constrrel = NULL; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE opt_or_replace CONSTRAINT TRIGGER name AFTER TriggerEvents ON qualified_name OptConstrFromTable ConstraintAttributeSpec @@ -5609,6 +5864,7 @@ CreateTrigStmt: EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')' { CreateTrigStmt *n = makeNode(CreateTrigStmt); + n->replace = $2; if (n->replace) /* not supported, see CreateTrigger */ ereport(ERROR, @@ -5629,7 +5885,7 @@ CreateTrigStmt: &n->deferrable, &n->initdeferred, NULL, NULL, yyscanner); n->constrrel = $10; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -5644,10 +5900,10 @@ TriggerEvents: { $$ = $1; } | TriggerEvents OR TriggerOneEvent { - int events1 = intVal(linitial($1)); - int events2 = intVal(linitial($3)); - List *columns1 = (List *) lsecond($1); - List *columns2 = (List *) lsecond($3); + int events1 = intVal(linitial($1)); + int events2 = intVal(linitial($3)); + List *columns1 = (List *) lsecond($1); + List *columns2 = (List *) lsecond($3); if (events1 & events2) parser_yyerror("duplicate trigger events specified"); @@ -5690,10 +5946,11 @@ TriggerTransition: TransitionOldOrNew TransitionRowOrTable opt_as TransitionRelName { TriggerTransition *n = makeNode(TriggerTransition); + n->name = $4; n->isNew = $1; n->isTable = $2; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -5827,22 +6084,24 @@ CreateEventTrigStmt: EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')' { CreateEventTrigStmt *n = makeNode(CreateEventTrigStmt); + n->trigname = $4; n->eventname = $6; n->whenclause = NULL; n->funcname = $9; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE EVENT TRIGGER name ON ColLabel WHEN event_trigger_when_list EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')' { CreateEventTrigStmt *n = makeNode(CreateEventTrigStmt); + n->trigname = $4; n->eventname = $6; n->whenclause = $8; n->funcname = $11; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -5869,6 +6128,7 @@ AlterEventTrigStmt: ALTER EVENT TRIGGER name enable_trigger { AlterEventTrigStmt *n = makeNode(AlterEventTrigStmt); + n->trigname = $4; n->tgenabled = $5; $$ = (Node *) n; @@ -5912,56 +6172,61 @@ DefineStmt: CREATE opt_or_replace AGGREGATE func_name aggr_args definition { DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_AGGREGATE; n->oldstyle = false; n->replace = $2; n->defnames = $4; n->args = $5; n->definition = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE opt_or_replace AGGREGATE func_name old_aggr_definition { /* old-style (pre-8.2) syntax for CREATE AGGREGATE */ DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_AGGREGATE; n->oldstyle = true; n->replace = $2; n->defnames = $4; n->args = NIL; n->definition = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE OPERATOR any_operator definition { DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_OPERATOR; n->oldstyle = false; n->defnames = $3; n->args = NIL; n->definition = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE TYPE_P any_name definition { DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TYPE; n->oldstyle = false; n->defnames = $3; n->args = NIL; n->definition = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE TYPE_P any_name { /* Shell type (identified by lack of definition) */ DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TYPE; n->oldstyle = false; n->defnames = $3; n->args = NIL; n->definition = NIL; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE TYPE_P any_name AS '(' OptTableFuncElementList ')' { @@ -5970,95 +6235,105 @@ DefineStmt: /* can't use qualified_name, sigh */ n->typevar = makeRangeVarFromAnyName($3, @3, yyscanner); n->coldeflist = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE TYPE_P any_name AS ENUM_P '(' opt_enum_val_list ')' { CreateEnumStmt *n = makeNode(CreateEnumStmt); + n->typeName = $3; n->vals = $7; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE TYPE_P any_name AS RANGE definition { CreateRangeStmt *n = makeNode(CreateRangeStmt); + n->typeName = $3; n->params = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE TEXT_P SEARCH PARSER any_name definition { DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TSPARSER; n->args = NIL; n->defnames = $5; n->definition = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE TEXT_P SEARCH DICTIONARY any_name definition { DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TSDICTIONARY; n->args = NIL; n->defnames = $5; n->definition = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE TEXT_P SEARCH TEMPLATE any_name definition { DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TSTEMPLATE; n->args = NIL; n->defnames = $5; n->definition = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE TEXT_P SEARCH CONFIGURATION any_name definition { DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TSCONFIGURATION; n->args = NIL; n->defnames = $5; n->definition = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE COLLATION any_name definition { DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_COLLATION; n->args = NIL; n->defnames = $3; n->definition = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE COLLATION IF_P NOT EXISTS any_name definition { DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_COLLATION; n->args = NIL; n->defnames = $6; n->definition = $7; n->if_not_exists = true; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE COLLATION any_name FROM any_name { DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_COLLATION; n->args = NIL; n->defnames = $3; n->definition = list_make1(makeDefElem("from", (Node *) $5, @5)); - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE COLLATION IF_P NOT EXISTS any_name FROM any_name { DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_COLLATION; n->args = NIL; n->defnames = $6; n->definition = list_make1(makeDefElem("from", (Node *) $8, @8)); n->if_not_exists = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -6080,12 +6355,12 @@ def_elem: ColLabel '=' def_arg ; /* Note: any simple identifier will be returned as a type name! */ -def_arg: func_type { $$ = (Node *)$1; } - | reserved_keyword { $$ = (Node *)makeString(pstrdup($1)); } - | qual_all_Op { $$ = (Node *)$1; } - | NumericOnly { $$ = (Node *)$1; } - | Sconst { $$ = (Node *)makeString($1); } - | NONE { $$ = (Node *)makeString(pstrdup($1)); } +def_arg: func_type { $$ = (Node *) $1; } + | reserved_keyword { $$ = (Node *) makeString(pstrdup($1)); } + | qual_all_Op { $$ = (Node *) $1; } + | NumericOnly { $$ = (Node *) $1; } + | Sconst { $$ = (Node *) makeString($1); } + | NONE { $$ = (Node *) makeString(pstrdup($1)); } ; old_aggr_definition: '(' old_aggr_list ')' { $$ = $2; } @@ -6102,7 +6377,7 @@ old_aggr_list: old_aggr_elem { $$ = list_make1($1); } */ old_aggr_elem: IDENT '=' def_arg { - $$ = makeDefElem($1, (Node *)$3, @1); + $$ = makeDefElem($1, (Node *) $3, @1); } ; @@ -6127,6 +6402,7 @@ AlterEnumStmt: ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists Sconst { AlterEnumStmt *n = makeNode(AlterEnumStmt); + n->typeName = $3; n->oldVal = NULL; n->newVal = $7; @@ -6138,6 +6414,7 @@ AlterEnumStmt: | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists Sconst BEFORE Sconst { AlterEnumStmt *n = makeNode(AlterEnumStmt); + n->typeName = $3; n->oldVal = NULL; n->newVal = $7; @@ -6149,6 +6426,7 @@ AlterEnumStmt: | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists Sconst AFTER Sconst { AlterEnumStmt *n = makeNode(AlterEnumStmt); + n->typeName = $3; n->oldVal = NULL; n->newVal = $7; @@ -6160,6 +6438,7 @@ AlterEnumStmt: | ALTER TYPE_P any_name RENAME VALUE_P Sconst TO Sconst { AlterEnumStmt *n = makeNode(AlterEnumStmt); + n->typeName = $3; n->oldVal = $6; n->newVal = $8; @@ -6191,6 +6470,7 @@ CreateOpClassStmt: USING name opt_opfamily AS opclass_item_list { CreateOpClassStmt *n = makeNode(CreateOpClassStmt); + n->opclassname = $4; n->isDefault = $5; n->datatype = $8; @@ -6211,6 +6491,7 @@ opclass_item: { CreateOpClassItem *n = makeNode(CreateOpClassItem); ObjectWithArgs *owa = makeNode(ObjectWithArgs); + owa->objname = $3; owa->objargs = NIL; n->itemtype = OPCLASS_ITEM_OPERATOR; @@ -6223,6 +6504,7 @@ opclass_item: opt_recheck { CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_OPERATOR; n->name = $3; n->number = $2; @@ -6232,6 +6514,7 @@ opclass_item: | FUNCTION Iconst function_with_argtypes { CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_FUNCTION; n->name = $3; n->number = $2; @@ -6240,6 +6523,7 @@ opclass_item: | FUNCTION Iconst '(' type_list ')' function_with_argtypes { CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_FUNCTION; n->name = $6; n->number = $2; @@ -6249,6 +6533,7 @@ opclass_item: | STORAGE Typename { CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_STORAGETYPE; n->storedtype = $2; $$ = (Node *) n; @@ -6290,6 +6575,7 @@ CreateOpFamilyStmt: CREATE OPERATOR FAMILY any_name USING name { CreateOpFamilyStmt *n = makeNode(CreateOpFamilyStmt); + n->opfamilyname = $4; n->amname = $6; $$ = (Node *) n; @@ -6300,6 +6586,7 @@ AlterOpFamilyStmt: ALTER OPERATOR FAMILY any_name USING name ADD_P opclass_item_list { AlterOpFamilyStmt *n = makeNode(AlterOpFamilyStmt); + n->opfamilyname = $4; n->amname = $6; n->isDrop = false; @@ -6309,6 +6596,7 @@ AlterOpFamilyStmt: | ALTER OPERATOR FAMILY any_name USING name DROP opclass_drop_list { AlterOpFamilyStmt *n = makeNode(AlterOpFamilyStmt); + n->opfamilyname = $4; n->amname = $6; n->isDrop = true; @@ -6326,6 +6614,7 @@ opclass_drop: OPERATOR Iconst '(' type_list ')' { CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_OPERATOR; n->number = $2; n->class_args = $4; @@ -6334,6 +6623,7 @@ opclass_drop: | FUNCTION Iconst '(' type_list ')' { CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_FUNCTION; n->number = $2; n->class_args = $4; @@ -6346,6 +6636,7 @@ DropOpClassStmt: DROP OPERATOR CLASS any_name USING name opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->objects = list_make1(lcons(makeString($6), $4)); n->removeType = OBJECT_OPCLASS; n->behavior = $7; @@ -6356,6 +6647,7 @@ DropOpClassStmt: | DROP OPERATOR CLASS IF_P EXISTS any_name USING name opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->objects = list_make1(lcons(makeString($8), $6)); n->removeType = OBJECT_OPCLASS; n->behavior = $9; @@ -6369,6 +6661,7 @@ DropOpFamilyStmt: DROP OPERATOR FAMILY any_name USING name opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->objects = list_make1(lcons(makeString($6), $4)); n->removeType = OBJECT_OPFAMILY; n->behavior = $7; @@ -6379,6 +6672,7 @@ DropOpFamilyStmt: | DROP OPERATOR FAMILY IF_P EXISTS any_name USING name opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->objects = list_make1(lcons(makeString($8), $6)); n->removeType = OBJECT_OPFAMILY; n->behavior = $9; @@ -6401,9 +6695,10 @@ DropOwnedStmt: DROP OWNED BY role_list opt_drop_behavior { DropOwnedStmt *n = makeNode(DropOwnedStmt); + n->roles = $4; n->behavior = $5; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -6411,9 +6706,10 @@ ReassignOwnedStmt: REASSIGN OWNED BY role_list TO RoleSpec { ReassignOwnedStmt *n = makeNode(ReassignOwnedStmt); + n->roles = $4; n->newrole = $6; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -6429,46 +6725,51 @@ ReassignOwnedStmt: DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = $2; n->missing_ok = true; n->objects = $5; n->behavior = $6; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP object_type_any_name any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = $2; n->missing_ok = false; n->objects = $3; n->behavior = $4; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP drop_type_name IF_P EXISTS name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = $2; n->missing_ok = true; n->objects = $5; n->behavior = $6; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP drop_type_name name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = $2; n->missing_ok = false; n->objects = $3; n->behavior = $4; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP object_type_name_on_any_name name ON any_name opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = $2; n->objects = list_make1(lappend($5, makeString($3))); n->behavior = $6; @@ -6479,6 +6780,7 @@ DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior | DROP object_type_name_on_any_name IF_P EXISTS name ON any_name opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = $2; n->objects = list_make1(lappend($7, makeString($5))); n->behavior = $8; @@ -6489,6 +6791,7 @@ DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior | DROP TYPE_P type_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_TYPE; n->missing_ok = false; n->objects = $3; @@ -6499,6 +6802,7 @@ DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior | DROP TYPE_P IF_P EXISTS type_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_TYPE; n->missing_ok = true; n->objects = $5; @@ -6509,6 +6813,7 @@ DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior | DROP DOMAIN_P type_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_DOMAIN; n->missing_ok = false; n->objects = $3; @@ -6519,6 +6824,7 @@ DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior | DROP DOMAIN_P IF_P EXISTS type_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_DOMAIN; n->missing_ok = true; n->objects = $5; @@ -6529,22 +6835,24 @@ DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior | DROP INDEX CONCURRENTLY any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_INDEX; n->missing_ok = false; n->objects = $4; n->behavior = $5; n->concurrent = true; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP INDEX CONCURRENTLY IF_P EXISTS any_name_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_INDEX; n->missing_ok = true; n->objects = $6; n->behavior = $7; n->concurrent = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -6628,10 +6936,11 @@ TruncateStmt: TRUNCATE opt_table relation_expr_list opt_restart_seqs opt_drop_behavior { TruncateStmt *n = makeNode(TruncateStmt); + n->relations = $3; n->restart_seqs = $4; n->behavior = $5; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -6651,6 +6960,7 @@ CommentStmt: COMMENT ON object_type_any_name any_name IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = $3; n->object = (Node *) $4; n->comment = $6; @@ -6659,6 +6969,7 @@ CommentStmt: | COMMENT ON COLUMN any_name IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_COLUMN; n->object = (Node *) $4; n->comment = $6; @@ -6667,6 +6978,7 @@ CommentStmt: | COMMENT ON object_type_name name IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = $3; n->object = (Node *) makeString($4); n->comment = $6; @@ -6675,6 +6987,7 @@ CommentStmt: | COMMENT ON TYPE_P Typename IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TYPE; n->object = (Node *) $4; n->comment = $6; @@ -6683,6 +6996,7 @@ CommentStmt: | COMMENT ON DOMAIN_P Typename IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_DOMAIN; n->object = (Node *) $4; n->comment = $6; @@ -6691,6 +7005,7 @@ CommentStmt: | COMMENT ON AGGREGATE aggregate_with_argtypes IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_AGGREGATE; n->object = (Node *) $4; n->comment = $6; @@ -6699,6 +7014,7 @@ CommentStmt: | COMMENT ON FUNCTION function_with_argtypes IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_FUNCTION; n->object = (Node *) $4; n->comment = $6; @@ -6707,6 +7023,7 @@ CommentStmt: | COMMENT ON OPERATOR operator_with_argtypes IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_OPERATOR; n->object = (Node *) $4; n->comment = $6; @@ -6715,6 +7032,7 @@ CommentStmt: | COMMENT ON CONSTRAINT name ON any_name IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TABCONSTRAINT; n->object = (Node *) lappend($6, makeString($4)); n->comment = $8; @@ -6723,6 +7041,7 @@ CommentStmt: | COMMENT ON CONSTRAINT name ON DOMAIN_P any_name IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_DOMCONSTRAINT; /* * should use Typename not any_name in the production, but @@ -6736,6 +7055,7 @@ CommentStmt: | COMMENT ON object_type_name_on_any_name name ON any_name IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = $3; n->object = (Node *) lappend($6, makeString($4)); n->comment = $8; @@ -6744,6 +7064,7 @@ CommentStmt: | COMMENT ON PROCEDURE function_with_argtypes IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_PROCEDURE; n->object = (Node *) $4; n->comment = $6; @@ -6752,6 +7073,7 @@ CommentStmt: | COMMENT ON ROUTINE function_with_argtypes IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_ROUTINE; n->object = (Node *) $4; n->comment = $6; @@ -6760,6 +7082,7 @@ CommentStmt: | COMMENT ON TRANSFORM FOR Typename LANGUAGE name IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TRANSFORM; n->object = (Node *) list_make2($5, makeString($7)); n->comment = $9; @@ -6768,6 +7091,7 @@ CommentStmt: | COMMENT ON OPERATOR CLASS any_name USING name IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_OPCLASS; n->object = (Node *) lcons(makeString($7), $5); n->comment = $9; @@ -6776,6 +7100,7 @@ CommentStmt: | COMMENT ON OPERATOR FAMILY any_name USING name IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_OPFAMILY; n->object = (Node *) lcons(makeString($7), $5); n->comment = $9; @@ -6784,6 +7109,7 @@ CommentStmt: | COMMENT ON LARGE_P OBJECT_P NumericOnly IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_LARGEOBJECT; n->object = (Node *) $5; n->comment = $7; @@ -6792,6 +7118,7 @@ CommentStmt: | COMMENT ON CAST '(' Typename AS Typename ')' IS comment_text { CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_CAST; n->object = (Node *) list_make2($5, $7); n->comment = $10; @@ -6819,6 +7146,7 @@ SecLabelStmt: IS security_label { SecLabelStmt *n = makeNode(SecLabelStmt); + n->provider = $3; n->objtype = $5; n->object = (Node *) $6; @@ -6829,6 +7157,7 @@ SecLabelStmt: IS security_label { SecLabelStmt *n = makeNode(SecLabelStmt); + n->provider = $3; n->objtype = OBJECT_COLUMN; n->object = (Node *) $6; @@ -6839,6 +7168,7 @@ SecLabelStmt: IS security_label { SecLabelStmt *n = makeNode(SecLabelStmt); + n->provider = $3; n->objtype = $5; n->object = (Node *) makeString($6); @@ -6849,6 +7179,7 @@ SecLabelStmt: IS security_label { SecLabelStmt *n = makeNode(SecLabelStmt); + n->provider = $3; n->objtype = OBJECT_TYPE; n->object = (Node *) $6; @@ -6859,6 +7190,7 @@ SecLabelStmt: IS security_label { SecLabelStmt *n = makeNode(SecLabelStmt); + n->provider = $3; n->objtype = OBJECT_DOMAIN; n->object = (Node *) $6; @@ -6869,6 +7201,7 @@ SecLabelStmt: IS security_label { SecLabelStmt *n = makeNode(SecLabelStmt); + n->provider = $3; n->objtype = OBJECT_AGGREGATE; n->object = (Node *) $6; @@ -6879,6 +7212,7 @@ SecLabelStmt: IS security_label { SecLabelStmt *n = makeNode(SecLabelStmt); + n->provider = $3; n->objtype = OBJECT_FUNCTION; n->object = (Node *) $6; @@ -6889,6 +7223,7 @@ SecLabelStmt: IS security_label { SecLabelStmt *n = makeNode(SecLabelStmt); + n->provider = $3; n->objtype = OBJECT_LARGEOBJECT; n->object = (Node *) $7; @@ -6899,6 +7234,7 @@ SecLabelStmt: IS security_label { SecLabelStmt *n = makeNode(SecLabelStmt); + n->provider = $3; n->objtype = OBJECT_PROCEDURE; n->object = (Node *) $6; @@ -6909,6 +7245,7 @@ SecLabelStmt: IS security_label { SecLabelStmt *n = makeNode(SecLabelStmt); + n->provider = $3; n->objtype = OBJECT_ROUTINE; n->object = (Node *) $6; @@ -6935,144 +7272,162 @@ security_label: Sconst { $$ = $1; } FetchStmt: FETCH fetch_args { FetchStmt *n = (FetchStmt *) $2; + n->ismove = false; - $$ = (Node *)n; + $$ = (Node *) n; } | MOVE fetch_args { FetchStmt *n = (FetchStmt *) $2; + n->ismove = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; fetch_args: cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $1; n->direction = FETCH_FORWARD; n->howMany = 1; - $$ = (Node *)n; + $$ = (Node *) n; } | from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $2; n->direction = FETCH_FORWARD; n->howMany = 1; - $$ = (Node *)n; + $$ = (Node *) n; } | NEXT opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $3; n->direction = FETCH_FORWARD; n->howMany = 1; - $$ = (Node *)n; + $$ = (Node *) n; } | PRIOR opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $3; n->direction = FETCH_BACKWARD; n->howMany = 1; - $$ = (Node *)n; + $$ = (Node *) n; } | FIRST_P opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $3; n->direction = FETCH_ABSOLUTE; n->howMany = 1; - $$ = (Node *)n; + $$ = (Node *) n; } | LAST_P opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $3; n->direction = FETCH_ABSOLUTE; n->howMany = -1; - $$ = (Node *)n; + $$ = (Node *) n; } | ABSOLUTE_P SignedIconst opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $4; n->direction = FETCH_ABSOLUTE; n->howMany = $2; - $$ = (Node *)n; + $$ = (Node *) n; } | RELATIVE_P SignedIconst opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $4; n->direction = FETCH_RELATIVE; n->howMany = $2; - $$ = (Node *)n; + $$ = (Node *) n; } | SignedIconst opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $3; n->direction = FETCH_FORWARD; n->howMany = $1; - $$ = (Node *)n; + $$ = (Node *) n; } | ALL opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $3; n->direction = FETCH_FORWARD; n->howMany = FETCH_ALL; - $$ = (Node *)n; + $$ = (Node *) n; } | FORWARD opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $3; n->direction = FETCH_FORWARD; n->howMany = 1; - $$ = (Node *)n; + $$ = (Node *) n; } | FORWARD SignedIconst opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $4; n->direction = FETCH_FORWARD; n->howMany = $2; - $$ = (Node *)n; + $$ = (Node *) n; } | FORWARD ALL opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $4; n->direction = FETCH_FORWARD; n->howMany = FETCH_ALL; - $$ = (Node *)n; + $$ = (Node *) n; } | BACKWARD opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $3; n->direction = FETCH_BACKWARD; n->howMany = 1; - $$ = (Node *)n; + $$ = (Node *) n; } | BACKWARD SignedIconst opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $4; n->direction = FETCH_BACKWARD; n->howMany = $2; - $$ = (Node *)n; + $$ = (Node *) n; } | BACKWARD ALL opt_from_in cursor_name { FetchStmt *n = makeNode(FetchStmt); + n->portalname = $4; n->direction = FETCH_BACKWARD; n->howMany = FETCH_ALL; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -7095,6 +7450,7 @@ GrantStmt: GRANT privileges ON privilege_target TO grantee_list opt_grant_grant_option opt_granted_by { GrantStmt *n = makeNode(GrantStmt); + n->is_grant = true; n->privileges = $2; n->targtype = ($4)->targtype; @@ -7103,7 +7459,7 @@ GrantStmt: GRANT privileges ON privilege_target TO grantee_list n->grantees = $6; n->grant_option = $7; n->grantor = $8; - $$ = (Node*)n; + $$ = (Node *) n; } ; @@ -7112,6 +7468,7 @@ RevokeStmt: FROM grantee_list opt_granted_by opt_drop_behavior { GrantStmt *n = makeNode(GrantStmt); + n->is_grant = false; n->grant_option = false; n->privileges = $2; @@ -7121,12 +7478,13 @@ RevokeStmt: n->grantees = $6; n->grantor = $7; n->behavior = $8; - $$ = (Node *)n; + $$ = (Node *) n; } | REVOKE GRANT OPTION FOR privileges ON privilege_target FROM grantee_list opt_granted_by opt_drop_behavior { GrantStmt *n = makeNode(GrantStmt); + n->is_grant = false; n->grant_option = true; n->privileges = $5; @@ -7136,7 +7494,7 @@ RevokeStmt: n->grantees = $9; n->grantor = $10; n->behavior = $11; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -7159,6 +7517,7 @@ privileges: privilege_list | ALL '(' columnList ')' { AccessPriv *n = makeNode(AccessPriv); + n->priv_name = NULL; n->cols = $3; $$ = list_make1(n); @@ -7166,6 +7525,7 @@ privileges: privilege_list | ALL PRIVILEGES '(' columnList ')' { AccessPriv *n = makeNode(AccessPriv); + n->priv_name = NULL; n->cols = $4; $$ = list_make1(n); @@ -7179,6 +7539,7 @@ privilege_list: privilege { $$ = list_make1($1); } privilege: SELECT opt_column_list { AccessPriv *n = makeNode(AccessPriv); + n->priv_name = pstrdup($1); n->cols = $2; $$ = n; @@ -7186,6 +7547,7 @@ privilege: SELECT opt_column_list | REFERENCES opt_column_list { AccessPriv *n = makeNode(AccessPriv); + n->priv_name = pstrdup($1); n->cols = $2; $$ = n; @@ -7193,6 +7555,7 @@ privilege: SELECT opt_column_list | CREATE opt_column_list { AccessPriv *n = makeNode(AccessPriv); + n->priv_name = pstrdup($1); n->cols = $2; $$ = n; @@ -7207,6 +7570,7 @@ privilege: SELECT opt_column_list | ColId opt_column_list { AccessPriv *n = makeNode(AccessPriv); + n->priv_name = $1; n->cols = $2; $$ = n; @@ -7243,6 +7607,7 @@ privilege_target: qualified_name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_TABLE; n->objs = $1; @@ -7251,6 +7616,7 @@ privilege_target: | TABLE qualified_name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_TABLE; n->objs = $2; @@ -7259,6 +7625,7 @@ privilege_target: | SEQUENCE qualified_name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_SEQUENCE; n->objs = $2; @@ -7267,6 +7634,7 @@ privilege_target: | FOREIGN DATA_P WRAPPER name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_FDW; n->objs = $4; @@ -7275,6 +7643,7 @@ privilege_target: | FOREIGN SERVER name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_FOREIGN_SERVER; n->objs = $3; @@ -7283,6 +7652,7 @@ privilege_target: | FUNCTION function_with_argtypes_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_FUNCTION; n->objs = $2; @@ -7291,6 +7661,7 @@ privilege_target: | PROCEDURE function_with_argtypes_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_PROCEDURE; n->objs = $2; @@ -7299,6 +7670,7 @@ privilege_target: | ROUTINE function_with_argtypes_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_ROUTINE; n->objs = $2; @@ -7307,6 +7679,7 @@ privilege_target: | DATABASE name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_DATABASE; n->objs = $2; @@ -7315,6 +7688,7 @@ privilege_target: | DOMAIN_P any_name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_DOMAIN; n->objs = $2; @@ -7323,6 +7697,7 @@ privilege_target: | LANGUAGE name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_LANGUAGE; n->objs = $2; @@ -7331,6 +7706,7 @@ privilege_target: | LARGE_P OBJECT_P NumericOnly_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_LARGEOBJECT; n->objs = $3; @@ -7347,6 +7723,7 @@ privilege_target: | SCHEMA name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_SCHEMA; n->objs = $2; @@ -7355,6 +7732,7 @@ privilege_target: | TABLESPACE name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_TABLESPACE; n->objs = $2; @@ -7363,6 +7741,7 @@ privilege_target: | TYPE_P any_name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_OBJECT; n->objtype = OBJECT_TYPE; n->objs = $2; @@ -7371,6 +7750,7 @@ privilege_target: | ALL TABLES IN_P SCHEMA name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_ALL_IN_SCHEMA; n->objtype = OBJECT_TABLE; n->objs = $5; @@ -7379,6 +7759,7 @@ privilege_target: | ALL SEQUENCES IN_P SCHEMA name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_ALL_IN_SCHEMA; n->objtype = OBJECT_SEQUENCE; n->objs = $5; @@ -7387,6 +7768,7 @@ privilege_target: | ALL FUNCTIONS IN_P SCHEMA name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_ALL_IN_SCHEMA; n->objtype = OBJECT_FUNCTION; n->objs = $5; @@ -7395,6 +7777,7 @@ privilege_target: | ALL PROCEDURES IN_P SCHEMA name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_ALL_IN_SCHEMA; n->objtype = OBJECT_PROCEDURE; n->objs = $5; @@ -7403,6 +7786,7 @@ privilege_target: | ALL ROUTINES IN_P SCHEMA name_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); + n->targtype = ACL_TARGET_ALL_IN_SCHEMA; n->objtype = OBJECT_ROUTINE; n->objs = $5; @@ -7437,12 +7821,13 @@ GrantRoleStmt: GRANT privilege_list TO role_list opt_grant_admin_option opt_granted_by { GrantRoleStmt *n = makeNode(GrantRoleStmt); + n->is_grant = true; n->granted_roles = $2; n->grantee_roles = $4; n->admin_opt = $5; n->grantor = $6; - $$ = (Node*)n; + $$ = (Node *) n; } ; @@ -7450,22 +7835,24 @@ RevokeRoleStmt: REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior { GrantRoleStmt *n = makeNode(GrantRoleStmt); + n->is_grant = false; n->admin_opt = false; n->granted_roles = $2; n->grantee_roles = $4; n->behavior = $6; - $$ = (Node*)n; + $$ = (Node *) n; } | REVOKE ADMIN OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior { GrantRoleStmt *n = makeNode(GrantRoleStmt); + n->is_grant = false; n->admin_opt = true; n->granted_roles = $5; n->grantee_roles = $7; n->behavior = $9; - $$ = (Node*)n; + $$ = (Node *) n; } ; @@ -7487,9 +7874,10 @@ AlterDefaultPrivilegesStmt: ALTER DEFAULT PRIVILEGES DefACLOptionList DefACLAction { AlterDefaultPrivilegesStmt *n = makeNode(AlterDefaultPrivilegesStmt); + n->options = $4; n->action = (GrantStmt *) $5; - $$ = (Node*)n; + $$ = (Node *) n; } ; @@ -7501,15 +7889,15 @@ DefACLOptionList: DefACLOption: IN_P SCHEMA name_list { - $$ = makeDefElem("schemas", (Node *)$3, @1); + $$ = makeDefElem("schemas", (Node *) $3, @1); } | FOR ROLE role_list { - $$ = makeDefElem("roles", (Node *)$3, @1); + $$ = makeDefElem("roles", (Node *) $3, @1); } | FOR USER role_list { - $$ = makeDefElem("roles", (Node *)$3, @1); + $$ = makeDefElem("roles", (Node *) $3, @1); } ; @@ -7522,6 +7910,7 @@ DefACLAction: opt_grant_grant_option { GrantStmt *n = makeNode(GrantStmt); + n->is_grant = true; n->privileges = $2; n->targtype = ACL_TARGET_DEFAULTS; @@ -7529,12 +7918,13 @@ DefACLAction: n->objects = NIL; n->grantees = $6; n->grant_option = $7; - $$ = (Node*)n; + $$ = (Node *) n; } | REVOKE privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior { GrantStmt *n = makeNode(GrantStmt); + n->is_grant = false; n->grant_option = false; n->privileges = $2; @@ -7543,12 +7933,13 @@ DefACLAction: n->objects = NIL; n->grantees = $6; n->behavior = $7; - $$ = (Node *)n; + $$ = (Node *) n; } | REVOKE GRANT OPTION FOR privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior { GrantStmt *n = makeNode(GrantStmt); + n->is_grant = false; n->grant_option = true; n->privileges = $5; @@ -7557,7 +7948,7 @@ DefACLAction: n->objects = NIL; n->grantees = $9; n->behavior = $10; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -7584,6 +7975,7 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name opt_include opt_unique_null_treatment opt_reloptions OptTableSpace where_clause { IndexStmt *n = makeNode(IndexStmt); + n->unique = $2; n->concurrent = $4; n->idxname = $5; @@ -7608,13 +8000,14 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name n->transformed = false; n->if_not_exists = false; n->reset_default_tblspc = false; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE opt_unique INDEX opt_concurrently IF_P NOT EXISTS name ON relation_expr access_method_clause '(' index_params ')' opt_include opt_unique_null_treatment opt_reloptions OptTableSpace where_clause { IndexStmt *n = makeNode(IndexStmt); + n->unique = $2; n->concurrent = $4; n->idxname = $8; @@ -7639,7 +8032,7 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name n->transformed = false; n->if_not_exists = true; n->reset_default_tblspc = false; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -7760,6 +8153,7 @@ CreateFunctionStmt: RETURNS func_return opt_createfunc_opt_list opt_routine_body { CreateFunctionStmt *n = makeNode(CreateFunctionStmt); + n->is_procedure = false; n->replace = $2; n->funcname = $4; @@ -7767,12 +8161,13 @@ CreateFunctionStmt: n->returnType = $7; n->options = $8; n->sql_body = $9; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults RETURNS TABLE '(' table_func_column_list ')' opt_createfunc_opt_list opt_routine_body { CreateFunctionStmt *n = makeNode(CreateFunctionStmt); + n->is_procedure = false; n->replace = $2; n->funcname = $4; @@ -7781,12 +8176,13 @@ CreateFunctionStmt: n->returnType->location = @7; n->options = $11; n->sql_body = $12; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults opt_createfunc_opt_list opt_routine_body { CreateFunctionStmt *n = makeNode(CreateFunctionStmt); + n->is_procedure = false; n->replace = $2; n->funcname = $4; @@ -7794,12 +8190,13 @@ CreateFunctionStmt: n->returnType = NULL; n->options = $6; n->sql_body = $7; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE opt_or_replace PROCEDURE func_name func_args_with_defaults opt_createfunc_opt_list opt_routine_body { CreateFunctionStmt *n = makeNode(CreateFunctionStmt); + n->is_procedure = true; n->replace = $2; n->funcname = $4; @@ -7807,7 +8204,7 @@ CreateFunctionStmt: n->returnType = NULL; n->options = $6; n->sql_body = $7; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -7835,6 +8232,7 @@ function_with_argtypes: func_name func_args { ObjectWithArgs *n = makeNode(ObjectWithArgs); + n->objname = $1; n->objargs = extractArgTypes($2); n->objfuncargs = $2; @@ -7848,6 +8246,7 @@ function_with_argtypes: | type_func_name_keyword { ObjectWithArgs *n = makeNode(ObjectWithArgs); + n->objname = list_make1(makeString(pstrdup($1))); n->args_unspecified = true; $$ = n; @@ -7855,6 +8254,7 @@ function_with_argtypes: | ColId { ObjectWithArgs *n = makeNode(ObjectWithArgs); + n->objname = list_make1(makeString($1)); n->args_unspecified = true; $$ = n; @@ -7862,6 +8262,7 @@ function_with_argtypes: | ColId indirection { ObjectWithArgs *n = makeNode(ObjectWithArgs); + n->objname = check_func_name(lcons(makeString($1), $2), yyscanner); n->args_unspecified = true; @@ -7898,6 +8299,7 @@ func_arg: arg_class param_name func_type { FunctionParameter *n = makeNode(FunctionParameter); + n->name = $2; n->argType = $3; n->mode = $1; @@ -7907,6 +8309,7 @@ func_arg: | param_name arg_class func_type { FunctionParameter *n = makeNode(FunctionParameter); + n->name = $1; n->argType = $3; n->mode = $2; @@ -7916,6 +8319,7 @@ func_arg: | param_name func_type { FunctionParameter *n = makeNode(FunctionParameter); + n->name = $1; n->argType = $2; n->mode = FUNC_PARAM_DEFAULT; @@ -7925,6 +8329,7 @@ func_arg: | arg_class func_type { FunctionParameter *n = makeNode(FunctionParameter); + n->name = NULL; n->argType = $2; n->mode = $1; @@ -7934,6 +8339,7 @@ func_arg: | func_type { FunctionParameter *n = makeNode(FunctionParameter); + n->name = NULL; n->argType = $1; n->mode = FUNC_PARAM_DEFAULT; @@ -8076,6 +8482,7 @@ aggregate_with_argtypes: func_name aggr_args { ObjectWithArgs *n = makeNode(ObjectWithArgs); + n->objname = $1; n->objargs = extractAggrArgTypes($2); n->objfuncargs = (List *) linitial($2); @@ -8106,91 +8513,91 @@ createfunc_opt_list: common_func_opt_item: CALLED ON NULL_P INPUT_P { - $$ = makeDefElem("strict", (Node *)makeBoolean(false), @1); + $$ = makeDefElem("strict", (Node *) makeBoolean(false), @1); } | RETURNS NULL_P ON NULL_P INPUT_P { - $$ = makeDefElem("strict", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("strict", (Node *) makeBoolean(true), @1); } | STRICT_P { - $$ = makeDefElem("strict", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("strict", (Node *) makeBoolean(true), @1); } | IMMUTABLE { - $$ = makeDefElem("volatility", (Node *)makeString("immutable"), @1); + $$ = makeDefElem("volatility", (Node *) makeString("immutable"), @1); } | STABLE { - $$ = makeDefElem("volatility", (Node *)makeString("stable"), @1); + $$ = makeDefElem("volatility", (Node *) makeString("stable"), @1); } | VOLATILE { - $$ = makeDefElem("volatility", (Node *)makeString("volatile"), @1); + $$ = makeDefElem("volatility", (Node *) makeString("volatile"), @1); } | EXTERNAL SECURITY DEFINER { - $$ = makeDefElem("security", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("security", (Node *) makeBoolean(true), @1); } | EXTERNAL SECURITY INVOKER { - $$ = makeDefElem("security", (Node *)makeBoolean(false), @1); + $$ = makeDefElem("security", (Node *) makeBoolean(false), @1); } | SECURITY DEFINER { - $$ = makeDefElem("security", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("security", (Node *) makeBoolean(true), @1); } | SECURITY INVOKER { - $$ = makeDefElem("security", (Node *)makeBoolean(false), @1); + $$ = makeDefElem("security", (Node *) makeBoolean(false), @1); } | LEAKPROOF { - $$ = makeDefElem("leakproof", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("leakproof", (Node *) makeBoolean(true), @1); } | NOT LEAKPROOF { - $$ = makeDefElem("leakproof", (Node *)makeBoolean(false), @1); + $$ = makeDefElem("leakproof", (Node *) makeBoolean(false), @1); } | COST NumericOnly { - $$ = makeDefElem("cost", (Node *)$2, @1); + $$ = makeDefElem("cost", (Node *) $2, @1); } | ROWS NumericOnly { - $$ = makeDefElem("rows", (Node *)$2, @1); + $$ = makeDefElem("rows", (Node *) $2, @1); } | SUPPORT any_name { - $$ = makeDefElem("support", (Node *)$2, @1); + $$ = makeDefElem("support", (Node *) $2, @1); } | FunctionSetResetClause { /* we abuse the normal content of a DefElem here */ - $$ = makeDefElem("set", (Node *)$1, @1); + $$ = makeDefElem("set", (Node *) $1, @1); } | PARALLEL ColId { - $$ = makeDefElem("parallel", (Node *)makeString($2), @1); + $$ = makeDefElem("parallel", (Node *) makeString($2), @1); } ; createfunc_opt_item: AS func_as { - $$ = makeDefElem("as", (Node *)$2, @1); + $$ = makeDefElem("as", (Node *) $2, @1); } | LANGUAGE NonReservedWord_or_Sconst { - $$ = makeDefElem("language", (Node *)makeString($2), @1); + $$ = makeDefElem("language", (Node *) makeString($2), @1); } | TRANSFORM transform_type_list { - $$ = makeDefElem("transform", (Node *)$2, @1); + $$ = makeDefElem("transform", (Node *) $2, @1); } | WINDOW { - $$ = makeDefElem("window", (Node *)makeBoolean(true), @1); + $$ = makeDefElem("window", (Node *) makeBoolean(true), @1); } | common_func_opt_item { @@ -8208,6 +8615,7 @@ func_as: Sconst { $$ = list_make1(makeString($1)); } ReturnStmt: RETURN a_expr { ReturnStmt *r = makeNode(ReturnStmt); + r->returnval = (Node *) $2; $$ = (Node *) r; } @@ -8267,6 +8675,7 @@ opt_definition: table_func_column: param_name func_type { FunctionParameter *n = makeNode(FunctionParameter); + n->name = $1; n->argType = $2; n->mode = FUNC_PARAM_TABLE; @@ -8298,6 +8707,7 @@ AlterFunctionStmt: ALTER FUNCTION function_with_argtypes alterfunc_opt_list opt_restrict { AlterFunctionStmt *n = makeNode(AlterFunctionStmt); + n->objtype = OBJECT_FUNCTION; n->func = $3; n->actions = $4; @@ -8306,6 +8716,7 @@ AlterFunctionStmt: | ALTER PROCEDURE function_with_argtypes alterfunc_opt_list opt_restrict { AlterFunctionStmt *n = makeNode(AlterFunctionStmt); + n->objtype = OBJECT_PROCEDURE; n->func = $3; n->actions = $4; @@ -8314,6 +8725,7 @@ AlterFunctionStmt: | ALTER ROUTINE function_with_argtypes alterfunc_opt_list opt_restrict { AlterFunctionStmt *n = makeNode(AlterFunctionStmt); + n->objtype = OBJECT_ROUTINE; n->func = $3; n->actions = $4; @@ -8350,62 +8762,68 @@ RemoveFuncStmt: DROP FUNCTION function_with_argtypes_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_FUNCTION; n->objects = $3; n->behavior = $4; n->missing_ok = false; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP FUNCTION IF_P EXISTS function_with_argtypes_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_FUNCTION; n->objects = $5; n->behavior = $6; n->missing_ok = true; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP PROCEDURE function_with_argtypes_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_PROCEDURE; n->objects = $3; n->behavior = $4; n->missing_ok = false; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP PROCEDURE IF_P EXISTS function_with_argtypes_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_PROCEDURE; n->objects = $5; n->behavior = $6; n->missing_ok = true; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP ROUTINE function_with_argtypes_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_ROUTINE; n->objects = $3; n->behavior = $4; n->missing_ok = false; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP ROUTINE IF_P EXISTS function_with_argtypes_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_ROUTINE; n->objects = $5; n->behavior = $6; n->missing_ok = true; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -8413,22 +8831,24 @@ RemoveAggrStmt: DROP AGGREGATE aggregate_with_argtypes_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_AGGREGATE; n->objects = $3; n->behavior = $4; n->missing_ok = false; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_AGGREGATE; n->objects = $5; n->behavior = $6; n->missing_ok = true; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -8436,22 +8856,24 @@ RemoveOperStmt: DROP OPERATOR operator_with_argtypes_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_OPERATOR; n->objects = $3; n->behavior = $4; n->missing_ok = false; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP OPERATOR IF_P EXISTS operator_with_argtypes_list opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_OPERATOR; n->objects = $5; n->behavior = $6; n->missing_ok = true; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -8489,6 +8911,7 @@ operator_with_argtypes: any_operator oper_argtypes { ObjectWithArgs *n = makeNode(ObjectWithArgs); + n->objname = $1; n->objargs = $2; $$ = n; @@ -8507,8 +8930,9 @@ operator_with_argtypes: DoStmt: DO dostmt_opt_list { DoStmt *n = makeNode(DoStmt); + n->args = $2; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -8520,11 +8944,11 @@ dostmt_opt_list: dostmt_opt_item: Sconst { - $$ = makeDefElem("as", (Node *)makeString($1), @1); + $$ = makeDefElem("as", (Node *) makeString($1), @1); } | LANGUAGE NonReservedWord_or_Sconst { - $$ = makeDefElem("language", (Node *)makeString($2), @1); + $$ = makeDefElem("language", (Node *) makeString($2), @1); } ; @@ -8538,34 +8962,37 @@ CreateCastStmt: CREATE CAST '(' Typename AS Typename ')' WITH FUNCTION function_with_argtypes cast_context { CreateCastStmt *n = makeNode(CreateCastStmt); + n->sourcetype = $4; n->targettype = $6; n->func = $10; n->context = (CoercionContext) $11; n->inout = false; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE CAST '(' Typename AS Typename ')' WITHOUT FUNCTION cast_context { CreateCastStmt *n = makeNode(CreateCastStmt); + n->sourcetype = $4; n->targettype = $6; n->func = NULL; n->context = (CoercionContext) $10; n->inout = false; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE CAST '(' Typename AS Typename ')' WITH INOUT cast_context { CreateCastStmt *n = makeNode(CreateCastStmt); + n->sourcetype = $4; n->targettype = $6; n->func = NULL; n->context = (CoercionContext) $10; n->inout = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -8578,12 +9005,13 @@ cast_context: AS IMPLICIT_P { $$ = COERCION_IMPLICIT; } DropCastStmt: DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_CAST; n->objects = list_make1(list_make2($5, $7)); n->behavior = $9; n->missing_ok = $3; n->concurrent = false; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -8601,12 +9029,13 @@ opt_if_exists: IF_P EXISTS { $$ = true; } CreateTransformStmt: CREATE opt_or_replace TRANSFORM FOR Typename LANGUAGE name '(' transform_element_list ')' { CreateTransformStmt *n = makeNode(CreateTransformStmt); + n->replace = $2; n->type_name = $5; n->lang = $7; n->fromsql = linitial($9); n->tosql = lsecond($9); - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -8632,11 +9061,12 @@ transform_element_list: FROM SQL_P WITH FUNCTION function_with_argtypes ',' TO S DropTransformStmt: DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_drop_behavior { DropStmt *n = makeNode(DropStmt); + n->removeType = OBJECT_TRANSFORM; n->objects = list_make1(list_make2($5, makeString($7))); n->behavior = $8; n->missing_ok = $3; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -8652,50 +9082,54 @@ ReindexStmt: REINDEX reindex_target_type opt_concurrently qualified_name { ReindexStmt *n = makeNode(ReindexStmt); + n->kind = $2; n->relation = $4; n->name = NULL; n->params = NIL; if ($3) n->params = lappend(n->params, - makeDefElem("concurrently", NULL, @3)); - $$ = (Node *)n; + makeDefElem("concurrently", NULL, @3)); + $$ = (Node *) n; } | REINDEX reindex_target_multitable opt_concurrently name { ReindexStmt *n = makeNode(ReindexStmt); + n->kind = $2; n->name = $4; n->relation = NULL; n->params = NIL; if ($3) n->params = lappend(n->params, - makeDefElem("concurrently", NULL, @3)); - $$ = (Node *)n; + makeDefElem("concurrently", NULL, @3)); + $$ = (Node *) n; } | REINDEX '(' utility_option_list ')' reindex_target_type opt_concurrently qualified_name { ReindexStmt *n = makeNode(ReindexStmt); + n->kind = $5; n->relation = $7; n->name = NULL; n->params = $3; if ($6) n->params = lappend(n->params, - makeDefElem("concurrently", NULL, @6)); - $$ = (Node *)n; + makeDefElem("concurrently", NULL, @6)); + $$ = (Node *) n; } | REINDEX '(' utility_option_list ')' reindex_target_multitable opt_concurrently name { ReindexStmt *n = makeNode(ReindexStmt); + n->kind = $5; n->name = $7; n->relation = NULL; n->params = $3; if ($6) n->params = lappend(n->params, - makeDefElem("concurrently", NULL, @6)); - $$ = (Node *)n; + makeDefElem("concurrently", NULL, @6)); + $$ = (Node *) n; } ; reindex_target_type: @@ -8719,19 +9153,21 @@ AlterTblSpcStmt: { AlterTableSpaceOptionsStmt *n = makeNode(AlterTableSpaceOptionsStmt); + n->tablespacename = $3; n->options = $5; n->isReset = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLESPACE name RESET reloptions { AlterTableSpaceOptionsStmt *n = makeNode(AlterTableSpaceOptionsStmt); + n->tablespacename = $3; n->options = $5; n->isReset = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -8744,525 +9180,580 @@ AlterTblSpcStmt: RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_AGGREGATE; n->object = (Node *) $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER COLLATION any_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_COLLATION; n->object = (Node *) $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER CONVERSION_P any_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_CONVERSION; n->object = (Node *) $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER DATABASE name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_DATABASE; n->subname = $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER DOMAIN_P any_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_DOMAIN; n->object = (Node *) $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER DOMAIN_P any_name RENAME CONSTRAINT name TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_DOMCONSTRAINT; n->object = (Node *) $3; n->subname = $6; n->newname = $8; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FOREIGN DATA_P WRAPPER name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_FDW; n->object = (Node *) makeString($5); n->newname = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FUNCTION function_with_argtypes RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_FUNCTION; n->object = (Node *) $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER GROUP_P RoleId RENAME TO RoleId { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_ROLE; n->subname = $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER opt_procedural LANGUAGE name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_LANGUAGE; n->object = (Node *) makeString($4); n->newname = $7; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER OPERATOR CLASS any_name USING name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_OPCLASS; n->object = (Node *) lcons(makeString($6), $4); n->newname = $9; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER OPERATOR FAMILY any_name USING name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_OPFAMILY; n->object = (Node *) lcons(makeString($6), $4); n->newname = $9; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER POLICY name ON qualified_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_POLICY; n->relation = $5; n->subname = $3; n->newname = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER POLICY IF_P EXISTS name ON qualified_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_POLICY; n->relation = $7; n->subname = $5; n->newname = $10; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER PROCEDURE function_with_argtypes RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_PROCEDURE; n->object = (Node *) $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER PUBLICATION name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_PUBLICATION; n->object = (Node *) makeString($3); n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER ROUTINE function_with_argtypes RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_ROUTINE; n->object = (Node *) $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SCHEMA name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_SCHEMA; n->subname = $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SERVER name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_FOREIGN_SERVER; n->object = (Node *) makeString($3); n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SUBSCRIPTION name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_SUBSCRIPTION; n->object = (Node *) makeString($3); n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE relation_expr RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TABLE; n->relation = $3; n->subname = NULL; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE IF_P EXISTS relation_expr RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TABLE; n->relation = $5; n->subname = NULL; n->newname = $8; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SEQUENCE qualified_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_SEQUENCE; n->relation = $3; n->subname = NULL; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SEQUENCE IF_P EXISTS qualified_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_SEQUENCE; n->relation = $5; n->subname = NULL; n->newname = $8; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER VIEW qualified_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_VIEW; n->relation = $3; n->subname = NULL; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER VIEW IF_P EXISTS qualified_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_VIEW; n->relation = $5; n->subname = NULL; n->newname = $8; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER MATERIALIZED VIEW qualified_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_MATVIEW; n->relation = $4; n->subname = NULL; n->newname = $7; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_MATVIEW; n->relation = $6; n->subname = NULL; n->newname = $9; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER INDEX qualified_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_INDEX; n->relation = $3; n->subname = NULL; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER INDEX IF_P EXISTS qualified_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_INDEX; n->relation = $5; n->subname = NULL; n->newname = $8; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FOREIGN TABLE relation_expr RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_FOREIGN_TABLE; n->relation = $4; n->subname = NULL; n->newname = $7; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_FOREIGN_TABLE; n->relation = $6; n->subname = NULL; n->newname = $9; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE relation_expr RENAME opt_column name TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_COLUMN; n->relationType = OBJECT_TABLE; n->relation = $3; n->subname = $6; n->newname = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_COLUMN; n->relationType = OBJECT_TABLE; n->relation = $5; n->subname = $8; n->newname = $10; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER VIEW qualified_name RENAME opt_column name TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_COLUMN; n->relationType = OBJECT_VIEW; n->relation = $3; n->subname = $6; n->newname = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_COLUMN; n->relationType = OBJECT_VIEW; n->relation = $5; n->subname = $8; n->newname = $10; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER MATERIALIZED VIEW qualified_name RENAME opt_column name TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_COLUMN; n->relationType = OBJECT_MATVIEW; n->relation = $4; n->subname = $7; n->newname = $9; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_COLUMN; n->relationType = OBJECT_MATVIEW; n->relation = $6; n->subname = $9; n->newname = $11; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE relation_expr RENAME CONSTRAINT name TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TABCONSTRAINT; n->relation = $3; n->subname = $6; n->newname = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE IF_P EXISTS relation_expr RENAME CONSTRAINT name TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TABCONSTRAINT; n->relation = $5; n->subname = $8; n->newname = $10; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FOREIGN TABLE relation_expr RENAME opt_column name TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_COLUMN; n->relationType = OBJECT_FOREIGN_TABLE; n->relation = $4; n->subname = $7; n->newname = $9; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_COLUMN; n->relationType = OBJECT_FOREIGN_TABLE; n->relation = $6; n->subname = $9; n->newname = $11; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER RULE name ON qualified_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_RULE; n->relation = $5; n->subname = $3; n->newname = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TRIGGER name ON qualified_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TRIGGER; n->relation = $5; n->subname = $3; n->newname = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EVENT TRIGGER name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_EVENT_TRIGGER; n->object = (Node *) makeString($4); n->newname = $7; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER ROLE RoleId RENAME TO RoleId { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_ROLE; n->subname = $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER USER RoleId RENAME TO RoleId { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_ROLE; n->subname = $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLESPACE name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TABLESPACE; n->subname = $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER STATISTICS any_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_STATISTIC_EXT; n->object = (Node *) $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH PARSER any_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TSPARSER; n->object = (Node *) $5; n->newname = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH DICTIONARY any_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TSDICTIONARY; n->object = (Node *) $5; n->newname = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH TEMPLATE any_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TSTEMPLATE; n->object = (Node *) $5; n->newname = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TSCONFIGURATION; n->object = (Node *) $5; n->newname = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TYPE_P any_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TYPE; n->object = (Node *) $3; n->newname = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TYPE_P any_name RENAME ATTRIBUTE name TO name opt_drop_behavior { RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_ATTRIBUTE; n->relationType = OBJECT_TYPE; n->relation = makeRangeVarFromAnyName($3, @3, yyscanner); @@ -9270,7 +9761,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name n->newname = $8; n->behavior = $9; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -9292,57 +9783,63 @@ AlterObjectDependsStmt: ALTER FUNCTION function_with_argtypes opt_no DEPENDS ON EXTENSION name { AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt); + n->objectType = OBJECT_FUNCTION; n->object = (Node *) $3; n->extname = makeString($8); n->remove = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER PROCEDURE function_with_argtypes opt_no DEPENDS ON EXTENSION name { AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt); + n->objectType = OBJECT_PROCEDURE; n->object = (Node *) $3; n->extname = makeString($8); n->remove = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER ROUTINE function_with_argtypes opt_no DEPENDS ON EXTENSION name { AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt); + n->objectType = OBJECT_ROUTINE; n->object = (Node *) $3; n->extname = makeString($8); n->remove = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TRIGGER name ON qualified_name opt_no DEPENDS ON EXTENSION name { AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt); + n->objectType = OBJECT_TRIGGER; n->relation = $5; n->object = (Node *) list_make1(makeString($3)); n->extname = makeString($10); n->remove = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER MATERIALIZED VIEW qualified_name opt_no DEPENDS ON EXTENSION name { AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt); + n->objectType = OBJECT_MATVIEW; n->relation = $4; n->extname = makeString($9); n->remove = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER INDEX qualified_name opt_no DEPENDS ON EXTENSION name { AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt); + n->objectType = OBJECT_INDEX; n->relation = $3; n->extname = makeString($8); n->remove = $4; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -9360,245 +9857,272 @@ AlterObjectSchemaStmt: ALTER AGGREGATE aggregate_with_argtypes SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_AGGREGATE; n->object = (Node *) $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER COLLATION any_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_COLLATION; n->object = (Node *) $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER CONVERSION_P any_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_CONVERSION; n->object = (Node *) $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER DOMAIN_P any_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_DOMAIN; n->object = (Node *) $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EXTENSION name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_EXTENSION; n->object = (Node *) makeString($3); n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FUNCTION function_with_argtypes SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_FUNCTION; n->object = (Node *) $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER OPERATOR operator_with_argtypes SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_OPERATOR; n->object = (Node *) $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER OPERATOR CLASS any_name USING name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_OPCLASS; n->object = (Node *) lcons(makeString($6), $4); n->newschema = $9; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER OPERATOR FAMILY any_name USING name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_OPFAMILY; n->object = (Node *) lcons(makeString($6), $4); n->newschema = $9; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER PROCEDURE function_with_argtypes SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_PROCEDURE; n->object = (Node *) $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER ROUTINE function_with_argtypes SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_ROUTINE; n->object = (Node *) $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE relation_expr SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_TABLE; n->relation = $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLE IF_P EXISTS relation_expr SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_TABLE; n->relation = $5; n->newschema = $8; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER STATISTICS any_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_STATISTIC_EXT; n->object = (Node *) $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH PARSER any_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_TSPARSER; n->object = (Node *) $5; n->newschema = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH DICTIONARY any_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_TSDICTIONARY; n->object = (Node *) $5; n->newschema = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH TEMPLATE any_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_TSTEMPLATE; n->object = (Node *) $5; n->newschema = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH CONFIGURATION any_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_TSCONFIGURATION; n->object = (Node *) $5; n->newschema = $8; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SEQUENCE qualified_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_SEQUENCE; n->relation = $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SEQUENCE IF_P EXISTS qualified_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_SEQUENCE; n->relation = $5; n->newschema = $8; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER VIEW qualified_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_VIEW; n->relation = $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER VIEW IF_P EXISTS qualified_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_VIEW; n->relation = $5; n->newschema = $8; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER MATERIALIZED VIEW qualified_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_MATVIEW; n->relation = $4; n->newschema = $7; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_MATVIEW; n->relation = $6; n->newschema = $9; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FOREIGN TABLE relation_expr SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_FOREIGN_TABLE; n->relation = $4; n->newschema = $7; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FOREIGN TABLE IF_P EXISTS relation_expr SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_FOREIGN_TABLE; n->relation = $6; n->newschema = $9; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TYPE_P any_name SET SCHEMA name { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_TYPE; n->object = (Node *) $3; n->newschema = $6; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -9612,9 +10136,10 @@ AlterOperatorStmt: ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')' { AlterOperatorStmt *n = makeNode(AlterOperatorStmt); + n->opername = $3; n->options = $6; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -9630,11 +10155,11 @@ operator_def_elem: ColLabel '=' NONE /* must be similar enough to def_arg to avoid reduce/reduce conflicts */ operator_def_arg: - func_type { $$ = (Node *)$1; } - | reserved_keyword { $$ = (Node *)makeString(pstrdup($1)); } - | qual_all_Op { $$ = (Node *)$1; } - | NumericOnly { $$ = (Node *)$1; } - | Sconst { $$ = (Node *)makeString($1); } + func_type { $$ = (Node *) $1; } + | reserved_keyword { $$ = (Node *) makeString(pstrdup($1)); } + | qual_all_Op { $$ = (Node *) $1; } + | NumericOnly { $$ = (Node *) $1; } + | Sconst { $$ = (Node *) makeString($1); } ; /***************************************************************************** @@ -9649,9 +10174,10 @@ AlterTypeStmt: ALTER TYPE_P any_name SET '(' operator_def_list ')' { AlterTypeStmt *n = makeNode(AlterTypeStmt); + n->typeName = $3; n->options = $6; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -9664,194 +10190,218 @@ AlterTypeStmt: AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_AGGREGATE; n->object = (Node *) $3; n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER COLLATION any_name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_COLLATION; n->object = (Node *) $3; n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER CONVERSION_P any_name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_CONVERSION; n->object = (Node *) $3; n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER DATABASE name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_DATABASE; n->object = (Node *) makeString($3); n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER DOMAIN_P any_name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_DOMAIN; n->object = (Node *) $3; n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FUNCTION function_with_argtypes OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_FUNCTION; n->object = (Node *) $3; n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER opt_procedural LANGUAGE name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_LANGUAGE; n->object = (Node *) makeString($4); n->newowner = $7; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER LARGE_P OBJECT_P NumericOnly OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_LARGEOBJECT; n->object = (Node *) $4; n->newowner = $7; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER OPERATOR operator_with_argtypes OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_OPERATOR; n->object = (Node *) $3; n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER OPERATOR CLASS any_name USING name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_OPCLASS; n->object = (Node *) lcons(makeString($6), $4); n->newowner = $9; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER OPERATOR FAMILY any_name USING name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_OPFAMILY; n->object = (Node *) lcons(makeString($6), $4); n->newowner = $9; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER PROCEDURE function_with_argtypes OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_PROCEDURE; n->object = (Node *) $3; n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER ROUTINE function_with_argtypes OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_ROUTINE; n->object = (Node *) $3; n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SCHEMA name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_SCHEMA; n->object = (Node *) makeString($3); n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TYPE_P any_name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_TYPE; n->object = (Node *) $3; n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TABLESPACE name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_TABLESPACE; n->object = (Node *) makeString($3); n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER STATISTICS any_name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_STATISTIC_EXT; n->object = (Node *) $3; n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH DICTIONARY any_name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_TSDICTIONARY; n->object = (Node *) $5; n->newowner = $8; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH CONFIGURATION any_name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_TSCONFIGURATION; n->object = (Node *) $5; n->newowner = $8; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER FOREIGN DATA_P WRAPPER name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_FDW; n->object = (Node *) makeString($5); n->newowner = $8; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SERVER name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_FOREIGN_SERVER; n->object = (Node *) makeString($3); n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER EVENT TRIGGER name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_EVENT_TRIGGER; n->object = (Node *) makeString($4); n->newowner = $7; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER PUBLICATION name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_PUBLICATION; n->object = (Node *) makeString($3); n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SUBSCRIPTION name OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_SUBSCRIPTION; n->object = (Node *) makeString($3); n->newowner = $6; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -9875,26 +10425,29 @@ CreatePublicationStmt: CREATE PUBLICATION name opt_definition { CreatePublicationStmt *n = makeNode(CreatePublicationStmt); + n->pubname = $3; n->options = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE PUBLICATION name FOR ALL TABLES opt_definition { CreatePublicationStmt *n = makeNode(CreatePublicationStmt); + n->pubname = $3; n->options = $7; n->for_all_tables = true; - $$ = (Node *)n; + $$ = (Node *) n; } | CREATE PUBLICATION name FOR pub_obj_list opt_definition { CreatePublicationStmt *n = makeNode(CreatePublicationStmt); + n->pubname = $3; n->options = $6; - n->pubobjects = (List *)$5; + n->pubobjects = (List *) $5; preprocess_pubobj_list(n->pubobjects, yyscanner); - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -9989,7 +10542,7 @@ PublicationObjSpec: } ; -pub_obj_list: PublicationObjSpec +pub_obj_list: PublicationObjSpec { $$ = list_make1($1); } | pub_obj_list ',' PublicationObjSpec { $$ = lappend($1, $3); } @@ -10016,36 +10569,40 @@ AlterPublicationStmt: ALTER PUBLICATION name SET definition { AlterPublicationStmt *n = makeNode(AlterPublicationStmt); + n->pubname = $3; n->options = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER PUBLICATION name ADD_P pub_obj_list { AlterPublicationStmt *n = makeNode(AlterPublicationStmt); + n->pubname = $3; n->pubobjects = $5; preprocess_pubobj_list(n->pubobjects, yyscanner); n->action = AP_AddObjects; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER PUBLICATION name SET pub_obj_list { AlterPublicationStmt *n = makeNode(AlterPublicationStmt); + n->pubname = $3; n->pubobjects = $5; preprocess_pubobj_list(n->pubobjects, yyscanner); n->action = AP_SetObjects; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER PUBLICATION name DROP pub_obj_list { AlterPublicationStmt *n = makeNode(AlterPublicationStmt); + n->pubname = $3; n->pubobjects = $5; preprocess_pubobj_list(n->pubobjects, yyscanner); n->action = AP_DropObjects; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10064,7 +10621,7 @@ CreateSubscriptionStmt: n->conninfo = $5; n->publication = $7; n->options = $8; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10079,87 +10636,96 @@ AlterSubscriptionStmt: { AlterSubscriptionStmt *n = makeNode(AlterSubscriptionStmt); + n->kind = ALTER_SUBSCRIPTION_OPTIONS; n->subname = $3; n->options = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SUBSCRIPTION name CONNECTION Sconst { AlterSubscriptionStmt *n = makeNode(AlterSubscriptionStmt); + n->kind = ALTER_SUBSCRIPTION_CONNECTION; n->subname = $3; n->conninfo = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SUBSCRIPTION name REFRESH PUBLICATION opt_definition { AlterSubscriptionStmt *n = makeNode(AlterSubscriptionStmt); + n->kind = ALTER_SUBSCRIPTION_REFRESH; n->subname = $3; n->options = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SUBSCRIPTION name ADD_P PUBLICATION name_list opt_definition { AlterSubscriptionStmt *n = makeNode(AlterSubscriptionStmt); + n->kind = ALTER_SUBSCRIPTION_ADD_PUBLICATION; n->subname = $3; n->publication = $6; n->options = $7; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SUBSCRIPTION name DROP PUBLICATION name_list opt_definition { AlterSubscriptionStmt *n = makeNode(AlterSubscriptionStmt); + n->kind = ALTER_SUBSCRIPTION_DROP_PUBLICATION; n->subname = $3; n->publication = $6; n->options = $7; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SUBSCRIPTION name SET PUBLICATION name_list opt_definition { AlterSubscriptionStmt *n = makeNode(AlterSubscriptionStmt); + n->kind = ALTER_SUBSCRIPTION_SET_PUBLICATION; n->subname = $3; n->publication = $6; n->options = $7; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SUBSCRIPTION name ENABLE_P { AlterSubscriptionStmt *n = makeNode(AlterSubscriptionStmt); + n->kind = ALTER_SUBSCRIPTION_ENABLED; n->subname = $3; n->options = list_make1(makeDefElem("enabled", - (Node *)makeBoolean(true), @1)); - $$ = (Node *)n; + (Node *) makeBoolean(true), @1)); + $$ = (Node *) n; } | ALTER SUBSCRIPTION name DISABLE_P { AlterSubscriptionStmt *n = makeNode(AlterSubscriptionStmt); + n->kind = ALTER_SUBSCRIPTION_ENABLED; n->subname = $3; n->options = list_make1(makeDefElem("enabled", - (Node *)makeBoolean(false), @1)); - $$ = (Node *)n; + (Node *) makeBoolean(false), @1)); + $$ = (Node *) n; } | ALTER SUBSCRIPTION name SKIP definition { AlterSubscriptionStmt *n = makeNode(AlterSubscriptionStmt); + n->kind = ALTER_SUBSCRIPTION_SKIP; n->subname = $3; n->options = $5; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10172,6 +10738,7 @@ AlterSubscriptionStmt: DropSubscriptionStmt: DROP SUBSCRIPTION name opt_drop_behavior { DropSubscriptionStmt *n = makeNode(DropSubscriptionStmt); + n->subname = $3; n->missing_ok = false; n->behavior = $4; @@ -10180,6 +10747,7 @@ DropSubscriptionStmt: DROP SUBSCRIPTION name opt_drop_behavior | DROP SUBSCRIPTION IF_P EXISTS name opt_drop_behavior { DropSubscriptionStmt *n = makeNode(DropSubscriptionStmt); + n->subname = $5; n->missing_ok = true; n->behavior = $6; @@ -10197,7 +10765,8 @@ RuleStmt: CREATE opt_or_replace RULE name AS ON event TO qualified_name where_clause DO opt_instead RuleActionList { - RuleStmt *n = makeNode(RuleStmt); + RuleStmt *n = makeNode(RuleStmt); + n->replace = $2; n->relation = $9; n->rulename = $4; @@ -10205,7 +10774,7 @@ RuleStmt: CREATE opt_or_replace RULE name AS n->event = $7; n->instead = $12; n->actions = $13; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10268,9 +10837,10 @@ opt_instead: NotifyStmt: NOTIFY ColId notify_payload { NotifyStmt *n = makeNode(NotifyStmt); + n->conditionname = $2; n->payload = $3; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10282,8 +10852,9 @@ notify_payload: ListenStmt: LISTEN ColId { ListenStmt *n = makeNode(ListenStmt); + n->conditionname = $2; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10291,14 +10862,16 @@ UnlistenStmt: UNLISTEN ColId { UnlistenStmt *n = makeNode(UnlistenStmt); + n->conditionname = $2; - $$ = (Node *)n; + $$ = (Node *) n; } | UNLISTEN '*' { UnlistenStmt *n = makeNode(UnlistenStmt); + n->conditionname = NULL; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10316,89 +10889,101 @@ TransactionStmt: ABORT_P opt_transaction opt_transaction_chain { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK; n->options = NIL; n->chain = $3; - $$ = (Node *)n; + $$ = (Node *) n; } | START TRANSACTION transaction_mode_list_or_empty { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_START; n->options = $3; - $$ = (Node *)n; + $$ = (Node *) n; } | COMMIT opt_transaction opt_transaction_chain { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_COMMIT; n->options = NIL; n->chain = $3; - $$ = (Node *)n; + $$ = (Node *) n; } | ROLLBACK opt_transaction opt_transaction_chain { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK; n->options = NIL; n->chain = $3; - $$ = (Node *)n; + $$ = (Node *) n; } | SAVEPOINT ColId { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_SAVEPOINT; n->savepoint_name = $2; - $$ = (Node *)n; + $$ = (Node *) n; } | RELEASE SAVEPOINT ColId { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_RELEASE; n->savepoint_name = $3; - $$ = (Node *)n; + $$ = (Node *) n; } | RELEASE ColId { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_RELEASE; n->savepoint_name = $2; - $$ = (Node *)n; + $$ = (Node *) n; } | ROLLBACK opt_transaction TO SAVEPOINT ColId { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK_TO; n->savepoint_name = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | ROLLBACK opt_transaction TO ColId { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK_TO; n->savepoint_name = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | PREPARE TRANSACTION Sconst { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_PREPARE; n->gid = $3; - $$ = (Node *)n; + $$ = (Node *) n; } | COMMIT PREPARED Sconst { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_COMMIT_PREPARED; n->gid = $3; - $$ = (Node *)n; + $$ = (Node *) n; } | ROLLBACK PREPARED Sconst { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK_PREPARED; n->gid = $3; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10406,17 +10991,19 @@ TransactionStmtLegacy: BEGIN_P opt_transaction transaction_mode_list_or_empty { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_BEGIN; n->options = $3; - $$ = (Node *)n; + $$ = (Node *) n; } | END_P opt_transaction opt_transaction_chain { TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_COMMIT; n->options = NIL; n->chain = $3; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10477,7 +11064,8 @@ opt_transaction_chain: ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions AS SelectStmt opt_check_option { - ViewStmt *n = makeNode(ViewStmt); + ViewStmt *n = makeNode(ViewStmt); + n->view = $4; n->view->relpersistence = $2; n->aliases = $5; @@ -10490,7 +11078,8 @@ ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions | CREATE OR REPLACE OptTemp VIEW qualified_name opt_column_list opt_reloptions AS SelectStmt opt_check_option { - ViewStmt *n = makeNode(ViewStmt); + ViewStmt *n = makeNode(ViewStmt); + n->view = $6; n->view->relpersistence = $4; n->aliases = $7; @@ -10503,7 +11092,8 @@ ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions | CREATE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions AS SelectStmt opt_check_option { - ViewStmt *n = makeNode(ViewStmt); + ViewStmt *n = makeNode(ViewStmt); + n->view = $5; n->view->relpersistence = $2; n->aliases = $7; @@ -10521,7 +11111,8 @@ ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions | CREATE OR REPLACE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions AS SelectStmt opt_check_option { - ViewStmt *n = makeNode(ViewStmt); + ViewStmt *n = makeNode(ViewStmt); + n->view = $7; n->view->relpersistence = $4; n->aliases = $9; @@ -10554,9 +11145,10 @@ opt_check_option: LoadStmt: LOAD file_name { - LoadStmt *n = makeNode(LoadStmt); + LoadStmt *n = makeNode(LoadStmt); + n->filename = $2; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10571,9 +11163,10 @@ CreatedbStmt: CREATE DATABASE name opt_with createdb_opt_list { CreatedbStmt *n = makeNode(CreatedbStmt); + n->dbname = $3; n->options = $5; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10590,11 +11183,11 @@ createdb_opt_items: createdb_opt_item: createdb_opt_name opt_equal SignedIconst { - $$ = makeDefElem($1, (Node *)makeInteger($3), @1); + $$ = makeDefElem($1, (Node *) makeInteger($3), @1); } | createdb_opt_name opt_equal opt_boolean_or_string { - $$ = makeDefElem($1, (Node *)makeString($3), @1); + $$ = makeDefElem($1, (Node *) makeString($3), @1); } | createdb_opt_name opt_equal DEFAULT { @@ -10642,30 +11235,34 @@ AlterDatabaseStmt: ALTER DATABASE name WITH createdb_opt_list { AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt); + n->dbname = $3; n->options = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER DATABASE name createdb_opt_list { AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt); + n->dbname = $3; n->options = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER DATABASE name SET TABLESPACE name { AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt); + n->dbname = $3; n->options = list_make1(makeDefElem("tablespace", - (Node *)makeString($6), @6)); - $$ = (Node *)n; + (Node *) makeString($6), @6)); + $$ = (Node *) n; } | ALTER DATABASE name REFRESH COLLATION VERSION_P { AlterDatabaseRefreshCollStmt *n = makeNode(AlterDatabaseRefreshCollStmt); + n->dbname = $3; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10673,9 +11270,10 @@ AlterDatabaseSetStmt: ALTER DATABASE name SetResetClause { AlterDatabaseSetStmt *n = makeNode(AlterDatabaseSetStmt); + n->dbname = $3; n->setstmt = $4; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10690,34 +11288,38 @@ AlterDatabaseSetStmt: DropdbStmt: DROP DATABASE name { DropdbStmt *n = makeNode(DropdbStmt); + n->dbname = $3; n->missing_ok = false; n->options = NULL; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP DATABASE IF_P EXISTS name { DropdbStmt *n = makeNode(DropdbStmt); + n->dbname = $5; n->missing_ok = true; n->options = NULL; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP DATABASE name opt_with '(' drop_option_list ')' { DropdbStmt *n = makeNode(DropdbStmt); + n->dbname = $3; n->missing_ok = false; n->options = $6; - $$ = (Node *)n; + $$ = (Node *) n; } | DROP DATABASE IF_P EXISTS name opt_with '(' drop_option_list ')' { DropdbStmt *n = makeNode(DropdbStmt); + n->dbname = $5; n->missing_ok = true; n->options = $8; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10752,8 +11354,9 @@ drop_option: AlterCollationStmt: ALTER COLLATION any_name REFRESH VERSION_P { AlterCollationStmt *n = makeNode(AlterCollationStmt); + n->collname = $3; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10769,14 +11372,16 @@ AlterSystemStmt: ALTER SYSTEM_P SET generic_set { AlterSystemStmt *n = makeNode(AlterSystemStmt); + n->setstmt = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | ALTER SYSTEM_P RESET generic_reset { AlterSystemStmt *n = makeNode(AlterSystemStmt); + n->setstmt = $4; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10791,11 +11396,12 @@ CreateDomainStmt: CREATE DOMAIN_P any_name opt_as Typename ColQualList { CreateDomainStmt *n = makeNode(CreateDomainStmt); + n->domainname = $3; n->typeName = $5; SplitColQualList($6, &n->constraints, &n->collClause, yyscanner); - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10804,66 +11410,73 @@ AlterDomainStmt: ALTER DOMAIN_P any_name alter_column_default { AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'T'; n->typeName = $3; n->def = $4; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER DOMAIN DROP NOT NULL */ | ALTER DOMAIN_P any_name DROP NOT NULL_P { AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'N'; n->typeName = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER DOMAIN SET NOT NULL */ | ALTER DOMAIN_P any_name SET NOT NULL_P { AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'O'; n->typeName = $3; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER DOMAIN ADD CONSTRAINT ... */ | ALTER DOMAIN_P any_name ADD_P TableConstraint { AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'C'; n->typeName = $3; n->def = $5; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER DOMAIN DROP CONSTRAINT [RESTRICT|CASCADE] */ | ALTER DOMAIN_P any_name DROP CONSTRAINT name opt_drop_behavior { AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'X'; n->typeName = $3; n->name = $6; n->behavior = $7; n->missing_ok = false; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER DOMAIN DROP CONSTRAINT IF EXISTS [RESTRICT|CASCADE] */ | ALTER DOMAIN_P any_name DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior { AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'X'; n->typeName = $3; n->name = $8; n->behavior = $9; n->missing_ok = true; - $$ = (Node *)n; + $$ = (Node *) n; } /* ALTER DOMAIN VALIDATE CONSTRAINT */ | ALTER DOMAIN_P any_name VALIDATE CONSTRAINT name { AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'V'; n->typeName = $3; n->name = $6; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10882,9 +11495,10 @@ AlterTSDictionaryStmt: ALTER TEXT_P SEARCH DICTIONARY any_name definition { AlterTSDictionaryStmt *n = makeNode(AlterTSDictionaryStmt); + n->dictname = $5; n->options = $6; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10892,64 +11506,70 @@ AlterTSConfigurationStmt: ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with any_name_list { AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->kind = ALTER_TSCONFIG_ADD_MAPPING; n->cfgname = $5; n->tokentype = $9; n->dicts = $11; n->override = false; n->replace = false; - $$ = (Node*)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with any_name_list { AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->kind = ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN; n->cfgname = $5; n->tokentype = $9; n->dicts = $11; n->override = true; n->replace = false; - $$ = (Node*)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING REPLACE any_name any_with any_name { AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->kind = ALTER_TSCONFIG_REPLACE_DICT; n->cfgname = $5; n->tokentype = NIL; n->dicts = list_make2($9,$11); n->override = false; n->replace = true; - $$ = (Node*)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list REPLACE any_name any_with any_name { AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->kind = ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN; n->cfgname = $5; n->tokentype = $9; n->dicts = list_make2($11,$13); n->override = false; n->replace = true; - $$ = (Node*)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING FOR name_list { AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->kind = ALTER_TSCONFIG_DROP_MAPPING; n->cfgname = $5; n->tokentype = $9; n->missing_ok = false; - $$ = (Node*)n; + $$ = (Node *) n; } | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING IF_P EXISTS FOR name_list { AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->kind = ALTER_TSCONFIG_DROP_MAPPING; n->cfgname = $5; n->tokentype = $11; n->missing_ok = true; - $$ = (Node*)n; + $$ = (Node *) n; } ; @@ -10973,12 +11593,13 @@ CreateConversionStmt: TO Sconst FROM any_name { CreateConversionStmt *n = makeNode(CreateConversionStmt); + n->conversion_name = $4; n->for_encoding_name = $6; n->to_encoding_name = $8; n->func_name = $10; n->def = $2; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -10996,42 +11617,46 @@ ClusterStmt: CLUSTER opt_verbose qualified_name cluster_index_specification { ClusterStmt *n = makeNode(ClusterStmt); + n->relation = $3; n->indexname = $4; n->params = NIL; if ($2) n->params = lappend(n->params, makeDefElem("verbose", NULL, @2)); - $$ = (Node*)n; + $$ = (Node *) n; } | CLUSTER '(' utility_option_list ')' qualified_name cluster_index_specification { ClusterStmt *n = makeNode(ClusterStmt); + n->relation = $5; n->indexname = $6; n->params = $3; - $$ = (Node*)n; + $$ = (Node *) n; } | CLUSTER opt_verbose { ClusterStmt *n = makeNode(ClusterStmt); + n->relation = NULL; n->indexname = NULL; n->params = NIL; if ($2) n->params = lappend(n->params, makeDefElem("verbose", NULL, @2)); - $$ = (Node*)n; + $$ = (Node *) n; } /* kept for pre-8.3 compatibility */ | CLUSTER opt_verbose name ON qualified_name { ClusterStmt *n = makeNode(ClusterStmt); + n->relation = $5; n->indexname = $3; n->params = NIL; if ($2) n->params = lappend(n->params, makeDefElem("verbose", NULL, @2)); - $$ = (Node*)n; + $$ = (Node *) n; } ; @@ -11052,6 +11677,7 @@ cluster_index_specification: VacuumStmt: VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); + n->options = NIL; if ($2) n->options = lappend(n->options, @@ -11067,11 +11693,12 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relati makeDefElem("analyze", NULL, @5)); n->rels = $6; n->is_vacuumcmd = true; - $$ = (Node *)n; + $$ = (Node *) n; } | VACUUM '(' utility_option_list ')' opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); + n->options = $3; n->rels = $5; n->is_vacuumcmd = true; @@ -11082,17 +11709,19 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relati AnalyzeStmt: analyze_keyword opt_verbose opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); + n->options = NIL; if ($2) n->options = lappend(n->options, makeDefElem("verbose", NULL, @2)); n->rels = $3; n->is_vacuumcmd = false; - $$ = (Node *)n; + $$ = (Node *) n; } | analyze_keyword '(' utility_option_list ')' opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); + n->options = $3; n->rels = $5; n->is_vacuumcmd = false; @@ -11189,6 +11818,7 @@ ExplainStmt: EXPLAIN ExplainableStmt { ExplainStmt *n = makeNode(ExplainStmt); + n->query = $2; n->options = NIL; $$ = (Node *) n; @@ -11196,6 +11826,7 @@ ExplainStmt: | EXPLAIN analyze_keyword opt_verbose ExplainableStmt { ExplainStmt *n = makeNode(ExplainStmt); + n->query = $4; n->options = list_make1(makeDefElem("analyze", NULL, @2)); if ($3) @@ -11206,6 +11837,7 @@ ExplainStmt: | EXPLAIN VERBOSE ExplainableStmt { ExplainStmt *n = makeNode(ExplainStmt); + n->query = $3; n->options = list_make1(makeDefElem("verbose", NULL, @2)); $$ = (Node *) n; @@ -11213,6 +11845,7 @@ ExplainStmt: | EXPLAIN '(' utility_option_list ')' ExplainableStmt { ExplainStmt *n = makeNode(ExplainStmt); + n->query = $5; n->options = $3; $$ = (Node *) n; @@ -11242,6 +11875,7 @@ ExplainableStmt: PrepareStmt: PREPARE name prep_type_clause AS PreparableStmt { PrepareStmt *n = makeNode(PrepareStmt); + n->name = $2; n->argtypes = $3; n->query = $5; @@ -11271,6 +11905,7 @@ PreparableStmt: ExecuteStmt: EXECUTE name execute_param_clause { ExecuteStmt *n = makeNode(ExecuteStmt); + n->name = $2; n->params = $3; $$ = (Node *) n; @@ -11280,6 +11915,7 @@ ExecuteStmt: EXECUTE name execute_param_clause { CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt); ExecuteStmt *n = makeNode(ExecuteStmt); + n->name = $7; n->params = $8; ctas->query = (Node *) n; @@ -11297,6 +11933,7 @@ ExecuteStmt: EXECUTE name execute_param_clause { CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt); ExecuteStmt *n = makeNode(ExecuteStmt); + n->name = $10; n->params = $11; ctas->query = (Node *) n; @@ -11325,24 +11962,28 @@ execute_param_clause: '(' expr_list ')' { $$ = $2; } DeallocateStmt: DEALLOCATE name { DeallocateStmt *n = makeNode(DeallocateStmt); + n->name = $2; $$ = (Node *) n; } | DEALLOCATE PREPARE name { DeallocateStmt *n = makeNode(DeallocateStmt); + n->name = $3; $$ = (Node *) n; } | DEALLOCATE ALL { DeallocateStmt *n = makeNode(DeallocateStmt); + n->name = NULL; $$ = (Node *) n; } | DEALLOCATE PREPARE ALL { DeallocateStmt *n = makeNode(DeallocateStmt); + n->name = NULL; $$ = (Node *) n; } @@ -11510,12 +12151,13 @@ DeleteStmt: opt_with_clause DELETE_P FROM relation_expr_opt_alias using_clause where_or_current_clause returning_clause { DeleteStmt *n = makeNode(DeleteStmt); + n->relation = $4; n->usingClause = $5; n->whereClause = $6; n->returningList = $7; n->withClause = $1; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -11534,12 +12176,12 @@ using_clause: LockStmt: LOCK_P opt_table relation_expr_list opt_lock opt_nowait { - LockStmt *n = makeNode(LockStmt); + LockStmt *n = makeNode(LockStmt); n->relations = $3; n->mode = $4; n->nowait = $5; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -11582,13 +12224,14 @@ UpdateStmt: opt_with_clause UPDATE relation_expr_opt_alias returning_clause { UpdateStmt *n = makeNode(UpdateStmt); + n->relation = $3; n->targetList = $5; n->fromClause = $6; n->whereClause = $7; n->returningList = $8; n->withClause = $1; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -11605,14 +12248,14 @@ set_clause: } | '(' set_target_list ')' '=' a_expr { - int ncolumns = list_length($2); - int i = 1; - ListCell *col_cell; + int ncolumns = list_length($2); + int i = 1; + ListCell *col_cell; /* Create a MultiAssignRef source for each target */ foreach(col_cell, $2) { - ResTarget *res_col = (ResTarget *) lfirst(col_cell); + ResTarget *res_col = (ResTarget *) lfirst(col_cell); MultiAssignRef *r = makeNode(MultiAssignRef); r->source = (Node *) $5; @@ -11656,7 +12299,7 @@ MergeStmt: ON a_expr merge_when_list { - MergeStmt *m = makeNode(MergeStmt); + MergeStmt *m = makeNode(MergeStmt); m->withClause = $1; m->relation = $4; @@ -11664,7 +12307,7 @@ MergeStmt: m->joinCondition = $8; m->mergeWhenClauses = $9; - $$ = (Node *)m; + $$ = (Node *) m; } ; @@ -11703,7 +12346,7 @@ merge_when_clause: m->commandType = CMD_NOTHING; m->condition = $3; - $$ = (Node *)m; + $$ = (Node *) m; } | WHEN NOT MATCHED opt_merge_when_condition THEN DO NOTHING { @@ -11713,7 +12356,7 @@ merge_when_clause: m->commandType = CMD_NOTHING; m->condition = $4; - $$ = (Node *)m; + $$ = (Node *) m; } ; @@ -11812,11 +12455,12 @@ merge_values_clause: DeclareCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR SelectStmt { DeclareCursorStmt *n = makeNode(DeclareCursorStmt); + n->portalname = $2; /* currently we always set FAST_PLAN option */ n->options = $3 | $5 | CURSOR_OPT_FAST_PLAN; n->query = $7; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -11999,6 +12643,7 @@ simple_select: group_clause having_clause window_clause { SelectStmt *n = makeNode(SelectStmt); + n->targetList = $3; n->intoClause = $4; n->fromClause = $5; @@ -12007,13 +12652,14 @@ simple_select: n->groupDistinct = ($7)->distinct; n->havingClause = $8; n->windowClause = $9; - $$ = (Node *)n; + $$ = (Node *) n; } | SELECT distinct_clause target_list into_clause from_clause where_clause group_clause having_clause window_clause { SelectStmt *n = makeNode(SelectStmt); + n->distinctClause = $2; n->targetList = $3; n->intoClause = $4; @@ -12023,14 +12669,14 @@ simple_select: n->groupDistinct = ($7)->distinct; n->havingClause = $8; n->windowClause = $9; - $$ = (Node *)n; + $$ = (Node *) n; } | values_clause { $$ = $1; } | TABLE relation_expr { /* same as SELECT * FROM relation_expr */ - ColumnRef *cr = makeNode(ColumnRef); - ResTarget *rt = makeNode(ResTarget); + ColumnRef *cr = makeNode(ColumnRef); + ResTarget *rt = makeNode(ResTarget); SelectStmt *n = makeNode(SelectStmt); cr->fields = list_make1(makeNode(A_Star)); @@ -12038,12 +12684,12 @@ simple_select: rt->name = NULL; rt->indirection = NIL; - rt->val = (Node *)cr; + rt->val = (Node *) cr; rt->location = -1; n->targetList = list_make1(rt); n->fromClause = list_make1($2); - $$ = (Node *)n; + $$ = (Node *) n; } | select_clause UNION set_quantifier select_clause { @@ -12099,6 +12745,7 @@ cte_list: common_table_expr: name opt_name_list AS opt_materialized '(' PreparableStmt ')' opt_search_clause opt_cycle_clause { CommonTableExpr *n = makeNode(CommonTableExpr); + n->ctename = $1; n->aliascolnames = $2; n->ctematerialized = $4; @@ -12120,6 +12767,7 @@ opt_search_clause: SEARCH DEPTH FIRST_P BY columnList SET ColId { CTESearchClause *n = makeNode(CTESearchClause); + n->search_col_list = $5; n->search_breadth_first = false; n->search_seq_column = $7; @@ -12129,6 +12777,7 @@ opt_search_clause: | SEARCH BREADTH FIRST_P BY columnList SET ColId { CTESearchClause *n = makeNode(CTESearchClause); + n->search_col_list = $5; n->search_breadth_first = true; n->search_seq_column = $7; @@ -12145,6 +12794,7 @@ opt_cycle_clause: CYCLE columnList SET ColId TO AexprConst DEFAULT AexprConst USING ColId { CTECycleClause *n = makeNode(CTECycleClause); + n->cycle_col_list = $2; n->cycle_mark_column = $4; n->cycle_mark_value = $6; @@ -12156,6 +12806,7 @@ opt_cycle_clause: | CYCLE columnList SET ColId USING ColId { CTECycleClause *n = makeNode(CTECycleClause); + n->cycle_col_list = $2; n->cycle_mark_column = $4; n->cycle_mark_value = makeBoolAConst(true, -1); @@ -12330,6 +12981,7 @@ select_limit: | offset_clause { SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit)); + n->limitOffset = $1; n->limitCount = NULL; n->limitOption = LIMIT_OPTION_COUNT; @@ -12346,6 +12998,7 @@ limit_clause: LIMIT select_limit_value { SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit)); + n->limitOffset = NULL; n->limitCount = $2; n->limitOption = LIMIT_OPTION_COUNT; @@ -12370,6 +13023,7 @@ limit_clause: | FETCH first_or_next select_fetch_first_value row_or_rows ONLY { SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit)); + n->limitOffset = NULL; n->limitCount = $3; n->limitOption = LIMIT_OPTION_COUNT; @@ -12378,6 +13032,7 @@ limit_clause: | FETCH first_or_next select_fetch_first_value row_or_rows WITH TIES { SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit)); + n->limitOffset = NULL; n->limitCount = $3; n->limitOption = LIMIT_OPTION_WITH_TIES; @@ -12386,6 +13041,7 @@ limit_clause: | FETCH first_or_next row_or_rows ONLY { SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit)); + n->limitOffset = NULL; n->limitCount = makeIntConst(1, -1); n->limitOption = LIMIT_OPTION_COUNT; @@ -12394,6 +13050,7 @@ limit_clause: | FETCH first_or_next row_or_rows WITH TIES { SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit)); + n->limitOffset = NULL; n->limitCount = makeIntConst(1, -1); n->limitOption = LIMIT_OPTION_WITH_TIES; @@ -12485,6 +13142,7 @@ group_clause: GROUP_P BY set_quantifier group_by_list { GroupClause *n = (GroupClause *) palloc(sizeof(GroupClause)); + n->distinct = $3 == SET_QUANTIFIER_DISTINCT; n->list = $4; $$ = n; @@ -12492,6 +13150,7 @@ group_clause: | /*EMPTY*/ { GroupClause *n = (GroupClause *) palloc(sizeof(GroupClause)); + n->distinct = false; n->list = NIL; $$ = n; @@ -12569,6 +13228,7 @@ for_locking_item: for_locking_strength locked_rels_list opt_nowait_or_skip { LockingClause *n = makeNode(LockingClause); + n->lockedRels = $2; n->strength = $1; n->waitPolicy = $3; @@ -12598,12 +13258,14 @@ values_clause: VALUES '(' expr_list ')' { SelectStmt *n = makeNode(SelectStmt); + n->valuesLists = list_make1($3); $$ = (Node *) n; } | values_clause ',' '(' expr_list ')' { SelectStmt *n = (SelectStmt *) $1; + n->valuesLists = lappend(n->valuesLists, $4); $$ = (Node *) n; } @@ -12639,6 +13301,7 @@ table_ref: relation_expr opt_alias_clause | relation_expr opt_alias_clause tablesample_clause { RangeTableSample *n = (RangeTableSample *) $3; + $1->alias = $2; /* relation_expr goes inside the RangeTableSample node */ n->relation = (Node *) $1; @@ -12647,6 +13310,7 @@ table_ref: relation_expr opt_alias_clause | func_table func_alias_clause { RangeFunction *n = (RangeFunction *) $1; + n->alias = linitial($2); n->coldeflist = lsecond($2); $$ = (Node *) n; @@ -12654,6 +13318,7 @@ table_ref: relation_expr opt_alias_clause | LATERAL_P func_table func_alias_clause { RangeFunction *n = (RangeFunction *) $2; + n->lateral = true; n->alias = linitial($3); n->coldeflist = lsecond($3); @@ -12662,12 +13327,14 @@ table_ref: relation_expr opt_alias_clause | xmltable opt_alias_clause { RangeTableFunc *n = (RangeTableFunc *) $1; + n->alias = $2; $$ = (Node *) n; } | LATERAL_P xmltable opt_alias_clause { RangeTableFunc *n = (RangeTableFunc *) $2; + n->lateral = true; n->alias = $3; $$ = (Node *) n; @@ -12675,6 +13342,7 @@ table_ref: relation_expr opt_alias_clause | select_with_parens opt_alias_clause { RangeSubselect *n = makeNode(RangeSubselect); + n->lateral = false; n->subquery = $1; n->alias = $2; @@ -12710,6 +13378,7 @@ table_ref: relation_expr opt_alias_clause | LATERAL_P select_with_parens opt_alias_clause { RangeSubselect *n = makeNode(RangeSubselect); + n->lateral = true; n->subquery = $2; n->alias = $3; @@ -12743,13 +13412,15 @@ table_ref: relation_expr opt_alias_clause } | json_table opt_alias_clause { - JsonTable *jt = castNode(JsonTable, $1); + JsonTable *jt = castNode(JsonTable, $1); + jt->alias = $2; $$ = (Node *) jt; } | LATERAL_P json_table opt_alias_clause { - JsonTable *jt = castNode(JsonTable, $2); + JsonTable *jt = castNode(JsonTable, $2); + jt->alias = $3; jt->lateral = true; $$ = (Node *) jt; @@ -12782,7 +13453,8 @@ joined_table: | table_ref CROSS JOIN table_ref { /* CROSS JOIN is same as unqualified inner join */ - JoinExpr *n = makeNode(JoinExpr); + JoinExpr *n = makeNode(JoinExpr); + n->jointype = JOIN_INNER; n->isNatural = false; n->larg = $1; @@ -12794,7 +13466,8 @@ joined_table: } | table_ref join_type JOIN table_ref join_qual { - JoinExpr *n = makeNode(JoinExpr); + JoinExpr *n = makeNode(JoinExpr); + n->jointype = $2; n->isNatural = false; n->larg = $1; @@ -12815,7 +13488,8 @@ joined_table: | table_ref JOIN table_ref join_qual { /* letting join_type reduce to empty doesn't work */ - JoinExpr *n = makeNode(JoinExpr); + JoinExpr *n = makeNode(JoinExpr); + n->jointype = JOIN_INNER; n->isNatural = false; n->larg = $1; @@ -12835,7 +13509,8 @@ joined_table: } | table_ref NATURAL join_type JOIN table_ref { - JoinExpr *n = makeNode(JoinExpr); + JoinExpr *n = makeNode(JoinExpr); + n->jointype = $3; n->isNatural = true; n->larg = $1; @@ -12848,7 +13523,8 @@ joined_table: | table_ref NATURAL JOIN table_ref { /* letting join_type reduce to empty doesn't work */ - JoinExpr *n = makeNode(JoinExpr); + JoinExpr *n = makeNode(JoinExpr); + n->jointype = JOIN_INNER; n->isNatural = true; n->larg = $1; @@ -12920,13 +13596,15 @@ func_alias_clause: } | AS ColId '(' TableFuncElementList ')' { - Alias *a = makeNode(Alias); + Alias *a = makeNode(Alias); + a->aliasname = $2; $$ = list_make2(a, $4); } | ColId '(' TableFuncElementList ')' { - Alias *a = makeNode(Alias); + Alias *a = makeNode(Alias); + a->aliasname = $1; $$ = list_make2(a, $3); } @@ -13030,14 +13708,16 @@ relation_expr_opt_alias: relation_expr %prec UMINUS } | relation_expr ColId { - Alias *alias = makeNode(Alias); + Alias *alias = makeNode(Alias); + alias->aliasname = $2; $1->alias = alias; $$ = $1; } | relation_expr AS ColId { - Alias *alias = makeNode(Alias); + Alias *alias = makeNode(Alias); + alias->aliasname = $3; $1->alias = alias; $$ = $1; @@ -13051,6 +13731,7 @@ tablesample_clause: TABLESAMPLE func_name '(' expr_list ')' opt_repeatable_clause { RangeTableSample *n = makeNode(RangeTableSample); + /* n->relation will be filled in later */ n->method = $2; n->args = $4; @@ -13080,6 +13761,7 @@ opt_repeatable_clause: func_table: func_expr_windowless opt_ordinality { RangeFunction *n = makeNode(RangeFunction); + n->lateral = false; n->ordinality = $2; n->is_rowsfrom = false; @@ -13090,6 +13772,7 @@ func_table: func_expr_windowless opt_ordinality | ROWS FROM '(' rowsfrom_list ')' opt_ordinality { RangeFunction *n = makeNode(RangeFunction); + n->lateral = false; n->ordinality = $6; n->is_rowsfrom = true; @@ -13128,6 +13811,7 @@ where_or_current_clause: | WHERE CURRENT_P OF cursor_name { CurrentOfExpr *n = makeNode(CurrentOfExpr); + /* cvarno is filled in by parse analysis */ n->cursor_name = $4; n->cursor_param = 0; @@ -13156,6 +13840,7 @@ TableFuncElementList: TableFuncElement: ColId Typename opt_collate_clause { ColumnDef *n = makeNode(ColumnDef); + n->colname = $1; n->typeName = $2; n->inhcount = 0; @@ -13169,7 +13854,7 @@ TableFuncElement: ColId Typename opt_collate_clause n->collOid = InvalidOid; n->constraints = NIL; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -13180,23 +13865,25 @@ xmltable: XMLTABLE '(' c_expr xmlexists_argument COLUMNS xmltable_column_list ')' { RangeTableFunc *n = makeNode(RangeTableFunc); + n->rowexpr = $3; n->docexpr = $4; n->columns = $6; n->namespaces = NIL; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | XMLTABLE '(' XMLNAMESPACES '(' xml_namespace_list ')' ',' c_expr xmlexists_argument COLUMNS xmltable_column_list ')' { RangeTableFunc *n = makeNode(RangeTableFunc); + n->rowexpr = $8; n->docexpr = $9; n->columns = $11; n->namespaces = $5; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -13207,7 +13894,7 @@ xmltable_column_list: xmltable_column_el { $$ = list_make1($1); } xmltable_column_el: ColId Typename { - RangeTableFuncCol *fc = makeNode(RangeTableFuncCol); + RangeTableFuncCol *fc = makeNode(RangeTableFuncCol); fc->colname = $1; fc->for_ordinality = false; @@ -13221,9 +13908,9 @@ xmltable_column_el: } | ColId Typename xmltable_column_option_list { - RangeTableFuncCol *fc = makeNode(RangeTableFuncCol); - ListCell *option; - bool nullability_seen = false; + RangeTableFuncCol *fc = makeNode(RangeTableFuncCol); + ListCell *option; + bool nullability_seen = false; fc->colname = $1; fc->typeName = $2; @@ -13278,7 +13965,7 @@ xmltable_column_el: } | ColId FOR ORDINALITY { - RangeTableFuncCol *fc = makeNode(RangeTableFuncCol); + RangeTableFuncCol *fc = makeNode(RangeTableFuncCol); fc->colname = $1; fc->for_ordinality = true; @@ -13837,6 +14524,7 @@ a_expr: c_expr { $$ = $1; } | a_expr COLLATE any_name { CollateClause *n = makeNode(CollateClause); + n->arg = $1; n->collname = $3; n->location = @2; @@ -13908,10 +14596,10 @@ a_expr: c_expr { $$ = $1; } } | a_expr LIKE a_expr ESCAPE a_expr %prec LIKE { - FuncCall *n = makeFuncCall(SystemFuncName("like_escape"), - list_make2($3, $5), - COERCE_EXPLICIT_CALL, - @2); + FuncCall *n = makeFuncCall(SystemFuncName("like_escape"), + list_make2($3, $5), + COERCE_EXPLICIT_CALL, + @2); $$ = (Node *) makeSimpleA_Expr(AEXPR_LIKE, "~~", $1, (Node *) n, @2); } @@ -13922,10 +14610,10 @@ a_expr: c_expr { $$ = $1; } } | a_expr NOT_LA LIKE a_expr ESCAPE a_expr %prec NOT_LA { - FuncCall *n = makeFuncCall(SystemFuncName("like_escape"), - list_make2($4, $6), - COERCE_EXPLICIT_CALL, - @2); + FuncCall *n = makeFuncCall(SystemFuncName("like_escape"), + list_make2($4, $6), + COERCE_EXPLICIT_CALL, + @2); $$ = (Node *) makeSimpleA_Expr(AEXPR_LIKE, "!~~", $1, (Node *) n, @2); } @@ -13936,10 +14624,10 @@ a_expr: c_expr { $$ = $1; } } | a_expr ILIKE a_expr ESCAPE a_expr %prec ILIKE { - FuncCall *n = makeFuncCall(SystemFuncName("like_escape"), - list_make2($3, $5), - COERCE_EXPLICIT_CALL, - @2); + FuncCall *n = makeFuncCall(SystemFuncName("like_escape"), + list_make2($3, $5), + COERCE_EXPLICIT_CALL, + @2); $$ = (Node *) makeSimpleA_Expr(AEXPR_ILIKE, "~~*", $1, (Node *) n, @2); } @@ -13950,47 +14638,47 @@ a_expr: c_expr { $$ = $1; } } | a_expr NOT_LA ILIKE a_expr ESCAPE a_expr %prec NOT_LA { - FuncCall *n = makeFuncCall(SystemFuncName("like_escape"), - list_make2($4, $6), - COERCE_EXPLICIT_CALL, - @2); + FuncCall *n = makeFuncCall(SystemFuncName("like_escape"), + list_make2($4, $6), + COERCE_EXPLICIT_CALL, + @2); $$ = (Node *) makeSimpleA_Expr(AEXPR_ILIKE, "!~~*", $1, (Node *) n, @2); } | a_expr SIMILAR TO a_expr %prec SIMILAR { - FuncCall *n = makeFuncCall(SystemFuncName("similar_to_escape"), - list_make1($4), - COERCE_EXPLICIT_CALL, - @2); + FuncCall *n = makeFuncCall(SystemFuncName("similar_to_escape"), + list_make1($4), + COERCE_EXPLICIT_CALL, + @2); $$ = (Node *) makeSimpleA_Expr(AEXPR_SIMILAR, "~", $1, (Node *) n, @2); } | a_expr SIMILAR TO a_expr ESCAPE a_expr %prec SIMILAR { - FuncCall *n = makeFuncCall(SystemFuncName("similar_to_escape"), - list_make2($4, $6), - COERCE_EXPLICIT_CALL, - @2); + FuncCall *n = makeFuncCall(SystemFuncName("similar_to_escape"), + list_make2($4, $6), + COERCE_EXPLICIT_CALL, + @2); $$ = (Node *) makeSimpleA_Expr(AEXPR_SIMILAR, "~", $1, (Node *) n, @2); } | a_expr NOT_LA SIMILAR TO a_expr %prec NOT_LA { - FuncCall *n = makeFuncCall(SystemFuncName("similar_to_escape"), - list_make1($5), - COERCE_EXPLICIT_CALL, - @2); + FuncCall *n = makeFuncCall(SystemFuncName("similar_to_escape"), + list_make1($5), + COERCE_EXPLICIT_CALL, + @2); $$ = (Node *) makeSimpleA_Expr(AEXPR_SIMILAR, "!~", $1, (Node *) n, @2); } | a_expr NOT_LA SIMILAR TO a_expr ESCAPE a_expr %prec NOT_LA { - FuncCall *n = makeFuncCall(SystemFuncName("similar_to_escape"), - list_make2($5, $7), - COERCE_EXPLICIT_CALL, - @2); + FuncCall *n = makeFuncCall(SystemFuncName("similar_to_escape"), + list_make2($5, $7), + COERCE_EXPLICIT_CALL, + @2); $$ = (Node *) makeSimpleA_Expr(AEXPR_SIMILAR, "!~", $1, (Node *) n, @2); } @@ -14006,35 +14694,39 @@ a_expr: c_expr { $$ = $1; } */ | a_expr IS NULL_P %prec IS { - NullTest *n = makeNode(NullTest); + NullTest *n = makeNode(NullTest); + n->arg = (Expr *) $1; n->nulltesttype = IS_NULL; n->location = @2; - $$ = (Node *)n; + $$ = (Node *) n; } | a_expr ISNULL { - NullTest *n = makeNode(NullTest); + NullTest *n = makeNode(NullTest); + n->arg = (Expr *) $1; n->nulltesttype = IS_NULL; n->location = @2; - $$ = (Node *)n; + $$ = (Node *) n; } | a_expr IS NOT NULL_P %prec IS { - NullTest *n = makeNode(NullTest); + NullTest *n = makeNode(NullTest); + n->arg = (Expr *) $1; n->nulltesttype = IS_NOT_NULL; n->location = @2; - $$ = (Node *)n; + $$ = (Node *) n; } | a_expr NOTNULL { - NullTest *n = makeNode(NullTest); + NullTest *n = makeNode(NullTest); + n->arg = (Expr *) $1; n->nulltesttype = IS_NOT_NULL; n->location = @2; - $$ = (Node *)n; + $$ = (Node *) n; } | row OVERLAPS row { @@ -14056,50 +14748,56 @@ a_expr: c_expr { $$ = $1; } | a_expr IS TRUE_P %prec IS { BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) $1; b->booltesttype = IS_TRUE; b->location = @2; - $$ = (Node *)b; + $$ = (Node *) b; } | a_expr IS NOT TRUE_P %prec IS { BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) $1; b->booltesttype = IS_NOT_TRUE; b->location = @2; - $$ = (Node *)b; + $$ = (Node *) b; } | a_expr IS FALSE_P %prec IS { BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) $1; b->booltesttype = IS_FALSE; b->location = @2; - $$ = (Node *)b; + $$ = (Node *) b; } | a_expr IS NOT FALSE_P %prec IS { BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) $1; b->booltesttype = IS_NOT_FALSE; b->location = @2; - $$ = (Node *)b; + $$ = (Node *) b; } | a_expr IS UNKNOWN %prec IS { BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) $1; b->booltesttype = IS_UNKNOWN; b->location = @2; - $$ = (Node *)b; + $$ = (Node *) b; } | a_expr IS NOT UNKNOWN %prec IS { BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) $1; b->booltesttype = IS_NOT_UNKNOWN; b->location = @2; - $$ = (Node *)b; + $$ = (Node *) b; } | a_expr IS DISTINCT FROM a_expr %prec IS { @@ -14147,13 +14845,14 @@ a_expr: c_expr { $$ = $1; } if (IsA($3, SubLink)) { /* generate foo = ANY (subquery) */ - SubLink *n = (SubLink *) $3; + SubLink *n = (SubLink *) $3; + n->subLinkType = ANY_SUBLINK; n->subLinkId = 0; n->testexpr = $1; n->operName = NIL; /* show it's IN not = ANY */ n->location = @2; - $$ = (Node *)n; + $$ = (Node *) n; } else { @@ -14168,7 +14867,8 @@ a_expr: c_expr { $$ = $1; } { /* generate NOT (foo = ANY (subquery)) */ /* Make an = ANY node */ - SubLink *n = (SubLink *) $4; + SubLink *n = (SubLink *) $4; + n->subLinkType = ANY_SUBLINK; n->subLinkId = 0; n->testexpr = $1; @@ -14185,14 +14885,15 @@ a_expr: c_expr { $$ = $1; } } | a_expr subquery_Op sub_type select_with_parens %prec Op { - SubLink *n = makeNode(SubLink); + SubLink *n = makeNode(SubLink); + n->subLinkType = $3; n->subLinkId = 0; n->testexpr = $1; n->operName = $2; n->subselect = $4; n->location = @2; - $$ = (Node *)n; + $$ = (Node *) n; } | a_expr subquery_Op sub_type '(' a_expr ')' %prec Op { @@ -14283,6 +14984,7 @@ a_expr: c_expr { $$ = $1; } json_key_uniqueness_constraint_opt %prec IS { JsonFormat *format = makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1); + $$ = makeNotExpr(makeJsonIsPredicate($1, format, $4, $5, @1), @1); } /* @@ -14308,9 +15010,10 @@ a_expr: c_expr { $$ = $1; } * lets us say something smarter than "syntax error". */ SetToDefault *n = makeNode(SetToDefault); + /* parse analysis will fill in the rest */ n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -14411,12 +15114,14 @@ c_expr: columnref { $$ = $1; } | AexprConst { $$ = $1; } | PARAM opt_indirection { - ParamRef *p = makeNode(ParamRef); + ParamRef *p = makeNode(ParamRef); + p->number = $1; p->location = @1; if ($2) { A_Indirection *n = makeNode(A_Indirection); + n->arg = (Node *) p; n->indirection = check_indirection($2, yyscanner); $$ = (Node *) n; @@ -14429,9 +15134,10 @@ c_expr: columnref { $$ = $1; } if ($4) { A_Indirection *n = makeNode(A_Indirection); + n->arg = $2; n->indirection = check_indirection($4, yyscanner); - $$ = (Node *)n; + $$ = (Node *) n; } else $$ = $2; @@ -14442,14 +15148,15 @@ c_expr: columnref { $$ = $1; } { $$ = $1; } | select_with_parens %prec UMINUS { - SubLink *n = makeNode(SubLink); + SubLink *n = makeNode(SubLink); + n->subLinkType = EXPR_SUBLINK; n->subLinkId = 0; n->testexpr = NULL; n->operName = NIL; n->subselect = $1; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | select_with_parens indirection { @@ -14463,73 +15170,80 @@ c_expr: columnref { $$ = $1; } * subscripting or field selection to a sub-SELECT result, * we need this redundant-looking production. */ - SubLink *n = makeNode(SubLink); + SubLink *n = makeNode(SubLink); A_Indirection *a = makeNode(A_Indirection); + n->subLinkType = EXPR_SUBLINK; n->subLinkId = 0; n->testexpr = NULL; n->operName = NIL; n->subselect = $1; n->location = @1; - a->arg = (Node *)n; + a->arg = (Node *) n; a->indirection = check_indirection($2, yyscanner); - $$ = (Node *)a; + $$ = (Node *) a; } | EXISTS select_with_parens { - SubLink *n = makeNode(SubLink); + SubLink *n = makeNode(SubLink); + n->subLinkType = EXISTS_SUBLINK; n->subLinkId = 0; n->testexpr = NULL; n->operName = NIL; n->subselect = $2; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | ARRAY select_with_parens { - SubLink *n = makeNode(SubLink); + SubLink *n = makeNode(SubLink); + n->subLinkType = ARRAY_SUBLINK; n->subLinkId = 0; n->testexpr = NULL; n->operName = NIL; n->subselect = $2; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | ARRAY array_expr { A_ArrayExpr *n = castNode(A_ArrayExpr, $2); + /* point outermost A_ArrayExpr to the ARRAY keyword */ n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | explicit_row { - RowExpr *r = makeNode(RowExpr); + RowExpr *r = makeNode(RowExpr); + r->args = $1; r->row_typeid = InvalidOid; /* not analyzed yet */ r->colnames = NIL; /* to be filled in during analysis */ r->row_format = COERCE_EXPLICIT_CALL; /* abuse */ r->location = @1; - $$ = (Node *)r; + $$ = (Node *) r; } | implicit_row { - RowExpr *r = makeNode(RowExpr); + RowExpr *r = makeNode(RowExpr); + r->args = $1; r->row_typeid = InvalidOid; /* not analyzed yet */ r->colnames = NIL; /* to be filled in during analysis */ r->row_format = COERCE_IMPLICIT_CAST; /* abuse */ r->location = @1; - $$ = (Node *)r; + $$ = (Node *) r; } | GROUPING '(' expr_list ')' { GroupingFunc *g = makeNode(GroupingFunc); + g->args = $3; g->location = @1; - $$ = (Node *)g; + $$ = (Node *) g; } ; @@ -14541,50 +15255,55 @@ func_application: func_name '(' ')' } | func_name '(' func_arg_list opt_sort_clause ')' { - FuncCall *n = makeFuncCall($1, $3, - COERCE_EXPLICIT_CALL, - @1); + FuncCall *n = makeFuncCall($1, $3, + COERCE_EXPLICIT_CALL, + @1); + n->agg_order = $4; - $$ = (Node *)n; + $$ = (Node *) n; } | func_name '(' VARIADIC func_arg_expr opt_sort_clause ')' { - FuncCall *n = makeFuncCall($1, list_make1($4), - COERCE_EXPLICIT_CALL, - @1); + FuncCall *n = makeFuncCall($1, list_make1($4), + COERCE_EXPLICIT_CALL, + @1); + n->func_variadic = true; n->agg_order = $5; - $$ = (Node *)n; + $$ = (Node *) n; } | func_name '(' func_arg_list ',' VARIADIC func_arg_expr opt_sort_clause ')' { - FuncCall *n = makeFuncCall($1, lappend($3, $6), - COERCE_EXPLICIT_CALL, - @1); + FuncCall *n = makeFuncCall($1, lappend($3, $6), + COERCE_EXPLICIT_CALL, + @1); + n->func_variadic = true; n->agg_order = $7; - $$ = (Node *)n; + $$ = (Node *) n; } | func_name '(' ALL func_arg_list opt_sort_clause ')' { - FuncCall *n = makeFuncCall($1, $4, - COERCE_EXPLICIT_CALL, - @1); + FuncCall *n = makeFuncCall($1, $4, + COERCE_EXPLICIT_CALL, + @1); + n->agg_order = $5; /* Ideally we'd mark the FuncCall node to indicate * "must be an aggregate", but there's no provision * for that in FuncCall at the moment. */ - $$ = (Node *)n; + $$ = (Node *) n; } | func_name '(' DISTINCT func_arg_list opt_sort_clause ')' { - FuncCall *n = makeFuncCall($1, $4, - COERCE_EXPLICIT_CALL, - @1); + FuncCall *n = makeFuncCall($1, $4, + COERCE_EXPLICIT_CALL, + @1); + n->agg_order = $5; n->agg_distinct = true; - $$ = (Node *)n; + $$ = (Node *) n; } | func_name '(' '*' ')' { @@ -14598,11 +15317,12 @@ func_application: func_name '(' ')' * so that later processing can detect what the argument * really was. */ - FuncCall *n = makeFuncCall($1, NIL, - COERCE_EXPLICIT_CALL, - @1); + FuncCall *n = makeFuncCall($1, NIL, + COERCE_EXPLICIT_CALL, + @1); + n->agg_star = true; - $$ = (Node *)n; + $$ = (Node *) n; } ; @@ -14618,7 +15338,8 @@ func_application: func_name '(' ')' */ func_expr: func_application within_group_clause filter_clause over_clause { - FuncCall *n = (FuncCall *) $1; + FuncCall *n = (FuncCall *) $1; + /* * The order clause for WITHIN GROUP and the one for * plain-aggregate ORDER BY share a field, so we have to @@ -14656,6 +15377,7 @@ func_expr: func_application within_group_clause filter_clause over_clause JsonAggConstructor *n = IsA($1, JsonObjectAgg) ? ((JsonObjectAgg *) $1)->constructor : ((JsonArrayAgg *) $1)->constructor; + n->agg_filter = $2; n->over = $3; $$ = (Node *) $1; @@ -14877,25 +15599,28 @@ func_expr_common_subexpr: | COALESCE '(' expr_list ')' { CoalesceExpr *c = makeNode(CoalesceExpr); + c->args = $3; c->location = @1; - $$ = (Node *)c; + $$ = (Node *) c; } | GREATEST '(' expr_list ')' { MinMaxExpr *v = makeNode(MinMaxExpr); + v->args = $3; v->op = IS_GREATEST; v->location = @1; - $$ = (Node *)v; + $$ = (Node *) v; } | LEAST '(' expr_list ')' { MinMaxExpr *v = makeNode(MinMaxExpr); + v->args = $3; v->op = IS_LEAST; v->location = @1; - $$ = (Node *)v; + $$ = (Node *) v; } | XMLCONCAT '(' expr_list ')' { @@ -14936,8 +15661,9 @@ func_expr_common_subexpr: makeXmlExpr(IS_XMLPARSE, NULL, NIL, list_make2($4, makeBoolAConst($5, -1)), @1); + x->xmloption = $3; - $$ = (Node *)x; + $$ = (Node *) x; } | XMLPI '(' NAME_P ColLabel ')' { @@ -14955,11 +15681,12 @@ func_expr_common_subexpr: | XMLSERIALIZE '(' document_or_content a_expr AS SimpleTypename ')' { XmlSerialize *n = makeNode(XmlSerialize); + n->xmloption = $3; n->expr = $4; n->typeName = $6; n->location = @1; - $$ = (Node *)n; + $$ = (Node *) n; } | json_func_expr { $$ = $1; } @@ -15075,7 +15802,8 @@ window_definition_list: window_definition: ColId AS window_specification { - WindowDef *n = $3; + WindowDef *n = $3; + n->name = $1; $$ = n; } @@ -15085,7 +15813,8 @@ over_clause: OVER window_specification { $$ = $2; } | OVER ColId { - WindowDef *n = makeNode(WindowDef); + WindowDef *n = makeNode(WindowDef); + n->name = $2; n->refname = NULL; n->partitionClause = NIL; @@ -15103,7 +15832,8 @@ over_clause: OVER window_specification window_specification: '(' opt_existing_window_name opt_partition_clause opt_sort_clause opt_frame_clause ')' { - WindowDef *n = makeNode(WindowDef); + WindowDef *n = makeNode(WindowDef); + n->name = NULL; n->refname = $2; n->partitionClause = $3; @@ -15142,28 +15872,32 @@ opt_partition_clause: PARTITION BY expr_list { $$ = $3; } opt_frame_clause: RANGE frame_extent opt_window_exclusion_clause { - WindowDef *n = $2; + WindowDef *n = $2; + n->frameOptions |= FRAMEOPTION_NONDEFAULT | FRAMEOPTION_RANGE; n->frameOptions |= $3; $$ = n; } | ROWS frame_extent opt_window_exclusion_clause { - WindowDef *n = $2; + WindowDef *n = $2; + n->frameOptions |= FRAMEOPTION_NONDEFAULT | FRAMEOPTION_ROWS; n->frameOptions |= $3; $$ = n; } | GROUPS frame_extent opt_window_exclusion_clause { - WindowDef *n = $2; + WindowDef *n = $2; + n->frameOptions |= FRAMEOPTION_NONDEFAULT | FRAMEOPTION_GROUPS; n->frameOptions |= $3; $$ = n; } | /*EMPTY*/ { - WindowDef *n = makeNode(WindowDef); + WindowDef *n = makeNode(WindowDef); + n->frameOptions = FRAMEOPTION_DEFAULTS; n->startOffset = NULL; n->endOffset = NULL; @@ -15173,7 +15907,8 @@ opt_frame_clause: frame_extent: frame_bound { - WindowDef *n = $1; + WindowDef *n = $1; + /* reject invalid cases */ if (n->frameOptions & FRAMEOPTION_START_UNBOUNDED_FOLLOWING) ereport(ERROR, @@ -15190,8 +15925,9 @@ frame_extent: frame_bound } | BETWEEN frame_bound AND frame_bound { - WindowDef *n1 = $2; - WindowDef *n2 = $4; + WindowDef *n1 = $2; + WindowDef *n2 = $4; + /* form merged options */ int frameOptions = n1->frameOptions; /* shift converts START_ options to END_ options */ @@ -15235,7 +15971,8 @@ frame_extent: frame_bound frame_bound: UNBOUNDED PRECEDING { - WindowDef *n = makeNode(WindowDef); + WindowDef *n = makeNode(WindowDef); + n->frameOptions = FRAMEOPTION_START_UNBOUNDED_PRECEDING; n->startOffset = NULL; n->endOffset = NULL; @@ -15243,7 +15980,8 @@ frame_bound: } | UNBOUNDED FOLLOWING { - WindowDef *n = makeNode(WindowDef); + WindowDef *n = makeNode(WindowDef); + n->frameOptions = FRAMEOPTION_START_UNBOUNDED_FOLLOWING; n->startOffset = NULL; n->endOffset = NULL; @@ -15251,7 +15989,8 @@ frame_bound: } | CURRENT_P ROW { - WindowDef *n = makeNode(WindowDef); + WindowDef *n = makeNode(WindowDef); + n->frameOptions = FRAMEOPTION_START_CURRENT_ROW; n->startOffset = NULL; n->endOffset = NULL; @@ -15259,7 +15998,8 @@ frame_bound: } | a_expr PRECEDING { - WindowDef *n = makeNode(WindowDef); + WindowDef *n = makeNode(WindowDef); + n->frameOptions = FRAMEOPTION_START_OFFSET_PRECEDING; n->startOffset = $1; n->endOffset = NULL; @@ -15267,7 +16007,8 @@ frame_bound: } | a_expr FOLLOWING { - WindowDef *n = makeNode(WindowDef); + WindowDef *n = makeNode(WindowDef); + n->frameOptions = FRAMEOPTION_START_OFFSET_FOLLOWING; n->startOffset = $1; n->endOffset = NULL; @@ -15393,6 +16134,7 @@ func_arg_expr: a_expr | param_name COLON_EQUALS a_expr { NamedArgExpr *na = makeNode(NamedArgExpr); + na->name = $1; na->arg = (Expr *) $3; na->argnumber = -1; /* until determined */ @@ -15402,6 +16144,7 @@ func_arg_expr: a_expr | param_name EQUALS_GREATER a_expr { NamedArgExpr *na = makeNode(NamedArgExpr); + na->name = $1; na->arg = (Expr *) $3; na->argnumber = -1; /* until determined */ @@ -15552,12 +16295,13 @@ trim_list: a_expr FROM expr_list { $$ = lappend($3, $1); } in_expr: select_with_parens { - SubLink *n = makeNode(SubLink); + SubLink *n = makeNode(SubLink); + n->subselect = $1; /* other fields will be filled later */ - $$ = (Node *)n; + $$ = (Node *) n; } - | '(' expr_list ')' { $$ = (Node *)$2; } + | '(' expr_list ')' { $$ = (Node *) $2; } ; /* @@ -15569,13 +16313,14 @@ in_expr: select_with_parens */ case_expr: CASE case_arg when_clause_list case_default END_P { - CaseExpr *c = makeNode(CaseExpr); + CaseExpr *c = makeNode(CaseExpr); + c->casetype = InvalidOid; /* not analyzed yet */ c->arg = (Expr *) $2; c->args = $3; c->defresult = (Expr *) $4; c->location = @1; - $$ = (Node *)c; + $$ = (Node *) c; } ; @@ -15588,11 +16333,12 @@ when_clause_list: when_clause: WHEN a_expr THEN a_expr { - CaseWhen *w = makeNode(CaseWhen); + CaseWhen *w = makeNode(CaseWhen); + w->expr = (Expr *) $2; w->result = (Expr *) $4; w->location = @1; - $$ = (Node *)w; + $$ = (Node *) w; } ; @@ -15627,6 +16373,7 @@ indirection_el: | '[' a_expr ']' { A_Indices *ai = makeNode(A_Indices); + ai->is_slice = false; ai->lidx = NULL; ai->uidx = $2; @@ -15635,6 +16382,7 @@ indirection_el: | '[' opt_slice_bound ':' opt_slice_bound ']' { A_Indices *ai = makeNode(A_Indices); + ai->is_slice = true; ai->lidx = $2; ai->uidx = $4; @@ -15677,6 +16425,7 @@ json_parse_expr: json_returning_clause_opt ')' { JsonParseExpr *n = makeNode(JsonParseExpr); + n->expr = (JsonValueExpr *) $3; n->unique_keys = $4; n->output = (JsonOutput *) $5; @@ -15689,6 +16438,7 @@ json_scalar_expr: JSON_SCALAR '(' a_expr json_returning_clause_opt ')' { JsonScalarExpr *n = makeNode(JsonScalarExpr); + n->expr = (Expr *) $3; n->output = (JsonOutput *) $4; n->location = @1; @@ -15700,6 +16450,7 @@ json_serialize_expr: JSON_SERIALIZE '(' json_value_expr json_output_clause_opt ')' { JsonSerializeExpr *n = makeNode(JsonSerializeExpr); + n->expr = (JsonValueExpr *) $3; n->output = (JsonOutput *) $4; n->location = @1; @@ -15715,6 +16466,7 @@ json_value_func_expr: ')' { JsonFuncExpr *n = makeNode(JsonFuncExpr); + n->op = JSON_VALUE_OP; n->common = (JsonCommon *) $3; n->output = (JsonOutput *) $4; @@ -15731,6 +16483,7 @@ json_api_common_syntax: json_passing_clause_opt { JsonCommon *n = makeNode(JsonCommon); + n->expr = (JsonValueExpr *) $1; n->pathspec = $3; n->pathname = $4; @@ -15771,6 +16524,7 @@ json_argument: json_value_expr AS ColLabel { JsonArgument *n = makeNode(JsonArgument); + n->val = (JsonValueExpr *) $1; n->name = $3; $$ = (Node *) n; @@ -15840,7 +16594,7 @@ json_behavior_empty: json_behavior_empty_array: EMPTY_P ARRAY { $$ = makeJsonBehavior(JSON_BEHAVIOR_EMPTY_ARRAY, NULL); } /* non-standard, for Oracle compatibility only */ - | EMPTY_P { $$ = makeJsonBehavior(JSON_BEHAVIOR_EMPTY_ARRAY, NULL); } + | EMPTY_P { $$ = makeJsonBehavior(JSON_BEHAVIOR_EMPTY_ARRAY, NULL); } ; json_behavior_empty_object: @@ -15879,6 +16633,7 @@ json_query_expr: ')' { JsonFuncExpr *n = makeNode(JsonFuncExpr); + n->op = JSON_QUERY_OP; n->common = (JsonCommon *) $3; n->output = (JsonOutput *) $4; @@ -15960,6 +16715,7 @@ json_table: ')' { JsonTable *n = makeNode(JsonTable); + n->common = (JsonCommon *) $3; n->columns = $4; n->plan = (JsonTablePlan *) $5; @@ -15982,7 +16738,7 @@ json_table_column_definition_list: json_table_column_definition: json_table_ordinality_column_definition %prec json_table_column - | json_table_regular_column_definition %prec json_table_column + | json_table_regular_column_definition %prec json_table_column | json_table_formatted_column_definition %prec json_table_column | json_table_exists_column_definition %prec json_table_column | json_table_nested_columns @@ -15992,6 +16748,7 @@ json_table_ordinality_column_definition: ColId FOR ORDINALITY { JsonTableColumn *n = makeNode(JsonTableColumn); + n->coltype = JTC_FOR_ORDINALITY; n->name = $1; n->location = @1; @@ -16007,6 +16764,7 @@ json_table_regular_column_definition: json_value_on_behavior_clause_opt { JsonTableColumn *n = makeNode(JsonTableColumn); + n->coltype = JTC_REGULAR; n->name = $1; n->typeName = $2; @@ -16027,6 +16785,7 @@ json_table_exists_column_definition: json_exists_error_clause_opt { JsonTableColumn *n = makeNode(JsonTableColumn); + n->coltype = JTC_EXISTS; n->name = $1; n->typeName = $2; @@ -16064,6 +16823,7 @@ json_table_formatted_column_definition: json_query_on_behavior_clause_opt { JsonTableColumn *n = makeNode(JsonTableColumn); + n->coltype = JTC_FORMATTED; n->name = $1; n->typeName = $2; @@ -16089,6 +16849,7 @@ json_table_nested_columns: json_table_columns_clause { JsonTableColumn *n = makeNode(JsonTableColumn); + n->coltype = JTC_NESTED; n->pathspec = $3; n->pathname = $4; @@ -16123,6 +16884,7 @@ json_table_plan_simple: json_table_path_name { JsonTablePlan *n = makeNode(JsonTablePlan); + n->plan_type = JSTP_SIMPLE; n->pathname = $1; n->location = @1; @@ -16177,6 +16939,7 @@ json_table_default_plan: PLAN DEFAULT '(' json_table_default_plan_choices ')' { JsonTablePlan *n = makeNode(JsonTablePlan); + n->plan_type = JSTP_DEFAULT; n->join_type = $4; n->location = @1; @@ -16207,6 +16970,7 @@ json_returning_clause_opt: RETURNING Typename { JsonOutput *n = makeNode(JsonOutput); + n->typeName = $2; n->returning = makeNode(JsonReturning); n->returning->format = @@ -16220,6 +16984,7 @@ json_output_clause_opt: RETURNING Typename json_format_clause_opt { JsonOutput *n = makeNode(JsonOutput); + n->typeName = $2; n->returning = makeNode(JsonReturning); n->returning->format = (JsonFormat *) $3; @@ -16236,6 +17001,7 @@ json_exists_predicate: ')' { JsonFuncExpr *p = makeNode(JsonFuncExpr); + p->op = JSON_EXISTS_OP; p->common = (JsonCommon *) $3; p->output = (JsonOutput *) $4; @@ -16277,7 +17043,8 @@ json_object_args: json_object_func_args: func_arg_list { - List *func = list_make1(makeString("json_object")); + List *func = list_make1(makeString("json_object")); + $$ = (Node *) makeFuncCall(func, $1, COERCE_EXPLICIT_CALL, @1); } ; @@ -16286,6 +17053,7 @@ json_object_constructor_args: json_object_constructor_args_opt json_output_clause_opt { JsonObjectConstructor *n = (JsonObjectConstructor *) $1; + n->output = (JsonOutput *) $2; n->location = @1; $$ = (Node *) n; @@ -16298,6 +17066,7 @@ json_object_constructor_args_opt: json_key_uniqueness_constraint_opt { JsonObjectConstructor *n = makeNode(JsonObjectConstructor); + n->exprs = $1; n->absent_on_null = $2; n->unique = $3; @@ -16306,6 +17075,7 @@ json_object_constructor_args_opt: | /* EMPTY */ { JsonObjectConstructor *n = makeNode(JsonObjectConstructor); + n->exprs = NULL; n->absent_on_null = false; n->unique = false; @@ -16347,6 +17117,7 @@ json_array_constructor: ')' { JsonArrayConstructor *n = makeNode(JsonArrayConstructor); + n->exprs = $3; n->absent_on_null = $4; n->output = (JsonOutput *) $5; @@ -16361,6 +17132,7 @@ json_array_constructor: ')' { JsonArrayQueryConstructor *n = makeNode(JsonArrayQueryConstructor); + n->query = $3; n->format = makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1); /* n->format = $4; */ @@ -16374,6 +17146,7 @@ json_array_constructor: ')' { JsonArrayConstructor *n = makeNode(JsonArrayConstructor); + n->exprs = NIL; n->absent_on_null = true; n->output = (JsonOutput *) $3; @@ -16407,6 +17180,7 @@ json_object_aggregate_constructor: ')' { JsonObjectAgg *n = makeNode(JsonObjectAgg); + n->arg = (JsonKeyValue *) $3; n->absent_on_null = $4; n->unique = $5; @@ -16427,6 +17201,7 @@ json_array_aggregate_constructor: ')' { JsonArrayAgg *n = makeNode(JsonArrayAgg); + n->arg = (JsonValueExpr *) $3; n->absent_on_null = $5; n->constructor = makeNode(JsonAggConstructor); @@ -16462,7 +17237,7 @@ target_el: a_expr AS ColLabel $$ = makeNode(ResTarget); $$->name = $3; $$->indirection = NIL; - $$->val = (Node *)$1; + $$->val = (Node *) $1; $$->location = @1; } | a_expr BareColLabel @@ -16470,7 +17245,7 @@ target_el: a_expr AS ColLabel $$ = makeNode(ResTarget); $$->name = $2; $$->indirection = NIL; - $$->val = (Node *)$1; + $$->val = (Node *) $1; $$->location = @1; } | a_expr @@ -16478,19 +17253,20 @@ target_el: a_expr AS ColLabel $$ = makeNode(ResTarget); $$->name = NULL; $$->indirection = NIL; - $$->val = (Node *)$1; + $$->val = (Node *) $1; $$->location = @1; } | '*' { - ColumnRef *n = makeNode(ColumnRef); + ColumnRef *n = makeNode(ColumnRef); + n->fields = list_make1(makeNode(A_Star)); n->location = @1; $$ = makeNode(ResTarget); $$->name = NULL; $$->indirection = NIL; - $$->val = (Node *)n; + $$->val = (Node *) n; $$->location = @1; } ; @@ -16587,15 +17363,16 @@ AexprConst: Iconst | func_name Sconst { /* generic type 'literal' syntax */ - TypeName *t = makeTypeNameFromNameList($1); + TypeName *t = makeTypeNameFromNameList($1); + t->location = @1; $$ = makeStringConstCast($2, @2, t); } | func_name '(' func_arg_list opt_sort_clause ')' Sconst { /* generic syntax with a type modifier */ - TypeName *t = makeTypeNameFromNameList($1); - ListCell *lc; + TypeName *t = makeTypeNameFromNameList($1); + ListCell *lc; /* * We must use func_arg_list and opt_sort_clause in the @@ -16629,13 +17406,15 @@ AexprConst: Iconst } | ConstInterval Sconst opt_interval { - TypeName *t = $1; + TypeName *t = $1; + t->typmods = $3; $$ = makeStringConstCast($2, @2, t); } | ConstInterval '(' Iconst ')' Sconst { - TypeName *t = $1; + TypeName *t = $1; + t->typmods = list_make2(makeIntConst(INTERVAL_FULL_RANGE, -1), makeIntConst($3, @3)); $$ = makeStringConstCast($5, @5, t); @@ -16665,7 +17444,8 @@ SignedIconst: Iconst { $$ = $1; } /* Role specifications */ RoleId: RoleSpec { - RoleSpec *spc = (RoleSpec *) $1; + RoleSpec *spc = (RoleSpec *) $1; + switch (spc->roletype) { case ROLESPEC_CSTRING: @@ -16704,50 +17484,51 @@ RoleId: RoleSpec ; RoleSpec: NonReservedWord + { + /* + * "public" and "none" are not keywords, but they must + * be treated specially here. + */ + RoleSpec *n; + + if (strcmp($1, "public") == 0) { - /* - * "public" and "none" are not keywords, but they must - * be treated specially here. - */ - RoleSpec *n; - if (strcmp($1, "public") == 0) - { - n = (RoleSpec *) makeRoleSpec(ROLESPEC_PUBLIC, @1); - n->roletype = ROLESPEC_PUBLIC; - } - else if (strcmp($1, "none") == 0) - { - ereport(ERROR, - (errcode(ERRCODE_RESERVED_NAME), - errmsg("role name \"%s\" is reserved", - "none"), - parser_errposition(@1))); - } - else - { - n = makeRoleSpec(ROLESPEC_CSTRING, @1); - n->rolename = pstrdup($1); - } - $$ = n; + n = (RoleSpec *) makeRoleSpec(ROLESPEC_PUBLIC, @1); + n->roletype = ROLESPEC_PUBLIC; } + else if (strcmp($1, "none") == 0) + { + ereport(ERROR, + (errcode(ERRCODE_RESERVED_NAME), + errmsg("role name \"%s\" is reserved", + "none"), + parser_errposition(@1))); + } + else + { + n = makeRoleSpec(ROLESPEC_CSTRING, @1); + n->rolename = pstrdup($1); + } + $$ = n; + } | CURRENT_ROLE - { - $$ = makeRoleSpec(ROLESPEC_CURRENT_ROLE, @1); - } + { + $$ = makeRoleSpec(ROLESPEC_CURRENT_ROLE, @1); + } | CURRENT_USER - { - $$ = makeRoleSpec(ROLESPEC_CURRENT_USER, @1); - } + { + $$ = makeRoleSpec(ROLESPEC_CURRENT_USER, @1); + } | SESSION_USER - { - $$ = makeRoleSpec(ROLESPEC_SESSION_USER, @1); - } + { + $$ = makeRoleSpec(ROLESPEC_SESSION_USER, @1); + } ; role_list: RoleSpec - { $$ = list_make1($1); } + { $$ = list_make1($1); } | role_list ',' RoleSpec - { $$ = lappend($1, $3); } + { $$ = lappend($1, $3); } ; @@ -17918,8 +18699,8 @@ makeColumnRef(char *colname, List *indirection, * transposed into the "fields" part of the ColumnRef node. */ ColumnRef *c = makeNode(ColumnRef); - int nfields = 0; - ListCell *l; + int nfields = 0; + ListCell *l; c->location = location; foreach(l, indirection) @@ -17962,7 +18743,8 @@ makeColumnRef(char *colname, List *indirection, static Node * makeTypeCast(Node *arg, TypeName *typename, int location) { - TypeCast *n = makeNode(TypeCast); + TypeCast *n = makeNode(TypeCast); + n->arg = arg; n->typeName = typename; n->location = location; @@ -17972,19 +18754,19 @@ makeTypeCast(Node *arg, TypeName *typename, int location) static Node * makeStringConst(char *str, int location) { - A_Const *n = makeNode(A_Const); + A_Const *n = makeNode(A_Const); n->val.sval.type = T_String; n->val.sval.sval = str; n->location = location; - return (Node *)n; + return (Node *) n; } static Node * makeStringConstCast(char *str, int location, TypeName *typename) { - Node *s = makeStringConst(str, location); + Node *s = makeStringConst(str, location); return makeTypeCast(s, typename, -1); } @@ -17992,66 +18774,66 @@ makeStringConstCast(char *str, int location, TypeName *typename) static Node * makeIntConst(int val, int location) { - A_Const *n = makeNode(A_Const); + A_Const *n = makeNode(A_Const); n->val.ival.type = T_Integer; n->val.ival.ival = val; n->location = location; - return (Node *)n; + return (Node *) n; } static Node * makeFloatConst(char *str, int location) { - A_Const *n = makeNode(A_Const); + A_Const *n = makeNode(A_Const); n->val.fval.type = T_Float; n->val.fval.fval = str; n->location = location; - return (Node *)n; + return (Node *) n; } static Node * makeBoolAConst(bool state, int location) { - A_Const *n = makeNode(A_Const); + A_Const *n = makeNode(A_Const); n->val.boolval.type = T_Boolean; n->val.boolval.boolval = state; n->location = location; - return (Node *)n; + return (Node *) n; } static Node * makeBitStringConst(char *str, int location) { - A_Const *n = makeNode(A_Const); + A_Const *n = makeNode(A_Const); n->val.bsval.type = T_BitString; n->val.bsval.bsval = str; n->location = location; - return (Node *)n; + return (Node *) n; } static Node * makeNullAConst(int location) { - A_Const *n = makeNode(A_Const); + A_Const *n = makeNode(A_Const); n->isnull = true; n->location = location; - return (Node *)n; + return (Node *) n; } static Node * makeAConst(Node *v, int location) { - Node *n; + Node *n; switch (v->type) { @@ -18078,7 +18860,7 @@ makeAConst(Node *v, int location) static RoleSpec * makeRoleSpec(RoleSpecType type, int location) { - RoleSpec *spec = makeNode(RoleSpec); + RoleSpec *spec = makeNode(RoleSpec); spec->roletype = type; spec->location = location; @@ -18351,7 +19133,7 @@ doNegate(Node *n, int location) { if (IsA(n, A_Const)) { - A_Const *con = (A_Const *)n; + A_Const *con = (A_Const *) n; /* report the constant's location as that of the '-' sign */ con->location = location; @@ -18374,7 +19156,7 @@ doNegate(Node *n, int location) static void doNegateFloat(Float *v) { - char *oldval = v->fval; + char *oldval = v->fval; if (*oldval == '+') oldval++; @@ -18390,7 +19172,7 @@ makeAndExpr(Node *lexpr, Node *rexpr, int location) /* Flatten "a AND b AND c ..." to a single BoolExpr on sight */ if (IsA(lexpr, BoolExpr)) { - BoolExpr *blexpr = (BoolExpr *) lexpr; + BoolExpr *blexpr = (BoolExpr *) lexpr; if (blexpr->boolop == AND_EXPR) { @@ -18407,7 +19189,7 @@ makeOrExpr(Node *lexpr, Node *rexpr, int location) /* Flatten "a OR b OR c ..." to a single BoolExpr on sight */ if (IsA(lexpr, BoolExpr)) { - BoolExpr *blexpr = (BoolExpr *) lexpr; + BoolExpr *blexpr = (BoolExpr *) lexpr; if (blexpr->boolop == OR_EXPR) { @@ -18499,7 +19281,7 @@ mergeTableFuncParameters(List *func_args, List *columns) static TypeName * TableFuncTypeName(List *columns) { - TypeName *result; + TypeName *result; if (list_length(columns) == 1) { @@ -18523,7 +19305,7 @@ TableFuncTypeName(List *columns) static RangeVar * makeRangeVarFromAnyName(List *names, int position, core_yyscan_t yyscanner) { - RangeVar *r = makeNode(RangeVar); + RangeVar *r = makeNode(RangeVar); switch (list_length(names)) { @@ -18565,7 +19347,7 @@ static RangeVar * makeRangeVarFromQualifiedName(char *name, List *namelist, int location, core_yyscan_t yyscanner) { - RangeVar *r; + RangeVar *r; check_qualified_name(namelist, yyscanner); r = makeRangeVar(NULL, NULL, location); @@ -18605,7 +19387,7 @@ SplitColQualList(List *qualList, *collClause = NULL; foreach(cell, qualList) { - Node *n = (Node *) lfirst(cell); + Node *n = (Node *) lfirst(cell); if (IsA(n, Constraint)) { diff --git a/src/backend/replication/repl_gram.y b/src/backend/replication/repl_gram.y index ee0c0774ea..4cf087e602 100644 --- a/src/backend/replication/repl_gram.y +++ b/src/backend/replication/repl_gram.y @@ -42,15 +42,15 @@ Node *replication_parse_result; %expect 0 %name-prefix="replication_yy" -%union { - char *str; - bool boolval; - uint32 uintval; - - XLogRecPtr recptr; - Node *node; - List *list; - DefElem *defelt; +%union +{ + char *str; + bool boolval; + uint32 uintval; + XLogRecPtr recptr; + Node *node; + List *list; + DefElem *defelt; } /* Non-keyword tokens */ @@ -215,27 +215,27 @@ create_slot_legacy_opt: K_EXPORT_SNAPSHOT { $$ = makeDefElem("snapshot", - (Node *)makeString("export"), -1); + (Node *) makeString("export"), -1); } | K_NOEXPORT_SNAPSHOT { $$ = makeDefElem("snapshot", - (Node *)makeString("nothing"), -1); + (Node *) makeString("nothing"), -1); } | K_USE_SNAPSHOT { $$ = makeDefElem("snapshot", - (Node *)makeString("use"), -1); + (Node *) makeString("use"), -1); } | K_RESERVE_WAL { $$ = makeDefElem("reserve_wal", - (Node *)makeBoolean(true), -1); + (Node *) makeBoolean(true), -1); } | K_TWO_PHASE { $$ = makeDefElem("two_phase", - (Node *)makeBoolean(true), -1); + (Node *) makeBoolean(true), -1); } ; diff --git a/src/backend/replication/repl_scanner.l b/src/backend/replication/repl_scanner.l index 4b64c0d768..586f0d3a5c 100644 --- a/src/backend/replication/repl_scanner.l +++ b/src/backend/replication/repl_scanner.l @@ -169,7 +169,8 @@ WAIT { return K_WAIT; } } {xdstop} { - int len; + int len; + yyless(1); BEGIN(INITIAL); yylval.str = litbufdup(); @@ -183,7 +184,7 @@ WAIT { return K_WAIT; } } {identifier} { - int len = strlen(yytext); + int len = strlen(yytext); yylval.str = downcase_truncate_identifier(yytext, len, true); return IDENT; diff --git a/src/backend/utils/adt/jsonpath_gram.y b/src/backend/utils/adt/jsonpath_gram.y index 7311d12e35..06d4c8c229 100644 --- a/src/backend/utils/adt/jsonpath_gram.y +++ b/src/backend/utils/adt/jsonpath_gram.y @@ -77,7 +77,8 @@ static JsonPathParseItem *makeItemLikeRegex(JsonPathParseItem *expr, %error-verbose %parse-param {JsonPathParseResult **result} -%union { +%union +{ JsonPathString str; List *elems; /* list of JsonPathParseItem */ List *indexs; /* list of integers */ @@ -313,7 +314,7 @@ method: static JsonPathParseItem * makeItemType(JsonPathItemType type) { - JsonPathParseItem *v = palloc(sizeof(*v)); + JsonPathParseItem *v = palloc(sizeof(*v)); CHECK_FOR_INTERRUPTS(); @@ -326,7 +327,7 @@ makeItemType(JsonPathItemType type) static JsonPathParseItem * makeItemString(JsonPathString *s) { - JsonPathParseItem *v; + JsonPathParseItem *v; if (s == NULL) { @@ -345,7 +346,7 @@ makeItemString(JsonPathString *s) static JsonPathParseItem * makeItemVariable(JsonPathString *s) { - JsonPathParseItem *v; + JsonPathParseItem *v; v = makeItemType(jpiVariable); v->value.string.val = s->val; @@ -357,7 +358,7 @@ makeItemVariable(JsonPathString *s) static JsonPathParseItem * makeItemKey(JsonPathString *s) { - JsonPathParseItem *v; + JsonPathParseItem *v; v = makeItemString(s); v->type = jpiKey; @@ -368,7 +369,7 @@ makeItemKey(JsonPathString *s) static JsonPathParseItem * makeItemNumeric(JsonPathString *s) { - JsonPathParseItem *v; + JsonPathParseItem *v; v = makeItemType(jpiNumeric); v->value.numeric = @@ -383,7 +384,7 @@ makeItemNumeric(JsonPathString *s) static JsonPathParseItem * makeItemBool(bool val) { - JsonPathParseItem *v = makeItemType(jpiBool); + JsonPathParseItem *v = makeItemType(jpiBool); v->value.boolean = val; @@ -393,7 +394,7 @@ makeItemBool(bool val) static JsonPathParseItem * makeItemBinary(JsonPathItemType type, JsonPathParseItem *la, JsonPathParseItem *ra) { - JsonPathParseItem *v = makeItemType(type); + JsonPathParseItem *v = makeItemType(type); v->value.args.left = la; v->value.args.right = ra; @@ -404,7 +405,7 @@ makeItemBinary(JsonPathItemType type, JsonPathParseItem *la, JsonPathParseItem * static JsonPathParseItem * makeItemUnary(JsonPathItemType type, JsonPathParseItem *a) { - JsonPathParseItem *v; + JsonPathParseItem *v; if (type == jpiPlus && a->type == jpiNumeric && !a->next) return a; @@ -428,9 +429,9 @@ makeItemUnary(JsonPathItemType type, JsonPathParseItem *a) static JsonPathParseItem * makeItemList(List *list) { - JsonPathParseItem *head, - *end; - ListCell *cell; + JsonPathParseItem *head, + *end; + ListCell *cell; head = end = (JsonPathParseItem *) linitial(list); @@ -455,9 +456,9 @@ makeItemList(List *list) static JsonPathParseItem * makeIndexArray(List *list) { - JsonPathParseItem *v = makeItemType(jpiIndexArray); - ListCell *cell; - int i = 0; + JsonPathParseItem *v = makeItemType(jpiIndexArray); + ListCell *cell; + int i = 0; Assert(list_length(list) > 0); v->value.array.nelems = list_length(list); @@ -467,7 +468,7 @@ makeIndexArray(List *list) foreach(cell, list) { - JsonPathParseItem *jpi = lfirst(cell); + JsonPathParseItem *jpi = lfirst(cell); Assert(jpi->type == jpiSubscript); @@ -481,7 +482,7 @@ makeIndexArray(List *list) static JsonPathParseItem * makeAny(int first, int last) { - JsonPathParseItem *v = makeItemType(jpiAny); + JsonPathParseItem *v = makeItemType(jpiAny); v->value.anybounds.first = (first >= 0) ? first : PG_UINT32_MAX; v->value.anybounds.last = (last >= 0) ? last : PG_UINT32_MAX; @@ -493,9 +494,9 @@ static JsonPathParseItem * makeItemLikeRegex(JsonPathParseItem *expr, JsonPathString *pattern, JsonPathString *flags) { - JsonPathParseItem *v = makeItemType(jpiLikeRegex); - int i; - int cflags; + JsonPathParseItem *v = makeItemType(jpiLikeRegex); + int i; + int cflags; v->value.like_regex.expr = expr; v->value.like_regex.pattern = pattern->val; diff --git a/src/backend/utils/adt/jsonpath_scan.l b/src/backend/utils/adt/jsonpath_scan.l index 1f08e7c51f..4351f6ec98 100644 --- a/src/backend/utils/adt/jsonpath_scan.l +++ b/src/backend/utils/adt/jsonpath_scan.l @@ -332,8 +332,8 @@ static const JsonPathKeyword keywords[] = { static enum yytokentype checkKeyword() { - int res = IDENT_P; - int diff; + int res = IDENT_P; + int diff; const JsonPathKeyword *StopLow = keywords, *StopHigh = keywords + lengthof(keywords), *StopMiddle; diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l index c70543fa74..4360c461df 100644 --- a/src/backend/utils/misc/guc-file.l +++ b/src/backend/utils/misc/guc-file.l @@ -49,10 +49,10 @@ static sigjmp_buf *GUC_flex_fatal_jmp; static void FreeConfigVariable(ConfigVariable *item); static void record_config_file_error(const char *errmsg, - const char *config_file, - int lineno, - ConfigVariable **head_p, - ConfigVariable **tail_p); + const char *config_file, + int lineno, + ConfigVariable **head_p, + ConfigVariable **tail_p); static int GUC_flex_fatal(const char *msg); diff --git a/src/bin/pgbench/exprparse.y b/src/bin/pgbench/exprparse.y index 23aec34bfc..b5592d4b97 100644 --- a/src/bin/pgbench/exprparse.y +++ b/src/bin/pgbench/exprparse.y @@ -30,7 +30,7 @@ static PgBenchExpr *make_integer_constant(int64 ival); static PgBenchExpr *make_double_constant(double dval); static PgBenchExpr *make_variable(char *varname); static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, - PgBenchExpr *lexpr, PgBenchExpr *rexpr); + PgBenchExpr *lexpr, PgBenchExpr *rexpr); static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); static int find_func(yyscan_t yyscanner, const char *fname); static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); @@ -240,7 +240,7 @@ make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) * meaning #args >= 1; * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which * has #args >= 3 and odd; - * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * - PGBENCH_NARGS_HASH is for hash functions, which have one required * and one optional argument; * - tag: function identifier from PgBenchFunction enum */ diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index 2367b860f5..996718cb8a 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -99,9 +99,9 @@ static short preproc_tos; static bool ifcond; static struct _if_value { - bool active; - bool saw_active; - bool else_branch; + bool active; + bool saw_active; + bool else_branch; } stacked_if_value[MAX_NESTED_IF]; %} @@ -1031,7 +1031,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+ char* endptr; errno = 0; - base_yylval.ival = strtoul((char *)yytext,&endptr,16); + base_yylval.ival = strtoul((char *) yytext, &endptr, 16); if (*endptr != '\0' || errno == ERANGE) { errno = 0; @@ -1166,7 +1166,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+ */ for (i = strlen(yytext)-2; i > 0 && ecpg_isspace(yytext[i]); - i-- ) + i--) ; yytext[i+1] = '\0'; @@ -1290,7 +1290,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+ } {exec_sql}{else}{space}*";" { /* only exec sql endif pops the stack, so take care of duplicated 'else' */ - if ( preproc_tos == 0 ) + if (preproc_tos == 0) mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\""); else if (stacked_if_value[preproc_tos].else_branch) mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE"); @@ -1312,7 +1312,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+ /* are we simulating Informix? */ if (INFORMIX_MODE) { - if ( preproc_tos == 0 ) + if (preproc_tos == 0) mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\""); else if (stacked_if_value[preproc_tos].else_branch) mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE"); @@ -1382,7 +1382,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+ */ for (i = strlen(yytext)-2; i > 0 && ecpg_isspace(yytext[i]); - i-- ) + i--) ; yytext[i+1] = '\0'; @@ -1456,7 +1456,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+ <> { if (yy_buffer == NULL) { - if ( preproc_tos > 0 ) + if (preproc_tos > 0) { preproc_tos = 0; mmfatal(PARSE_ERROR, "missing \"EXEC SQL ENDIF;\""); @@ -1479,7 +1479,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+ if (yyin != NULL) fclose(yyin); - yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_delete_buffer(YY_CURRENT_BUFFER); yy_switch_to_buffer(yy_buffer->buffer); yylineno = yy_buffer->lineno; @@ -1661,7 +1661,7 @@ parse_include(void) if (strcmp(inc_file + strlen(inc_file) - 2, ".h") != 0) { strcat(inc_file, ".h"); - yyin = fopen( inc_file, "r" ); + yyin = fopen(inc_file, "r"); } } /* if the command was "include_next" we have to disregard the first hit */ @@ -1677,7 +1677,7 @@ parse_include(void) mmfatal(NO_INCLUDE_FILE, "could not open include file \"%s\" on line %d", yytext, yylineno); input_filename = mm_strdup(inc_file); - yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE )); + yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); yylineno = 1; output_line_number(); diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y index 11e86c1609..0b8aea9504 100644 --- a/src/pl/plpgsql/src/pl_gram.y +++ b/src/pl/plpgsql/src/pl_gram.y @@ -116,55 +116,56 @@ static void check_raise_parameters(PLpgSQL_stmt_raise *stmt); %name-prefix="plpgsql_yy" %locations -%union { - core_YYSTYPE core_yystype; - /* these fields must match core_YYSTYPE: */ - int ival; - char *str; - const char *keyword; +%union +{ + core_YYSTYPE core_yystype; + /* these fields must match core_YYSTYPE: */ + int ival; + char *str; + const char *keyword; - PLword word; - PLcword cword; - PLwdatum wdatum; - bool boolean; - Oid oid; - struct - { - char *name; - int lineno; - } varname; - struct - { - char *name; - int lineno; - PLpgSQL_datum *scalar; - PLpgSQL_datum *row; - } forvariable; - struct - { - char *label; - int n_initvars; - int *initvarnos; - } declhdr; - struct - { - List *stmts; - char *end_label; - int end_label_location; - } loop_body; - List *list; - PLpgSQL_type *dtype; - PLpgSQL_datum *datum; - PLpgSQL_var *var; - PLpgSQL_expr *expr; - PLpgSQL_stmt *stmt; - PLpgSQL_condition *condition; - PLpgSQL_exception *exception; - PLpgSQL_exception_block *exception_block; - PLpgSQL_nsitem *nsitem; - PLpgSQL_diag_item *diagitem; - PLpgSQL_stmt_fetch *fetch; - PLpgSQL_case_when *casewhen; + PLword word; + PLcword cword; + PLwdatum wdatum; + bool boolean; + Oid oid; + struct + { + char *name; + int lineno; + } varname; + struct + { + char *name; + int lineno; + PLpgSQL_datum *scalar; + PLpgSQL_datum *row; + } forvariable; + struct + { + char *label; + int n_initvars; + int *initvarnos; + } declhdr; + struct + { + List *stmts; + char *end_label; + int end_label_location; + } loop_body; + List *list; + PLpgSQL_type *dtype; + PLpgSQL_datum *datum; + PLpgSQL_var *var; + PLpgSQL_expr *expr; + PLpgSQL_stmt *stmt; + PLpgSQL_condition *condition; + PLpgSQL_exception *exception; + PLpgSQL_exception_block *exception_block; + PLpgSQL_nsitem *nsitem; + PLpgSQL_diag_item *diagitem; + PLpgSQL_stmt_fetch *fetch; + PLpgSQL_case_when *casewhen; } %type decl_sect @@ -425,7 +426,7 @@ pl_block : decl_sect K_BEGIN proc_sect exception_sect K_END opt_label check_labels($1.label, $6, @6); plpgsql_ns_pop(); - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -538,8 +539,8 @@ decl_statement : decl_varname decl_const decl_datatype decl_collate decl_notnull PLpgSQL_var *new; PLpgSQL_expr *curname_def; char buf[NAMEDATALEN * 2 + 64]; - char *cp1; - char *cp2; + char *cp1; + char *cp2; /* pop local namespace for cursor args */ plpgsql_ns_pop(); @@ -611,8 +612,8 @@ decl_cursor_args : | '(' decl_cursor_arglist ')' { PLpgSQL_row *new; - int i; - ListCell *l; + int i; + ListCell *l; new = palloc0(sizeof(PLpgSQL_row)); new->dtype = PLPGSQL_DTYPE_ROW; @@ -903,7 +904,7 @@ proc_stmt : pl_block ';' stmt_perform : K_PERFORM { PLpgSQL_stmt_perform *new; - int startloc; + int startloc; new = palloc0(sizeof(PLpgSQL_stmt_perform)); new->cmd_type = PLPGSQL_STMT_PERFORM; @@ -932,7 +933,7 @@ stmt_perform : K_PERFORM check_sql_expr(new->expr->query, new->expr->parseMode, startloc + 1); - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -951,7 +952,7 @@ stmt_call : K_CALL /* Remember we may need a procedure resource owner */ plpgsql_curr_compile->requires_procedure_resowner = true; - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } | K_DO @@ -970,7 +971,7 @@ stmt_call : K_CALL /* Remember we may need a procedure resource owner */ plpgsql_curr_compile->requires_procedure_resowner = true; - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -1000,7 +1001,7 @@ stmt_assign : T_DATUM check_assignable($1.datum, @1); new = palloc0(sizeof(PLpgSQL_stmt_assign)); new->cmd_type = PLPGSQL_STMT_ASSIGN; - new->lineno = plpgsql_location_to_lineno(@1); + new->lineno = plpgsql_location_to_lineno(@1); new->stmtid = ++plpgsql_curr_compile->nstatements; new->varno = $1.datum->dno; /* Push back the head name to include it in the stmt */ @@ -1010,19 +1011,19 @@ stmt_assign : T_DATUM false, true, true, NULL, NULL); - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; stmt_getdiag : K_GET getdiag_area_opt K_DIAGNOSTICS getdiag_list ';' { - PLpgSQL_stmt_getdiag *new; - ListCell *lc; + PLpgSQL_stmt_getdiag *new; + ListCell *lc; new = palloc0(sizeof(PLpgSQL_stmt_getdiag)); new->cmd_type = PLPGSQL_STMT_GETDIAG; - new->lineno = plpgsql_location_to_lineno(@1); - new->stmtid = ++plpgsql_curr_compile->nstatements; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; new->is_stacked = $2; new->diag_items = $4; @@ -1072,7 +1073,7 @@ stmt_getdiag : K_GET getdiag_area_opt K_DIAGNOSTICS getdiag_list ';' } } - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -1114,7 +1115,7 @@ getdiag_list_item : getdiag_target assign_operator getdiag_item getdiag_item : { - int tok = yylex(); + int tok = yylex(); if (tok_is_keyword(tok, &yylval, K_ROW_COUNT, "row_count")) @@ -1192,15 +1193,15 @@ stmt_if : K_IF expr_until_then proc_sect stmt_elsifs stmt_else K_END K_IF ';' PLpgSQL_stmt_if *new; new = palloc0(sizeof(PLpgSQL_stmt_if)); - new->cmd_type = PLPGSQL_STMT_IF; - new->lineno = plpgsql_location_to_lineno(@1); - new->stmtid = ++plpgsql_curr_compile->nstatements; - new->cond = $2; - new->then_body = $3; + new->cmd_type = PLPGSQL_STMT_IF; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->cond = $2; + new->then_body = $3; new->elsif_list = $4; - new->else_body = $5; + new->else_body = $5; - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -1214,8 +1215,8 @@ stmt_elsifs : new = palloc0(sizeof(PLpgSQL_if_elsif)); new->lineno = plpgsql_location_to_lineno(@2); - new->cond = $3; - new->stmts = $4; + new->cond = $3; + new->stmts = $4; $$ = lappend($1, new); } @@ -1240,7 +1241,7 @@ stmt_case : K_CASE opt_expr_until_when case_when_list opt_case_else K_END K_CAS opt_expr_until_when : { PLpgSQL_expr *expr = NULL; - int tok = yylex(); + int tok = yylex(); if (tok != K_WHEN) { @@ -1267,8 +1268,8 @@ case_when : K_WHEN expr_until_then proc_sect PLpgSQL_case_when *new = palloc(sizeof(PLpgSQL_case_when)); new->lineno = plpgsql_location_to_lineno(@1); - new->expr = $2; - new->stmts = $3; + new->expr = $2; + new->stmts = $3; $$ = new; } ; @@ -1298,15 +1299,15 @@ stmt_loop : opt_loop_label K_LOOP loop_body new = palloc0(sizeof(PLpgSQL_stmt_loop)); new->cmd_type = PLPGSQL_STMT_LOOP; - new->lineno = plpgsql_location_to_lineno(@2); - new->stmtid = ++plpgsql_curr_compile->nstatements; - new->label = $1; - new->body = $3.stmts; + new->lineno = plpgsql_location_to_lineno(@2); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->label = $1; + new->body = $3.stmts; check_labels($1, $3.end_label, $3.end_label_location); plpgsql_ns_pop(); - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -1316,16 +1317,16 @@ stmt_while : opt_loop_label K_WHILE expr_until_loop loop_body new = palloc0(sizeof(PLpgSQL_stmt_while)); new->cmd_type = PLPGSQL_STMT_WHILE; - new->lineno = plpgsql_location_to_lineno(@2); - new->stmtid = ++plpgsql_curr_compile->nstatements; - new->label = $1; - new->cond = $3; - new->body = $4.stmts; + new->lineno = plpgsql_location_to_lineno(@2); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->label = $1; + new->cond = $3; + new->body = $4.stmts; check_labels($1, $4.end_label, $4.end_label_location); plpgsql_ns_pop(); - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -1334,26 +1335,26 @@ stmt_for : opt_loop_label K_FOR for_control loop_body /* This runs after we've scanned the loop body */ if ($3->cmd_type == PLPGSQL_STMT_FORI) { - PLpgSQL_stmt_fori *new; + PLpgSQL_stmt_fori *new; new = (PLpgSQL_stmt_fori *) $3; - new->lineno = plpgsql_location_to_lineno(@2); - new->label = $1; - new->body = $4.stmts; + new->lineno = plpgsql_location_to_lineno(@2); + new->label = $1; + new->body = $4.stmts; $$ = (PLpgSQL_stmt *) new; } else { - PLpgSQL_stmt_forq *new; + PLpgSQL_stmt_forq *new; Assert($3->cmd_type == PLPGSQL_STMT_FORS || $3->cmd_type == PLPGSQL_STMT_FORC || $3->cmd_type == PLPGSQL_STMT_DYNFORS); /* forq is the common supertype of all three */ new = (PLpgSQL_stmt_forq *) $3; - new->lineno = plpgsql_location_to_lineno(@2); - new->label = $1; - new->body = $4.stmts; + new->lineno = plpgsql_location_to_lineno(@2); + new->label = $1; + new->body = $4.stmts; $$ = (PLpgSQL_stmt *) new; } @@ -1371,9 +1372,9 @@ for_control : for_variable K_IN if (tok == K_EXECUTE) { /* EXECUTE means it's a dynamic FOR loop */ - PLpgSQL_stmt_dynfors *new; - PLpgSQL_expr *expr; - int term; + PLpgSQL_stmt_dynfors *new; + PLpgSQL_expr *expr; + int term; expr = read_sql_expression2(K_LOOP, K_USING, "LOOP or USING", @@ -1381,7 +1382,7 @@ for_control : for_variable K_IN new = palloc0(sizeof(PLpgSQL_stmt_dynfors)); new->cmd_type = PLPGSQL_STMT_DYNFORS; - new->stmtid = ++plpgsql_curr_compile->nstatements; + new->stmtid = ++plpgsql_curr_compile->nstatements; if ($1.row) { new->var = (PLpgSQL_variable *) $1.row; @@ -1422,8 +1423,8 @@ for_control : for_variable K_IN ((PLpgSQL_var *) yylval.wdatum.datum)->datatype->typoid == REFCURSOROID) { /* It's FOR var IN cursor */ - PLpgSQL_stmt_forc *new; - PLpgSQL_var *cursor = (PLpgSQL_var *) yylval.wdatum.datum; + PLpgSQL_stmt_forc *new; + PLpgSQL_var *cursor = (PLpgSQL_var *) yylval.wdatum.datum; new = (PLpgSQL_stmt_forc *) palloc0(sizeof(PLpgSQL_stmt_forc)); new->cmd_type = PLPGSQL_STMT_FORC; @@ -1460,9 +1461,9 @@ for_control : for_variable K_IN } else { - PLpgSQL_expr *expr1; - int expr1loc; - bool reverse = false; + PLpgSQL_expr *expr1; + int expr1loc; + bool reverse = false; /* * We have to distinguish between two @@ -1503,10 +1504,10 @@ for_control : for_variable K_IN if (tok == DOT_DOT) { /* Saw "..", so it must be an integer loop */ - PLpgSQL_expr *expr2; - PLpgSQL_expr *expr_by; - PLpgSQL_var *fvar; - PLpgSQL_stmt_fori *new; + PLpgSQL_expr *expr2; + PLpgSQL_expr *expr_by; + PLpgSQL_var *fvar; + PLpgSQL_stmt_fori *new; /* * Relabel first expression as an expression; @@ -1547,12 +1548,12 @@ for_control : for_variable K_IN new = palloc0(sizeof(PLpgSQL_stmt_fori)); new->cmd_type = PLPGSQL_STMT_FORI; - new->stmtid = ++plpgsql_curr_compile->nstatements; - new->var = fvar; - new->reverse = reverse; - new->lower = expr1; - new->upper = expr2; - new->step = expr_by; + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->var = fvar; + new->reverse = reverse; + new->lower = expr1; + new->upper = expr2; + new->step = expr_by; $$ = (PLpgSQL_stmt *) new; } @@ -1561,7 +1562,7 @@ for_control : for_variable K_IN /* * No "..", so it must be a query loop. */ - PLpgSQL_stmt_fors *new; + PLpgSQL_stmt_fors *new; if (reverse) ereport(ERROR, @@ -1723,11 +1724,11 @@ stmt_exit : exit_type opt_label opt_exitcond new = palloc0(sizeof(PLpgSQL_stmt_exit)); new->cmd_type = PLPGSQL_STMT_EXIT; - new->stmtid = ++plpgsql_curr_compile->nstatements; - new->is_exit = $1; - new->lineno = plpgsql_location_to_lineno(@1); - new->label = $2; - new->cond = $3; + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->is_exit = $1; + new->lineno = plpgsql_location_to_lineno(@1); + new->label = $2; + new->cond = $3; if ($2) { @@ -1766,7 +1767,7 @@ stmt_exit : exit_type opt_label opt_exitcond parser_errposition(@1))); } - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -1782,7 +1783,7 @@ exit_type : K_EXIT stmt_return : K_RETURN { - int tok; + int tok; tok = yylex(); if (tok == 0) @@ -1808,19 +1809,19 @@ stmt_return : K_RETURN stmt_raise : K_RAISE { - PLpgSQL_stmt_raise *new; - int tok; + PLpgSQL_stmt_raise *new; + int tok; new = palloc(sizeof(PLpgSQL_stmt_raise)); - new->cmd_type = PLPGSQL_STMT_RAISE; - new->lineno = plpgsql_location_to_lineno(@1); - new->stmtid = ++plpgsql_curr_compile->nstatements; + new->cmd_type = PLPGSQL_STMT_RAISE; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; new->elog_level = ERROR; /* default */ - new->condname = NULL; - new->message = NULL; - new->params = NIL; - new->options = NIL; + new->condname = NULL; + new->message = NULL; + new->params = NIL; + new->options = NIL; tok = yylex(); if (tok == 0) @@ -1913,7 +1914,7 @@ stmt_raise : K_RAISE K_SQLSTATE, "sqlstate")) { /* next token should be a string literal */ - char *sqlstatestr; + char *sqlstatestr; if (yylex() != SCONST) yyerror("syntax error"); @@ -1947,20 +1948,20 @@ stmt_raise : K_RAISE check_raise_parameters(new); - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; stmt_assert : K_ASSERT { - PLpgSQL_stmt_assert *new; - int tok; + PLpgSQL_stmt_assert *new; + int tok; new = palloc(sizeof(PLpgSQL_stmt_assert)); - new->cmd_type = PLPGSQL_STMT_ASSERT; - new->lineno = plpgsql_location_to_lineno(@1); - new->stmtid = ++plpgsql_curr_compile->nstatements; + new->cmd_type = PLPGSQL_STMT_ASSERT; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; new->cond = read_sql_expression2(',', ';', ", or ;", @@ -2033,7 +2034,7 @@ stmt_dynexecute : K_EXECUTE { PLpgSQL_stmt_dynexecute *new; PLpgSQL_expr *expr; - int endtoken; + int endtoken; expr = read_sql_construct(K_INTO, K_USING, ';', "INTO or USING or ;", @@ -2088,7 +2089,7 @@ stmt_dynexecute : K_EXECUTE yyerror("syntax error"); } - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -2096,7 +2097,7 @@ stmt_dynexecute : K_EXECUTE stmt_open : K_OPEN cursor_variable { PLpgSQL_stmt_open *new; - int tok; + int tok; new = palloc0(sizeof(PLpgSQL_stmt_open)); new->cmd_type = PLPGSQL_STMT_OPEN; @@ -2133,7 +2134,7 @@ stmt_open : K_OPEN cursor_variable tok = yylex(); if (tok == K_EXECUTE) { - int endtoken; + int endtoken; new->dynquery = read_sql_expression2(K_USING, ';', @@ -2167,7 +2168,7 @@ stmt_open : K_OPEN cursor_variable new->argquery = read_cursor_args($2, ';'); } - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -2197,7 +2198,7 @@ stmt_fetch : K_FETCH opt_fetch_direction cursor_variable K_INTO fetch->curvar = $3->dno; fetch->is_move = false; - $$ = (PLpgSQL_stmt *)fetch; + $$ = (PLpgSQL_stmt *) fetch; } ; @@ -2206,10 +2207,10 @@ stmt_move : K_MOVE opt_fetch_direction cursor_variable ';' PLpgSQL_stmt_fetch *fetch = $2; fetch->lineno = plpgsql_location_to_lineno(@1); - fetch->curvar = $3->dno; - fetch->is_move = true; + fetch->curvar = $3->dno; + fetch->is_move = true; - $$ = (PLpgSQL_stmt *)fetch; + $$ = (PLpgSQL_stmt *) fetch; } ; @@ -2229,7 +2230,7 @@ stmt_close : K_CLOSE cursor_variable ';' new->stmtid = ++plpgsql_curr_compile->nstatements; new->curvar = $2->dno; - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -2250,7 +2251,7 @@ stmt_commit : K_COMMIT opt_transaction_chain ';' new->stmtid = ++plpgsql_curr_compile->nstatements; new->chain = $2; - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -2264,7 +2265,7 @@ stmt_rollback : K_ROLLBACK opt_transaction_chain ';' new->stmtid = ++plpgsql_curr_compile->nstatements; new->chain = $2; - $$ = (PLpgSQL_stmt *)new; + $$ = (PLpgSQL_stmt *) new; } ; @@ -2710,12 +2711,12 @@ read_sql_construct(int until, int *startloc, int *endtoken) { - int tok; - StringInfoData ds; - IdentifierLookup save_IdentifierLookup; - int startlocation = -1; - int parenlevel = 0; - PLpgSQL_expr *expr; + int tok; + StringInfoData ds; + IdentifierLookup save_IdentifierLookup; + int startlocation = -1; + int parenlevel = 0; + PLpgSQL_expr *expr; initStringInfo(&ds); @@ -2792,12 +2793,12 @@ read_sql_construct(int until, } expr = palloc0(sizeof(PLpgSQL_expr)); - expr->query = pstrdup(ds.data); - expr->parseMode = parsemode; - expr->plan = NULL; - expr->paramnos = NULL; - expr->target_param = -1; - expr->ns = plpgsql_ns_top(); + expr->query = pstrdup(ds.data); + expr->parseMode = parsemode; + expr->plan = NULL; + expr->paramnos = NULL; + expr->target_param = -1; + expr->ns = plpgsql_ns_top(); pfree(ds.data); if (valid_sql) @@ -2809,11 +2810,11 @@ read_sql_construct(int until, static PLpgSQL_type * read_datatype(int tok) { - StringInfoData ds; - char *type_name; - int startlocation; - PLpgSQL_type *result; - int parenlevel = 0; + StringInfoData ds; + char *type_name; + int startlocation; + PLpgSQL_type *result; + int parenlevel = 0; /* Should only be called while parsing DECLARE sections */ Assert(plpgsql_IdentifierLookup == IDENTIFIER_LOOKUP_DECLARE); @@ -2830,7 +2831,7 @@ read_datatype(int tok) */ if (tok == T_WORD) { - char *dtname = yylval.word.ident; + char *dtname = yylval.word.ident; tok = yylex(); if (tok == '%') @@ -2854,7 +2855,7 @@ read_datatype(int tok) } else if (plpgsql_token_is_unreserved_keyword(tok)) { - char *dtname = pstrdup(yylval.keyword); + char *dtname = pstrdup(yylval.keyword); tok = yylex(); if (tok == '%') @@ -2878,7 +2879,7 @@ read_datatype(int tok) } else if (tok == T_CWORD) { - List *dtnames = yylval.cword.idents; + List *dtnames = yylval.cword.idents; tok = yylex(); if (tok == '%') @@ -2945,17 +2946,17 @@ read_datatype(int tok) static PLpgSQL_stmt * make_execsql_stmt(int firsttoken, int location) { - StringInfoData ds; - IdentifierLookup save_IdentifierLookup; + StringInfoData ds; + IdentifierLookup save_IdentifierLookup; PLpgSQL_stmt_execsql *execsql; - PLpgSQL_expr *expr; - PLpgSQL_variable *target = NULL; - int tok; - int prev_tok; - bool have_into = false; - bool have_strict = false; - int into_start_loc = -1; - int into_end_loc = -1; + PLpgSQL_expr *expr; + PLpgSQL_variable *target = NULL; + int tok; + int prev_tok; + bool have_into = false; + bool have_strict = false; + int into_start_loc = -1; + int into_end_loc = -1; initStringInfo(&ds); @@ -3041,24 +3042,24 @@ make_execsql_stmt(int firsttoken, int location) ds.data[--ds.len] = '\0'; expr = palloc0(sizeof(PLpgSQL_expr)); - expr->query = pstrdup(ds.data); - expr->parseMode = RAW_PARSE_DEFAULT; - expr->plan = NULL; - expr->paramnos = NULL; - expr->target_param = -1; - expr->ns = plpgsql_ns_top(); + expr->query = pstrdup(ds.data); + expr->parseMode = RAW_PARSE_DEFAULT; + expr->plan = NULL; + expr->paramnos = NULL; + expr->target_param = -1; + expr->ns = plpgsql_ns_top(); pfree(ds.data); check_sql_expr(expr->query, expr->parseMode, location); execsql = palloc0(sizeof(PLpgSQL_stmt_execsql)); execsql->cmd_type = PLPGSQL_STMT_EXECSQL; - execsql->lineno = plpgsql_location_to_lineno(location); - execsql->stmtid = ++plpgsql_curr_compile->nstatements; + execsql->lineno = plpgsql_location_to_lineno(location); + execsql->stmtid = ++plpgsql_curr_compile->nstatements; execsql->sqlstmt = expr; - execsql->into = have_into; - execsql->strict = have_strict; - execsql->target = target; + execsql->into = have_into; + execsql->strict = have_strict; + execsql->target = target; return (PLpgSQL_stmt *) execsql; } @@ -3080,11 +3081,11 @@ read_fetch_direction(void) */ fetch = (PLpgSQL_stmt_fetch *) palloc0(sizeof(PLpgSQL_stmt_fetch)); fetch->cmd_type = PLPGSQL_STMT_FETCH; - fetch->stmtid = ++plpgsql_curr_compile->nstatements; + fetch->stmtid = ++plpgsql_curr_compile->nstatements; /* set direction defaults: */ fetch->direction = FETCH_FORWARD; - fetch->how_many = 1; - fetch->expr = NULL; + fetch->how_many = 1; + fetch->expr = NULL; fetch->returns_multiple_rows = false; tok = yylex(); @@ -3232,9 +3233,9 @@ make_return_stmt(int location) new = palloc0(sizeof(PLpgSQL_stmt_return)); new->cmd_type = PLPGSQL_STMT_RETURN; - new->lineno = plpgsql_location_to_lineno(location); - new->stmtid = ++plpgsql_curr_compile->nstatements; - new->expr = NULL; + new->lineno = plpgsql_location_to_lineno(location); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->expr = NULL; new->retvarno = -1; if (plpgsql_curr_compile->fn_retset) @@ -3277,7 +3278,7 @@ make_return_stmt(int location) * We want to special-case simple variable references for efficiency. * So peek ahead to see if that's what we have. */ - int tok = yylex(); + int tok = yylex(); if (tok == T_DATUM && plpgsql_peek() == ';' && (yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_VAR || @@ -3319,11 +3320,11 @@ make_return_next_stmt(int location) parser_errposition(location))); new = palloc0(sizeof(PLpgSQL_stmt_return_next)); - new->cmd_type = PLPGSQL_STMT_RETURN_NEXT; - new->lineno = plpgsql_location_to_lineno(location); - new->stmtid = ++plpgsql_curr_compile->nstatements; - new->expr = NULL; - new->retvarno = -1; + new->cmd_type = PLPGSQL_STMT_RETURN_NEXT; + new->lineno = plpgsql_location_to_lineno(location); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->expr = NULL; + new->retvarno = -1; if (plpgsql_curr_compile->out_param_varno >= 0) { @@ -3340,7 +3341,7 @@ make_return_next_stmt(int location) * We want to special-case simple variable references for efficiency. * So peek ahead to see if that's what we have. */ - int tok = yylex(); + int tok = yylex(); if (tok == T_DATUM && plpgsql_peek() == ';' && (yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_VAR || @@ -3397,7 +3398,7 @@ make_return_query_stmt(int location) else { /* dynamic SQL */ - int term; + int term; new->dynquery = read_sql_expression2(';', K_USING, "; or USING", &term); @@ -3525,16 +3526,16 @@ read_into_scalar_list(char *initial_name, PLpgSQL_datum *initial_datum, int initial_location) { - int nfields; - char *fieldnames[1024]; - int varnos[1024]; - PLpgSQL_row *row; - int tok; + int nfields; + char *fieldnames[1024]; + int varnos[1024]; + PLpgSQL_row *row; + int tok; check_assignable(initial_datum, initial_location); fieldnames[0] = initial_name; - varnos[0] = initial_datum->dno; - nfields = 1; + varnos[0] = initial_datum->dno; + nfields = 1; while ((tok = yylex()) == ',') { @@ -3587,7 +3588,7 @@ read_into_scalar_list(char *initial_name, row->varnos[nfields] = varnos[nfields]; } - plpgsql_adddatum((PLpgSQL_datum *)row); + plpgsql_adddatum((PLpgSQL_datum *) row); return row; } @@ -3604,7 +3605,7 @@ make_scalar_list1(char *initial_name, PLpgSQL_datum *initial_datum, int lineno, int location) { - PLpgSQL_row *row; + PLpgSQL_row *row; check_assignable(initial_datum, location); @@ -3619,7 +3620,7 @@ make_scalar_list1(char *initial_name, row->fieldnames[0] = initial_name; row->varnos[0] = initial_datum->dno; - plpgsql_adddatum((PLpgSQL_datum *)row); + plpgsql_adddatum((PLpgSQL_datum *) row); return row; } @@ -3691,7 +3692,7 @@ plpgsql_sql_error_callback(void *arg) errpos = geterrposition(); if (errpos > 0) { - int myerrpos = getinternalerrposition(); + int myerrpos = getinternalerrposition(); if (myerrpos > 0) /* safety check */ internalerrposition(myerrpos + errpos - 1); @@ -3818,11 +3819,11 @@ read_cursor_args(PLpgSQL_var *cursor, int until) for (argc = 0; argc < row->nfields; argc++) { PLpgSQL_expr *item; - int endtoken; - int argpos; - int tok1, - tok2; - int arglocation; + int endtoken; + int argpos; + int tok1, + tok2; + int arglocation; /* Check if it's a named parameter: "param := value" */ plpgsql_peek2(&tok1, &tok2, &arglocation, NULL); @@ -3923,12 +3924,12 @@ read_cursor_args(PLpgSQL_var *cursor, int until) } expr = palloc0(sizeof(PLpgSQL_expr)); - expr->query = pstrdup(ds.data); - expr->parseMode = RAW_PARSE_PLPGSQL_EXPR; - expr->plan = NULL; - expr->paramnos = NULL; - expr->target_param = -1; - expr->ns = plpgsql_ns_top(); + expr->query = pstrdup(ds.data); + expr->parseMode = RAW_PARSE_PLPGSQL_EXPR; + expr->plan = NULL; + expr->paramnos = NULL; + expr->target_param = -1; + expr->ns = plpgsql_ns_top(); pfree(ds.data); /* Next we'd better find the until token */ @@ -3950,7 +3951,7 @@ read_raise_options(void) for (;;) { PLpgSQL_raise_option *opt; - int tok; + int tok; if ((tok = yylex()) == 0) yyerror("unexpected end of function definition"); @@ -4044,7 +4045,7 @@ static PLpgSQL_stmt * make_case(int location, PLpgSQL_expr *t_expr, List *case_when_list, List *else_stmts) { - PLpgSQL_stmt_case *new; + PLpgSQL_stmt_case *new; new = palloc(sizeof(PLpgSQL_stmt_case)); new->cmd_type = PLPGSQL_STMT_CASE; @@ -4070,9 +4071,9 @@ make_case(int location, PLpgSQL_expr *t_expr, */ if (t_expr) { - char varname[32]; + char varname[32]; PLpgSQL_var *t_var; - ListCell *l; + ListCell *l; /* use a name unlikely to collide with any user names */ snprintf(varname, sizeof(varname), "__Case__Variable_%d__", @@ -4095,7 +4096,7 @@ make_case(int location, PLpgSQL_expr *t_expr, { PLpgSQL_case_when *cwt = (PLpgSQL_case_when *) lfirst(l); PLpgSQL_expr *expr = cwt->expr; - StringInfoData ds; + StringInfoData ds; /* We expect to have expressions not statements */ Assert(expr->parseMode == RAW_PARSE_PLPGSQL_EXPR);