public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: Japin Li <[email protected]>
Cc: Andrew Dunstan <[email protected]>
Cc: Zsolt Parragi <[email protected]>
Cc: Euler Taveira <[email protected]>
Cc: Álvaro Herrera <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: pg_get__*_ddl consolidation
Date: Thu, 2 Apr 2026 06:35:59 -0700
Message-ID: <CAKFQuwYcppypeGBwa7ZbDAfoUXSv+kLhJuAXsdwBmKrvy8wDFw@mail.gmail.com> (raw)
In-Reply-To: <SY7PR01MB10921A6E1E08A48F3426FE529B651A@SY7PR01MB10921.ausprd01.prod.outlook.com>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<CAN4CZFNYM5jNA_gLu9miAXg_7c8Z2zf-ePc+0rzidAV3CBs=cw@mail.gmail.com>
	<[email protected]>
	<SY7PR01MB10921A6E1E08A48F3426FE529B651A@SY7PR01MB10921.ausprd01.prod.outlook.com>

On Thursday, April 2, 2026, Japin Li <[email protected]> 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.

David J.


view thread (31+ messages)  latest in thread

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: pg_get__*_ddl consolidation
  In-Reply-To: <CAKFQuwYcppypeGBwa7ZbDAfoUXSv+kLhJuAXsdwBmKrvy8wDFw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox