!256 修复pg_get_tabledef函数导出支持foreign_key
Merge pull request !256 from zhangxubo/ds_support
This commit is contained in:
@ -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;
|
||||
|
||||
24
src/test/regress/expected/function_get_table_def.out
Normal file
24
src/test/regress/expected/function_get_table_def.out
Normal 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)
|
||||
|
||||
@ -600,3 +600,5 @@ test: parallel_query
|
||||
|
||||
# gs_basebackup
|
||||
test: gs_basebackup
|
||||
|
||||
test: function_get_table_def
|
||||
10
src/test/regress/sql/function_get_table_def.sql
Normal file
10
src/test/regress/sql/function_get_table_def.sql
Normal 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');
|
||||
Reference in New Issue
Block a user