!458 函数pg_get_tabledef()支持显示全局临时表的DDL

Merge pull request !458 from 勇往直前/ggt
This commit is contained in:
opengauss-bot
2020-12-14 09:12:40 +08:00
committed by Gitee
4 changed files with 33 additions and 3 deletions

View File

@ -1752,8 +1752,9 @@ static char* pg_get_tabledef_worker(Oid table_oid)
appendStringInfo(&buf, "SET search_path = %s;", quote_identifier(get_namespace_name(table_info.spcid, true)));
appendStringInfo(&buf,
"\nCREATE %s %s %s",
table_info.relpersistence == RELPERSISTENCE_UNLOGGED ? "UNLOGGED" : "",
"\nCREATE %s%s %s",
(table_info.relpersistence == RELPERSISTENCE_UNLOGGED) ? "UNLOGGED " :
((table_info.relpersistence == RELPERSISTENCE_GLOBAL_TEMP) ? "GLOBAL TEMPORARY " : ""),
rel_type_name,
rel_name);

View File

@ -0,0 +1,20 @@
CREATE GLOBAL TEMPORARY TABLE gtt1 (
ID INTEGER NOT NULL,
NAME CHAR(16) NOT NULL,
ADDRESS VARCHAR(50),
POSTCODE CHAR(6)
)
ON COMMIT PRESERVE ROWS;
select * from pg_get_tabledef('gtt1');
pg_get_tabledef
----------------------------------------------------------------------
SET search_path = public; +
CREATE GLOBAL TEMPORARY TABLE gtt1 ( +
id integer NOT NULL, +
name character(16) NOT NULL, +
address character varying(50), +
postcode character(6) +
) +
WITH (orientation=row, compression=no, on_commit_delete_rows=false);
(1 row)

View File

@ -83,3 +83,4 @@ test: explain_gather
test: gs_guc_show_error
test: line_operator
test: synchronous_commit_test
test: global_temporary_table_get_table_def

View File

@ -0,0 +1,8 @@
CREATE GLOBAL TEMPORARY TABLE gtt1 (
ID INTEGER NOT NULL,
NAME CHAR(16) NOT NULL,
ADDRESS VARCHAR(50),
POSTCODE CHAR(6)
)
ON COMMIT PRESERVE ROWS;
select * from pg_get_tabledef('gtt1');