public inbox for [email protected]  
help / color / mirror / Atom feed
From: Kirill Reshke <[email protected]>
To: Akshay Joshi <[email protected]>
Cc: Japin Li <[email protected]>
Cc: Rafia Sabih <[email protected]>
Cc: Álvaro Herrera <[email protected]>
Cc: Euler Taveira <[email protected]>
Cc: Amul Sul <[email protected]>
Cc: Andrew Dunstan <[email protected]>
Cc: Chao Li <[email protected]>
Cc: Quan Zongliang <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement
Date: Tue, 10 Mar 2026 15:16:25 +0500
Message-ID: <CALdSSPjqAEicVAaq=FC2HyhbXdYBN0Vh8cqpkcS8DEwic8YunQ@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDf+Ak=S+V1Rx25Eqh7r6cuWZtHYiEo_AZsn9eqiWbVGEg@mail.gmail.com>
References: <SY7PR01MB10921BB04879E2BDE787AA5EFB67CA@SY7PR01MB10921.ausprd01.prod.outlook.com>
	<[email protected]>
	<CANxoLDcW2iyOq8JJYQXkzXkK6PtQX-z7Hxe=Ri3nQJX6AaPLjw@mail.gmail.com>
	<SY7PR01MB10921B6F9D478C3F1B2639901B67CA@SY7PR01MB10921.ausprd01.prod.outlook.com>
	<CANxoLDdNsuXxL7yLgqWNaR=VCjqMgJ77oU3OvJ6KwBVKi7NVEw@mail.gmail.com>
	<CA+FpmFeMfmRx3fNE97X5VZpLpiausHCKsRG5aEosfTwq_idPNg@mail.gmail.com>
	<CANxoLDfA7gVFhpYPOJSScfh=O8Ohj0m_uDM9G=L0SUW+2bfKeg@mail.gmail.com>
	<CA+FpmFfTSO5jC9_UYjR1G8ofayijYXubvauHj0TCHUnqaJ0xaA@mail.gmail.com>
	<CANxoLDeCXmzMnmhYSqL+kBEVynGQ99TyJp74UWwj_jeGS0J_6g@mail.gmail.com>
	<SY7PR01MB1092148A0ADF42B45E8EFB7B7B67AA@SY7PR01MB10921.ausprd01.prod.outlook.com>
	<CANxoLDf+Ak=S+V1Rx25Eqh7r6cuWZtHYiEo_AZsn9eqiWbVGEg@mail.gmail.com>

On Mon, 9 Mar 2026 at 17:08, Akshay Joshi <[email protected]> wrote:
>
> I have resolved the review comments. Removed the hardcoded 'utf-8' encoding, the logic now retrieves the encoding dynamically. This ensures accuracy because the default encoding for CREATE DATABASE is derived from the template database (template1) rather than being a static value.
>
> Attached is the v13 patch, now ready for further review.
>
> On Fri, Mar 6, 2026 at 8:13 PM Japin Li <[email protected]> wrote:
>>
>>
>> Hi, Akshay
>>
>> On Fri, 06 Mar 2026 at 17:21, Akshay Joshi <[email protected]> wrote:
>> > I have updated the documentation.
>> > Attached is the v12 patch, now ready for further review.
>> >
>>
>> Thanks for updating the patch.
>>
>> I might not have expressed myself clearly in my last email — apologies.
>> Here's a diff that should make it clearer.
>>
>> diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
>> index bbf82c1d6c0..1ed56ee71ab 100644
>> --- a/src/backend/utils/adt/ruleutils.c
>> +++ b/src/backend/utils/adt/ruleutils.c
>> @@ -13859,7 +13859,6 @@ parse_ddl_options(FunctionCallInfo fcinfo, int variadic_start)
>>         bool       *nulls;
>>         Oid                *types;
>>         int                     nargs;
>> -       bool            found = false;
>>
>>         /* Extract variadic arguments */
>>         nargs = extract_variadic_args(fcinfo, variadic_start, true,
>> @@ -13887,8 +13886,7 @@ parse_ddl_options(FunctionCallInfo fcinfo, int variadic_start)
>>         {
>>                 char       *name;
>>                 bool            bval;
>> -
>> -               found = false;
>> +               bool            found = false;
>>
>>                 /* Key must not be null */
>>                 if (nulls[i])
>> @@ -13925,8 +13923,8 @@ parse_ddl_options(FunctionCallInfo fcinfo, int variadic_start)
>>                         if (!parse_bool(valstr, &bval))
>>                                 ereport(ERROR,
>>                                                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
>> -                                                errmsg("argument %d: invalid value \"%s\" for key \"%s\"",
>> -                                                               i + 2, valstr, name),
>> +                                                errmsg("value for option \"%s\" at position %d has invalid value \"%s\"",
>> +                                                               name, i + 2, valstr),
>>                                                  errhint("Valid values are: true, false, yes, no, 1, 0, on, off.")));
>>                         pfree(valstr);
>>                 }
>> @@ -13934,8 +13932,8 @@ parse_ddl_options(FunctionCallInfo fcinfo, int variadic_start)
>>                 {
>>                         ereport(ERROR,
>>                                         (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
>> -                                        errmsg("argument %d: value for key \"%s\" must be boolean or text type",
>> -                                                       i + 2, name)));
>> +                                        errmsg("value for option \"%s\" at position %d has type %s, expected type boolean or text",
>> +                                                       name, i + 2, format_type_be(types[i + 1]))));
>>                 }
>>
>>                 /*
>> @@ -13983,7 +13981,7 @@ parse_ddl_options(FunctionCallInfo fcinfo, int variadic_start)
>>  /*
>>   * pg_get_database_ddl
>>   *
>> - * Generate a CREATE DATABASE statement for the specified database name or oid.
>> + * Generate a CREATE DATABASE statement for the specified database oid.
>>   *
>>   * db_oid - OID of the database for which to generate the DDL.
>>   * options - Variadic name/value pairs to modify the output.
>>
>> --
>> Regards,
>> Japin Li
>> ChengDu WenWu Information Technology Co., Ltd.


Hi!
I noticed this in v13: DDLOptionDef is missing from typedefs.list.
This results in pgident to incorrectly format sources.



-- 
Best regards,
Kirill Reshke





view thread (41+ 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], [email protected], [email protected], [email protected]
  Subject: Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement
  In-Reply-To: <CALdSSPjqAEicVAaq=FC2HyhbXdYBN0Vh8cqpkcS8DEwic8YunQ@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