Re: alter table set TABLE ACCESS METHOD - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: alter table set TABLE ACCESS METHOD
Date
Msg-id 20210610024014.GA16435@telsasoft.com
Whole thread Raw
In response to Re: alter table set TABLE ACCESS METHOD  (Zhihong Yu <zyu@yugabyte.com>)
List pgsql-hackers
On Wed, Jun 09, 2021 at 01:45:52PM -0700, Zhihong Yu wrote:
> +           /* check if another access method change was already requested
> */
> +           if (tab->newAccessMethod)
> +               ereport(ERROR,
> +                       (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> +                        errmsg("cannot change access method setting twice")));
> 
> I think the error message can be refined - changing  access method twice is
> supported, as long as the two changes don't overlap.

That language is consistent wtih existing errors.

src/backend/commands/tablecmds.c:                                                errmsg("cannot change persistence
settingtwice")));
 
src/backend/commands/tablecmds.c:                                                errmsg("cannot change persistence
settingtwice")));
 
                                 errmsg("cannot alter type of column \"%s\" twice",

However, I think that SET TABLESPACE is a better template to follow:
                                 errmsg("cannot have multiple SET TABLESPACE subcommands")));

Michael pointed out that there's two, redundant checks:

+       if (rel->rd_rel->relam == amoid)
+               return;
+  
+       /* Save info for Phase 3 to do the real work */
+       if (OidIsValid(tab->newAccessMethod))
+               ereport(ERROR,
+                               (errcode(ERRCODE_SYNTAX_ERROR),
+                                errmsg("cannot have multiple SET ACCESS METHOD subcommands")));

I think that the "multiple subcommands" test should be before the "no-op" test.

@Jeff: In my original patch, I also proposed patches 2,3:

Subject: [PATCH v2 2/3] Allow specifying acccess method of partitioned tables..
Subject: [PATCH v2 3/3] Implement lsyscache get_rel_relam()
                        
 



pgsql-hackers by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: alter table set TABLE ACCESS METHOD
Next
From: Amit Kapila
Date:
Subject: Re: Decoding of two-phase xacts missing from CREATE_REPLICATION_SLOT command