Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements - Mailing list pgsql-hackers

From Marcos Pegoraro
Subject Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements
Date
Msg-id CAB-JLwY=RYPJhdFid0YDqk1L1OQPuHFz9J2tOeeVCFLjov+Ktg@mail.gmail.com
Whole thread
In response to Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements  (Akshay Joshi <akshay.joshi@enterprisedb.com>)
Responses Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements
List pgsql-hackers
Em qui., 11 de jun. de 2026 às 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

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Make SPI_prepare argtypes argument const
Next
From: Andres Freund
Date:
Subject: Re: Heads Up: cirrus-ci is shutting down June 1st