Re: ALTER TABLE: warn when actions do not recurse to partitions - Mailing list pgsql-hackers

From Chao Li
Subject Re: ALTER TABLE: warn when actions do not recurse to partitions
Date
Msg-id CAEoWx2nic2MaPUEKwb0Me1iwO3LsCf8wUHm55pjqaTRgJEZpcQ@mail.gmail.com
Whole thread Raw
In response to Re: ALTER TABLE: warn when actions do not recurse to partitions  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: ALTER TABLE: warn when actions do not recurse to partitions
List pgsql-hackers
Hi David and Greg,

Thanks a lot for your reviews and feedbacks.

On Jan 12, 2026, at 22:40, David G. Johnston <david.g.johnston@gmail.com> wrote:

On Monday, January 12, 2026, Chao Li <li.evan.chao@gmail.com> wrote:

For now, I’ve limited the change to REPLICA IDENTITY to see whether there are objections to this approach. If there are none, I plan to extend the same warning behavior to the other sub-commands listed above. After that, users can reasonably assume that an ALTER TABLE partitioned_table ... action will recurse to child partitions unless a warning explicitly tells them otherwise.

It should be a notice, not a warning.

Make sense. I changed to NOTICE in v2.


How about indicating how many partitions were affected in the notice and

I added partition count in the notice message in v2.

allowing the absence of such a notice to be the indicator that cascading did not happen?

David J.


I don’t think relying on the absence of a notice works well in this case.

Currently, cascading never happens, which is exactly why I’m adding a NOTICE. If we rely on silence to indicate “no cascade”, users have no signal that their expectation was incorrect.

The ALTER TABLE documentation says:
```
If ONLY is specified before the table name, only that table is altered. If ONLY is not specified, the table and all its descendant tables (if any) are altered.
```

Given this, users reasonably expect that omitting ONLY will cause REPLICA IDENTITY to cascade to partitions. In reality, it never does, which breaks that expectation. The NOTICE is intended to make this behavior explicit in exactly that case.


On Jan 12, 2026, at 23:23, Greg Sabino Mullane <htamfids@gmail.com> wrote:

On Mon, Jan 12, 2026 at 9:40 AM David G. Johnston <david.g.johnston@gmail.com> wrote:
How about indicating how many partitions were affected in the notice and allowing the absence of such a notice to be the indicator that cascading did not happen?

I like the idea of number of partitions, but think we need to be more explicit than people surmising the lack of a notice is significant.

Cheers,
Greg

As explained above, the NOTICE is only emitted in the case where the documented ALTER TABLE semantics suggest cascading, but REPLICA IDENTITY
does not actually cascade to partitions. This makes the behavior explicit, rather than relying on users to infer meaning from the absence of a message.

PSA v2:

* Changed level log to NOTICE
* Rephrased the notice message and included partition count in the message.

Now, the message is like:
```
evantest=# alter table sensor_data replica identity full;
NOTICE:  REPLICA IDENTITY does not apply to partitions (1 affected)
ALTER TABLE
```

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




Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: [Patch] add new parameter to pg_replication_origin_session_setup
Next
From: "David G. Johnston"
Date:
Subject: Re: ALTER TABLE: warn when actions do not recurse to partitions