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 1wWqtO-002tj2-23 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jun 2026 07:28:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wWqtN-005gdx-1Z for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jun 2026 07:28:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wWqtN-005gdo-0d for pgsql-hackers@lists.postgresql.org; Tue, 09 Jun 2026 07:28:57 +0000 Received: from mail-dy1-x132b.google.com ([2607:f8b0:4864:20::132b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wWqtK-00000001oQU-1njU for pgsql-hackers@lists.postgresql.org; Tue, 09 Jun 2026 07:28:56 +0000 Received: by mail-dy1-x132b.google.com with SMTP id 5a478bee46e88-3078e0dcd67so3165232eec.0 for ; Tue, 09 Jun 2026 00:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780990134; x=1781594934; 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=dwI+lKFU8+gOafl3XnMp6z6BxS9u46sVAE0pOoGzytk=; b=gmYdQDKiBlvu+4mfAIYDaJQTepXpB5ZUSgP+fjC0aNON0z1jPUULfAVCjj3tLr0USP NnebzbKmKDk3S2U73O6UpTBByJmSNT3aHpzCpSe0cNfAQF3Kjgczkf5AG+bBrl9nos2w xoGqnOIlzjr/GF/+MnhEPpOpSDvcfkaKRN1xE2HMgIXHI8lt3uYk0qImvHY9vJz0tFQb RFOp8MPq+n8RjItPPCttTLpjw/rRz4qTLV/U94meBeocLmJb6mEL0BsnW6NZrkOms/88 FaY2TAVQe7liAu62EQ/L+Na/6RBIGwI6nF+WAhN2pLUyCCWXm+4/22z+/mb32QhiLiZd XsAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780990134; x=1781594934; 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=dwI+lKFU8+gOafl3XnMp6z6BxS9u46sVAE0pOoGzytk=; b=iifsAfCnAUMCSWb+lU4MQkdigCM5hst00gA+USOR8sXwcZMUfaDbDq0PG3ZO6SeGeX MbxWl88nq5NlE8V608UgnDpxVPfad0BKNd04fU4kI3RwZDgMwZ0vsdffQpnjhypkUo3q XWbA7DZjbizYZIF0xXu9kklgVuDGi5Oko9EClS6rbOd13S07xhTAXE5twIUF7jBucV5w 5BbWXFOlBzMPi1y0oE7XCOuN/UMjg/92PA1qI8scMP874or/fzUK6vBbggXdGPcgjIbY /G31horblE6M3nJF3P1uFZCC7N9LqL4Ha0BzlZTpg+rgwiq4VNtHy5S6tBV5zIn7B5M3 xlyA== X-Gm-Message-State: AOJu0YyXsGJnqSnAYISSYECdZIUuXxHjb+0m/ut4VyNFvUvU9dqv4vAh q9zrUvFPsO6t5QErc2HwQKU6pfJ/cEO8aZJkQetquRhs8Lp9A6CYod1kQ99Nfwz3xuU= X-Gm-Gg: Acq92OEfUzQR5k/64A21ijyc98ir7jiWclYcjg4va+GjyEbgg9XaPgyBGrHwvi2pwwR /U7sKxWixandn2sbemHWm8AXNTKjoU5I3mpigp1P8j+XPpJkA9Sfealgk7nOwDynNgbI4NCTZ7n EhJPmgu8jGS2zAD1pEwLbnb1y2X0KhGBY0mKjqijTQnqoagk2Aa0H9d9jbLxxKjh3+dlDsabtih YgraCZl2YwelGDdpaskTO4FzB8fVDqZXkhZSihtkEAtOwUPk6C0UhYCghyzhagON3U4g0NFAxzC eknViFcDg0m2vtztsPzCHmyLUZWqiQmpDSi7rb6jQYVje+Et70AUQ506ipymEYMMn7R3Q3ocJ/8 NGI+93lY2+ah2zgl7Uyb0FZbIqF3G5yGn0rXm5K1fOqpiVNlpywzGj6wIfMUyK5s0VWuypwMLYa 4GJu83NzhDf8CCYvp4GSUD+YLNpa/tUPEjRHEPBkYpj4LzBWTGh/I= X-Received: by 2002:a05:7300:cd91:b0:2c5:220c:5670 with SMTP id 5a478bee46e88-3077af324a4mr10491053eec.2.1780990133581; Tue, 09 Jun 2026 00:28:53 -0700 (PDT) Received: from smtpclient.apple ([64.32.14.230]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3074db5610esm20029305eec.4.2026.06.09.00.28.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jun 2026 00:28:53 -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: Date: Tue, 9 Jun 2026 15:28:18 +0800 Cc: Postgres hackers , Peter Eisentraut Content-Transfer-Encoding: quoted-printable Message-Id: <5B739323-C897-4B1A-9BFC-656E5CB4AD58@gmail.com> References: <71242FEA-15A3-4073-9FA1-561CA744ACBD@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: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 Thanks for pointing out that. I will review 6755. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/