From: Álvaro Herrera <alvherre@kurilemu.de>
To: shihao zhong <zhong950419@gmail.com>
Cc: Manu <manuelreyesbravo@gmail.com>
Cc: Richard Guo <guofenglinux@gmail.com>
Cc: Richard Guo <rguo@postgresql.org>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned
Date: Wed, 11 Nov 2026 16:41:34 +0100
Message-ID: <avSIMSJb3doxjrv3@alvherre.pgsql> (raw)
In-Reply-To: <CAGRkXqRBPdwHEsVhtj2_w=eVT8tucYbfO19Uon3C61DtamJzBQ@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: alvherre@kurilemu.de, zhong950419@gmail.com, manuelreyesbravo@gmail.com, guofenglinux@gmail.com, rguo@postgresql.org, pgsql-hackers@lists.postgresql.org
Subject: Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned
In-Reply-To: <avSIMSJb3doxjrv3@alvherre.pgsql>
References: <CAGRkXqRBPdwHEsVhtj2_w=eVT8tucYbfO19Uon3C61DtamJzBQ@mail.gmail.com> <avSIMSJb3doxjrv3@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox