pgsql: Fix dependency of partitioned table and table AM with CREATE TAB

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix dependency of partitioned table and table AM with CREATE TAB
Date: 2024-10-28 23:42:29
Message-ID: E1t5ZNW-002usz-2l@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix dependency of partitioned table and table AM with CREATE TABLE .. USING

A pg_depend entry between a partitioned table and its table access
method was missing when using CREATE TABLE .. USING with an unpinned
access method. DROP ACCESS METHOD could be used, while it should be
blocked if CASCADE is not specified, even if there was a partitioned
table that depends on the table access method. pg_class.relam would
then hold an orphaned OID value still pointing to the AM dropped.

The problem is fixed by adding a dependency between the partitioned
table and its table access method if set when the relation is created.
A test checking the contents of pg_depend in this case is added.

Issue introduced in 374c7a229042, that has added support for CREATE
TABLE .. USING for partitioned tables.

Reviewed-by: Alexander Lakhin
Discussion: https://postgr.es/m/18674-1ef01eceec278fab@postgresql.org
Backpatch-through: 17

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bb584e831288042d9aee368a1c5daa3dafbb95c3

Modified Files
--------------
src/backend/catalog/heap.c | 6 ++++--
src/test/regress/expected/create_am.out | 14 ++++++++++++++
src/test/regress/sql/create_am.sql | 10 ++++++++++
3 files changed, 28 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2024-10-29 03:24:36 pgsql: Doc: clarify enable_indexscan=off also disabled Index Only Scans
Previous Message Nathan Bossart 2024-10-28 21:45:36 pgsql: Ensure we have a snapshot when updating pg_index in index_drop()