Re: Command order bug in pg_dump - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Command order bug in pg_dump
Date
Msg-id 592472.1745247403@sss.pgh.pa.us
Whole thread Raw
In response to Command order bug in pg_dump  (Kirill Reshke <reshkekirill@gmail.com>)
Responses Re: Command order bug in pg_dump
Re: Command order bug in pg_dump
Re: Command order bug in pg_dump
List pgsql-bugs
Kirill Reshke <reshkekirill@gmail.com> 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



pgsql-bugs by date:

Previous
From: Александр Иванов
Date:
Subject: ...
Next
From: vignesh C
Date:
Subject: Re: Disabled logical replication origin session causes primary key errors