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 1wXEt4-0039ED-1Y for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2026 09:06:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wXEt3-00AFlN-1M for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2026 09:06:13 +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 1wXEt3-00AFl8-0R for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2026 09:06:13 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wXEt0-00000002IrM-2EAk for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2026 09:06:12 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-2c0c35980fdso65536335ad.2 for ; Wed, 10 Jun 2026 02:06:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781082368; x=1781687168; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=q8R1USWg1l+/4KKnoeOyxWbRWhurgjVL7N4XAL3Upjc=; b=Gh+oKeEo+mrWB1iha/qn0FYmIiUAtxAosMu4nnm8shFuXHYmXMlXIlHmQl6235gIRE ktN8KjC498bbh5m+fW2y7E/eSqSh52fADvckibLmqjbdA8c59cxXCFRPaI8U/AAs1lOo DPwOBxMhYcWSM5SNUmJ5J1N2oCGkEjauXGWMkGEa/XtV/SIlKYYqcHGH2cCyfRpjQlMv MrGJg/N73vR21aX6iwKq2oea0eXjWg9nmdC05qFJXlSP7ndDCtqJAj90dWPljQ6VZJO9 TLTmF/9zYp4EhbGbc8zNiVEXVXN0k2ENRBfolOjc8h1aPyuEwgYKVbYdovcOBI6sZmB4 RoJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781082368; x=1781687168; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=q8R1USWg1l+/4KKnoeOyxWbRWhurgjVL7N4XAL3Upjc=; b=LwfotK0gQVEevwzxXGDU4Xth2bxmx+FHpIcaCSYsEk0iHrp+xo5Yj7k/QuOuO1pvm1 /rqAduZdB9fC6ifkK6f2xpYy+oNy+k9fqxbWLvUv8uc/VTa1mWitCwP10cVdx2r+vjSR j6a0cp7AZjaYOOrEb/jtBfgqVOfxZjdzUacxxEPfkEqnOD9iRqf45+S9MWJzA+rAVn5z PoFSd+xKWzL12bEgTTKcJWqAZCrAO0doGthueulSWyk4ieHfx/fabmuy+pNCKBpNVHbl 97xph3cCAG130XaFUigVNcWqKHd9QrxhFfIXH4/gyv78Xf28xMZxDpxrQ6qUWb96wSId iHNA== X-Gm-Message-State: AOJu0YxiBK5mrmf/Scomaxfn4BGLHYn9LOnoZ0KRlpVJiZ+3mppS5Bl+ rsGdBFuYRvVlS2XLxH6ywCQ/25/7fALH59SFxtpsrCR5ELdjJBJtFhVqr2sb3HYO X-Gm-Gg: Acq92OHBEvAkwOEHbzz7D4yOt71XWpExctpmA5lxEsi+BAnTLN8tqImfIBxG5iB9hzo cIVjDkS/w87xPtOao1tdYpbQ9HWPfEDIqGOmlyWuXpbsJN2DV06KAJ1h5RVAp8mXoO42WWliQdR V6effIjDJZHYWWmI0EH1o1O2wIBPPhFXba8SRzVX2li3jm+bFSPwUrsosi80CgAN3bdjCfSSYFr yMa8weQOTRyA+sLSgyxHlJUXpVwf2bSyLN2RJmnbKaRpzvRKkWbPOwcRdVsmmuDamPxiRhYxoLa SQiXTO7LoG/IxW8hGoI6ueV1pXepaeT3zx9wzoqqb/zmKg5msTMLKf2WlzT8jivcy+M5ZrrfE8p Iw3fd2gc3N4/harrXWo9XRzxdLsg8s7TeNYygYNhKT3VWDxZMNMoQ/UI6Rfa7yOVnCzlzfi2hNZ PK+gjdXRnBaXurkVXYwavi1NL7SCDyilaAMuugtIMkPFg= X-Received: by 2002:a17:903:3b8b:b0:2bf:114b:924 with SMTP id d9443c01a7336-2c1e85ca6b6mr286671865ad.34.1781082368153; Wed, 10 Jun 2026 02:06:08 -0700 (PDT) Received: from smtpclient.apple ([185.135.79.161]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c166495203sm231038065ad.70.2026.06.10.02.06.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jun 2026 02:06:07 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: Fix SET EXPRESSION for virtual columns with whole-row dependencies From: Chao Li In-Reply-To: <5B739323-C897-4B1A-9BFC-656E5CB4AD58@gmail.com> Date: Wed, 10 Jun 2026 17:05:30 +0800 Cc: Postgres hackers , Peter Eisentraut Content-Transfer-Encoding: quoted-printable Message-Id: References: <71242FEA-15A3-4073-9FA1-561CA744ACBD@gmail.com> <5B739323-C897-4B1A-9BFC-656E5CB4AD58@gmail.com> To: jian he X-Mailer: Apple Mail (2.3864.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Jun 9, 2026, at 15:28, Chao Li wrote: >=20 >=20 >=20 >> On Jun 9, 2026, at 15:23, jian he = wrote: >>=20 >> On Tue, Jun 9, 2026 at 2:23=E2=80=AFPM Chao Li = wrote: >>>=20 >>> Hi, >>>=20 >>> While testing =E2=80=9C[f80bedd52] Allow ALTER COLUMN SET EXPRESSION = on virtual columns=E2=80=9D, I found that the feature missed handling = whole-row check constraints. >>>=20 >>> Here is a repro: >>> ``` >>> evantest=3D# create table t( >>> evantest(# a int, >>> evantest(# b int generated always as (a*2) virtual, >>> evantest(# constraint row_c check (t is not null) >>> evantest(# ); >>> CREATE TABLE >>> evantest=3D# insert into t(a) values(1); >>> INSERT 0 1 >>> evantest=3D# alter table t alter b set expression as (nullif(a, 1)); >>> ALTER TABLE >>> evantest=3D# select * from t; >>> a | b >>> ---+--- >>> 1 | >>> (1 row) >>> ``` >>>=20 >>> The ALTER TABLE should fail, because it makes b become NULL, which = breaks the constraint row_c. >>>=20 >>=20 >> Hi. >>=20 >> In case you are wondering whole-row objects: >> ALTER TABLE DROP COLUMN and ALTER COLUMN SET DATA TYPE are covered by >> https://commitfest.postgresql.org/patch/5988 and >> https://commitfest.postgresql.org/patch/6055. >>=20 >> Meanwhile, ALTER TABLE SET EXPRESSION is being handled over in >> https://commitfest.postgresql.org/patch/6755 >=20 > Thanks for pointing out that. I will review 6755. >=20 > Best regards, > -- > Chao Li (Evan) > HighGo Software Co., Ltd. > https://www.highgo.com/ >=20 After reading the other implementation in [1], I realized that I had = missed the partial-index case, so I added coverage for that. I am still sending an updated version of this patch because my = implementation is different from the one in [1]. I would like people to = compare the two approaches and decide which direction is better. [1] = https://postgr.es/m/CAJTYsWXOkyeDVbzymWc9sKrq7Y_MUv6XJXN4H9GfsBOPd3NJ+w@ma= il.gmail.com Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/