Re: ALTER TABLE SET ACCESS METHOD on partitioned tables

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Soumyadeep Chakraborty <soumyadeep2007(at)gmail(dot)com>, Zhihong Yu <zyu(at)yugabyte(dot)com>, pgsql-hackers(at)postgresql(dot)org, Ashwin Agrawal <ashwinstar(at)gmail(dot)com>, vanjared(at)vmware(dot)com
Subject: Re: ALTER TABLE SET ACCESS METHOD on partitioned tables
Date: 2023-06-01 12:50:50
Message-ID: ZHiUKhhT71X4CjJl@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 31, 2023 at 06:35:34PM -0500, Justin Pryzby wrote:
> What do you think the comment ought to say ? It already says:
>
> src/backend/catalog/heap.c- * Make a dependency link to force the relation to be deleted if its
> src/backend/catalog/heap.c- * access method is.

This is the third location where we rely on the fact that
RELKIND_HAS_TABLE_AM() does not include RELKIND_PARTITIONED_TABLE, so
it seems worth documenting what we are relying on as a comment? Say:
* Make a dependency link to force the relation to be deleted if its
* access method is.
*
* No need to add an explicit dependency for the toast table, as the
* main table depends on it. Partitioned tables have a table access
* method defined, and RELKIND_HAS_TABLE_AM ignores them.

>> Speaking of which, ATExecSetAccessMethodNoStorage() does a catalog
>> update even if ALTER TABLE is defined to use the same table AM as what
>> is currently set. There is no need to update the relation's pg_class
>> entry in this case. Be careful that InvokeObjectPostAlterHook() still
>> needs to be checked in this case. Perhaps some tests should be added
>> in test_oat_hooks.sql? It would be tempted to add a new SQL file for
>> that.
>
> Are you suggesting to put this in a conditional: if oldrelam!=newAccessMethod ?

Yes, that's what I would add with a few lines close to the beginning
of ATExecSetTableSpaceNoStorage() to save from catalog updates if
these are not needed.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-06-01 13:11:49 Re: [PATCH] Missing dep on Catalog.pm in meson rules
Previous Message Dagfinn Ilmari Mannsåker 2023-06-01 12:41:40 [PATCH] Missing dep on Catalog.pm in meson rules