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 1x9VJ3-000000022lH-06PS for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Sep 2026 22:19:13 +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 1x9VJ2-000000084LQ-0JHp for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Sep 2026 22:19:12 +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 1x9VJ1-000000084LI-3JeL for pgsql-hackers@lists.postgresql.org; Wed, 23 Sep 2026 22:19:11 +0000 Received: from mail-wm2-x11.google.com ([2a00:1450:4864:31::11]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x9VIy-00000000xLu-0Cnp for pgsql-hackers@postgresql.org; Wed, 23 Sep 2026 22:19:10 +0000 Received: by mail-wm2-x11.google.com with SMTP id 5b1f17b1804b1-49e71cdb22bso10196325e9.2 for ; Wed, 23 Sep 2026 15:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790201947; x=1790806747; darn=postgresql.org; h=in-reply-to:references:subject:to:from:cc:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=N3D34Zx8nuTqF8Ny24LqU5wu8vjSxcu1YIFl41UarrE=; b=hPhirfs0tpKyQhBtIdqoABeHxdNi+hFs4Nn8mn/IFinRNC+mKlG5R83Qex/mhK3Ndz CmQaoUi8gCzltahjA9nlTA3iSUssdgfBVqO1Qt8IOwwYAbj97v8/NNAreqh8CW9qEzUG wQUXZPP8mlIVHX0jJ/nzCQoIaU3T2H3ElLokhRFOxwJi7xZ6922bNsE/2eupF6AIO8UJ ffniiD/s97rJmmsC84PgEgCBQ1gFls81Im7VbJLKBJfh15VIEJVHZfdN3McSRf4XEHU9 Ra+Yb+NUHi8GXN346UpgGqfgM5toJWBatHTQMiEaiur7+L6WS+ivQP3d+yh7YqudmZhs hj2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790201947; x=1790806747; h=in-reply-to:references:subject:to:from:cc:message-id:date :content-type:content-transfer-encoding:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=N3D34Zx8nuTqF8Ny24LqU5wu8vjSxcu1YIFl41UarrE=; b=yFevAwcOKZQaOaufymBbP8RjTVXH2DbB7vHIMDpaiVpZetUfrWtszHyIa6KYHBoycT OSAFtcxjohxpFaQuvw4bIbfRsJLrKbfFUCustrU+C9UasLF1gBK/x7sGXGZ9Fxux0L0k d1Skv3G8zhgbNVPbcz0hV5KXsmuX+WcutIS0u9BESar4gkXbK52YTh+ZzzYp8hcdbcHP W1BYCtq+vO1KPHYCciAi3HZz+fP1JTkHdMPqgkeOjYh7b2wwJmDoVY5emMjR3drnEbxE yO2G1qXVVSCw60dizR70PFhgaVDhSY3SXU/OCols1kuQiY5RHHxsqpOiTuuOzX2+r76r P+tA== X-Forwarded-Encrypted: i=1; AKwUvBxMRl0UqetOo/Vg5CdnXDKvfRn76lSDk0sw9BGSHlHwlm0sM4bxlq8xk3m9V4Hd9iLShE1zKyi/m/oLnwkd@postgresql.org X-Gm-Message-State: AFuF++kdiu+TxhLIPaDuP45SqlF9Zazl3mu84JwxyrF6wVZSBPys1DQv bNei6iITJrAI5GnBW4L7FKUFHQzZouZNhDR3Fawxdgloy2pfj2EFunQN X-Gm-Gg: AYBFou0UgV4s2MPwqdcCQmjhLv+X0hjLq2jhSlqCxkZgiGgZBYMI4WmxeoOq4AXipOK meY7CBj18RlykYJlCQFD3QkW1vS4FhSX0XvQT90q73Fq3hLH0+mGN9uk2ZKwZdS1vqzKScbfc61 RJe6c94ZVMEj5+vPclFA3xqsUNxu+8XLMf4mfWqjEIC3InLnnByqyvUnguKWnRGyfbYg6Hz4R21 eq+gOCis1Pli/8jifQAffgiE1Pr5NlGMzGs5ZAt6SPpJQ0D5ILt4+TNt5SJDKCCMt2mUUPDY57u o7x2PoBkp2+pLNRzH5OQdclMwlUZrJiX2sB2tWG3QXUvLVQ1ScVLNZrU2KVohmFhRRJQluDMuWK 04tq8GHwe/H4lGUi+wjccU0L9aSSKGM6+UpTE2cax5BbcorWPht9ET0ueJ+UTBpdMhoDNKsaErs n6CxlxYzKClEyoc5XB/nI4bQ+VFx7BkZw/bpdG9JZBG76YO4Rr1ZxGcmiBNHbuwVyGUs7hpBRsI ol2cnOuJnowRH7RntqFcrg9iIXc X-Received: by 2002:a05:600c:138f:b0:49f:cbf3:551c with SMTP id 5b1f17b1804b1-49fe66cc5camr8539665e9.12.1790201946546; Wed, 23 Sep 2026 15:19:06 -0700 (PDT) Received: from localhost ([2a02:169:191:0:a400:2a1:d4ec:566c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fe5b9f253sm19063705e9.1.2026.09.23.15.19.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Sep 2026 15:19:06 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 24 Sep 2026 00:19:05 +0200 Message-Id: Cc: "Alberto Piai" , From: "Alberto Piai" To: "Laurenz Albe" , "Matthias van de Meent" , =?utf-8?q?=C3=81lvaro_Herrera?= Subject: Re: Adding a stored generated column without long-lived locks X-Mailer: aerc 0.21.0 References: In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed Sep 23, 2026 at 12:26 PM CEST, Laurenz Albe wrote: > On Wed, 2026-09-23 at 12:07 +0200, Matthias van de Meent wrote: >> On Tue, 22 Sept 2026 at 17:17, =C3=81lvaro Herrera wrote: >> > On 2026-Sep-21, Alberto Piai wrote: >> >=20 >> > > Repro: >> > >=20 >> > > 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); >> > >=20 >> > > alter table tgen.t_repro_1 >> > > alter b add generated using constraint chk_gen stored; >> > >=20 >> > > update tgen.t_repro_1 set a =3D a; >> > > ERROR: duplicate key value violates unique constraint "t_repro_1_= b_idx" >> > > DETAIL: Key ((b::text))=3D(1.0) already exists. >> >=20 >> > Does this _matter_? >>=20 >> Yes, this does matter. > > I tend to agree. I too think this matters. The main arugment is IMHO the catastrophic failure mode: successful ALTER TABLE command, broken pg_restore... I would hate to put anyone in that situation. I find Matthias' proposal of exposing a function to check image equality very compelling for the purpose of this patch: besides fixing this problem, it would also make the command usable for data types which don't define =3D (json), as well as those which don't (can't?) define equalimage()... jsonb, numeric but also tsvector and PostGIS geometry. I'll take some time to study/review the patch and the discussion around it. Kind regards, Alberto --=20 Alberto Piai Sensational AG Z=C3=BCrich, Switzerland