MichaelDBA/pg_get_tabledef

information_schema.sql_identifier) does not exist

liuhangyu opened this issue · 6 comments

step1:
psql -h127.0.0.1 -p 5432 -U liuhy -W -d dts < ./pg_get_tabledef.sql

step2:
dts=# \df
List of functions
Schema | Name | Result data type | Argument data types | Type
--------+-----------------+------------------+-------------------------------------------------------------------------------------------------------------------------------+------
public | pg_get_coldef | text | in_schema character varying, in_table character varying, in_column character varying | func
public | pg_get_tabledef | text | in_schema character varying, in_table character varying, _verbose boolean, VARIADIC arr tabledefs[] DEFAULT '{}'::tabledefs[] | func
(2 rows)

step3:
dts=# \d
List of relations
Schema | Name | Type | Owner
--------+-----------------+----------+-------
public | persons0 | table | liuhy
public | persons0_id_seq | sequence | liuhy
(2 rows)

dts=# select * from public.pg_get_tabledef('public','persons0', false);
ERROR: line=PL/pgSQL function pg_get_tabledef(character varying,character varying,boolean,tabledefs[]) line 203 at assignment. 42883. function pg_get_coldef(character varying, character varying, information_schema.sql_identifier) does not exist
CONTEXT: PL/pgSQL function pg_get_tabledef(character varying,character varying,boolean,tabledefs[]) line 364 at RAISE
dts=#

dts=# select version()
;
version

PostgreSQL 15.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.1.0, 64-bit
(1 row)

dts=#

drop table persons0;
CREATE TABLE persons0 (id serial PRIMARY KEY, lastname varchar(255), firstname varchar(255), address varchar(255), city varchar(255));

My Bad! I should have done some more testing. I didn't completely fix issue#6. Now its fixed. Give it another try.

you're great. solved it.

I get the error again

dts1=> select * from public.pg_get_tabledef('b','test_child_23210642', false);
pg_get_tabledef

CREATE TABLE b.test_child_23210642( +
) INHERITS (b.test_parent_23210642) +
TABLESPACE pg_default; +
+

The original table is:
CREATE SCHEMA a;
create table a.test_parent_23210642 ( i serial );

CREATE SCHEMA b;
create table b.test_child_23210642 () inherits (a.test_parent_23210642);

b.test_parent_23210642 mistake, should be a.test_parent_23210642

I am not understanding completely what you are saying.

Please show the entire DDL for schema a including parent and child defs. Also, show what PG version.

Also, please don't attach this to an existing closed issue. It should be a new issue. I'm closing this one, waiting for you to open a new one with my ask above.