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

From: Chao Li <[email-masked]>
Date: Mon, 12 Jan 2026 17:02:19 +0800

Hi Hacker,

This patch is part of a broader effort to make ALTER TABLE actions behave
more consistently with respect to partitioned tables. There has been
ongoing discussion around this area; see [1], which also links to earlier
related threads.

In short, changing ALTER TABLE semantics requires more discussion and
coordination than a single patch can realistically achieve. Before that
larger work happens, I’m following up on [1] by trying to clarify the
current behavior, both in documentation and in user-facing feedback.

This patch adds warning messages for sub-commands that appear to recurse
but in fact do not. These currently include:

* SET STATISTICS
* SET/RESET (attribute_option = value)
* ENABLE/DISABLE [ REPLICA | ALWAYS] RULE
* ENABLE/DISABLE ROW LEVEL SECURITY
* NO FORCE / FORCE ROW LEVEL SECURITY
* OWNER TO
* REPLICA IDENTITY
* SET SCHEMA

For example, if a user runs:
```
ALTER TABLE ONLY a_partitioned_table REPLICA IDENTITY FULL;
```
the semantics are clear: only the partitioned table itself is modified.

However, if the user runs the same command without ONLY:
```
ALTER TABLE a_partitioned_table REPLICA IDENTITY FULL;
```
there is potential confusion. From the command syntax alone, it is
reasonable to assume that the change would propagate to child partitions,
but in reality, it does not. Since the ALTER TABLE documentation does not
explicitly spell this out, users often need to test the behavior themselves
to be sure, which is a poor user experience.

With this patch, the command instead emits a warning such as:
```
evantest=# alter table sensor_data replica identity full;
WARNING:  REPLICA IDENTITY is only applied to the partitioned table itself
ALTER TABLE
```
This makes the behavior explicit and removes the ambiguity.

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.

[1] https://postgr.es/m/[email-masked]

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

---

From: "David G. Johnston" <[email-masked]>
Date: Mon, 12 Jan 2026 07:40:00 -0700

> ... action will recurse to child partitions unless a warning explicitly

It should be a notice, not a warning.

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?

David J.

---

From: Chao Li <[email-masked]>
Date: Tue, 13 Jan 2026 11:18:58 +0800

Hi David and Greg,

Thanks a lot for your reviews and feedbacks.

On Jan 12, 2026, at 22:40, David G. Johnston <[email-masked]>
wrote:

Make sense. I changed to NOTICE in v2.

I added partition count in the notice message in v2.

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 <[email-masked]> wrote:

On Mon, Jan 12, 2026 at 9:40 AM David G. Johnston <
[email-masked]> 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,

---

From: "David G. Johnston" <[email-masked]>
Date: Mon, 12 Jan 2026 20:42:08 -0700

> NOTICE:  REPLICA IDENTITY does not apply to partitions (1 affected)

If it doesn't recurse there should be no count.  It would either always be
1, so not helpful, or if did show a partition count, beside the point.  In
the later case suppress the message if there are no partitions present.

The statement “does not apply to partitions” is also factually wrong.  One
would just need to name the partition explicitly.

NOTICE: present partitions not affected
HINT: partitions may be modified individually using separate commands
ALTER TABLE

David J.

---

From: Chao Li <[email-masked]>
Date: Tue, 13 Jan 2026 12:02:54 +0800

> the later case suppress the message if there are no partitions present.

The count was real. I agree that we can suppress the message when there are
no partitions. Addressed that in v3.

> HINT: partitions may be modified individually using separate commands

Thanks for the suggestion, I took that in v3.

PSA v3:

* Rephrased the notice message as David's suggestion.
* Removed partition count from notice message.
* If a partitioned table doesn't have any partition, then suppress the
message.

Now the command outputs look like:
```
evantest=# alter table sensor_data replica identity full;
NOTICE:  present partitions not affected
HINT:  partitions may be modified individually using separate commands
ALTER TABLE
```

Best regards,