Re: Command order bug in pg_dump

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Subject: Re: Command order bug in pg_dump
Date: 2025-04-21 17:08:05
Message-ID: 769270.1745255285@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> 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.

Oh, I see what's happening. We create both the specified constraint
and an inherited child constraint on the named partitioned table.
If tt_a_fkey is added first, the name chosen for its child is
"tt_i_fkey", breaking the later attempt by the user to use that name.
Apparently there is some hack in psql to not show that child
constraint entry, because you don't see it in \d output, which
is what confused me before (and would confuse most people
hitting this).

We could fool around with the generation rule for the child
constraint's name, but fundamentally we're infringing on user
namespace here, so I think that's likely to just move the problem
cases around. Why do we need this child pg_constraint entry at all?

If we can't avoid having it, probably choosing a name like
"tt_a_fkey1" would be marginally less likely to cause trouble
... but only marginally.

In any case, it's pretty awful that we make these entries but
\d does not show them.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Kirill Reshke 2025-04-21 17:30:10 Re: Command order bug in pg_dump
Previous Message Masahiko Sawada 2025-04-21 17:00:05 Re: Disabled logical replication origin session causes primary key errors