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 1vtlbB-00BHsI-03 for pgsql-bugs@arkaria.postgresql.org; Sat, 21 Feb 2026 11:56:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vtlb9-009liH-2R for pgsql-bugs@arkaria.postgresql.org; Sat, 21 Feb 2026 11:56:35 +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 1vtlb8-009li9-2d for pgsql-bugs@lists.postgresql.org; Sat, 21 Feb 2026 11:56:35 +0000 Received: from fhigh-b7-smtp.messagingengine.com ([202.12.124.158]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vtlb4-00000000YfG-2yOv for pgsql-bugs@lists.postgresql.org; Sat, 21 Feb 2026 11:56:34 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id 972977A0182; Sat, 21 Feb 2026 06:56:28 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Sat, 21 Feb 2026 06:56:28 -0500 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=fm2; t=1771674988; x= 1771761388; bh=QKZgpT0JZ2zfTygy3IWUgzi16qp7hYipk/jjkd9fNBA=; b=e pY2J8oYKO4ji8WJTC3D2rgOnLT5WtCrpJYerLG883jo3EL92P3iNuOhmqTrNVHp3 1rhe9UQXWphapeGsqShWNIAHb2EOfWrrcONg4E1/HkZz9MLtXtKHwEb8l7oA3Zfj dVTaia/M1kZ/4dXZSnXc37kLf8YmzwrrTCUoVrfTXXZqH6Cztjmj2jA7ZbrCqPeo udYqD9XDgKj1yVbSUKrTD6CmsVzTWG/9YtE5owTNMdTKH0uDDxpfx+bWzOnQcG8t wcdPIk4cYfAjwySzs+VzwsGSAhLGUKShSVFeALHJnp4WFLaPW8XsCjV0pftRv/DG 04XGRyIg2Y6Pv2wuKIO8g== 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=fm3; t=1771674988; x=1771761388; bh=Q KZgpT0JZ2zfTygy3IWUgzi16qp7hYipk/jjkd9fNBA=; b=SQMKqwVYjSvqyglOm +r7IwOnKpHbn2WfPVqAjRpeOVe1v3+eMHUOthOsgq8yy7M1OAOac79QLVoNjRarH gFFz44UovvhW5VY4CKu/yGxcmHFFEKDUwvLOayDurRj3FNP3oqJ6Ov/enjJXwvE8 9S4plM6chp/S/H/mhAapPWRtcIIgXr/EZKlmNRYMKL197SF3pN5PPtvg7mWPjYcE E7HYI1zJ8DG0PGTOCdsTYk5Dv/KtM6Cauxvyj+9rVDJjqipX5xlG4ZoDzfDbyO8n FnV/Ym3a9/JTr7EtfLyD5PiH32OBNeei08YeeFNS2YEIHghOdrYuT+x2b8ex8EQ0 9anQQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvfedufedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheplmhlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsehkuhhrihhlvghmuhdruggvqeenucggtf frrghtthgvrhhnpeegvedukeelheeggeefieeijeejieeljeeffeffieekgfeuudefledu tdeufeejfeenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmpdhlfihnrd hnvghtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep rghlvhhhvghrrhgvsehkuhhrihhlvghmuhdruggvpdhnsggprhgtphhtthhopeefpdhmoh guvgepshhmthhpohhuthdprhgtphhtthhopehlrghurhgvnhiirdgrlhgsvgestgihsggv rhhtvggtrdgrthdprhgtphhtthhopehhuhhsvgihihhnrdgufehrsehgmhgrihhlrdgtoh hmpdhrtghpthhtohepphhgshhqlhdqsghughhssehlihhsthhsrdhpohhsthhgrhgvshhq lhdrohhrgh X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 21 Feb 2026 06:56:27 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1771674985; bh=yLbsbKggIVJeAmisob7GET6pdL10EtSzFJsZFshv0nw=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=t2lJePreESNhz6WzwRmbOMQ4VjmTzq0u4w2tzQ3boih+KsZ8QR2i7j+v/fiFCn4/C pDvgDhDaLnAC0FeFrY3zDTz49K0Bc7XcUpmYliHmH4Fcc7aJkIZDHeS+JdCjJcYETa zGfTx5WayADjadUgZOpRPkwrIvrvyyzND9zpxiya6NPEigM3Xjk+KPqUsc4icbINzT +Szv/vvUObfM2gAJYzIcAU38okDiey+2biR/wYD6HAGe1oVeMmQQhZskuZXDNzSxcF qJBLDm5mbhHbpMpYr0ueB1LM+gm/95WX4SCN4U4ODgpoItUdki8oXcHPF8ly/MEBTc FLe+CojeYEw8Q== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id 04C8B7A; Sat, 21 Feb 2026 12:56:24 +0100 (CET) Date: Sat, 21 Feb 2026 12:56:24 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Laurenz Albe Cc: huseyin.d3r@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19393: pg_upgrade fails with duplicate key violation when CHECK constraint named *_not_null exists Message-ID: <202602211127.yhfjy43if2kk@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <61c535617992fff830961ecc09a9c20096bc1f36.camel@cybertec.at> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-Feb-05, Laurenz Albe wrote: > On Thu, 2026-02-05 at 15:58 +0100, I wrote: > > The bug is actually not in pg_upgrade, but in CREATE TABLE. The attached patch > > fixes the problem for me by avoiding given constraint names when generating > > the names for NOT NULL constraints. > > ... and here is v2, including a regression test. Thanks for this! I have pushed it now to 18 and master (right before the embargo for next week's release -- not really apologizing about that, since this is clearly something that's going to bite users as they move up to 18). Two notes: 1. this will cause an ABI break report for AddRelationNotNullConstraints in branch 18. I considered the idea of adding a shim function preserving the original API, but I think this is not a function likely to be used by third-party code. So I'll address this by adding an entry to .abi-compliance-history instead. 2. I moved this foreach loop > @@ -2905,6 +2907,12 @@ AddRelationNotNullConstraints(Relation rel, List *constraints, > * system-generated name conflicts we just generate another. > */ > nnnames = NIL; > + foreach_ptr(CookedConstraint, cons, existing_constraints) > + { > + if (cons->name != NULL) > + nnnames = lappend(nnnames, cons->name); > + } > + > givennames = NIL; from AddRelationNotNullConstraints to DefineRelation; it seems more natural for the former to receive a list of constraint names than a list of CookedConstraints. Thanks Hüseyin for the report and Laurenz for the fix! -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "How strange it is to find the words "Perl" and "saner" in such close proximity, with no apparent sense of irony. I doubt that Larry himself could have managed it." (ncm, http://lwn.net/Articles/174769/)