Re: tablecmds: reject CLUSTER ON for partitioned tables earlier
Chao Li <li.evan.chao@gmail.com>
From: Chao Li <li.evan.chao@gmail.com>
To: Zsolt Parragi <zsolt.parragi@percona.com>
Cc: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-01-28T02:15:29Z
Lists: pgsql-hackers
Attachments
- v7-0001-tablecmds-reject-CLUSTER-ON-for-partitioned-table.patch (application/octet-stream) patch v7-0001
- v7-0002-tablecmds-reject-INHERIT-NO-INHERIT-for-partition.patch (application/octet-stream) patch v7-0002
> On Jan 27, 2026, at 16:55, Zsolt Parragi <zsolt.parragi@percona.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/
Commits
-
Refactor some code around ALTER TABLE [NO] INHERIT
- 1a7ccd2b332d 19 (unreleased) landed
-
Add regression test for ALTER TABLE .. NO INHERIT on typed tables
- cbf9a72993ec 19 (unreleased) landed
-
Reject ALTER TABLE .. CLUSTER earlier for partitioned tables
- c336133c65a7 19 (unreleased) landed
-
Ignore partitioned indexes where appropriate
- 05fb5d661925 11.0 cited