Re: pg_get__*_ddl consolidation

Jelte Fennema <postgres@jeltef.nl>

From: "Jelte Fennema-Nio" <postgres@jeltef.nl>
To: "Andrew Dunstan" <andrew@dunslane.net>
Cc: "David G. Johnston" <david.g.johnston@gmail.com>, "Japin Li" <japinli@hotmail.com>, "Zsolt Parragi" <zsolt.parragi@percona.com>, "Euler Taveira" <euler@eulerto.com>, Álvaro Herrera <alvherre@kurilemu.de>, "PostgreSQL Hackers" <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-06T15:24:06Z
Lists: pgsql-hackers

Attachments

On Mon, 6 Apr 2026 at 13:55, Andrew Dunstan <andrew@dunslane.net> wrote:
> There was quite a deal of discussion around this mechanism. See Euler's
> review at [1] and follow-up at [2] for the original discussion of the
> VARIADIC option-parsing design and the use cases it was meant to
> address. I'm prepared to revisit it is there's a strong consensus on the
> point.

Thanks for those links. I had not seen that part of the discussion. But
I only see an explanation of why these functions are configurable with
optional key+value pairs in their arguments. I think that makes sense,
and I totally agree that we should do that.

The thing I'm questioning is whether we need a new way of providing
key+value pairs as optional arguments to functions. IMO we already had a
perfectly fine one. Introducing another adds complexity (both to the
code and to the user) and I don't see any compelling reason to do so.

Attached is a patch with roughly what I have in mind instead. By doing
this we can also make the functinos STRICT, so that we don't have to
worry about handling NULL values for the first argument.

Afaict this named parameter approach only has benefits over the VARIADIC
argument one. But if I'm wrong about that, please let me know.

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Use named boolean parameters for pg_get_*_ddl option arguments

  2. Convert ddlutils regression tests to TAP tests.

  3. Fix pfree crash in pg_get_role_ddl() and pg_get_database_ddl().

  4. Fixups for a4f774cf1c7

  5. Add infrastructure for pg_get_*_ddl functions

  6. Add pg_get_database_ddl() function

  7. Add pg_get_role_ddl() function

  8. Add pg_get_tablespace_ddl() function