Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly
Justin Pryzby <pryzby@telsasoft.com>
From: Justin Pryzby <pryzby@telsasoft.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Alexey Kondratov <a.kondratov@postgrespro.ru>, Masahiko Sawada <masahiko.sawada@2ndquadrant.com>, Steve Singer <steve@ssinger.info>, pgsql-hackers@lists.postgresql.org, 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-12-22T08:32:05Z
Lists: pgsql-hackers
On Tue, Dec 22, 2020 at 03:47:57PM +0900, Michael Paquier wrote:
> On Wed, Dec 16, 2020 at 10:01:11AM +0900, Michael Paquier wrote:
> > On Tue, Dec 15, 2020 at 09:45:17PM -0300, Alvaro Herrera wrote:
> > > I don't like this idea too much, because adding an option causes an ABI
> > > break. I don't think we commonly add options in backbranches, but it
> > > has happened. The bitmask is much easier to work with in that regard.
> >
> > ABI flexibility is a good point here. I did not consider this point
> > of view. Thanks!
>
> FWIW, I have taken a shot at this part of the patch, and finished with
> the attached. This uses bits32 for the bitmask options and an hex
> style for the bitmask params, while bundling all the flags into
> dedicated structures for all the options that can be extended for the
> tablespace case (or some filtering for REINDEX).
Seems fine, but why do you do memcpy() instead of a structure assignment ?
> @@ -3965,8 +3965,11 @@ reindex_relation(Oid relid, int flags, int options)
> * Note that this should fail if the toast relation is missing, so
> * reset REINDEXOPT_MISSING_OK.
> */
> - result |= reindex_relation(toast_relid, flags,
> - options & ~(REINDEXOPT_MISSING_OK));
> + ReindexOptions newoptions;
> +
> + memcpy(&newoptions, options, sizeof(ReindexOptions));
> + newoptions.flags &= ~(REINDEXOPT_MISSING_OK);
> + result |= reindex_relation(toast_relid, flags, &newoptions);
Could be newoptions = *options;
Also, this one is going to be subsumed by ExecReindex(), so the palloc will go
away (otherwise I would ask to pass it in from the caller):
> +ReindexOptions *
> ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt)
> {
> ListCell *lc;
> - int options = 0;
> + ReindexOptions *options;
> bool concurrently = false;
> bool verbose = false;
>
> + options = (ReindexOptions *) palloc0(sizeof(ReindexOptions));
> +
--
Justin
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