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 1x92FB-00000001hrC-3bfj for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Sep 2026 15:17:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x92FB-0000000GmTC-0Yii for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Sep 2026 15:17: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.98.2) (envelope-from ) id 1x92FA-0000000GmT3-2QPX for pgsql-hackers@lists.postgresql.org; Tue, 22 Sep 2026 15:17:16 +0000 Received: from fout-b7-smtp.messagingengine.com ([202.12.124.150]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x92F5-00000000igc-0jPj for pgsql-hackers@postgresql.org; Tue, 22 Sep 2026 15:17:16 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id E27F21D000E8; Tue, 22 Sep 2026 11:17:08 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Tue, 22 Sep 2026 11:17:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm3; t=1790090228; x= 1790176628; bh=Q7LZyXqq/H4gz0oQ5G1hvOPHzBw1M22iadaW7bw+Sa8=; b=A NnJXZB5QJAT0XYtnaiUaTmCWvg+kVgPzppzjLFcYJh/Jx2XazSDjsCnS9O2tyXhB fZ7srHaRrHtyCQ4695hWVk7uLtIqI9FLouwVIaCf8N8P0TpvBuOgmDmfbsIfAEIj tm4JzAW2Mq96MEosfnVFd8wmeFk2iqUgFJ4l3En6xi1HKQ01C0Yiy134BXKRWKeG 3s7vU91WkQHNsSZA3nJ4meNoEkGOlCdO8MADek/NsEsjpTHDnxTQxwf5f5TVu5pZ QC2O/W1qoL6yexJTHC6HgnZX+uegg+pMMPXKHtgSUUrpbt3zZAeaEB9oBoujoLan ZltT/JmWAoNrwFii1EV9w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1790090228; x=1790176628; bh=Q 7LZyXqq/H4gz0oQ5G1hvOPHzBw1M22iadaW7bw+Sa8=; b=L0QGljhTAPTLXQJuu sMC0fTsL6p0wQj/Arg7CpOt3AlZc49xrMzmR09D3Sul7OpY1c7dXyIipNlAsLVsi oo/5O2PBhbOu4hs2bAMnlzqDPAaYtLWtPTxbXoZfkaTrQxdK2iwnJnpndiCBMYAh ZCwPwPqVtsK9yUmBZfTbsUoV/knnY9jxL6Pv6fUT2wAydU4XnH0bXH56274JgzM2 rmBw4Ezb2oQ5yZDFdTwLzzdKPORoXgXVEm9G+3Qd7c3X7E/x2h7Te6mi7Ib+l3Sj JE5+U5CufdiTsXNSFC0RHPFJNGtYC5Jo5ifmOfrCd119jasRt7BrQzyI37GDnaj5 R+dMQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGMeu/SaZQoiICghfkFznb1FjN3QZcWJu5iJ0IY2x+BBxAqRxep+NODQqHvjVk8fU CNh9lF3qY9QfnHAgiFdE+pjLJX33nxrVa16/VloouQRkrUBzRPgutZ8ZkMBptVFXqbm9on C/vwrdLmpH4cTxLf3puLCxReW6VNq8raxMBpjeNl1Tb9QlJWzKI6Zqy1yYbWlCb44NQXFZ Ow4stttdFT6Hbyq5Spu2WtGE+9QPTPbOQ9TR1nnxHNT0aC8JHUR7W2aX1/caW//jrmfC1Q iJR5mnnxZLyy4SVRfQ6fstMB+5x3QcX5iqNghdwtq8UEL9ZOJUbeeybr3ihXDKo+SeJdOV eGgwMQYOq1JaQ8FEfIWixlk8JrajacNQUzchYBV+btuwQTLTGXQEreLVaoE0bdGHkiM74l dyRmMieu+4vOsa1PouQBc1NpFdFgoKhqxBogkYeXNH60+IaxxU+LOjwZd64xjfGkliinY/ UkptejYmqrXAlF7j6I/IInPmOChfXVQ/FD3kt3mgHSXkICvBXNMM1Tqd7iin3OSMuHFrg1 5U390H7Sr+sjhHlEnIcb2eSWsBmImTaYuAoNqMsyl2JH3hjftpQ0d/Oipc/5eMkv7C40uf Jt8sHFDQqYE29909FYdkTjCdkY/bI+5BebY65KOEs4S3MV/a3sTIHE9axvfA X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 22 Sep 2026 11:17:08 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1790090225; bh=4cS835h21xkEcMHe7Si0LegUyWXr9lbxUHZLeAR27cU=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=R2CoPkM5Dyl6w78doNQmAMSF8pClBlyMtBnhjWqD7w6TeUM228s2oE90yntL2kch1 2+syxSJeGTGBrOG99uSFaDXnR+4gBzS65pcq9wV/VEsILr3PUBFhrn5Hwz6CKZrqFj 3bmXP5pW6t8ClfFPiXGRH+LEvu1iT1QWKxIMHuXoQfiLwVlzEndaa6Q54XBdmjDbZX lPbCENRYNPI3U3PVfs/+XHfs76IQKcxqJTeQIRhveNPVLGawAhKkDnpn/36xUmGDdB SJZgrWU3b5bX8vd6FqjdmTFWUQznk2Yoj68mnWOGOL1a0DFjaBRCnYafDGTtZUi1ME E4YJFTAZm3h1w== Received: by ida.kurilemu.internal (Postfix, from userid 1000) id E147CB00096; Tue, 22 Sep 2026 17:17:05 +0200 (CEST) Date: Tue, 22 Sep 2026 17:17:05 +0200 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Alberto Piai Cc: Laurenz Albe , pgsql-hackers@postgresql.org Subject: Re: Adding a stored generated column without long-lived locks Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-Sep-21, Alberto Piai wrote: > Repro: > > create table tgen.t_repro_1 (a numeric, b numeric); > insert into tgen.t_repro_1 values ('1.0', '1.00'), ('1.0', '1.0'); > create unique index on tgen.t_repro_1 ((b::text)); > alter table tgen.t_repro_1 > add constraint chk_gen check (b is not distinct from a); > > alter table tgen.t_repro_1 > alter b add generated using constraint chk_gen stored; > > update tgen.t_repro_1 set a = a; > ERROR: duplicate key value violates unique constraint "t_repro_1_b_idx" > DETAIL: Key ((b::text))=(1.0) already exists. Does this _matter_? Does anybody want to have a generated numeric column that's identical to the base column except it has more zeroes in the decimal part? Or to generate a text column that's not binary identical to another text column but compares equal when viewed through an nondeterministic collation? I think the answer is no. I'm pretty okay with saying that if you want to add a new column that's generated in such a way, then you have to go the normal route of using the blocking command. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "La experiencia nos dice que el hombre peló millones de veces las patatas, pero era forzoso admitir la posibilidad de que en un caso entre millones, las patatas pelarían al hombre" (Ijon Tichy)