Re: pg_get__*_ddl consolidation

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_get__*_ddl consolidation
Date: 2026-03-19 21:32:21
Message-ID: CAN4CZFOE0w4YwuVA74G39BMoKCSvVjCOJ+7X+XiSiaBaH4LXmA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello!

I found a few problematic corner cases while testing the patches,
please look at the following:

Doesn't pg_get_database_ddl need more filtering for roles?

See example:

CREATE DATABASE testdb;
CREATE ROLE testrole;
ALTER DATABASE testdb SET work_mem TO '256MB';
ALTER ROLE testrole IN DATABASE testdb SET work_mem TO '512MB';
SELECT pg_get_database_ddl('testdb');

Another issue is that the data style isn't fixed:

CREATE ROLE regress_datestyle_test VALID UNTIL '2030-12-31 23:59:59+00';
SET DateStyle TO 'SQL, DMY';
SELECT * FROM pg_get_role_ddl('regress_datestyle_test');
-- returned statement fails with invalid input syntax for timestamp

+ appendStringInfo(&buf, "ALTER DATABASE %s OWNER = %s;",
+ dbname, quote_identifier(owner));

Shouldn't that be OWNER TO? Similarly this will result in an error
when executed.

Role memberships seem to be missing. I would expect those to be included?

CREATE ROLE regress_parent;
CREATE ROLE regress_child;
GRANT regress_parent TO regress_child;
SELECT * FROM pg_get_role_ddl('regress_child');

+ dbname = quote_identifier(NameStr(dbform->datname));

Isn't an pstrdup missing from here? dbname is used after ReleaseSysCache.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-03-19 21:33:36 Re: Add uuid_to_base32hex() and base32hex_to_uuid() built-in functions
Previous Message Andrew Dunstan 2026-03-19 21:30:06 Re: pg_get__*_ddl consolidation