From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Noah Misch <noah@leadboat.com>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Melanie Plageman <melanieplageman@gmail.com>
Cc: gonzalemario@gmail.com
Cc: dbryan.green@gmail.com
Cc: euler@eulerto.com
Cc: pgsql-hackers@postgresql.org
Subject: Re: pg_get_*_ddl() needs a redesign
Date: Fri, 11 Sep 2026 00:55:54 -0400
Message-ID: <956966.1789102554@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+Tgmoa2aBFUREeN1AWZ9O8h5WjTD0wdwAzDJj4c3j5aOP=eTA@mail.gmail.com>
References: <20260827015242.54.noahmisch@microsoft.com>
<CAAKRu_a0KX2OONvtcEOwyOX0DzOC-B8sh-w8s5tNkKwczmVzeQ@mail.gmail.com>
<c75aa91a-7029-4c69-9f98-fe4d2f18bc11@dunslane.net>
<20260909172132.0a.noahmisch@microsoft.com>
<640139.1788975299@sss.pgh.pa.us>
<ccd76a86-51c0-4395-b6b2-2e7214c2fbf2@dunslane.net>
<20260910035953.59.noahmisch@microsoft.com>
<CA+Tgmoa2aBFUREeN1AWZ9O8h5WjTD0wdwAzDJj4c3j5aOP=eTA@mail.gmail.com>
Robert Haas <robertmhaas@gmail.com> writes:
> That said, if this is coming out of v19 anyway, then IMHO it is fair
> game to reopen the question of whether we want it in v20. But if we're
> going to do that, we should hash that out now rather than in six
> months from now or twelve months from now. Personally, I have mixed
> feelings about this feature. On the one hand, I am sure it will get
> some use, and I have wanted it myself. On the other hand, it will get
> far less use, and far less testing, than the equivalent code in
> pg_dump, so it's more likely to have bugs now and in the future, and
> the fact that there's no reasonable way (at least, not that I can see)
> to handle version skew within a facility like this is a major
> disadvantage vs. pg_dump.
I'm a bit confused why you say that. To my mind, if we were going
to proceed in this direction, version skew would ideally be solved
like this:
1. Server-side DDL-reconstruction functions only need to work with
their particular server version; necessarily so, since that's the
only catalog data they'll ever see.
2. pg_dump just calls the source server's DDL-reconstruction functions
and doesn't have to worry about version skew.
The difficulty is how do we get to #2 from where we are. Part of that
could be handled by saying "well, pg_dump calls the server functions
when source server version >= N, and otherwise does it locally",
and expecting that we could eventually retire the "locally" code.
Since the "locally" code would only need to work with frozen server
versions, that doesn't seem too unmaintainable. The hard parts as
I see it are
(A) pg_dump is optimized to gather data across the entire database
at once. Converting it to call functions that produce info about
a single object at a time would almost certainly be catastrophic
for performance on large databases.
(B) pg_dump slices and dices the data in ways that don't necessarily
make sense for standalone usage. For example it doesn't want to
mention a primary key when creating a table, rather it wants to add
that constraint (and build the index) after loading data.
I do not feel that these problems are necessarily insoluble, but
they do require some hard work to define the server-side functionality
properly.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, noah@leadboat.com, andrew@dunslane.net, melanieplageman@gmail.com, gonzalemario@gmail.com, dbryan.green@gmail.com, euler@eulerto.com
Subject: Re: pg_get_*_ddl() needs a redesign
In-Reply-To: <956966.1789102554@sss.pgh.pa.us>
References: <20260827015242.54.noahmisch@microsoft.com> <CAAKRu_a0KX2OONvtcEOwyOX0DzOC-B8sh-w8s5tNkKwczmVzeQ@mail.gmail.com> <c75aa91a-7029-4c69-9f98-fe4d2f18bc11@dunslane.net> <20260909172132.0a.noahmisch@microsoft.com> <640139.1788975299@sss.pgh.pa.us> <ccd76a86-51c0-4395-b6b2-2e7214c2fbf2@dunslane.net> <20260910035953.59.noahmisch@microsoft.com> <CA+Tgmoa2aBFUREeN1AWZ9O8h5WjTD0wdwAzDJj4c3j5aOP=eTA@mail.gmail.com> <956966.1789102554@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox