| From: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
|---|---|
| To: | Akshay Joshi <akshay(dot)joshi(at)enterprisedb(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-15 21:09:30 |
| Message-ID: | CAN4CZFMkCJHBR19=Ws2PX56sO9+g_mdYz0DhdOjkxv9ftJKnmg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
I can confirm that most fixes work correctly, but there are two
remaining issues / regressions caused by the fixes:
1.
CREATE TABLE pidx (a int, b int) PARTITION BY RANGE (a);
CREATE TABLE pidx_1 PARTITION OF pidx FOR VALUES FROM (0) TO (10);
CREATE TABLE pidx_2 PARTITION OF pidx FOR VALUES FROM (10) TO (20);
CREATE INDEX ON pidx (b);
is emitted as:
CREATE TABLE public.pidx (a integer, b integer) PARTITION BY RANGE (a);
CREATE INDEX pidx_b_idx ON ONLY public.pidx USING btree (b);
CREATE TABLE public.pidx_1 PARTITION OF public.pidx FOR VALUES FROM (0) TO (10);
CREATE INDEX pidx_1_b_idx ON public.pidx_1 USING btree (b); <-- fails here
-- ERROR: relation "pidx_1_b_idx" already exists
ALTER INDEX public.pidx_b_idx ATTACH PARTITION pidx_1_b_idx;
-- ...
2.
CREATE TABLE idt (a int GENERATED BY DEFAULT AS IDENTITY);
ALTER SEQUENCE idt_a_seq AS smallint;
is emitted as:
-- ERROR: conflicting or redundant options
-- LINE 1: ....idt (a integer GENERATED BY DEFAULT AS IDENTITY (AS smallin...
CREATE TABLE public.idt (a integer GENERATED BY DEFAULT AS IDENTITY
(AS smallint MAXVALUE 32767) NOT NULL);
> > Interestingly pg_dump also skips this, that looks like a pg_dump bug?
>
> The behavior was indeed inconsistent with what emit_indexes() already
> did for non-constraint indexes. emit_local_constraints() now emits ALTER
> INDEX ... ALTER COLUMN n SET STATISTICS for PK/UNIQUE/EXCLUSION constraint
> backing indexes.
I submitted a matching patch for pg_dump:
https://www.postgresql.org/message-id/CAN4CZFMd9riOuV5LkM%2BuV%3DuF-HYp49C8Fh22xWyMxptGLBCZ3A%40mail.gmail.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jeff Davis | 2026-07-15 21:39:11 | Re: Small patch to improve safety of utf8_to_unicode(). |
| Previous Message | Paul A Jungwirth | 2026-07-15 21:02:10 | Re: Fix RLS checks for UPDATE/DELETE FOR PORTION OF leftover rows |