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

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: Manu <manuelreyesbravo(at)gmail(dot)com>, Richard Guo <guofenglinux(at)gmail(dot)com>, Richard Guo <rguo(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned
Date: 2026-11-11 15:41:34
Message-ID: avSIMSJb3doxjrv3@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 2026-Oct-26, shihao zhong wrote:

> Hi Manu,
>
> Thanks for testing the pg_upgrade, I forgot about that.
>
> I don't think the logic is wrong here, but maybe we can make some
> improvement to the error message. v2 changes
>
> on the partitioned table of each column listed in the file
> =>
> on the partitioned table of each column. In version 18 this is not
> allowed on a table with CHECK constraints, so drop them first and
> add them back afterwards. A list of the problem columns is in the
> file

I think the doc changes here are not ideal; they kinda suggest that there are
numerous different generated column types for which you can have different
generation expressions except for one special case -- rather than one case yes,
one case no. How about something like this?

If a parent column is a generated column, its child column must also
- be a generated column of the same kind (stored or virtual); however,
- the child column can have a different generation expression, except
- that a virtual generated column of a partition must have the same
- generation expression as the partitioned table.
+ be a generated column of the same kind (stored or virtual).
+ In addition, for virtual generated columns, the child column's
+ generation expression must be identical to that of the parent.
+ For stored generated columns, they are allowed to differ.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"I'm impressed how quickly you are fixing this obscure issue. I came from
MS SQL and it would be hard for me to put into words how much of a better job
you all are doing on [PostgreSQL]."
Steve Midgley, http://archives.postgresql.org/pgsql-sql/2008-08/msg00000.php

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Álvaro Herrera 2026-11-11 15:47:06 Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned
Previous Message Tomas Vondra 2026-11-11 15:36:10 pgsql: Fix constant propagation through FULL JOIN clauses

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2026-11-11 15:47:06 Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned
Previous Message Zhijie Hou 2026-11-11 15:13:13 Re: Assertion failure in update_local_synced_slot(), slotsync.c:364