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 1wXf8v-003P9j-1z for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Jun 2026 13:08:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wXf8u-00G2z3-0L for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Jun 2026 13:08:20 +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 1wXf8t-00G2yu-1w for pgsql-hackers@lists.postgresql.org; Thu, 11 Jun 2026 13:08:19 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wXf8q-00000002BP6-0Zc2 for pgsql-hackers@lists.postgresql.org; Thu, 11 Jun 2026 13:08:18 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-5aa6cdebc33so7292505e87.2 for ; Thu, 11 Jun 2026 06:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781183294; cv=none; d=google.com; s=arc-20240605; b=CgBUXudKy+XBPFczM0rYen/4xYGgkpYf8GvaPOcKLw8vvDNdJz92srIb7tMjR/oAOi LaLXcTkeUfkn1diZlOFhphxIhVTNn5dNjF/c4sI2gi19gMFMweUiAsesCMd4Hql7PwfD hkaFs2a6yaI1Erx6RVkoJHYJTNAEZFELAGNddI2kYHo/0GdmHkKUr+JxuGdDoGPCvLlQ kMtsuawYsLcvQIITTpaXxFsdZH8KMtFbydt3YlPhdAiwafl87havuzwexn0u/st7icS8 pUwCWNUFxiHSZ6hAo/GGlugIPuYT7Na4olGfPGgnIsNnNHcCXg4nJvUC6ZEk1YzENN4G 2e5w== 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=21nCrfgh/kt2iO57m2/9rvi9cmtGCwaM/YGjbtMalHc=; fh=RAlZRcQ3CJ7jhllMrKVzbbMImL8iQikROAJ2fSgsO1k=; b=FixXHxPzHu47Mn5BKtqjCQfUy8UejxkcBisKC4vFOZ79I7UVfkhZBXKebHXe7+Wzn3 sNPS6VtOU2AyvDvfi/D9hnj/hVjEy46vvlrUnKPbxlzqPAGtsCO9wQHzw8KdWY6ed5qM FKKxVLTsLP8BCLaOtZByBwWofJBgAEfYZZLb2Y5AgDNSxx/HgWeV/X1D1pnDyZieLu3r 5b933WdNNrCd1+Hev38cDMQ3jAeU2RcvH1pb8fWPkoPicQLRSuM9rKhma83MQCEYEYfm 6z33hJ4mm3O7HiE3eabOO/tUBHztHkVs3CvYIZe1VgH19lbPQkng9QJbkNrysFSaH+M4 XBXQ==; 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=f10-com-br.20251104.gappssmtp.com; s=20251104; t=1781183294; x=1781788094; 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=21nCrfgh/kt2iO57m2/9rvi9cmtGCwaM/YGjbtMalHc=; b=pqOdXfBJO/ubHicapo24kwnmbp/qUusQKiVS6OnAwIDe/z8K+tytXWVW23N39WUEmz 0kXwCJaU73Z4YGh56YoY46HPqDDbAhduWbOH1FYPr6xmWQlrIWfMjoOlXHCOmOIvpx6E 594ARrQLzChZUoBJHAx8a3ZuRTTzMigZT4i9nWUvhBvjYZGSLllJD4w0/aqk12/0xxDT naEk7O5cxKYyOxvZkotilrz3mlp4miIZu4ip7LqRtmeH2F9c/SSVe11Hv8TSYuMy3oY6 GGHB/fGlx/TQdPKmakZu9ATOs3w/x54cVtc8S+BX1VRk7NX29UoLkFdc6XFijcfd8xRZ 8JgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781183294; x=1781788094; 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=21nCrfgh/kt2iO57m2/9rvi9cmtGCwaM/YGjbtMalHc=; b=DgWbn02PDjJBuonrBQqCOhd7mgu2O0Uh8xmkCWpvr9B/vOCiyF1223XbrIaa7Yc629 oirZuBB+TBMVuyK+//O4Gwj3u/Hm6Sdjt0BTU+wtL+/SVw0oLu0qX/L7HGxTgZYe0giH PCOXtibZwM71NdPx257YL4HATeP2UiKtWWGt9ZCUIE1k4ZAxRWH9AlPE7hKuP2KYQoZB yhow/o0hQm32ADWzetNeNDH7vk+tqmxN9fLHM0++2N/zIFPCrXoCB8ghlaP5d1MlzuCG 96S6hfsmmF5kkyTIshoabd1rmfx30s9ZwSqaydo4LmAXNGJUR4eoAfJOtPJgvJjc8C9n k7uw== X-Forwarded-Encrypted: i=1; AFNElJ/nImY4kvvM577YlCHjns8VVPuA5JtAmm04e9MKaddP0LDR49IL7ooDPPZJuuxZz8x8r8WWsNEItK2aArTv@lists.postgresql.org X-Gm-Message-State: AOJu0Yy7bcYYJP3Lb4i7YwMt4EB7CtrSGzYo3hd5W5FTHy4AyLQgtihP +8dRrbgGHLWzvddY9ofAwVH+MG0P/ThvGNtPOUvn49I2kQ1ErtLO74Juritc0scISGb71aahOOU VLfa8AgjUBBxoXOZEZ/fz/kIY5CcSjiAPU6z64Qy6slkjbGuds9lLCncH X-Gm-Gg: Acq92OHqOScaP1cB2ir2noi6b7SfG7Sgmk+bZ2QxcV0JC2t8zJ0ACDHMiBYe+rKkV5B DvSsIrnrnrWlwMbSHfsC5bMbwHAwgqAqNZOVZp/2yKbrSKjLi9IrHzx9d86/74g+iPopttCOGLU 3O7Ou216ICp2tGx5SQKI/uzxKNPj29LyB58NcHgILoGu3Wp60mmrklqQq49blGjs7g95erFCaQ2 2Pb0qsT7VbbEDrVZq4QelK//+5HvJKD5lueuOh4zQ/dmWUcA2yFUqCREj40kLtOQ+KvxJXDOcwY H/ZrNHTgubxq38u1 X-Received: by 2002:a05:6512:6c3:b0:5aa:6dff:cf1f with SMTP id 2adb3069b0e04-5ad27fc1488mr1045432e87.45.1781183293970; Thu, 11 Jun 2026 06:08:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Marcos Pegoraro Date: Thu, 11 Jun 2026 10:07:37 -0300 X-Gm-Features: AVVi8Cfdem3iBqRwwXOz5n69wmyIoVw-if5cxJr-1JWfoacCp3AElcG4yOUZVQM Message-ID: Subject: Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements To: Akshay Joshi Cc: Zsolt Parragi , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000084682c0653fa0de0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000084682c0653fa0de0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Em qui., 11 de jun. de 2026 =C3=A0s 04:48, Akshay Joshi < akshay.joshi@enterprisedb.com> escreveu: > Fixed the issue above. The v5 patch is ready for review/testing. > One thing I noticed, though I'm not sure if it's the point here, is that it's not possible to extract only the foreign keys or only the triggers from the table. So if we want to extract the objects independently by type, we would need to have all the return types as optional, and we could have more granularity in the return types. Just like you have... if (!ctx->include_indexes) You could have too + if (!ctx->include_create_table) + if (!ctx->include_foreign_keys) + if (!ctx->include_primary_keys) Because only in this way can we more or less execute the dump behavior here, which is to create all the tables beforehand, then primary keys, then foreign keys, then triggers. I repeat, sorry if this is not the function's intended purpose. regards Marcos --00000000000084682c0653fa0de0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Em qui., 11 de jun. de = 2026 =C3=A0s 04:48, Akshay Joshi <akshay.joshi@enterprisedb.com> escreveu:
=C2=A0Fixed the= issue above. The v5 patch is ready for review/testing.

One= thing I noticed, though I'm not sure if it's the point here, is th= at it's not possible to extract only the foreign keys or only the trigg= ers from the table. So if we want to extract the objects independently by t= ype, we would need to have all the return types as optional, and we could h= ave more granularity in the return types.
Just like you have...
if (!= ctx->include_indexes)

You could have too
+ if (!ctx->include_create_ta= ble)
+ if (!ctx->include_foreign_keys)
+ if (!ctx->include_primary_keys)
Because only in this way can we more or less execute the dump behav= ior here, which is to create all the tables beforehand, then primary keys, = then foreign keys, then triggers.=C2=A0

I repeat, sorry if this is not the function's intended p= urpose.

regards
Marcos

--00000000000084682c0653fa0de0--