Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oWFet-0007am-OD for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Sep 2022 11:25:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oWFes-0004Kx-IQ for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Sep 2022 11:25:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oWFes-0004Jo-95 for pgsql-hackers@lists.postgresql.org; Thu, 08 Sep 2022 11:25:22 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oWFep-0003Mc-NP for pgsql-hackers@postgresql.org; Thu, 08 Sep 2022 11:25:21 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id AB1145C01AB; Thu, 8 Sep 2022 07:25:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 08 Sep 2022 07:25:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1662636318; x=1662722718; bh=p 6E38e4UbtNGN/09ZERFAUxaTh7zpupd4F3sEGXnLfQ=; b=0Ug5FX54RPbuT4tWE WrkCZ3to8oxtIkpga8LIJ5279mkyCVNuqtoUG2fFwPjD01Vxe6xx7FOrJVNMeFiT ZY0tQVW44Hj3X6KE0P5awaeFok67NHHXCFenlmHGtZkziRUAJsloqLJ6hCfWzQHU NazBil0OG0ZfOD5aK5cJxErsu/ky7NSNKYHjhyCQ529YwLApv5Jg6msgcQHkULIq 3sSSElZ18nRU95S/6ugfQ59uE7E+h9uQpzbAleMLtJTFD1ks6D8c6qRfvyijX8cy N8kSxAL1HsQ0STgpI2td3OthBV9hrx9MTPDGaF8bAluZmAxZQbbKil+dELa8txA1 RqqjQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedtvddggeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfggtggugfgjsehtke ertddttdejnecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhr vgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpeehkeeugeeiue evgfelgfetkeehteejheejveeijeevgeekheehjefhledvgfdugeenucffohhmrghinhep vghnthgvrhhprhhishgvuggsrdgtohhmpdhslhgrshhhughothdrohhrghenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvges rghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 8 Sep 2022 07:25:18 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id D5157387; Thu, 8 Sep 2022 13:25:15 +0200 (CEST) Date: Thu, 8 Sep 2022 13:25:15 +0200 From: Alvaro Herrera To: Jehan-Guillaume de Rorthais Cc: pgsql-hackers Subject: Re: [BUG] wrong FK constraint name when colliding name on ATTACH Message-ID: <20220908112515.5pe5obtk4a63aiee@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220908094026.640a0224@karst> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Sep-08, Jehan-Guillaume de Rorthais wrote: > Hi there, > > I believe this very small bug and its fix are really trivial and could be push > out of the way quite quickly. It's just about a bad constraint name fixed by > moving one assignation after the next one. This could easily be fixed for next > round of releases. > > Well, I hope I'm not wrong :) I think you're right, so pushed, and backpatched to 12. I added the test case to regression also. For 11, I adjusted the test case so that it didn't depend on an FK pointing to a partitioned table (which is not supported there); it turns out that the old code is not smart enough to get into the problem in the first place. Setup is CREATE TABLE parted_fk_naming_pk (id bigint primary key); CREATE TABLE parted_fk_naming ( id_abc bigint, CONSTRAINT dummy_constr FOREIGN KEY (id_abc) REFERENCES parted_fk_naming_pk (id) ) PARTITION BY LIST (id_abc); CREATE TABLE parted_fk_naming_1 ( id_abc bigint, CONSTRAINT dummy_constr CHECK (true) ); and then ALTER TABLE parted_fk_naming ATTACH PARTITION parted_fk_naming_1 FOR VALUES IN ('1'); throws this error: ERROR: duplicate key value violates unique constraint "pg_constraint_conrelid_contypid_conname_index" DETALLE: Key (conrelid, contypid, conname)=(686125, 0, dummy_constr) already exists. It seems fair to say that this case, with pg11, is unsupported and people should upgrade if they want better behavior. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "Those who use electric razors are infidels destined to burn in hell while we drink from rivers of beer, download free vids and mingle with naked well shaved babes." (http://slashdot.org/comments.pl?sid=44793&cid=4647152)