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

From Akshay Joshi
Subject Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements
Date
Msg-id CANxoLDcRacGAd2Rsmnp=CZjaLMiz7sbCHYo95Rto1OMwJJeOmg@mail.gmail.com
Whole thread
List pgsql-hackers


On Tue, Jun 23, 2026 at 7:33 PM Marcos Pegoraro <marcos@f10.com.br> wrote:
Em ter., 23 de jun. de 2026 às 10:34, Akshay Joshi <akshay.joshi@enterprisedb.com> escreveu:
A quick note on a design change I made in the pg_get_table_ddl option surface

Much better now.

All options can be present or omitted, so why couldn't the owner also be part of the include/exclude options too ?

Just one addition, some options are plural and others are not.
We have indexes, policies, triggers, but we also have check, unique, exclusion.
You don't know how many indices or checks you have, so wouldn't it be better to have them in singular form ?

Regarding moving owner into the include/exclude syntax, I prefer keeping it as a top-level boolean for now:
1) It aligns with existing sibling functions (pg_get_role_ddl, pg_get_tablespace_ddl, and pg_get_database_ddl), which all use a boolean owner.
2) Existing regression tests and early callers pass owner => false for output stability. Moving this into the exclude list would create unnecessary churn that I'd prefer to avoid bundling here.

As for the naming inconsistency (singular vs. plural), you're entirely right mixing indexes/policies/triggers with checks/uniques/exclusions was an oversight. Note that I left statistics alone to match the CREATE STATISTICS keyword.

I'll address the naming consistency in the next patch. 

regards
Marcos

pgsql-hackers by date:

Previous
From: Xuneng Zhou
Date:
Subject: Re: psql: add tab completion for subscription wal_receiver_timeout
Next
From: Fujii Masao
Date:
Subject: Re: psql: add tab completion for subscription wal_receiver_timeout