Re: docs: clarify ALTER TABLE behavior on partitioned tables - Mailing list pgsql-hackers

From Chao Li
Subject Re: docs: clarify ALTER TABLE behavior on partitioned tables
Date
Msg-id D8FD5BAF-2AC0-4289-B96E-D3BD99599BE6@gmail.com
Whole thread Raw
In response to Re: docs: clarify ALTER TABLE behavior on partitioned tables  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: docs: clarify ALTER TABLE behavior on partitioned tables
List pgsql-hackers

> On Jan 26, 2026, at 12:36, David G. Johnston <david.g.johnston@gmail.com> wrote:
>
> On Sunday, January 25, 2026, Chao Li <li.evan.chao@gmail.com> wrote:
>
> >      <para>
> >       When applied to a partitioned table, partition columns and constraints
> >       are implicitly renamed.
> >       Specifying <literal>ONLY</literal> is not allowed, and this command
> >       cannot be used on individual partitions.
> >      </para>
>
> But for "Specifying <literal>ONLY</literal> is not allowed, and this command, cannot be used on individual
partitions.”,that doesn’t seem correct. See my test: 
> ```
> evantest=# create table root (i int, j int) partition by list(i);
> CREATE TABLE
> evantest=# create table p1 partition of root for values in (1);
> CREATE TABLE
> evantest=# alter table p1 rename to pp1; <== Rename a partition is allowed.
> ALTER TABLE
> evantest=# alter table only pp1 rename to p1; <== ONLY can be used, but just no effect
> ALTER TABLE
> ```
>
> I was mentally restricting the second sentence about ONLY to the column and constraints renaming action, which are
calledout by the first sentence.  It makes little sense to talk about renaming the table, parent or child, here in the
contextof ONLY.  It goes without mention that table renaming never cascades.  Only is implied for that action, even if
onlyshould just be considered valid on a parent in any case. 
>
> But I’d accept a sentence like: “Table renames always only apply to the named table.” Added to that paragraph; it’s a
convolutedcommand. 
>
> David J.
>

How about this:
```
<para>
 When applied to a partitioned table to rename columns or constraints,
 the corresponding partition columns and constraints are renamed
 implicitly. <literal>ONLY</literal> is not allowed, and the command
 cannot be used on individual partitions. When the rename target is the
 table name, only the named table is renamed.
</para>
```

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







pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: docs: clarify ALTER TABLE behavior on partitioned tables
Next
From: vaibhave postgres
Date:
Subject: [BUG#19384] Fix Server crash at textout