From 5f508b6dea19b66961c645bf5e5c427ac3af8359 Mon Sep 17 00:00:00 2001 From: Stephen Frost Date: Sun, 13 Apr 2014 01:02:44 -0400 Subject: [PATCH] Make a dedicated AlterTblSpcStmt production Given that ALTER TABLESPACE has moved on from just existing for general purpose rename/owner changes, it deserves its own top-level production in the grammar. This also cleans up the RenameStmt to only ever be used for actual RENAMEs again- it really wasn't appropriate to hide non-RENAME productions under there. Noted by Alvaro. --- src/backend/parser/gram.y | 239 ++++++++++++++++++++------------------ 1 file changed, 124 insertions(+), 115 deletions(-) diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index e3060a4dff..7b9895d61e 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -218,7 +218,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); AlterDatabaseStmt AlterDatabaseSetStmt AlterDomainStmt AlterEnumStmt AlterFdwStmt AlterForeignServerStmt AlterGroupStmt AlterObjectSchemaStmt AlterOwnerStmt AlterSeqStmt AlterSystemStmt AlterTableStmt - AlterExtensionStmt AlterExtensionContentsStmt AlterForeignTableStmt + AlterTblSpcStmt AlterExtensionStmt AlterExtensionContentsStmt AlterForeignTableStmt AlterCompositeTypeStmt AlterUserStmt AlterUserMappingStmt AlterUserSetStmt AlterRoleStmt AlterRoleSetStmt AlterDefaultPrivilegesStmt DefACLAction @@ -728,6 +728,7 @@ stmt : | AlterSeqStmt | AlterSystemStmt | AlterTableStmt + | AlterTblSpcStmt | AlterCompositeTypeStmt | AlterRoleSetStmt | AlterRoleStmt @@ -6934,6 +6935,128 @@ opt_force: FORCE { $$ = TRUE; } ; +/***************************************************************************** + * + * ALTER TABLESPACE + * + *****************************************************************************/ + +AlterTblSpcStmt: ALTER TABLESPACE name MOVE ALL TO name opt_nowait + { + AlterTableSpaceMoveStmt *n = + makeNode(AlterTableSpaceMoveStmt); + n->orig_tablespacename = $3; + n->objtype = -1; + n->move_all = true; + n->roles = NIL; + n->new_tablespacename = $7; + n->nowait = $8; + $$ = (Node *)n; + } + | ALTER TABLESPACE name MOVE TABLES TO name opt_nowait + { + AlterTableSpaceMoveStmt *n = + makeNode(AlterTableSpaceMoveStmt); + n->orig_tablespacename = $3; + n->objtype = OBJECT_TABLE; + n->move_all = false; + n->roles = NIL; + n->new_tablespacename = $7; + n->nowait = $8; + $$ = (Node *)n; + } + | ALTER TABLESPACE name MOVE INDEXES TO name opt_nowait + { + AlterTableSpaceMoveStmt *n = + makeNode(AlterTableSpaceMoveStmt); + n->orig_tablespacename = $3; + n->objtype = OBJECT_INDEX; + n->move_all = false; + n->roles = NIL; + n->new_tablespacename = $7; + n->nowait = $8; + $$ = (Node *)n; + } + | ALTER TABLESPACE name MOVE MATERIALIZED VIEWS TO name opt_nowait + { + AlterTableSpaceMoveStmt *n = + makeNode(AlterTableSpaceMoveStmt); + n->orig_tablespacename = $3; + n->objtype = OBJECT_MATVIEW; + n->move_all = false; + n->roles = NIL; + n->new_tablespacename = $8; + n->nowait = $9; + $$ = (Node *)n; + } + | ALTER TABLESPACE name MOVE ALL OWNED BY role_list TO name opt_nowait + { + AlterTableSpaceMoveStmt *n = + makeNode(AlterTableSpaceMoveStmt); + n->orig_tablespacename = $3; + n->objtype = -1; + n->move_all = true; + n->roles = $8; + n->new_tablespacename = $10; + n->nowait = $11; + $$ = (Node *)n; + } + | ALTER TABLESPACE name MOVE TABLES OWNED BY role_list TO name opt_nowait + { + AlterTableSpaceMoveStmt *n = + makeNode(AlterTableSpaceMoveStmt); + n->orig_tablespacename = $3; + n->objtype = OBJECT_TABLE; + n->move_all = false; + n->roles = $8; + n->new_tablespacename = $10; + n->nowait = $11; + $$ = (Node *)n; + } + | ALTER TABLESPACE name MOVE INDEXES OWNED BY role_list TO name opt_nowait + { + AlterTableSpaceMoveStmt *n = + makeNode(AlterTableSpaceMoveStmt); + n->orig_tablespacename = $3; + n->objtype = OBJECT_INDEX; + n->move_all = false; + n->roles = $8; + n->new_tablespacename = $10; + n->nowait = $11; + $$ = (Node *)n; + } + | ALTER TABLESPACE name MOVE MATERIALIZED VIEWS OWNED BY role_list TO name opt_nowait + { + AlterTableSpaceMoveStmt *n = + makeNode(AlterTableSpaceMoveStmt); + n->orig_tablespacename = $3; + n->objtype = OBJECT_MATVIEW; + n->move_all = false; + n->roles = $9; + n->new_tablespacename = $11; + n->nowait = $12; + $$ = (Node *)n; + } + | ALTER TABLESPACE name SET reloptions + { + AlterTableSpaceOptionsStmt *n = + makeNode(AlterTableSpaceOptionsStmt); + n->tablespacename = $3; + n->options = $5; + n->isReset = FALSE; + $$ = (Node *)n; + } + | ALTER TABLESPACE name RESET reloptions + { + AlterTableSpaceOptionsStmt *n = + makeNode(AlterTableSpaceOptionsStmt); + n->tablespacename = $3; + n->options = $5; + n->isReset = TRUE; + $$ = (Node *)n; + } + ; + /***************************************************************************** * * ALTER THING name RENAME TO newname @@ -7322,120 +7445,6 @@ RenameStmt: ALTER AGGREGATE func_name aggr_args RENAME TO name n->missing_ok = false; $$ = (Node *)n; } - | ALTER TABLESPACE name MOVE ALL TO name opt_nowait - { - AlterTableSpaceMoveStmt *n = - makeNode(AlterTableSpaceMoveStmt); - n->orig_tablespacename = $3; - n->objtype = -1; - n->move_all = true; - n->roles = NIL; - n->new_tablespacename = $7; - n->nowait = $8; - $$ = (Node *)n; - } - | ALTER TABLESPACE name MOVE TABLES TO name opt_nowait - { - AlterTableSpaceMoveStmt *n = - makeNode(AlterTableSpaceMoveStmt); - n->orig_tablespacename = $3; - n->objtype = OBJECT_TABLE; - n->move_all = false; - n->roles = NIL; - n->new_tablespacename = $7; - n->nowait = $8; - $$ = (Node *)n; - } - | ALTER TABLESPACE name MOVE INDEXES TO name opt_nowait - { - AlterTableSpaceMoveStmt *n = - makeNode(AlterTableSpaceMoveStmt); - n->orig_tablespacename = $3; - n->objtype = OBJECT_INDEX; - n->move_all = false; - n->roles = NIL; - n->new_tablespacename = $7; - n->nowait = $8; - $$ = (Node *)n; - } - | ALTER TABLESPACE name MOVE MATERIALIZED VIEWS TO name opt_nowait - { - AlterTableSpaceMoveStmt *n = - makeNode(AlterTableSpaceMoveStmt); - n->orig_tablespacename = $3; - n->objtype = OBJECT_MATVIEW; - n->move_all = false; - n->roles = NIL; - n->new_tablespacename = $8; - n->nowait = $9; - $$ = (Node *)n; - } - | ALTER TABLESPACE name MOVE ALL OWNED BY role_list TO name opt_nowait - { - AlterTableSpaceMoveStmt *n = - makeNode(AlterTableSpaceMoveStmt); - n->orig_tablespacename = $3; - n->objtype = -1; - n->move_all = true; - n->roles = $8; - n->new_tablespacename = $10; - n->nowait = $11; - $$ = (Node *)n; - } - | ALTER TABLESPACE name MOVE TABLES OWNED BY role_list TO name opt_nowait - { - AlterTableSpaceMoveStmt *n = - makeNode(AlterTableSpaceMoveStmt); - n->orig_tablespacename = $3; - n->objtype = OBJECT_TABLE; - n->move_all = false; - n->roles = $8; - n->new_tablespacename = $10; - n->nowait = $11; - $$ = (Node *)n; - } - | ALTER TABLESPACE name MOVE INDEXES OWNED BY role_list TO name opt_nowait - { - AlterTableSpaceMoveStmt *n = - makeNode(AlterTableSpaceMoveStmt); - n->orig_tablespacename = $3; - n->objtype = OBJECT_INDEX; - n->move_all = false; - n->roles = $8; - n->new_tablespacename = $10; - n->nowait = $11; - $$ = (Node *)n; - } - | ALTER TABLESPACE name MOVE MATERIALIZED VIEWS OWNED BY role_list TO name opt_nowait - { - AlterTableSpaceMoveStmt *n = - makeNode(AlterTableSpaceMoveStmt); - n->orig_tablespacename = $3; - n->objtype = OBJECT_MATVIEW; - n->move_all = false; - n->roles = $9; - n->new_tablespacename = $11; - n->nowait = $12; - $$ = (Node *)n; - } - | ALTER TABLESPACE name SET reloptions - { - AlterTableSpaceOptionsStmt *n = - makeNode(AlterTableSpaceOptionsStmt); - n->tablespacename = $3; - n->options = $5; - n->isReset = FALSE; - $$ = (Node *)n; - } - | ALTER TABLESPACE name RESET reloptions - { - AlterTableSpaceOptionsStmt *n = - makeNode(AlterTableSpaceOptionsStmt); - n->tablespacename = $3; - n->options = $5; - n->isReset = TRUE; - $$ = (Node *)n; - } | ALTER TEXT_P SEARCH PARSER any_name RENAME TO name { RenameStmt *n = makeNode(RenameStmt); -- 2.40.0