!256 修复pg_get_tabledef函数导出支持foreign_key

Merge pull request !256 from zhangxubo/ds_support
This commit is contained in:
opengauss-bot
2020-09-28 09:47:19 +08:00
committed by Gitee
4 changed files with 37 additions and 1 deletions

View File

@ -1774,7 +1774,7 @@ static char* pg_get_tabledef_worker(Oid table_oid)
while (HeapTupleIsValid(tuple = systable_getnext(scan))) {
Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tuple);
if (con->contype == 'c') {
if (con->contype == 'c' || con->contype == 'f') {
if (!con->convalidated) {
has_not_valid_check = true;
continue;

View File

@ -0,0 +1,24 @@
create table table_function_export_def_base (
id integer primary key,
name varchar(100)
);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "table_function_export_def_base_pkey" for table "table_function_export_def_base"
create table table_function_export_def (
id integer primary key,
fid integer,
constraint table_export_base_fkey foreign key (fid) references table_function_export_def_base(id)
);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "table_function_export_def_pkey" for table "table_function_export_def"
select * from pg_get_tabledef('table_function_export_def');
pg_get_tabledef
-------------------------------------------------------------------------------------------------------
SET search_path = public; +
CREATE TABLE table_function_export_def ( +
id integer NOT NULL, +
fid integer, +
CONSTRAINT table_export_base_fkey FOREIGN KEY (fid) REFERENCES table_function_export_def_base(id)+
) +
WITH (orientation=row, compression=no); +
ALTER TABLE table_function_export_def ADD CONSTRAINT table_function_export_def_pkey PRIMARY KEY (id);
(1 row)

View File

@ -600,3 +600,5 @@ test: parallel_query
# gs_basebackup
test: gs_basebackup
test: function_get_table_def

View File

@ -0,0 +1,10 @@
create table table_function_export_def_base (
id integer primary key,
name varchar(100)
);
create table table_function_export_def (
id integer primary key,
fid integer,
constraint table_export_base_fkey foreign key (fid) references table_function_export_def_base(id)
);
select * from pg_get_tabledef('table_function_export_def');