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