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 1wbxLN-002yfd-1K for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jun 2026 09:22:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wbxLL-00AqSw-1r for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jun 2026 09:22:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wbxLL-00AqSn-0o for pgsql-hackers@lists.postgresql.org; Tue, 23 Jun 2026 09:22:55 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wbxLH-00000001tfl-1N5K for pgsql-hackers@lists.postgresql.org; Tue, 23 Jun 2026 09:22:53 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-befee9e5ef7so656598166b.0 for ; Tue, 23 Jun 2026 02:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782206569; cv=none; d=google.com; s=arc-20240605; b=gBkFCRPwzflaZRePjrvSLRVpSJspq4Ez+fFhxvufH2R/7XIGRNGRrok3PDxtOLGCq0 aO51lO0Y/xYvpx/6jMhJr7eI6CjkiuKrBN1itOC6hmZwG7CkAd7V6bn/Yg4zbF3x5i6P Lp4z2k4oJCAGgL3jPDS7TA2+0eDkZPGHpkXD8x4soL8fBjwjdtq3NuQWHb8+d+3ybcEY 1HmCH+2KuLF1Oh+avt6JyFTrD8UxVc8L87owzhOwx0qi0okAWK4c/kPpuoQZit2QJXeo uABTcfmuU+HLlAPlsgRVG0VXNZm6gNHS8zwkYqrtjvgK6Aa0+IKBajy7+qQZh7yBpLXI 9bvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=eeP5rO6ThdoFkNN7DZ5S/u8zTTB8MWFtN+ThNDghQxo=; fh=0N4mHb8h8jBkTtb2xM3vV2yq+bcTsca2f2jlQ1xFcbc=; b=gupYm8gyZhISgjyxqDZHEsmiSzwohFScceQfSerCT+IauLcWaVkVy4+GdRLL7sUoZs xLNersu+ZTseo3dir5tBQIxgg5JAe5X9OA0V1EayUIyDouqJ5vGaHM5Es+U/2sFwruqd u+FUr14/499dnHd6DWuod2/cyxXoWOrnxRCXwiDwHtTnXYOnPr0OLhgMGIQmbFchInkD 55qYtzOhp2FJAP5i2snUm5mW+PJNs9SN9GTCyB5GBGMovwh+H27oa5ffKvZKY9Z0/O4T A0c3Ug4Sj8hqY1zQgD4H8HSlHvmRk66dIiMCwyh7ETvTOvkuiNmsZGoSzMTn3ff6qhib QXDw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1782206569; x=1782811369; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=eeP5rO6ThdoFkNN7DZ5S/u8zTTB8MWFtN+ThNDghQxo=; b=hz2Veno75UDVImCdc01IsXMtclJnvyaO2sa/7HyqhwAJoV5xECx+3zJpXiENIeYnbu oKbA+uwaP+PFrhWTuj5VqH6630I8SCgFunBPETwuEAi1Ym81LxW6+3ddX/WDnLU9WPR9 jAJglaqAmMZJx7XPBmp0iC/2/607RGlMBUsu/ZQEzVxAPU/Bj2+4yOOMUCj7wLTVo01g gHArRHjFMbRYneEMx0udX3ie0cblc7gmbLiHHhoPGLZv33C4O0yglDgVB1ZDXo/o0yjP BbbEp83BdouXaSxXpqJJdyIXVJNDNt8QF09dMa/roudo+wzDLV2Fp4QKTs+812gAWnvr +6cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782206569; x=1782811369; h=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=eeP5rO6ThdoFkNN7DZ5S/u8zTTB8MWFtN+ThNDghQxo=; b=E4GK0aZ1iQGoZ0Wxa5rT0wmgugQntK2/D/ifhHNjxsQHU98rq20v7cuibaSFZxrptU j5wtFbubNeup5KTvc+hXT3NbnVaa5UTq0hiAp/wQ9AQUswCwkUheQhayKrdwFVlZoOpu tlH71mR8WfP8alxgkZDslQkDHFHOwlYDGEIw/I9ZCcDYTmC1qBmC4Qng2eR6G9G7x0FL P71lzIb1N+SmaTxcGWqgGyoNIQ2XePawjRIBJCdmccPFCcfpHLjUfadrpdCy/62CG0H2 d1nqt+fEqtRa0ECU7iBIT8UN0NPBziKSSgz3je/Kh9NtF39MUsEwG7ZMn6SPUJ5F92/w Y58A== X-Forwarded-Encrypted: i=1; AFNElJ/T3IkF9JRHTpZCgqUTpgxzM7sTmmMxaBkuN2jKAHH/QIERcfq0JGd67IozqVCKRZWub3ZfJwuxhpEaSpFD@lists.postgresql.org X-Gm-Message-State: AOJu0Yy1gxQ8+Sf1g5Z7zra3lWCTJG5f1JiuUSc4zfcA0rdL7+CrUrlJ uwy81MRxesPy9MlzuB5r3lxh3fydZ99I9BoDSlw+I1KMe+VWB0sKPphDuCouxw+AxbHnrOAWt8O Mc65Q6hHcq3zrLIz3VqPFQp4NchOIRwIb9EM/rANH X-Gm-Gg: AfdE7ckVgiL0fy7/Ym1Mn8a6YnIp8qhQf+KEa9EKYL/+/zQwHULZoLG+DoqBL6CqKOs ISjxfxT1cY1pYmTX6Ze18DkYdk/0FZ9y/x5Wr9AUZkUvEff8IoR5gH8v+J81T7lTYXSJ0L6V3Xc 1Yrg0rXZVYlV4XWF9XuQGvG0L/nXTQ5WhDTphcR3VBme2RKYFUb20jeoA5pHxCpzwQwmXlYC9mc o/+IQAgWGjxanIk5qCK2oduWtwq2K+PMnatvyo2oU9zL6VozGKUUO4soIxUiZMgcThQoEWcmA== X-Received: by 2002:a17:906:208f:b0:c0c:9f16:90df with SMTP id a640c23a62f3a-c0c9f1694c2mr409115066b.13.1782206568327; Tue, 23 Jun 2026 02:22:48 -0700 (PDT) MIME-Version: 1.0 References: <983C7B03-D9C3-4F15-8913-7616EC5E6414@gmail.com> <20260623.162104.775158751399277188.horikyota.ntt@gmail.com> In-Reply-To: <20260623.162104.775158751399277188.horikyota.ntt@gmail.com> From: Akshay Joshi Date: Tue, 23 Jun 2026 14:52:37 +0530 X-Gm-Features: AVVi8CdYqFpJ5Hc0a1CjzM58jOb0t8o-0e_WclqC8tvQb5nVFXUiiu0jQXT-TBw Message-ID: Subject: Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements To: Kyotaro Horiguchi Cc: li.evan.chao@gmail.com, zsolt.parragi@percona.com, pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000006c006f0654e84d48" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006c006f0654e84d48 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jun 23, 2026 at 12:51=E2=80=AFPM Kyotaro Horiguchi wrote: > At Mon, 22 Jun 2026 18:10:53 +0530, Akshay Joshi < > akshay.joshi@enterprisedb.com> wrote in > > The v9 patch is ready for review. > > I have not looked closely at the DDL generation logic itself, but I > have a few comments on how pg_get_table_ddl handles its options. > > Since pg_get_table_ddl_internal() appears to copy these values into > TableDdlContext almost immediately, I wonder whether TableDdlContext > could be initialized by the caller instead. > > Using positional boolean arguments is probably fine when there are > only a handful of options, but with around fifteen of them the current > approach seems somewhat error-prone. > > It might also be clearer to initialize the default values first, and > then override only the fields corresponding to explicitly specified > options, rather than folding the default handling and option lookup > into the same expression. > I assume that changing the implementation model, as I mentioned in my other email, will solve this problem as well. We can drop the entire includes_* family and only_foreign_keys, and replace them with two mutually exclusive variadic keys: include =3D> 'kind1,kind2,...' =E2=80=94 emit only these kinds exclude =3D> 'kind1,kind2,...' =E2=80=94 emit everything except these kinds > > > Regards, > > -- > Kyotaro Horiguchi > NTT Open Source Software Center > --0000000000006c006f0654e84d48 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, Jun 23,= 2026 at 12:51=E2=80=AFPM Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:
At Mon, 22 Jun 2026 18:10:53 +0530, = Akshay Joshi <akshay.joshi@enterprisedb.com> wrote in
> The v9 patch is ready for review.

I have not looked closely at the DDL generation logic itself, but I
have a few comments on how pg_get_table_ddl handles its options.

Since pg_get_table_ddl_internal() appears to copy these values into
TableDdlContext almost immediately, I wonder whether TableDdlContext
could be initialized by the caller instead.

Using positional boolean arguments is probably fine when there are
only a handful of options, but with around fifteen of them the current
approach seems somewhat error-prone.

It might also be clearer to initialize the default values first, and
then override only the fields corresponding to explicitly specified
options, rather than folding the default handling and option lookup
into the same expression.

I assume that changing the implementation= model, as I mentioned in my other email, will solve this problem as well. = We can drop the entire includes_* family and only_foreign_keys, and replace= them with two mutually exclusive variadic keys:
include =3D>= ; 'kind1,kind2,...' =E2=80=94 emit only these kinds
exclude =3D&= gt; 'kind1,kind2,...' =E2=80=94 emit everything except these kinds<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">
Regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center
--0000000000006c006f0654e84d48--