!85 支持create GTT表的on commit选项覆盖reloptions中on_commit_delete_rows参数。

Merge pull request !85 from wangzhijun/master
This commit is contained in:
opengauss-bot 2020-08-07 11:41:49 +08:00 committed by Gitee
commit 94c0253d15
4 changed files with 22 additions and 18 deletions

View File

@ -1612,8 +1612,7 @@ static void transformTableLikeClause(
cxt->reloptions = untransformRelOptions(reloptions);
/* remove on_commit_delete_rows option */
if (cxt->relation->relpersistence != RELPERSISTENCE_TEMP &&
cxt->relation->relpersistence != RELPERSISTENCE_GLOBAL_TEMP) {
if (cxt->relation->relpersistence != RELPERSISTENCE_GLOBAL_TEMP) {
cxt->reloptions = RemoveRelOption(cxt->reloptions, "on_commit_delete_rows", NULL);
}

View File

@ -1587,13 +1587,12 @@ Oid DefineRelation(CreateStmt* stmt, char relkind, Oid ownerId)
OnCommitAction oncommitAction = GttOncommitOption(stmt->options);
if (stmt->relation->relpersistence == RELPERSISTENCE_GLOBAL_TEMP &&
relkind == RELKIND_RELATION) {
if (oncommitAction != ONCOMMIT_NOOP) {
if (stmt->oncommit != ONCOMMIT_NOOP && stmt->oncommit != oncommitAction) {
elog(ERROR, "could not create global temporary table with different on commit parameter and with "
"clause options at same time");
}
if (oncommitAction != ONCOMMIT_NOOP && stmt->oncommit == ONCOMMIT_NOOP) {
stmt->oncommit = oncommitAction;
} else {
if (oncommitAction != ONCOMMIT_NOOP && stmt->oncommit != ONCOMMIT_NOOP) {
stmt->options = RemoveRelOption(stmt->options, "on_commit_delete_rows", NULL);
}
DefElem *opt = makeNode(DefElem);
opt->type = T_DefElem;

View File

@ -136,9 +136,9 @@ select relname ,relkind, relpersistence, reloptions from pg_class where relname
-- ERROR
create global temp table gtt3(a int primary key, b text) on commit drop;
ERROR: ON COMMIT only support PRESERVE ROWS or DELETE ROWS option
-- ERROR
create global temp table gtt4(a int primary key, b text) with(on_commit_delete_rows=true) on commit preserve rows;
ERROR: could not create global temporary table with different on commit parameter and with clause options at same time
-- ok
create global temp table gtt10(a int primary key, b text) with(on_commit_delete_rows=true) on commit preserve rows;
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "gtt10_pkey" for table "gtt10"
-- ok
create global temp table gtt4(a int primary key, b text) with(on_commit_delete_rows=true) on commit delete rows;
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "gtt4_pkey" for table "gtt4"
@ -147,9 +147,10 @@ create global temp table gtt5(a int primary key, b text) with(on_commit_delete_r
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "gtt5_pkey" for table "gtt5"
-- ok
create table tb1 (like gtt2 including reloptions);
-- ERROR
create global temp table gtt7 (like gtt2 including reloptions) on commit preserve rows;
ERROR: could not create global temporary table with different on commit parameter and with clause options at same time
-- ok
create temp table ltb1 (like gtt1 including reloptions) on commit delete rows;
-- ok
create global temp table gtt11 (like gtt2 including reloptions) on commit preserve rows;
-- ok
create global temp table gtt7 (like gtt2 including reloptions) on commit delete rows;
-- ok
@ -381,16 +382,18 @@ create global temp table gtt_test11(c1 int) with(on_commit_delete_rows='');
ERROR: parameter "on_commit_delete_rows" requires a Boolean value
reset search_path;
drop schema gtt_function cascade;
NOTICE: drop cascades to 32 other objects
NOTICE: drop cascades to 34 other objects
DETAIL: drop cascades to table gtt_function.gtt1
drop cascades to table gtt_function.gtt2
drop cascades to table gtt_function.gtt3
drop cascades to table gtt_function.gtt6
drop cascades to table gtt_function.tbl_inherits_parent
drop cascades to table gtt_function.tbl_inherits_parent_global_temp
drop cascades to table gtt_function.gtt10
drop cascades to table gtt_function.gtt4
drop cascades to table gtt_function.gtt5
drop cascades to table gtt_function.tb1
drop cascades to table gtt_function.gtt11
drop cascades to table gtt_function.gtt7
drop cascades to table gtt_function.gtt8
drop cascades to table gtt_function.gtt9

View File

@ -131,8 +131,8 @@ select relname ,relkind, relpersistence, reloptions from pg_class where relname
-- ERROR
create global temp table gtt3(a int primary key, b text) on commit drop;
-- ERROR
create global temp table gtt4(a int primary key, b text) with(on_commit_delete_rows=true) on commit preserve rows;
-- ok
create global temp table gtt10(a int primary key, b text) with(on_commit_delete_rows=true) on commit preserve rows;
-- ok
create global temp table gtt4(a int primary key, b text) with(on_commit_delete_rows=true) on commit delete rows;
@ -143,8 +143,11 @@ create global temp table gtt5(a int primary key, b text) with(on_commit_delete_r
-- ok
create table tb1 (like gtt2 including reloptions);
-- ERROR
create global temp table gtt7 (like gtt2 including reloptions) on commit preserve rows;
-- ok
create temp table ltb1 (like gtt1 including reloptions) on commit delete rows;
-- ok
create global temp table gtt11 (like gtt2 including reloptions) on commit preserve rows;
-- ok
create global temp table gtt7 (like gtt2 including reloptions) on commit delete rows;