From 76e91b38ba64e1da70ea21744b342cb105ea3400 Mon Sep 17 00:00:00 2001 From: Stephen Frost Date: Sat, 18 Jan 2014 18:56:40 -0500 Subject: Add ALTER TABLESPACE ... MOVE command This adds a 'MOVE' sub-command to ALTER TABLESPACE which allows moving sets of objects from one tablespace to another. This can be extremely handy and avoids a lot of error-prone scripting. ALTER TABLESPACE ... MOVE will only move objects the user owns, will notify the user if no objects were found, and can be used to move ALL objects or specific types of objects (TABLES, INDEXES, or MATERIALIZED VIEWS). --- src/backend/parser/gram.y | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'src/backend/parser') diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index f0b95071d5e..1b63d415318 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -601,7 +601,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); UNTIL UPDATE USER USING VACUUM VALID VALIDATE VALIDATOR VALUE_P VALUES VARCHAR VARIADIC VARYING - VERBOSE VERSION_P VIEW VOLATILE + VERBOSE VERSION_P VIEW VIEWS VOLATILE WHEN WHERE WHITESPACE_P WINDOW WITH WITHIN WITHOUT WORK WRAPPER WRITE @@ -7319,6 +7319,49 @@ 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->new_tablespacename = $7; + n->nowait = $8; + n->move_all = true; + $$ = (Node *)n; + } + | ALTER TABLESPACE name MOVE TABLES TO name opt_nowait + { + AlterTableSpaceMoveStmt *n = + makeNode(AlterTableSpaceMoveStmt); + n->orig_tablespacename = $3; + n->new_tablespacename = $7; + n->nowait = $8; + n->objtype = OBJECT_TABLE; + n->move_all = false; + $$ = (Node *)n; + } + | ALTER TABLESPACE name MOVE INDEXES TO name opt_nowait + { + AlterTableSpaceMoveStmt *n = + makeNode(AlterTableSpaceMoveStmt); + n->orig_tablespacename = $3; + n->new_tablespacename = $7; + n->nowait = $8; + n->objtype = OBJECT_INDEX; + n->move_all = false; + $$ = (Node *)n; + } + | ALTER TABLESPACE name MOVE MATERIALIZED VIEWS TO name opt_nowait + { + AlterTableSpaceMoveStmt *n = + makeNode(AlterTableSpaceMoveStmt); + n->orig_tablespacename = $3; + n->new_tablespacename = $8; + n->nowait = $9; + n->objtype = OBJECT_MATVIEW; + n->move_all = false; + $$ = (Node *)n; + } | ALTER TABLESPACE name SET reloptions { AlterTableSpaceOptionsStmt *n = @@ -12887,6 +12930,7 @@ unreserved_keyword: | VARYING | VERSION_P | VIEW + | VIEWS | VOLATILE | WHITESPACE_P | WITHIN -- cgit v1.2.3