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 1wfD5x-005Khe-29 for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Jul 2026 08:48:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wfD5w-000zUN-1o for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Jul 2026 08:48:28 +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 1wfD5w-000zTv-0m for pgsql-hackers@lists.postgresql.org; Thu, 02 Jul 2026 08:48:28 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wfD5t-00000001Ljo-0xLq for pgsql-hackers@lists.postgresql.org; Thu, 02 Jul 2026 08:48:27 +0000 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-c126e47a82cso191975266b.2 for ; Thu, 02 Jul 2026 01:48:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782982098; cv=none; d=google.com; s=arc-20260327; b=cO+hooFx+8rD4AZBot8cILphGzclZTJkGdGusoXDyNnUPtkPv2BWM2Cs6mEsZnNnkz MzNkL6oUe2WmGt8dvJqVPN0GPPTxf5gBMziPnEjgAeyYC7OkI4SIkzK072gpq9N+z0u1 vWfavpo+78gcPpC0mXOYpa6q6moxPf3bcZsQJE1VBPF+Q6yl92IE63EZtp3P+LXVces0 snVEnJyFAPZE/bSIlIKQ/M/3mawrw3vpT8V9kjl3QFYDChyoMMnfikHfJT1iIgSq+IDp 23UxI8aK19WmBz/IvKUohC8PWN+DgLmKQhHly+ayEbXdMN7X6CRmtb6NI7Bj+WSkZzHH NnYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=IAcON9vJ8XzGwU5OR71W5ezKyd+So2OEWrR5d4dyw8A=; fh=IrRr6dti+2qMWhl5ILZUzqDSbjjZT4s/QY7IHwDLnNI=; b=dqM0V0w5wx8ze5SZkW0hznsc+aew1cuC/gX0igOr75ziJNhR2eCyJZYxFPoWQPq7tl GHuMMUBYc0651KiEJVwPVnnvhIrOdXJBhvWmvuTkhyHPnDxURXc7VWoQqHsbkvTTrPyU VF4QHUMZTKdwPIwFhPb59ANw57C7F4N8kOr/U2DNC+3Zg8DF+3cmLFwrRi/kIoV0Z0h1 RLEuNDMX+soCrEXnQSb4OxUCmA1I2ZHcjQ732CCU5dDH5DS4szwRrHK6zLYncgE9w2gz 3xWVzPuwfrNgnthlqFwDTEs9daQWED3JcYWkU+8C5jPYg2DkerNxOd+7u4pmpWpWKHJa 3wbg==; 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=1782982098; x=1783586898; 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=IAcON9vJ8XzGwU5OR71W5ezKyd+So2OEWrR5d4dyw8A=; b=GrS4eOQbQbi0Wv8Si2VBQ5bpHvI35tUxK0NfcHhGhhNkB6BMZVv/zKKj/La91ura66 5F5dbfekpjUbVo6xsuPx78HAIhJ4cNrRkwt+ThuEVeETBsVm/aRRdgAm+b4awIQjisFB /F+ZedCoLF8y1LaGCIa0B6nQeoTt72uaDIIKn9x/ltcSDolKXFO9GKyv6ccU+nAOquHB XMSraJ0EzzQFuJSYdkDWnZNNeC247J9nvQ2jrUY4NYf9zbbL/QjZYufxkv9r57xGIpqu LVKEDrvKUyubuBr+SrwsVMALrxudo1jN5DirmxN7evf7PH9RZuXY/xH3GAuFmWAs8HJf 4cWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782982098; x=1783586898; 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=IAcON9vJ8XzGwU5OR71W5ezKyd+So2OEWrR5d4dyw8A=; b=b/rcUeVk7ugOGb4E53fJT+TkFSI8JUV3Yszlnw1vMkFFY1S+MTl4kohqru1eFhJ2YT cBpHZQrFHqIDHhOT6nQSIJgkKoJkwyQ6ap2T3QTewDr8uRGnLQRlnCyRyvA4o3JdsKwA i14n4/TQ9KP303xBvGXzOoQia3GHMqqXmBGyOX2eNh6H3dQ7OY2I8F6q+uFZSi/rMJwf UzK8NcCNgFVCD9s8tW5/jf3d88PgjABIXIBzg1TNpvfa9sFiKGxsJxYNuSTaB2k7uSIU yO2ecIJpAgATwqUtONV5xqfjHtQiykp9SEsWDWwIsEq3bfgAmvGCkVg/ui44HZ9hdylz XqtA== X-Forwarded-Encrypted: i=1; AHgh+Rr5NRcx9mKc0RXwtHx4XX0JOT0TDN9j8cidobvezNhoaXwcPy8sd7yeStFGDIOYzYc/5g4AEZV/GDwRfvr3@lists.postgresql.org X-Gm-Message-State: AOJu0YwEZ9wWS8E8nu4CNGiCA7OBZYzQuGQK3mHmHybY9cPPDoKGdZZs mvrUy6SUWYkQVfK3w/Nbj/t4Q+Cd7OhgyARvfe7ACyMK4XYZV3122NmJj7r2ovfuRaWPsphjtYY 1B0zBdAtbmhNzxiGcixkYggNtxBl5Ax6htx2cd1itJJ3lFTXekdloTVyJ X-Gm-Gg: AfdE7ckcwJfVRITJE3d5T+7SrJ7wM2oGOCblJWyTzxYVtM1tY5VJF3UswksWZwXhFbN fMviAQaZpQMWfb+WLg0QmQ7aDOSax64mTd8AX8mZxLTztzbDkoBI/3lvmaNmFV/iE7iugQ4dY8F 7uabBLuuqrGgLBbSj8Biek0rbCzeUOX40T9wTs1+GyTscha7GmmgqY35xb93igTA0mrG+TPbp+1 OjNSwMk1szWlc3eA3QW/L7Z0/AdWuveYC1sIzPBl9Q72D2Q/8UeLVY04u1qd9Tq0DBRW9hFlkE= X-Received: by 2002:a05:6938:a089:20b0:c10:fcc2:793e with SMTP id a640c23a62f3a-c12a9d42cf9mr169310166b.3.1782982097906; Thu, 02 Jul 2026 01:48:17 -0700 (PDT) MIME-Version: 1.0 References: <20260702.111715.277646207293239004.horikyota.ntt@gmail.com> In-Reply-To: <20260702.111715.277646207293239004.horikyota.ntt@gmail.com> From: Akshay Joshi Date: Thu, 2 Jul 2026 14:18:06 +0530 X-Gm-Features: AVVi8CeaYysH0Agv2gV8VyHGt-moYGqM0sNDagOLGTGcOi-HOxlVVaG_Td5xdSI Message-ID: Subject: Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements To: Kyotaro Horiguchi Cc: zsolt.parragi@percona.com, pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000963d7f06559cde87" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000963d7f06559cde87 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jul 2, 2026 at 7:47=E2=80=AFAM Kyotaro Horiguchi wrote: > Hello, > > Looking at this, one thing that concerns me is the large amount of > overlap with dumpTableSchema() in pg_dump. > > I wonder if it would make sense to separate the SQL generation logic > into frontend/backend-shared code so that it could also be used by > pg_dump. The catalog lookup would naturally remain separate, but > sharing the DDL generation itself would significantly reduce the > duplication. > Thanks for the suggestion. The overlap is real, but sharing the SQL generation logic at the C level runs into a few structural mismatches: dumpTableSchema drives column rendering off pre-populated TableInfo arrays that pg_dump bulk-loaded at startup, while the backend function uses live syscache lookups - a shared builder would need an adapter layer roughly as large as the code it replaces. The pattern PostgreSQL already uses for this kind of sharing is to call backend pg_get_*def functions via SQL from pg_dump =E2=80=94 it already does this 20 times for indexes, constraints, t= riggers, rules, and statistics. The natural long-term path would be for pg_dump to call pg_get_table_ddl() the same way and retire dumpTableSchema, but that is a substantial refactor in its own right and feels out of scope here. By the way, a couple of comments use a Unicode RIGHTWARDS ARROW > (U+2192). Please use an ASCII equivalent instead. > Will fix it in the next v15 patch. > > Regards, > > -- > Kyotaro Horiguchi > NTT Open Source Software Center > --000000000000963d7f06559cde87 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Thu, Jul 2, = 2026 at 7:47=E2=80=AFAM Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:
Hello,

