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

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned
Date: 2026-10-13 15:45:13
Message-ID: as5LS1intVNRgPRR@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 2026-Oct-13, Richard Guo wrote:

> On Tue, Oct 13, 2026 at 9:43 PM Álvaro Herrera <alvherre(at)kurilemu(dot)de> wrote:
> > I find this very surprising. Are we sure that it makes sense for a
> > partition to have a generating expression that differs from the one in
> > the parent table?
>
> No, I don't think it makes sense for a partition to have a different
> virtual generation expression than its parent. I raised this exact
> same complaint in [1], the paragraph starting with "Regarding #4",
> quoted below:
>
> Regarding #4, the fix is to not trust NOT NULL on a virtual generated
> column of a partitioned table. But I don't like this fix at all. I
> think the real problem is that a partition is allowed to have a
> different virtual generation expression than its parent.

It looks like we reached the same conclusion. I propose we restrict
this. Ideally we'd do that at least starting with 19. (I would in fact
go even further and say that we should add restrictions to all affected
stable branches, and provide SQL scripts that users can run to find and
remove those that already exist there.) I don't have a patch though,
but I imagine it should be easy.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Hay quien adquiere la mala costumbre de ser infeliz" (M. A. Evans)

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Álvaro Herrera 2026-10-13 16:00:02 Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned
Previous Message shihao zhong 2026-10-13 15:41:39 Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2026-10-13 16:00:02 Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned
Previous Message Fujii Masao 2026-10-13 15:44:58 Re: Incremental backups report progress as if they were full backups