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.94.2) (envelope-from ) id 1u6sZo-006x16-SQ for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Apr 2025 14:56:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u6sZl-006Eyi-79 for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Apr 2025 14:56:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u6sZk-006EyM-UK for pgsql-bugs@lists.postgresql.org; Mon, 21 Apr 2025 14:56:49 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u6sZi-001CF7-2w for pgsql-bugs@postgresql.org; Mon, 21 Apr 2025 14:56:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 53LEuhOt592473; Mon, 21 Apr 2025 10:56:43 -0400 From: Tom Lane To: Kirill Reshke cc: pgsql-bugs@postgresql.org, Alvaro Herrera Subject: Re: Command order bug in pg_dump In-reply-to: References: Comments: In-reply-to Kirill Reshke message dated "Mon, 21 Apr 2025 15:56:39 +0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <592471.1745247403.1@sss.pgh.pa.us> Date: Mon, 21 Apr 2025 10:56:43 -0400 Message-ID: <592472.1745247403@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Kirill Reshke writes: > psql:dump-p.sql:120: ERROR: constraint "tt_i_fkey" for relation "tt" > already exists I don't think this is pg_dump's fault: there is no such constraint when the ALTER TABLE starts. Something inside the ALTER TABLE recursion seems to be messing up if there is already another similar FK constraint. This trace is pretty interesting: regression=# create database db1; CREATE DATABASE regression=# \c db1 You are now connected to database "db1" as user "postgres". db1=# create table tfk (i int unique) partition by range (i ); CREATE TABLE db1=# create table tfk_po partition of tfk for values from ( 0 ) to (1); CREATE TABLE db1=# create table tt (i int) partition by range (i ); CREATE TABLE db1=# create table tt_po partition of tt for values from ( 0 ) to (1); CREATE TABLE db1=# ALTER TABLE public.tt db1-# ADD CONSTRAINT tt_a_fkey FOREIGN KEY (i) REFERENCES public.tfk(i); ALTER TABLE db1=# ALTER TABLE public.tt db1-# ADD CONSTRAINT tt_i_fkey FOREIGN KEY (i) REFERENCES public.tfk(i); ERROR: constraint "tt_i_fkey" for relation "tt" already exists db1=# ALTER TABLE public.tt drop CONSTRAINT tt_a_fkey; ALTER TABLE db1=# ALTER TABLE public.tt ADD CONSTRAINT tt_i_fkey FOREIGN KEY (i) REFERENCES public.tfk(i); ALTER TABLE Doesn't seem to be a new problem, either ... this trace is against v13. regards, tom lane