Looking at this, one thing that concerns me is the large amount of
overlap with dumpTableSchema() in pg_dump.

I wonder if it would make sense to separate the SQL generation logic
into frontend/backend-shared code so that it could also be used by
pg_dump. The catalog lookup would naturally remain separate, but
sharing the DDL generation itself would significantly reduce the
duplication.

Than= ks for the suggestion. The overlap is real, but sharing the SQL generation = logic at the C level runs into a few structural mismatches: dumpTableSchema= drives column rendering off pre-populated=C2=A0TableInfo arrays that pg_dump bulk-loaded at start= up, while the backend function uses live syscache lookups - a shared builde= r would need an adapter layer roughly as large as the code it replaces.=C2= =A0The pattern PostgreS= QL already uses for this kind of sharing is to call backend pg_get_*def fun= ctions via SQL from pg_dump =E2=80=94 it already does this 20 times for ind= exes, constraints, triggers, rules, and=C2=A0statistics. The natural long-term path would be for p= g_dump to call pg_get_table_ddl() the same way and retire dumpTableSchema, = but that is a substantial refactor in its own right and feels out of scope= =C2=A0here.

By the way, a couple of comments use a Unicode RIGHTWARDS ARROW
(U+2192). Please use an ASCII equivalent instead.
=C2= =A0 =C2=A0
=C2=A0 =C2=A0Will fix it in the next v15 patch.=C2=A0

Regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center
--000000000000963d7f06559cde87--