Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Amul Sul <sulamul(at)gmail(dot)com>
Cc: Akshay Joshi <akshay(dot)joshi(at)enterprisedb(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Euler Taveira <euler(at)eulerto(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, japin <japinli(at)hotmail(dot)com>, Quan Zongliang <quanzongliang(at)yeah(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement
Date: 2026-02-25 11:53:57
Message-ID: 202602251144.gu4luvkj6e2c@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2026-Feb-24, Amul Sul wrote:

> On Mon, Feb 23, 2026 at 7:27 PM Akshay Joshi
> <akshay(dot)joshi(at)enterprisedb(dot)com> wrote:
> >
> > On Mon, Feb 23, 2026 at 6:50 PM Amul Sul <sulamul(at)gmail(dot)com> wrote:

> > >
> > > + /* If it's with defaults, we skip default encoding check */
> > > + if (is_with_defaults ||
> > > + (pg_strcasecmp(pg_encoding_to_char(dbform->encoding),
> > > + DDL_DEFAULTS.DATABASE.ENCODING) != 0))
> > >
> > >
> > > Comment doesn't quite match the logic in the condition.
> >
> > Will update this in my next patch. When we decide which approach to follow:
> > 1) Double Dash:
> > v8-0001-Add-pg_get_database_ddl-function-to-reconstruct-double-dash.patch
> > 2) DefElem (Key-Value):
> > v8-0002-Add-pg_get_database_ddl-function-to-reconstruct-DefElem.patch
>
> That’s a bit subjective, as different people will likely have
> different opinions. I prefer the first version without the -- prefix,
> since the counterpart would be the default behavior. For example, if
> "no-tablespace" is not specified, the tablespace would be included in
> the DDL dump by default.

I'm surprised to not have seen an update on this topic following the
discovery by Mark Wong that commit d32d1463995c (in branch 18) already
established a convention for passing arguments to functions: use argument
pairs to variadic functions, the way pg_restore_relation_stats() and
pg_restore_attribute_stats() work. While I like my previous suggestion
of using DefElems better, I think it's more sensible to follow this
established precedent and not innovate on this.

Regards

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jakub Wartak 2026-02-25 11:57:19 Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc?
Previous Message Peter Eisentraut 2026-02-25 11:33:58 Re: SQL Property Graph Queries (SQL/PGQ)