Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8c65830

Browse files
committed
[refer #PGPRO-2887] Prohibit autovacuum for global temporary tables
1 parent 77d411d commit 8c65830

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/backend/access/gist/gistutil.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,8 @@ gistGetFakeLSN(Relation rel)
10281028
{
10291029
static XLogRecPtr counter = FirstNormalUnloggedLSN;
10301030

1031-
if (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
1031+
if (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP ||
1032+
rel->rd_rel->relpersistence == RELPERSISTENCE_SESSION)
10321033
{
10331034
/*
10341035
* Temporary relations are only accessible in our session, so a simple

src/backend/commands/tablecmds.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,8 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
586586
* Check consistency of arguments
587587
*/
588588
if (stmt->oncommit != ONCOMMIT_NOOP
589-
&& stmt->relation->relpersistence != RELPERSISTENCE_TEMP)
589+
&& stmt->relation->relpersistence != RELPERSISTENCE_TEMP
590+
&& stmt->relation->relpersistence != RELPERSISTENCE_SESSION)
590591
ereport(ERROR,
591592
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
592593
errmsg("ON COMMIT can only be used on temporary tables")));

src/backend/postmaster/autovacuum.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,8 @@ do_autovacuum(void)
20692069
* Check if it is a temp table (presumably, of some other backend's).
20702070
* We cannot safely process other backends' temp tables.
20712071
*/
2072-
if (classForm->relpersistence == RELPERSISTENCE_TEMP)
2072+
if (classForm->relpersistence == RELPERSISTENCE_TEMP ||
2073+
classForm->relpersistence == RELPERSISTENCE_SESSION)
20732074
{
20742075
/*
20752076
* We just ignore it if the owning backend is still active and
@@ -2154,7 +2155,8 @@ do_autovacuum(void)
21542155
/*
21552156
* We cannot safely process other backends' temp tables, so skip 'em.
21562157
*/
2157-
if (classForm->relpersistence == RELPERSISTENCE_TEMP)
2158+
if (classForm->relpersistence == RELPERSISTENCE_TEMP ||
2159+
classForm->relpersistence == RELPERSISTENCE_SESSION)
21582160
continue;
21592161

21602162
relid = classForm->oid;
@@ -2239,7 +2241,8 @@ do_autovacuum(void)
22392241
*/
22402242
if (!((classForm->relkind == RELKIND_RELATION ||
22412243
classForm->relkind == RELKIND_MATVIEW) &&
2242-
classForm->relpersistence == RELPERSISTENCE_TEMP))
2244+
(classForm->relpersistence == RELPERSISTENCE_TEMP ||
2245+
classForm->relpersistence == RELPERSISTENCE_SESSION)))
22432246
{
22442247
UnlockRelationOid(relid, AccessExclusiveLock);
22452248
continue;

0 commit comments

Comments
 (0)