Re: ALTER TABLE: warn when actions do not recurse to partitions

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: ALTER TABLE: warn when actions do not recurse to partitions
Date: 2026-01-13 03:18:58
Message-ID: CAEoWx2nic2MaPUEKwb0Me1iwO3LsCf8wUHm55pjqaTRgJEZpcQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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(dot)g(dot)johnston(at)gmail(dot)com>
wrote:

On Monday, January 12, 2026, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)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(at)gmail(dot)com> wrote:

On Mon, Jan 12, 2026 at 9:40 AM David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)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 Content-Type Size
v2-0001-Add-notice-when-ALTER-TABLE-REPLICA-IDENTITY-does.patch application/octet-stream 3.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2026-01-13 03:42:08 Re: ALTER TABLE: warn when actions do not recurse to partitions
Previous Message Amit Kapila 2026-01-13 02:56:54 Re: [Patch] add new parameter to pg_replication_origin_session_setup