Re: support fast default for domain with constraints

From: Viktor Holmberg <v(at)viktorh(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: support fast default for domain with constraints
Date: 2026-03-12 10:15:56
Message-ID: 86e2c66e-f07b-4285-b42e-e3d821e0f0d7@Spark
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12 Mar 2026 at 04:36 +0100, jian he <jian(dot)universality(at)gmail(dot)com>, wrote:
> On Thu, Mar 12, 2026 at 3:50 AM Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
> > Also added some tests.
>
> V11 looks good to me.
>
>
> On Wed, Mar 11, 2026 at 6:34 PM Viktor Holmberg <v(at)viktorh(dot)net> wrote:
> >
> > I’ve been burned my this issue in the past so would be great if this could get in.
> >
> > + /*
> > + * If the domain has volatile constraints, we must do a table rewrite
> > + * since the constraint result could differ per row and cannot be
> > + * evaluated once and cached as a missing value.
> > + */
> > + if (has_volatile)
> > + {
> > + Assert(has_domain_constraints);
> > + tab->rewrite |= AT_REWRITE_DEFAULT_VAL;
> > + }
> >
> > I'm not sure. But seems to me this makes the pre-existing guard for virtual columns
> > redundant?
> > I mean this code on line 7633:
> > if (colDef->generated != ATTRIBUTE_GENERATED_VIRTUAL)
> > tab->rewrite |= AT_REWRITE_DEFAULT_VAL;
> >
>
> If the first `if (has_volatile)` is false, then
> > if (colDef->generated != ATTRIBUTE_GENERATED_VIRTUAL)
> > tab->rewrite |= AT_REWRITE_DEFAULT_VAL;
> is still reachable.
>
> > Also, perhaps virtual generated columns could use a test?
>
> Virtual generated columns based on domain are not currently supported.
> I have a patch for it: https://commitfest.postgresql.org/patch/5725
> but it's not doable now because of
> https://git.postgresql.org/cgit/postgresql.git/commit/?id=0cd69b3d7ef357f2b43258de5831c4de0bd51dec
> You may also be interested in https://commitfest.postgresql.org/patch/5907
>
> --
> jian
> https://www.enterprisedb.com/
Nice, v11 looks good to me. I’ll change the status of the commitfest entry to ready for committer.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2026-03-12 10:26:41 Re: Defend against -ffast-math in meson builds
Previous Message jinbinge 2026-03-12 10:12:06 Re:Re: Odd code around ginScanToDelete