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.98.2) (envelope-from ) id 1xU7VP-00000000mVq-2xyi for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Nov 2026 19:09:12 +0000 Received: from localhost ([127.0.0.1]:41084 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xU7VN-00000003E2A-0VxP for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Nov 2026 19:09:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:38792) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xU7VM-00000003E22-3QaG for pgsql-hackers@lists.postgresql.org; Thu, 19 Nov 2026 19:09:08 +0000 Received: from mail-dy1-x1333.google.com ([2607:f8b0:4864:20::1333]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xU7VK-00000000ZvR-3fbB for pgsql-hackers@lists.postgresql.org; Thu, 19 Nov 2026 19:09:08 +0000 Received: by mail-dy1-x1333.google.com with SMTP id 5a478bee46e88-382b463a972so2417eec.2 for ; Thu, 19 Nov 2026 11:09:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795115345; x=1795720145; darn=lists.postgresql.org; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=yUrMAjMSft8hpZtObY058Vwpjl2ucl/x027I8O2zkfk=; b=v4DPGgPU3nMirxKOiWZuQHbIpovM8gRyyfMwdfJqUKaLdoEAwlcbZWt7p1NMc0f0H3 mH+5bUApJUkJm/YJeaYWEbOFUfXzIULG8NZYSqfIsWZwBpE5+mgK9Z2SRVW4sf/SaZHH ufASQUA8Ftkalgb1x4YYsiEfLjPLoQ4ZfJ3LmdCsBmAVH+rrpdF5NwM4qp2oUKHmS7Yh 58F2KhXyS+xXV4WiK4rZd8J01ytats1MC9T2ebwDE7k4u2DzM+HnydAWoXggz6Mpee+5 rjOhIt9rhvM9s9pyeOSIlfAOebeo2/vBSs8Z19kb8xL6lcvD+5R7MjeWujcc1lbF6kvX YqQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795115345; x=1795720145; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yUrMAjMSft8hpZtObY058Vwpjl2ucl/x027I8O2zkfk=; b=IYFnbCP9+H8DxygnDOxy0rut0GtArF3qsaPH8kX0G53BuCvCL7R8gkLiEXL75xZ5N7 mig/PmR925gu3Yv2BpWk9zOUlf0drppsqZVGRincWuDSoD6uUG2Yw3iIDFXv/cwb8Geq SJHrGei9tA9wXu7/NM15le9C7MwKOL9D6WGip4aw4+108NqICU9KeWxEgKncnTeGhv3g 4zs3om+vpIkabZIf5e5w7yDXPSJ6YMctbnKOt125HA+oKVv/DtLpmXb+/+ZTSkmqjpba izFG34ZlE+qdjSugOkGKjcGaccvvsPtWHIFe5UfacYhzS54PGq/vjEAmbxVXUQ9mwpJ0 JELg== X-Forwarded-Encrypted: i=1; AL+hErE+keRgTs0KlvKuLIQlPpxbsZlCGrGNLs9HUdiUZeUQLifAEN0U6ZmKT+YKwnz+P71Xu/nB8iNntYoFJLpU@lists.postgresql.org X-Gm-Message-State: APuU4Z/h/bZFhgMrBlUFxsUoh1S6tPOR4stSqGQWzLQVXnIf2w/19WSl K0Qo2LJ8Cz078j9xlTeKusOiGfoCTvVQZSl8IU9n6xdaZJqm0qegXnht X-Gm-Gg: AZFdTZeg+57fFpNbbVEKw9V92A/r/IA6kvtk9LfOPVnrj/+M3MJBaTfUyobK3wgqMYj m41VddXjK+Ru6nqa4nZNbDqA3mDDrsxQi6oIiDHQFDxGeDKhan6Run+xZqfTJS+jRug+Pet8qMs 5U1Oj9AtdKQpk7cQ7Ut1v5iHtQgbh/1ueap30pujdm4MjTkReKj3IRwl5mOaO7fhYVJcIprPhDd eA9z4F9NjglpSlNkg4bi6ejdO8UQ2adJqiNaecGwA5JZd7p8ZNMOZJRnpbS1/vWhmHf8tppG1VW AaDfwtrokXA+xOSk1tnIVMUH/JXvGJcr0hzIiJVPNt6Fe8//Lu8gRNYJCs5AalDUFICeUMruekX J71mTy5abU1ioLBX6Tj1EAeA3gStkQuzdhPzhJL8f86c3hxKBv2IFFD6s13I2kahHFh8GmN3tsz K9+GM/jj9s6+g1diJnAe344c1osV5Bes7w1cEa4QCuJrW2bzM3cC1leUT1ClZOnP87TvSBtBVZP ps27PXKkiiVkjtcNh4JKJ5ODcUKg3ZFS7+jtR6E8wjL0+HVXtzw4xruTjKKIk/4YHX9CBOvZD39 H/4ey+bX0/0sfT1KFp39+pftVuZ3w2rzEPwgwJAlZJMbxlv7k+F0hrWGTsYT+90DXbI8ApAawE/ XYH6qQIxV2imwVgQbQz9e3rLcLNM9vKC4sWm5lZMipwTmU4FwGWXRwl6+atGSTtmoQEn8wqfiiQ maDw== X-Received: by 2002:a05:7300:1c24:b0:384:a0cb:a6d0 with SMTP id 5a478bee46e88-3856de58f7fmr401149eec.1.1795115344485; Thu, 19 Nov 2026 11:09:04 -0800 (PST) Received: from 192.168.1.109 ([190.12.171.222]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38567daaf70sm786475eec.28.2026.11.19.11.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2026 11:09:03 -0800 (PST) From: Manu To: shihao zhong Cc: Zsolt Parragi , =?utf-8?q?=C3=81lvaro?= Herrera , Richard Guo , pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned Date: Thu, 19 Nov 2026 16:08:57 -0300 Message-ID: <179511533762.1055718.4280891924320654081@gmail.com> In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Shihao, On Thu, Nov 19, 2026 at 12:01 AM shihao zhong wrote: > Thanks for catching both, v6 attached. v6 passes everything we had, on master (b443bc7406f), REL_19_STABLE (b1bc8f8ea5d) and, in its 18 version, REL_18_STABLE (ecfe3a44dab). Two new cases, both on trees that an unpatched 18 or 19 left divergent, after the minor update. 1. A child with two parents. The pg_upgrade text says to run SET EXPRESSION on the top-level parent, which works on unpatched 18 but not with the patch: -- unpatched 18 CREATE TABLE ip (x int, v int GENERATED ALWAYS AS (x * 2) VIRTUAL); CREATE TABLE iq (x int, v int GENERATED ALWAYS AS (x * 2) VIRTUAL); CREATE TABLE ic (v int GENERATED ALWAYS AS (x * 3) VIRTUAL) INHERITS (ip, iq); -- 18 with the patch; the same on 19 with the master patch ALTER TABLE ip ALTER COLUMN v SET EXPRESSION AS (x * 2); ERROR: cannot alter inherited column "v" of relation "ic" The same for iq. If the parents' expressions differ (x * 2 and x * 3, the child giving its own, as 18's ddl.sgml asks), the text does not work on any branch, unpatched included. What works on all of them is NO INHERIT from all parents but one, SET EXPRESSION, and INHERIT again. Maybe, after "add them back afterwards.": A child table with more than one parent must first be removed from all but one with NO INHERIT, and added back once all its parents have the same expression. 2. With the patch, adding a virtual column to the parent of such a tree fails, naming the old column: -- unpatched 18 CREATE TABLE ta (x int, v int GENERATED ALWAYS AS (x * 2) VIRTUAL) PARTITION BY LIST (x); CREATE TABLE ta1 PARTITION OF ta (v GENERATED ALWAYS AS (x * 3) VIRTUAL) FOR VALUES IN (1); -- 18 with the patch ALTER TABLE ta ADD COLUMN w int GENERATED ALWAYS AS (x + 1) VIRTUAL; ERROR: column "v" of relation "ta1" must have the same generation expression as in parent relation "ta" The check after the recursion in ATExecAddColumn (tablecmds.c:8347 on master, 8285 on 18) compares every virtual column of the parent, but only the one being added is new to the child; ATTACH and INHERIT are the ones that bring a whole new parent. Maybe compare only that column there? Regards, Manu