1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-25 01:02:05 +03:00

Rework 'MOVE ALL' to 'ALTER .. ALL IN TABLESPACE'

As 'ALTER TABLESPACE .. MOVE ALL' really didn't change the tablespace
but instead changed objects inside tablespaces, it made sense to
rework the syntax and supporting functions to operate under the
'ALTER (TABLE|INDEX|MATERIALIZED VIEW)' syntax and to be in
tablecmds.c.

Pointed out by Alvaro, who also suggested the new syntax.

Back-patch to 9.4.
This commit is contained in:
Stephen Frost
2014-08-21 19:06:17 -04:00
parent f57791985a
commit 3c4cf08087
18 changed files with 305 additions and 392 deletions

View File

@ -1763,6 +1763,28 @@ AlterTableStmt:
n->missing_ok = true;
$$ = (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;
}
| 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;
}
| ALTER INDEX qualified_name alter_table_cmds
{
AlterTableStmt *n = makeNode(AlterTableStmt);
@ -1781,6 +1803,28 @@ AlterTableStmt:
n->missing_ok = true;
$$ = (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;
}
| 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;
}
| ALTER SEQUENCE qualified_name alter_table_cmds
{
AlterTableStmt *n = makeNode(AlterTableStmt);
@ -1835,6 +1879,28 @@ AlterTableStmt:
n->missing_ok = true;
$$ = (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;
}
| 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;
}
;
alter_table_cmds:
@ -7002,103 +7068,8 @@ opt_force: FORCE { $$ = TRUE; }
*
*****************************************************************************/
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
AlterTblSpcStmt:
ALTER TABLESPACE name SET reloptions
{
AlterTableSpaceOptionsStmt *n =
makeNode(AlterTableSpaceOptionsStmt);