From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: 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 11:14:41 -0400
Message-ID: <994515.1789139681@sss.pgh.pa.us> (raw)
In-Reply-To: <25geh4lsb4uwqurcvh4toqbeknjmo5arw5rdvubtghdxz2bdk3@fqenqkj464zj>
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>
<25geh4lsb4uwqurcvh4toqbeknjmo5arw5rdvubtghdxz2bdk3@fqenqkj464zj>
Andres Freund <andres@anarazel.de> writes:
> On 2026-09-11 00:55:54 -0400, Tom Lane wrote:
>> 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.
> Isn't the problem with that that we occasionally need to adapt the syntax
> between versions to some degree? I think it has become less common, but I'm a
> bit sceptical that it's wise to decide we won't ever again need that...
I think we try very very hard to avoid making changes that would break
existing dump files. There are certainly times where we change what
pg_dump prefers to output, but the server should continue to accept
what pg_dump used to output (at least for quite a few years). Users
don't always have the luxury of being able to follow the advice to
"use the newest pg_dump to make your dump".
> I wonder if the right thing here would be to separate the "metadata
> collection" aspect from the "SQL generation" aspect. I.e. have a small library
> that can generate DDL statements from its inputs, without any catalog
> accesses. We'd still end up - annoyingly - with two versions of the metadata
> collection (one from syscaches for the get_ddl* SQL functions, one via queries
> for pg_dump), but at least the SQL generation aspect would be deduplicated.
Hmm...
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, andres@anarazel.de, 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: <994515.1789139681@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> <25geh4lsb4uwqurcvh4toqbeknjmo5arw5rdvubtghdxz2bdk3@fqenqkj464zj> <994515.1789139681@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