From b7953f51cf1bd2d7ae37acf47e2bab9a257495f4 Mon Sep 17 00:00:00 2001 From: wangzhijun2018 Date: Thu, 20 Aug 2020 17:31:47 +0800 Subject: [PATCH] fix long regression temp table issue --- src/common/backend/utils/cache/relcache.cpp | 10 ++-------- src/test/regress/expected/gtt_function.out | 8 ++++++-- src/test/regress/sql/gtt_function.sql | 8 +++++++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/common/backend/utils/cache/relcache.cpp b/src/common/backend/utils/cache/relcache.cpp index 1baabb1a38..4a343ca08a 100644 --- a/src/common/backend/utils/cache/relcache.cpp +++ b/src/common/backend/utils/cache/relcache.cpp @@ -1699,12 +1699,9 @@ static Relation relation_build_desc(Oid targetRelId, bool insertIt, bool buildke switch (relation->rd_rel->relpersistence) { case RELPERSISTENCE_UNLOGGED: case RELPERSISTENCE_PERMANENT: - relation->rd_backend = InvalidBackendId; - relation->rd_islocaltemp = false; - break; case RELPERSISTENCE_TEMP: // @Temp Table. Temp table here is just like unlogged table. relation->rd_backend = InvalidBackendId; - relation->rd_islocaltemp = true; + relation->rd_islocaltemp = false; break; case RELPERSISTENCE_GLOBAL_TEMP: // global temp table { @@ -3712,12 +3709,9 @@ Relation RelationBuildLocalRelation(const char* relname, Oid relnamespace, Tuple switch (relpersistence) { case RELPERSISTENCE_UNLOGGED: case RELPERSISTENCE_PERMANENT: - rel->rd_backend = InvalidBackendId; - rel->rd_islocaltemp = false; - break; case RELPERSISTENCE_TEMP: // @Temp Table. Temp table here is just like unlogged table. rel->rd_backend = InvalidBackendId; - rel->rd_islocaltemp = true; + rel->rd_islocaltemp = false; break; case RELPERSISTENCE_GLOBAL_TEMP: // global temp table rel->rd_backend = BackendIdForTempRelations; diff --git a/src/test/regress/expected/gtt_function.out b/src/test/regress/expected/gtt_function.out index a53fd63e4a..02863b2601 100644 --- a/src/test/regress/expected/gtt_function.out +++ b/src/test/regress/expected/gtt_function.out @@ -157,11 +157,15 @@ create global temp table gtt7 (like gtt2 including reloptions) on commit delete create global temp table gtt8 on commit delete rows as select * from gtt3; -- ok select * into global temp table gtt9 from gtt2; -create global temp table gtt_test_rename(a int primary key, b text); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "gtt_test_rename_pkey" for table "gtt_test_rename" +create global temp table gtt_test_rename(a int, b text); --ok alter table gtt_test_rename rename to gtt_test_new; --ok +alter table gtt_test_new add constraint pk1 primary key(a); +NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pk1" for table "gtt_test_new" +--ok +alter table gtt_test_new drop constraint pk1; +--ok ALTER TABLE gtt_test_new ADD COLUMN address integer; --ok insert into gtt_test_new values(1, 'hello postgres', 128); diff --git a/src/test/regress/sql/gtt_function.sql b/src/test/regress/sql/gtt_function.sql index 339143003f..3df1126d5e 100644 --- a/src/test/regress/sql/gtt_function.sql +++ b/src/test/regress/sql/gtt_function.sql @@ -158,11 +158,17 @@ create global temp table gtt8 on commit delete rows as select * from gtt3; -- ok select * into global temp table gtt9 from gtt2; -create global temp table gtt_test_rename(a int primary key, b text); +create global temp table gtt_test_rename(a int, b text); --ok alter table gtt_test_rename rename to gtt_test_new; +--ok +alter table gtt_test_new add constraint pk1 primary key(a); + +--ok +alter table gtt_test_new drop constraint pk1; + --ok ALTER TABLE gtt_test_new ADD COLUMN address integer; -- Gitee