Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vzu8n-001QcG-2t for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Mar 2026 10:16:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vzu8m-002V7z-0Y for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Mar 2026 10:16:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vzu8l-002V7r-2A for pgsql-hackers@lists.postgresql.org; Tue, 10 Mar 2026 10:16:40 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vzu8j-00000001Qs5-406s for pgsql-hackers@postgresql.org; Tue, 10 Mar 2026 10:16:38 +0000 Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-5090c7e9081so22785351cf.0 for ; Tue, 10 Mar 2026 03:16:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773137797; cv=none; d=google.com; s=arc-20240605; b=SQtf6lZ3sGRASu0e1PkumX4dtjEDMb8yycaW2EeGIc8mb8xGO01lUbo0D9TI/rlf5I 2BHHQZ53a19AGcXw9mQEUQvND+Aa+9Napqye6Bf87j208jrUcv9kk7GUd3p9vI1wSbiQ ey4qauVeODsyju6VTq7ueaQQ1YbuwyNSiT0xA+OsU7GmFhEvfrThpEq5esJLzjDsotsr 9+KY7JFUchN1TMPDLcmsXvpdJRXKp1wmZ/WL097GysnnmXe8k2G+/NtBlH+XadfIPpWl mTBg+e4dAwxfZ8kfLsdx9cBGkwx7IR5LYqtFer4vyZ53KcT5fT45RlSeOH30bEF0KcWp kCUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=s9ea3JbPmMpmm1p5/jme6Gf4RRf/h8qbQ/O2bQlh5bU=; fh=ibq+NIENWEtlMRNe/03smoKmezupRrJ5GmuKIGg4dNo=; b=XM/1+oTf6Rnrvvv8p9TNsVqWVl9cUVo6Fwz/VfhpySl8kQtuALZzMLQQFLHmEOPdhi +oxbcxSUTklS7XJCuF7ViJuA1tXuWQFMbvUuwTH2AtPVG7dwN2+9LXWP+Rs7B+v7wlEh 3WsdVKSAYgxpwEVYjWgYhTxXc/8Tg6XRO6s6w75HS1Ubatj3cdX+8W+qnDvLNda443ic LTdnApizB0+qMe8R/SHYBZyS1Ux2ov9SMsuNICvRG3N46gW+bVSNNIJF581CVerPwSO3 4tt7LOOnSwWRWXJLP9eKf0YHWy3sBcGUTO6MZ3KPeC+5NRB9Fr35fOaD+H+ZSHizGFF6 8BWg==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773137797; x=1773742597; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=s9ea3JbPmMpmm1p5/jme6Gf4RRf/h8qbQ/O2bQlh5bU=; b=X+Coq1Sp99QxfaY3kAtaCQeg1GutDY4Ydb0psIkbbStzFVuRlTSFW0WrEQzX1/jmjx JrH/Lw7yJ8iRW4TsfXv7QivfCEjr2+4rikuRabM/Qs0RzmMMmlbk6Vsed8YrwVRWrxiy oPg3a10w0iJsaj7hWsgEC/0zR27SCxLs8bWO9FhDM0rdT7hThMl2jqoPYLT0z9Q7wXP+ jyH2Ew+2alRhcWe3CKFGWXDcSCWWEf/5QQU7MYjZ2etYPYIeaJnQPKVQACzHe68ajiMH WpoZrPd8yTjW7urEeth3OUIgn6IyDUuwWh4WfLrztVvGh10eOw96wAB+MxxYtNjFlPKA X7dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773137797; x=1773742597; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=s9ea3JbPmMpmm1p5/jme6Gf4RRf/h8qbQ/O2bQlh5bU=; b=oNcHA5OtjOunJivLv9CnkSzyKaHIn8wy+0ECJGqYDyY/xttEvocC3b99M9F28+cjd9 WYxjyhcgMc+zuRbqIcN6hx29yX1NmGXmP3vCD2C0qJr+hyuVClgNCD4Ta0tvos95c4Pd UcxEhmvw+j3YELDkIlNs2XJ0rTF8bWs6nldCUidWQrYJQWr/gbtofl/+e/D+vSm4419r hnDZuPvXhR5iKulnY7XRhbatuYcmm64xXD213HJC+W4zCfZTIbVdtDTxKZDtV+jOO4XW z02M/T9LtVhgwNNVaMxVtBP4/cXrz8FRO6ceq/XbEQMpcCpGBzzzm0Rmd5oE8z/M3cx7 uiMg== X-Forwarded-Encrypted: i=1; AJvYcCXmqwDfZE943Q7iinV7QlKmmfnT6zPyNYIP780ZCtHRIEHU7UifGrWLpUIHXKDayj/N5Gp0qrps7gVJIRPx@postgresql.org X-Gm-Message-State: AOJu0Yw1bNJY1ch8Y8nT1e3pKcQ8L9npLYTW4vBwXK7Jnc4WMo6kFCMd rUvgNH3N1jbC5w01WwHGOWQc5mC3xFF4qL5z7X4sw2FOSp5W3MuS9QwC9gKy58Y/G3ti2DXh10T ThJuN++nmqMYA5g9l5cYzAS89gDCELSs= X-Gm-Gg: ATEYQzxJFJca59dmlUPN/4r5uRw20Mc0NFdIQCICVsmer4ZB/IeeiEaLdUSK1b89MWv KqaTHZSHgPrlxl1Eg4rBf60hCBwoQT4O84x/Kx9vjbVIFAkLFmuiXy9cKgLhMAqKyCoVAVlushE y69waWqh8pC2PdJIFo2u1LbJfa7aXBHfCj0ZpdGbnApJaQBhpaIpGSzBrXvhgcfBuwU6vfyiryu L+nf+ytAn/VtO6+iv0uR7fIHKMw8Kxy4PxRwq9/95uBH1oBA5lbhnBjFTvQsla3uw8rm+trJ8us tNklD7Eyv+MUK5yeycnukcfoku5TtpsXU+0R/iE1jvuCNOeoyV2jRmsl4El50X7h4d4wcv9+TdL r+HLw X-Received: by 2002:a05:622a:1a84:b0:509:1b01:8929 with SMTP id d75a77b69052e-5091b018dbdmr76618411cf.3.1773137797169; Tue, 10 Mar 2026 03:16:37 -0700 (PDT) MIME-Version: 1.0 References: <202603040943.2jvgphmddgcs@alvherre.pgsql> In-Reply-To: From: Kirill Reshke Date: Tue, 10 Mar 2026 15:16:25 +0500 X-Gm-Features: AaiRm53ntbitg3lI9h8NVYysjtMAO0_B1O_OJMqP0HCNu-zkJm61_CCCbqyYasA Message-ID: Subject: Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement To: Akshay Joshi Cc: Japin Li , Rafia Sabih , =?UTF-8?Q?=C3=81lvaro_Herrera?= , Euler Taveira , Amul Sul , Andrew Dunstan , Chao Li , Quan Zongliang , pgsql-hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 9 Mar 2026 at 17:08, Akshay Joshi w= rote: > > I have resolved the review comments. Removed the hardcoded 'utf-8' encodi= ng, the logic now retrieves the encoding dynamically. This ensures accuracy= because the default encoding for CREATE DATABASE is derived from the templ= ate 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=E2=80=AFPM Japin Li wro= te: >> >> >> Hi, Akshay >> >> On Fri, 06 Mar 2026 at 17:21, Akshay Joshi 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 =E2=80=94 apo= logies. >> Here's a diff that should make it clearer. >> >> diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/r= uleutils.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 v= ariadic_start) >> bool *nulls; >> Oid *types; >> int nargs; >> - bool found =3D false; >> >> /* Extract variadic arguments */ >> nargs =3D extract_variadic_args(fcinfo, variadic_start, true, >> @@ -13887,8 +13886,7 @@ parse_ddl_options(FunctionCallInfo fcinfo, int v= ariadic_start) >> { >> char *name; >> bool bval; >> - >> - found =3D false; >> + bool found =3D false; >> >> /* Key must not be null */ >> if (nulls[i]) >> @@ -13925,8 +13923,8 @@ parse_ddl_options(FunctionCallInfo fcinfo, int v= ariadic_start) >> if (!parse_bool(valstr, &bval)) >> ereport(ERROR, >> (errcode(ERRCODE_INVALID= _PARAMETER_VALUE), >> - errmsg("argument %d: in= valid value \"%s\" for key \"%s\"", >> - i + 2, v= alstr, name), >> + errmsg("value for optio= n \"%s\" at position %d has invalid value \"%s\"", >> + name, i = + 2, valstr), >> errhint("Valid values a= re: true, false, yes, no, 1, 0, on, off."))); >> pfree(valstr); >> } >> @@ -13934,8 +13932,8 @@ parse_ddl_options(FunctionCallInfo fcinfo, int v= ariadic_start) >> { >> ereport(ERROR, >> (errcode(ERRCODE_INVALID_PARAMET= ER_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, for= mat_type_be(types[i + 1])))); >> } >> >> /* >> @@ -13983,7 +13981,7 @@ parse_ddl_options(FunctionCallInfo fcinfo, int v= ariadic_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. --=20 Best regards, Kirill Reshke