pgsql: Add support for not-null constraints on virtual generated column

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add support for not-null constraints on virtual generated column
Date: 2025-03-28 12:54:29
Message-ID: E1ty9ED-001QT8-2f@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add support for not-null constraints on virtual generated columns

This was left out of the original patch for virtual generated columns
(commit 83ea6c54025).

This just involves a bit of extra work in the executor to expand the
generation expressions and run a "IS NOT NULL" test against them.

There is also a bit of work to make sure that not-null constraints are
checked during a table rewrite.

Author: jian he <jian(dot)universality(at)gmail(dot)com>
Reviewed-by: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Reviewed-by: Navneet Kumar <thanit3111(at)gmail(dot)com>
Reviewed-by: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Discussion: https://postgr.es/m/CACJufxHArQysbDkWFmvK+D1TPHQWWTxWN15cMuUaTYX3xhQXgg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/cdc168ad4b22ea4183f966688b245cabb5935d1f

Modified Files
--------------
src/backend/catalog/heap.c | 10 --
src/backend/commands/indexcmds.c | 10 +-
src/backend/commands/tablecmds.c | 71 ++++++--
src/backend/executor/execMain.c | 220 ++++++++++++++++++------
src/backend/parser/parse_utilcmd.c | 14 --
src/include/executor/executor.h | 4 +
src/include/nodes/execnodes.h | 6 +
src/test/regress/expected/generated_virtual.out | 90 ++++++++--
src/test/regress/sql/generated_virtual.sql | 54 +++++-
9 files changed, 360 insertions(+), 119 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2025-03-28 13:09:26 pgsql: pg_overexplain: Call previous hooks as appropriate.
Previous Message Amit Kapila 2025-03-28 11:50:53 Re: pgsql: Stablize tests added in 3abe9dc188.