Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly
Alexey Kondratov <a.kondratov@postgrespro.ru>
From: Alexey Kondratov <a.kondratov@postgrespro.ru>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Michael Paquier <michael@paquier.xyz>, Masahiko Sawada
<masahiko.sawada@2ndquadrant.com>, Steve Singer <steve@ssinger.info>,
pgsql-hackers@lists.postgresql.org, Alvaro Herrera
<alvherre@2ndquadrant.com>, Robert Haas <robertmhaas@gmail.com>, Alexander
Korotkov <a.korotkov@postgrespro.ru>, Masahiko Sawada
<sawada.mshk@gmail.com>, Jose Luis Tallon <jltallon@adv-solutions.net>
Date: 2020-03-26T19:22:08Z
Lists: pgsql-hackers
On 2020-03-26 21:01, Justin Pryzby wrote: > >> @@ -262,7 +280,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel) >> * and error messages should refer to the operation as VACUUM not >> CLUSTER. >> */ >> void >> -cluster_rel(Oid tableOid, Oid indexOid, int options) >> +cluster_rel(Oid tableOid, Oid indexOid, Oid tablespaceOid, int >> options) > > Add a comment here about the tablespaceOid parameter, like the other > functions > where it's added. > > The permission checking is kind of duplicitive, so I'd suggest to > factor it > out. Ideally we'd only have one place that checks for > pg_global/system/mapped. > It needs to check that it's not a system relation, or that > system_table_mods > are allowed, and in any case that if it's a mapped rel, that it's not > being > moved. I would pass a boolean indicating if the tablespace is being > changed. > Yes, but I wanted to make sure first that all necessary validations are there to do not miss something as I did last time. I do not like repetitive code either, so I would like to introduce more common check after reviewing the code as a whole. > > Another issue is this: >> +VACUUM ( FULL [, ...] ) [ TABLESPACE <replaceable >> class="parameter">new_tablespace</replaceable> ] [ <replaceable >> class="parameter">table_and_columns</replaceable> [, ...] ] > As you mentioned in your v1 patch, in the other cases, "tablespace > [tablespace]" is added at the end of the command rather than in the > middle. I > wasn't able to make that work, maybe because "tablespace" isn't a fully > reserved word (?). I didn't try with "SET TABLESPACE", although I > understand > it'd be better without "SET". > Initially I tried "SET TABLESPACE", but also failed to completely get rid of shift/reduce conflicts. I will try to rewrite VACUUM's part again with OptTableSpace. Maybe I will manage it this time. I will take into account all your text edits as well. Thanks -- Alexey Kondratov Postgres Professional https://www.postgrespro.com Russian Postgres Company
Commits
-
Add TABLESPACE option to REINDEX
- c5b286047cd6 14.0 landed
-
Refactor code in tablecmds.c to check and process tablespace moves
- 4c9c359d38ff 14.0 landed
-
Refactor option handling of CLUSTER, REINDEX and VACUUM
- a3dc926009be 14.0 landed
-
pg_dump: Don't use enums for defining bit mask values
- d2a2808eb444 14.0 landed
-
Refactor CLUSTER and REINDEX grammar to use DefElem for option lists
- b5913f612079 14.0 landed
-
Refactor parsing rules for option lists of EXPLAIN, VACUUM and ANALYZE
- 873ea9ee692e 14.0 landed
-
Improve tab completion of REINDEX in psql
- 1f75b454134c 14.0 landed
-
Fix possible crash during FATAL exit from reindexing.
- d12bdba77b0f 13.0 cited