Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Alexey Kondratov <a(dot)kondratov(at)postgrespro(dot)ru>, Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com>, Steve Singer <steve(at)ssinger(dot)info>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Robert Haas <robertmhaas(at)gmail(dot)com>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Jose Luis Tallon <jltallon(at)adv-solutions(dot)net>
Subject: Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly
Date: 2020-12-22 08:32:05
Message-ID: 20201222083204.GL30237@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2020-12-22 08:37:17 Re: Fail Fast In CTAS/CMV If Relation Already Exists To Avoid Unnecessary Rewrite, Planning Costs
Previous Message Amit Langote 2020-12-22 08:16:46 Re: ModifyTable overheads in generic plans