Re: pg_get_*_ddl() needs a redesign

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, gonzalemario(at)gmail(dot)com, dbryan(dot)green(at)gmail(dot)com, euler(at)eulerto(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_get_*_ddl() needs a redesign
Date: 2026-09-11 15:14:41
Message-ID: 994515.1789139681@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2026-09-11 15:14:42 Re: pg_get_*_ddl() needs a redesign
Previous Message Greg Burd 2026-09-11 14:47:56 Re: [PATCH] Batched clock sweep to reduce cross-socket atomic contention