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-JLwae7bWN_hTtzFqqk5=g1OFp5MwtL34KY7EfcUVBv8EQFw@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., 9 de jul. de 2026 às 05:54, Akshay Joshi <akshay.joshi@enterprisedb.com> escreveu:
Fixed the documentation. v19 patch is now ready for review.

I didn't understand when a word is considered reserved, so that it has double quotes.

postgres=# create table int(int4 integer primary key, integer integer, interval interval, boolean boolean, insert boolean);
CREATE TABLE
postgres=# select pg_get_table_ddl('int'::regclass, schema_qualified=>false, owner=>true, only_kinds => ARRAY['primary_key','check','table']);
                                                    pg_get_table_ddl
------------------------------------------------------------------------------------------------------------------------
 CREATE TABLE "int" (int4 integer NOT NULL, "integer" integer, "interval" interval, "boolean" boolean, insert boolean);
 ALTER TABLE "int" OWNER TO postgres;
 ALTER TABLE "int" ADD CONSTRAINT int_pkey PRIMARY KEY (int4);
(3 rows)

And as for the owner, I think that causes a bit of confusion when used with kinds parameters, doesn't it ?
It emits other ALTER TABLE except the OWNER TO.

postgres=# create table self(id integer primary key, self_id integer constraint self_self references self(id));
CREATE TABLE
postgres=# select pg_get_table_ddl('self'::regclass, owner=>true, except_kinds => ARRAY['table']);
                                         pg_get_table_ddl
--------------------------------------------------------------------------------------------------
 ALTER TABLE public.self ADD CONSTRAINT self_pkey PRIMARY KEY (id);
 ALTER TABLE public.self ADD CONSTRAINT
self_self FOREIGN KEY (self_id) REFERENCES public.self(id);
(2 rows)
regards
Marcos

pgsql-hackers by date:

Previous
From: Dmitry Fomin
Date:
Subject: Re: [PATCH v1 0/7] Wait event timing and tracing instrumentation
Next
From: Thom Brown
Date:
Subject: Re: SQL/JSON json_table plan clause