Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w0d5W-0024Xg-1I for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Mar 2026 10:16:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0d5U-00EBWQ-2j for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Mar 2026 10:16:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w0d5U-00EBWI-1a for pgsql-hackers@lists.postgresql.org; Thu, 12 Mar 2026 10:16:17 +0000 Received: from out-02.pe-bsn.jellyfish.systems ([66.29.159.80]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w0d5Q-00000002HaW-0PZ0 for pgsql-hackers@postgresql.org; Thu, 12 Mar 2026 10:16:16 +0000 Received: from MTA-08.privateemail.com (unknown [10.50.14.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by BSN-02.privateemail.com (Postfix) with ESMTPS id 4fWk6H5q9mz3hhTj; Thu, 12 Mar 2026 06:16:07 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=viktorh.net; s=default; t=1773310567; bh=usmplbAEIVaRzB4Rn2+vMQ4YamTRDFbSkKcejIZwVL4=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=UGf3S5z/HeLQrPugQY+LFg2uIwT7y0EUXsQwjakqjo0q0dei7a82xylusdeHGxq9q LqLOo/zCsXrMR6d50/UxbQtZqq37ObNhVG8+BU0VlwOjE8ZVC8noWKjI/eHKwdjqIH fgHtDQXhBe/O0zyE177f32Vh4R/Fvfg4lVLx5TRfwZhb476hSY0sEYM1+7efMwk0aF Ju/XpIluBSj4HuLnmQzm69ufqIsGB5CpqWk3OG1/za5Hdf/VH7S5IZBPvXbo1IPSAr HpS14ztE/BJNaa+C6mchv2Z2y1QJ29aoeQjFJX35Lt4RcfJX+IUZRCl+Cu+yzcQHdu iU5nLRhoiI8iA== Received: from mta-08.privateemail.com (localhost [127.0.0.1]) by mta-08.privateemail.com (Postfix) with ESMTP id 4fWk6H4Wxyz3hhVK; Thu, 12 Mar 2026 06:16:07 -0400 (EDT) Received: from [192.168.0.130] (c188-151-222-15.bredband.tele2.se [188.151.222.15]) by mta-08.privateemail.com (Postfix) with ESMTPA; Thu, 12 Mar 2026 06:16:04 -0400 (EDT) Date: Thu, 12 Mar 2026 11:15:56 +0100 From: Viktor Holmberg To: Andrew Dunstan , jian he Cc: PostgreSQL-development Message-ID: <86e2c66e-f07b-4285-b42e-e3d821e0f0d7@Spark> In-Reply-To: References: <229413.1741144420@sss.pgh.pa.us> <5a8c55ea-81d3-47f4-aff9-a89fabcc2304@Spark> <31d12caf-17d8-4ab7-af58-ec3c5a310a92@dunslane.net> Subject: Re: support fast default for domain with constraints X-Readdle-Message-ID: 86e2c66e-f07b-4285-b42e-e3d821e0f0d7@Spark MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="69b29261_721da317_91cf" X-Virus-Scanned: ClamAV using ClamSMTP List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --69b29261_721da317_91cf Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 12 Mar 2026 at 04:36 +0100, jian he , w= rote: > On Thu, Mar 12, 2026 at 3:50=E2=80=AFAM Andrew Dunstan wrote: > > Also added some tests. > > V11 looks good to me. > > > On Wed, Mar 11, 2026 at 6:34=E2=80=AFPM Viktor Holmberg wrote: > > > > I=E2=80=99ve 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 rewrit= e > > + * since the constraint result could differ per row and cannot be > > + * evaluated once and cached as a missing value. > > + */ > > + if (has=5Fvolatile) > > + =7B > > + Assert(has=5Fdomain=5Fconstraints); > > + tab->rewrite =7C=3D AT=5FREWRITE=5FDE=46AULT=5FVAL; > > + =7D > > > > I'm not sure. But seems to me this makes the pre-existing guard for v= irtual columns > > redundant=3F > > I mean this code on line 7633: > > if (colDef->generated =21=3D ATTRIBUTE=5FGENERATED=5FVIRTUAL) > > tab->rewrite =7C=3D AT=5FREWRITE=5FDE=46AULT=5FVAL; > > > > If the first =60if (has=5Fvolatile)=60 is false, then > > if (colDef->generated =21=3D ATTRIBUTE=5FGENERATED=5FVIRTUAL) > > tab->rewrite =7C=3D AT=5FREWRITE=5FDE=46AULT=5FVAL; > is still reachable. > > > Also, perhaps virtual generated columns could use a test=3F > > 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/=3Fid=3D0cd69b3d7= ef357f2b43258de5831c4de0bd51dec > You may also be interested in https://commitfest.postgresql.org/patch/5= 907 > > -- > jian > https://www.enterprisedb.com/ Nice, v11 looks good to me. I=E2=80=99ll change the status of the commitf= est entry to ready for committer. --69b29261_721da317_91cf Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
On 12 Mar 2026 at 04:36 +0100, jian he <jian.uni= versality=40gmail.com>, wrote:
On Thu, Mar 12, 2026 at 3:50=E2=80=AFAM Andrew Dunstan <andrew=40duns= lane.net> wrote:
Also added some tests.

V11 looks good to me.


On Wed, Mar 11, 2026 at 6:34=E2=80=AFPM Viktor Holmberg <v=40viktorh.n= et> wrote:

I=E2=80=99ve been burned my this issue in the past so would be great if t= his 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=5Fvolatile)
+ =7B
+ Assert(has=5Fdomain=5Fconstraints);
+ tab->rewrite =7C=3D AT=5FREWRITE=5FDE=46AULT=5FVAL;
+ =7D

I'm not sure. But seems to me this makes the pre-existing guard for virtu= al columns
redundant=3F
I mean this code on line 7633:
if (colDef->generated =21=3D ATTRIBUTE=5FGENERATED=5FVIRTUAL)
tab->rewrite =7C=3D AT=5FREWRITE=5FDE=46AULT=5FVAL;


If the first =60if (has=5Fvolatile)=60 is false, then
if (colDef->generated =21=3D ATTRIBUTE=5FGENERATED=5FVIRTUAL)
tab->rewrite =7C=3D AT=5FREWRITE=5FDE=46AULT=5FVAL;
is still reachable.

Also, perhaps virtual generated columns could use a test=3F
=
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/=3Fid=3D0cd69b3d7ef= 357f2b43258de5831c4de0bd51dec
You may also be interested in https://commitfest.postgresql.org/patch/590= 7

--
jian
https://www.enterprisedb.com/
Nice, v11 looks good to me. I=E2=80=99ll change the= status of the commitfest entry to ready for committer.
--69b29261_721da317_91cf--