| From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
|---|---|
| To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Japin Li <japinli(at)hotmail(dot)com> |
| Cc: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Euler Taveira <euler(at)eulerto(dot)com>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: pg_get__*_ddl consolidation |
| Date: | 2026-04-02 16:27:21 |
| Message-ID: | a533fb1b-0f2c-4fc9-ab3b-6fb5ddac1800@dunslane.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 2026-04-02 Th 9:35 AM, David G. Johnston wrote:
> On Thursday, April 2, 2026, Japin Li <japinli(at)hotmail(dot)com> wrote:
>
>
> v3-0004
> ========
>
> 1.
> + append_ddl_option(&buf, pretty, 4, "WITH TEMPLATE =
> template0");
>
> I'm curious why WITH TEMPLATE = template0 is hardcoded. For example:
>
> [local]:1374846 postgres=# create database db01 IS_TEMPLATE true;
> CREATE DATABASE
> [local]:1374846 postgres=# create database db02 template db01;
> CREATE DATABASE
> [local]:1374846 postgres=# select pg_get_database_ddl('db02');
> pg_get_database_ddl
>
> -----------------------------------------------------------------------------------------------------------------
> CREATE DATABASE db02 WITH TEMPLATE = template0 ENCODING =
> 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'en_US.UTF-8';
> ALTER DATABASE db02 OWNER TO japin;
> (2 rows)
>
> Is this working as expected?
>
> It seems there's no way to reconstruct the WITH TEMPLATE clause,
> right?
> A comment here would help.
>
>
> There is no way or use in constructing the original template clause,
> though I agree it’s worth a comment. At the end of the day the
> catalog data that was found in the db01 database already exists in the
> db02 database when executing these DLL reconstruction functions
> against the existing db02 database. Taking nothing from the template
> is the correct behavior - hence template0.
>
>
OK, here's a v4.
cheers
andrew
--
Andrew Dunstan
EDB:https://www.enterprisedb.com
| Attachment | Content-Type | Size |
|---|---|---|
| v4-0001-Add-infrastructure-for-pg_get_-_ddl-functions.patch | text/x-patch | 9.9 KB |
| v4-0002-Add-pg_get_role_ddl-function.patch | text/x-patch | 27.3 KB |
| v4-0003-Add-pg_get_tablespace_ddl-function.patch | text/x-patch | 20.4 KB |
| v4-0004-Add-pg_get_database_ddl-function.patch | text/x-patch | 22.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-04-02 16:29:52 | Re: pg_waldump: support decoding of WAL inside tarfile |
| Previous Message | Andres Freund | 2026-04-02 16:27:12 | Re: some more include removal from headers |