The new design is definitely an improvement as a more generic
interface. I'm unsure about the "include" wording, to me that suggest
"also includes", while the actual behavior is "only includes". To me
it would be a bit surprising pg_get_table_ddl including something not
including the basic create table statement.
I also found a few issues with include in v10.
Include check doesn't seem to work:
CREATE TABLE t (
id int PRIMARY KEY,
qty int CHECK (qty > 0),
CONSTRAINT t_id_pos CHECK (id > 0)
);
SELECT * FROM pg_get_table_ddl('t', 'include', 'check'); -- empty?
The include partitions clause also doesn't work:
CREATE TABLE p (id int, val text) PARTITION BY RANGE (id);
CREATE TABLE p_a PARTITION OF p FOR VALUES FROM (0) TO (100);
CREATE TABLE p_b PARTITION OF p FOR VALUES FROM (100) TO (200);
SELECT * FROM pg_get_table_ddl('p','include','partitions'); -- empty
There's also an issue with replica identity non primary key unique indexes:
CREATE TABLE t2 (a int NOT NULL UNIQUE, b int);
ALTER TABLE t2 REPLICA IDENTITY USING INDEX t2_a_key;
SELECT * FROM pg_get_table_ddl('t2','exclude','unique');
-- ALTER TABLE public.t2 REPLICA IDENTITY USING INDEX t2_a_key;
-- but there's no such index