MichaelDBA/pg_get_tabledef

Failed to obtain the definition of an array in the table

Closed this issue · 6 comments

create table:
create table tbpgdts_0412173049(c1 int primary key, c2 int not null, c3 int);
create table unionkey_tbpgdts_0412173049 (id1 int, id2 int, id3 int, id4 numeric, id5 numeric, col1 int[], primary key (id2, id4, id5));
create table _ref_tbpgdts_0412173049(c1 int primary key, c2 int REFERENCES tbpgdts_0412173049(c1));
create view vpgdts_0412173049 as select * from tbpgdts_0412173049 limit 100;

call func:
dts2=> select * from public.pg_get_tabledef('public','unionkey_tbpgdts_0412173049', false)
dts2-> ;
pg_get_tabledef

CREATE TABLE public.unionkey_tbpgdts_0412173049 ( +
id1 integer NULL, +
id2 integer NOT NULL, +
id3 integer NULL, +
id4 numeric NOT NULL, +
id5 numeric NOT NULL, +
col1 ARRAY NULL, +
CONSTRAINT unionkey_tbpgdts_0412173049_pkey PRIMARY KEY (id2, id4, id5)+
) TABLESPACE pg_default; +
+

unionkey_tbpgdts_0412173049 col col1 int[] ===> col1 ARRAY

postgres version
dts2=> show server_version;
server_version

11.12
(1 row)

Thanks, confirmed it is a bug, will work on it, unless you got a fix for it

ts2=>
dts2=> select * from public.pg_get_tabledef('public','unionkey_tbpgdts_0412173049', true);
NOTICE: version=110012
INFO: (1)tabledef so far:
INFO: (2)tabledef so far: CREATE TABLE public.unionkey_tbpgdts_0412173049 (
id1 integer NULL,
id2 integer NOT NULL,
id3 integer NULL,
id4 numeric NOT NULL,
id5 numeric NOT NULL,
col1 ARRAY NULL,

INFO: (3)tabledef so far: CREATE TABLE public.unionkey_tbpgdts_0412173049 (
id1 integer NULL,
id2 integer NOT NULL,
id3 integer NULL,
id4 numeric NOT NULL,
id5 numeric NOT NULL,
col1 ARRAY NULL,
CONSTRAINT unionkey_tbpgdts_0412173049_pkey PRIMARY KEY (id2, id4, id5),

INFO: (4)tabledef so far: CREATE TABLE public.unionkey_tbpgdts_0412173049 (
id1 integer NULL,
id2 integer NOT NULL,
id3 integer NULL,
id4 numeric NOT NULL,
id5 numeric NOT NULL,
col1 ARRAY NULL,
CONSTRAINT unionkey_tbpgdts_0412173049_pkey PRIMARY KEY (id2, id4, id5)

INFO: (5)tabledef so far: CREATE TABLE public.unionkey_tbpgdts_0412173049 (
id1 integer NULL,
id2 integer NOT NULL,
id3 integer NULL,
id4 numeric NOT NULL,
id5 numeric NOT NULL,
col1 ARRAY NULL,
CONSTRAINT unionkey_tbpgdts_0412173049_pkey PRIMARY KEY (id2, id4, id5)
) TABLESPACE pg_default;

INFO: (6)tabledef so far: CREATE TABLE public.unionkey_tbpgdts_0412173049 (
id1 integer NULL,
id2 integer NOT NULL,
id3 integer NULL,
id4 numeric NOT NULL,
id5 numeric NOT NULL,
col1 ARRAY NULL,
CONSTRAINT unionkey_tbpgdts_0412173049_pkey PRIMARY KEY (id2, id4, id5)
) TABLESPACE pg_default;

INFO: (7)tabledef so far: CREATE TABLE public.unionkey_tbpgdts_0412173049 (
id1 integer NULL,
id2 integer NOT NULL,
id3 integer NULL,
id4 numeric NOT NULL,
id5 numeric NOT NULL,
col1 ARRAY NULL,
CONSTRAINT unionkey_tbpgdts_0412173049_pkey PRIMARY KEY (id2, id4, id5)
) TABLESPACE pg_default;

                          pg_get_tabledef                              

CREATE TABLE public.unionkey_tbpgdts_0412173049 ( +
id1 integer NULL, +
id2 integer NOT NULL, +
id3 integer NULL, +
id4 numeric NOT NULL, +
id5 numeric NOT NULL, +
col1 ARRAY NULL, +
CONSTRAINT unionkey_tbpgdts_0412173049_pkey PRIMARY KEY (id2, id4, id5)+
) TABLESPACE pg_default; +
+

Thanks you

Fixed!

you are awesome