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 CAEoWx2mZsWnyS_XLDL5mL+yuU_g65p_tmHNesyfngqow7gtS3A@mail.gmail.com
Whole thread Raw
In response to Re: ALTER TABLE: warn when actions do not recurse to partitions  (Chao Li <li.evan.chao@gmail.com>)
Responses Re: ALTER TABLE: warn when actions do not recurse to partitions
List pgsql-hackers


On Jan 14, 2026, at 08:52, Chao Li <li.evan.chao@gmail.com> wrote:



On Jan 13, 2026, at 19:16, Jim Jones <jim.jones@uni-muenster.de> wrote:

Hi Chao

On 13/01/2026 05:02, Chao Li wrote:

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.

I've been playing with this patch, and it seems to work as expected -
I'm surprised it didn't break any existing tests :). Do you plan to
extend this patch to other subcommands mentioned in your initial post,
such as SET STATISTICS?

Thanks for the patch

Best, Jim


Hi Jim,

Thanks for your testing. Yes, I plan to add the notice to other sub-commands as needed. I only updated REPLICA IDENTITY first to call for feedback. As you see, David has suggested the great wording for the notice message. Once the change on REPLICA IDENTITY is reviewed, it’s easy to extend to other sub-commands.


PFA v4.

I’ve extended the NOTICE to cover all sub-commands for which ONLY has no effect and where actions on a partitioned table do not propagate to its partitions:

 - ALTER COLUMN SET/RESET attribute_option
 - ALTER COLUMN SET COMPRESSION
 - ENABLE/DISABLE RULE
 - ENABLE/DISABLE/FORCE/NO FORCE ROW LEVEL SECURITY
 - REPLICA IDENTITY
 - OWNER TO
 - SET TABLESPACE
 - SET SCHEMA

RENAME is intentionally excluded. Using ONLY (or not) has no effect for RENAME, since relation names are independent by nature and there is no expectation of recursion.

OF / NOT OF are also excluded. Using ONLY has no effect for these commands, as they apply only to the partitioned table itself and not to its partitions.

One thing worth noting: following David’s suggestion, I removed the action name from the NOTICE message in v2. However, I later realized that we do need to include the action name, because an ALTER TABLE command may contain multiple sub-commands, and the NOTICE would otherwise be ambiguous.

In v4, I reuse alter_table_type_to_string() to construct the action name, consistent with what ATSimplePermissions() does. The NOTICE message itself also follows the same style as messages emitted by ATSimplePermissions(). For example, when an ALTER TABLE contains multiple sub-commands, the output now looks like:

```
evantest=# alter table p_test replica identity full, alter column username set (n_distinct = 0.1);
NOTICE:  ALTER action REPLICA IDENTITY on relation "p_test" does not affect present partitions
HINT:  partitions may be modified individually, or specify ONLY to suppress this message
NOTICE:  ALTER action ALTER COLUMN ... SET on relation "p_test" does not affect present partitions
HINT:  partitions may be modified individually, or specify ONLY to suppress this message
ALTER TABLE
```

Regression tests have been updated, and a few new tests have been added. v4 should now be ready for review.

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




Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Having problems generating a code coverage report
Next
From: jian he
Date:
Subject: Re: CREATE TABLE LIKE INCLUDING POLICIES