Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements

From: Akshay Joshi <akshay(dot)joshi(at)enterprisedb(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements
Date: 2026-07-03 08:47:25
Message-ID: CANxoLDfY0BucA49t_1n+AAkKZfxmQPfihjP8YMObf=8=-3XfUQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks Zsolt for the review. I have tried to fix most of the *edge cases. *I
added 12 new test cases.
The v16 patch is ready for review.
*Note: Windows-MinGW-Meson *builds are failing but not because of this
patch.

On Fri, Jul 3, 2026 at 4:04 AM Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
wrote:

> Hello!
>
> I can confirm the previous issues fixed, however I also found one more
> with unique indexes on partitioned tables:
>
> CREATE SCHEMA s;
> CREATE TABLE s.p (id int, region text) PARTITION BY LIST (region);
> CREATE TABLE s.p_a PARTITION OF s.p FOR VALUES IN ('a');
> CREATE UNIQUE INDEX p_uidx ON s.p (id, region);
>
> SELECT pg_get_table_ddl('s.p', owner => false);
> -- CREATE TABLE s.p (id integer, region text) PARTITION BY LIST (region);
> -- CREATE UNIQUE INDEX p_uidx ON s.p USING btree (id, region);
> -- CREATE TABLE s.p_a PARTITION OF s.p FOR VALUES IN ('a');
> -- CREATE UNIQUE INDEX p_a_id_region_idx ON s.p_a USING btree (id,
> region); -- fails because index already exists
>
>
>

Attachment Content-Type Size
v16-0001-Add-pg_get_table_ddl-to-reconstruct-CREATE-TABLE.patch application/octet-stream 219.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2026-07-03 08:57:42 Re: [PATCH] Refactor *_abbrev_convert() functions
Previous Message Japin Li 2026-07-03 08:38:06 Re: WAL compression setting after PostgreSQL LZ4 default change