Re: ALTER TABLE SET ACCESS METHOD on partitioned tables

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: ALTER TABLE SET ACCESS METHOD on partitioned tables
Дата
Msg-id ZHiUKhhT71X4CjJl@paquier.xyz
обсуждение исходный текст
Ответ на Re: ALTER TABLE SET ACCESS METHOD on partitioned tables  (Justin Pryzby <pryzby@telsasoft.com>)
Ответы Re: ALTER TABLE SET ACCESS METHOD on partitioned tables  (Daniel Gustafsson <daniel@yesql.se>)
Re: ALTER TABLE SET ACCESS METHOD on partitioned tables  (Justin Pryzby <pryzby@telsasoft.com>)
Re: ALTER TABLE SET ACCESS METHOD on partitioned tables  (Justin Pryzby <pryzby@telsasoft.com>)
Список 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

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Dagfinn Ilmari Mannsåker
Дата:
Сообщение: [PATCH] Missing dep on Catalog.pm in meson rules
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: [PATCH] Missing dep on Catalog.pm in meson rules