Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Manu <manuelreyesbravo(at)gmail(dot)com>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Richard Guo <guofenglinux(at)gmail(dot)com>
Subject: Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned
Date: 2026-11-19 05:01:29
Message-ID: CAGRkXqTzGuoK7Xo9Z5JZPRirNXa+J+LLyNks3OktUqXuaDe=ow@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Hi Zsolt,

Thanks for catching both, v6 attached.

> But it can with a combined alter:

The check ran before the ADD COLUMN, so the column did not exist yet.
v6 runs it when SET EXPRESSION executes, and your example now fails
like the two statement form.

> But that hint won't work, as the testcase shows.

v6 gives the hint only for partitions, since a partition always has a
single top-level parent.

A simpler option is to reject the combined command, as ALTER COLUMN
TYPE does for a column added by the same command. I'm happy to switch
if that is preferred.

Thanks,
Shihao

Attachment Content-Type Size
v6-0001-Require-child-tables-to-use-the-parent-s-virtual-gen.patch application/octet-stream 48.4 KB
nocfbot-v6-REL_18-0001-Require-child-tables-to-use-the-parent-s-virtual-gen.patch application/octet-stream 41.8 KB

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-11-19 07:11:44 pgsql: Fix pg_combinebackup handling of intermediate truncations
Previous Message Fujii Masao 2026-11-19 04:31:42 pgsql: Avoid delaying WAL receiver shutdown while draining WAL

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2026-11-19 05:04:44 Re: [PATCH] pg_createsubscriber: add hint to wal_level error
Previous Message shveta malik 2026-11-19 04:45:21 Re: Per-table resync for logical replication subscriptions