| 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-01-23 00:54:33 |
| Message-ID: | EA6CB317-60C2-4BA9-8E02-DBCAD384F107@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Jan 23, 2026, at 07:30, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
>
>
>> On Jan 22, 2026, at 17:01, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>>
>>
>>
>>> On Jan 21, 2026, at 11:55, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>>>
>>> Hi Hacker,
>>>
>>> I noticed this while working other patches related to “ALTER TABLE”.
>>>
>>> “ALTER TABLE … CLUSTER ON” and "SET WITHOUT CLUSTER" are not supported for partitioned tables, but currently ATPrepCmd() allows them through and they only fail later at execution time.
>>>
>>> This patch rejects these commands earlier by using the existing ATSimplePermissions() infrastructure in ATPrepCmd(), matching the handling of other unsupported ALTER TABLE actions on partitioned tables (such as SET LOGGED / SET UNLOGGED). This makes the behavior more consistent and simplifies the code path.
>>>
>>> As a result, the error reported for partitioned tables changes:
>>>
>>> Before the patch:
>>> ```
>>> evantest=# ALTER TABLE p_test CLUSTER ON idx_p_test_id;
>>> ERROR: cannot mark index clustered in partitioned table
>>> ```
>>>
>>> With the patch:
>>> ```
>>> evantest=# ALTER TABLE p_test CLUSTER ON idx_p_test_id;
>>> ERROR: ALTER action CLUSTER ON cannot be performed on relation "p_test"
>>> DETAIL: This operation is not supported for partitioned tables.
>>> ```
>>>
>>> Best regards,
>>> --
>>> Chao Li (Evan)
>>> HighGo Software Co., Ltd.
>>> https://www.highgo.com/
>>>
>>>
>>>
>>>
>>> <v1-0001-tablecmds-reject-CLUSTER-ON-for-partitioned-table.patch>
>>
>>
>>
>> Applying the same change to INHERIT/NO INHeRIT in v2-0002. Other than that, fixing 2 more things for INHERIT/NO INHERIT:
>>
>> * The header comment of ATPrepAddInherit() was a copy-paste mistake, it described something totally unrelated.
>> * NO INHERIT didn’t call ATPrepAddInherit() to check early, so it had to go deeper and run unnecessary checks.
>>
>> Basically, 0001 and 0002 do the same thing on two sub-commands. If accepted, they can be squashed.
>>
>> Best regards,
>> --
>> Chao Li (Evan)
>> HighGo Software Co., Ltd.
>> https://www.highgo.com/
>>
>> <v2-0001-tablecmds-reject-CLUSTER-ON-for-partitioned-table.patch><v2-0002-tablecmds-reject-INHERIT-NO-INHERIT-for-partition.patch>
>
> PFA v3:
>
> 0001 is the same as v2. In 0002:
>
> * Restored the header comment of ATPrepAddInherit, because I realized the should belong to ATExecAddInherit.
> * Renamed ATPrepAddInherit to ATPrepChangeInherit.
>
> Best regards,
> --
> Chao Li (Evan)
> HighGo Software Co., Ltd.
> https://www.highgo.com/
>
>
>
>
> <v3-0001-tablecmds-reject-CLUSTER-ON-for-partitioned-table.patch><v3-0002-tablecmds-reject-INHERIT-NO-INHERIT-for-partition.patch>
Please ignore v3 that was badly generated.
PFA v4:
> 0001 is the same as v2. In 0002:
>
> * Restored the header comment of ATPrepAddInherit, because I realized the should belong to ATExecAddInherit.
> * Renamed ATPrepAddInherit to ATPrepChangeInherit.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| Attachment | Content-Type | Size |
|---|---|---|
| v4-0001-tablecmds-reject-CLUSTER-ON-for-partitioned-table.patch | application/octet-stream | 2.7 KB |
| v4-0002-tablecmds-reject-INHERIT-NO-INHERIT-for-partition.patch | application/octet-stream | 5.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-01-23 01:16:17 | Re: pg_upgrade: optimize replication slot caught-up check |
| Previous Message | Chao Li | 2026-01-23 00:11:35 | Re: ALTER TABLE: warn when actions do not recurse to partitions |