diff options
author | Stephen Frost | 2014-01-18 23:56:40 +0000 |
---|---|---|
committer | Stephen Frost | 2014-01-18 23:56:40 +0000 |
commit | 76e91b38ba64e1da70ea21744b342cb105ea3400 (patch) | |
tree | bc485da708d31d5484d5a3de6489cf73684a9640 /src/backend/parser | |
parent | 6f25c62d788ea6312fe718ed57a3d169d8efc066 (diff) |
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).
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/gram.y | 46 |
1 files changed, 45 insertions, 1 deletions
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 |