| From: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements |
| Date: | 2026-06-29 21:31:41 |
| Message-ID: | CAN4CZFPxokhJ2vTiTu9Bhj+v7T+5jZd4pjT7QXdjoZ4Vqv5KhQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello
I noticed that there's an inconsistency with schema qualification, if
the schema is in the search path:
CREATE SCHEMA s;
CREATE TABLE s.parent (id int PRIMARY KEY);
CREATE TABLE s.t (id int PRIMARY KEY, pid int REFERENCES s.parent(id),
name text);
CREATE INDEX t_name_idx ON s.t (name);
CREATE STATISTICS s.t_stat ON id, pid FROM s.t;
SET search_path = s, public;
SELECT pg_get_table_ddl('s.t', 'owner', 'false');
outputs:
CREATE TABLE s.t (id integer NOT NULL, pid integer, name text);
CREATE INDEX t_name_idx ON t USING btree (name); -- should be s.t
ALTER TABLE s.t ADD CONSTRAINT t_pid_fkey FOREIGN KEY (pid) REFERENCES
parent(id); -- should be s.parent
ALTER TABLE s.t ADD CONSTRAINT t_pkey PRIMARY KEY (id);
CREATE STATISTICS t_stat ON id, pid FROM t; -- should be s.t
In the included testcase:
+drop cascades to view v
+drop cascades to sequence s
+ERROR: relation "parted_range_1" already exists
+CONTEXT: SQL statement "CREATE TABLE pgtbl_ddl_test.parted_range_1
PARTITION OF pgtbl_ddl_test.parted_range FOR VALUES FROM (0) TO
(100);"
+PL/pgSQL function inline_code_block line 22 at EXECUTE
is this error expected, doesn't it break the test?
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruce Momjian | 2026-06-29 21:39:37 | Re: First draft of PG 19 release notes |
| Previous Message | Zsolt Parragi | 2026-06-29 21:16:59 | Re: [PATCH] Don't call ereport(ERROR) from recovery target GUC assign hooks |