Re: FK Constraint sort order with pg_dump

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christian Barthel <bch(at)online(dot)de>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: FK Constraint sort order with pg_dump
Date: 2022-07-21 20:46:33
Message-ID: 286980.1658436393@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Christian Barthel <bch(at)online(dot)de> writes:
> On Thursday, July 21, 2022, Adrian Klaver wrote:
>> Why does it matter?

> As the comment in pg_dump.c states, logically identical schemas should
> produce identical dumps:

Agreed, but this is far from the only deficiency in DOTypeNameCompare.
If we're going to try to fill in the gaps, we should be systematic
about it. I took a quick stab at implementing the cases it omits,
as attached. There are still a few gaps:

* DO_OPCLASS and DO_OPFAMILY ought to have a subsidiary sort on the
access method name, since their names are only unique per-access-method.
The trouble here is that OpclassInfo/OpfamilyInfo don't provide any
way to get to the access method. That could be fixed with more fields,
and maybe it's worth doing, but I didn't do that here.

* For casts, the cast name is consed up as the concatenation of the source
and target type names, which isn't enough to guarantee uniqueness. We
could add the types' schema names, perhaps ... is it worth the trouble?
(Not to mention possible breakage of scripts that expect the current
naming convention.)

* Likewise for transforms, we'd need to add the type's schema name if
we want the transform name to be unique.

Not sure whether it's worth venturing into such nonlocal fixes.

regards, tom lane

Attachment Content-Type Size
improve-DOTypeNameCompare-1.patch text/x-diff 3.1 KB

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Zsolt Ero 2022-07-21 22:28:18 Re: could not link file in wal restore lines
Previous Message Adrian Klaver 2022-07-21 18:36:19 Re: FK Constraint sort order with pg_dump