Re: tablecmds: reject CLUSTER ON for partitioned tables earlier

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: tablecmds: reject CLUSTER ON for partitioned tables earlier
Date: 2026-03-13 03:38:17
Message-ID: 8A3FAABD-F297-41D1-9B07-20A37E311C29@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Jan 28, 2026, at 10:15, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
>
>
>> On Jan 27, 2026, at 16:55, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote:
>>
>>> I added two new test cases in 0002 that trigger the check.
>>
>> I also tested these scenarios previously. It's good that they are part
>> of the test suite, but they don't hit that error path. Verified with
>> this:
>>
>> diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
>> index 379f4d4ebaf..50f80724cb3 100644
>> --- a/src/backend/commands/tablecmds.c
>> +++ b/src/backend/commands/tablecmds.c
>> @@ -17857,9 +17857,7 @@ ATExecDropInherit(Relation rel, RangeVar
>> *parent, LOCKMODE lockmode)
>> Relation parent_rel;
>>
>> if (rel->rd_rel->relispartition)
>> - ereport(ERROR,
>> - (errcode(ERRCODE_WRONG_OBJECT_TYPE),
>> - errmsg("cannot change inheritance of a partition")));
>> + Assert(0);
>>
>> /*
>> * AccessShareLock on the parent is probably enough, seeing that DROP
>
> Thank you so much for pointing out this, and sorry for misunderstanding you. You are right, as the check has been added to ATPrepChangeInherit(), the same check in ATExecDropInherit becomes redundant. I thought you were talking about the check in ATPrepChangeInherit().
>
> PFA v7:
>
> * In 0001, replaced ereport with assert in mark_index_clustered(). See my previous email for the analysis.
> * In 0002, removed the redundant check of relispartition from ATExecDropInherit().
>
> Best regards,
> --
> Chao Li (Evan)
> HighGo Software Co., Ltd.
> https://www.highgo.com/
>
>
>
>
> <v7-0001-tablecmds-reject-CLUSTER-ON-for-partitioned-table.patch><v7-0002-tablecmds-reject-INHERIT-NO-INHERIT-for-partition.patch>

PFA v8: rebase requested by CF https://commitfest.postgresql.org/patch/6415/

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachment Content-Type Size
v8-0001-tablecmds-reject-CLUSTER-ON-for-partitioned-table.patch application/octet-stream 3.7 KB
v8-0002-tablecmds-reject-INHERIT-NO-INHERIT-for-partition.patch application/octet-stream 7.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2026-03-13 03:55:44 Re: IS JSON predicate support for domain base type as JSON/JSONB/BYTEA/TEXT
Previous Message Peter Smith 2026-03-13 03:24:45 Re: Skipping schema changes in publication