Skip to content

Commit aab5d17

Browse files
author
Commitfest Bot
committed
[PATCH]: ./v1-move-check-for-other-temp-table.patch
1 parent 630a937 commit aab5d17

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/backend/storage/buffer/bufmgr.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ PrefetchBuffer(Relation reln, ForkNumber forkNum, BlockNumber blockNum)
657657

658658
if (RelationUsesLocalBuffers(reln))
659659
{
660-
/* see comments in ReadBufferExtended */
660+
/* see comments in PinBufferForBlock */
661661
if (RELATION_IS_OTHER_TEMP(reln))
662662
ereport(ERROR,
663663
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -794,16 +794,6 @@ ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum,
794794
{
795795
Buffer buf;
796796

797-
/*
798-
* Reject attempts to read non-local temporary relations; we would be
799-
* likely to get wrong data since we have no visibility into the owning
800-
* session's local buffers.
801-
*/
802-
if (RELATION_IS_OTHER_TEMP(reln))
803-
ereport(ERROR,
804-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
805-
errmsg("cannot access temporary tables of other sessions")));
806-
807797
/*
808798
* Read the buffer, and update pgstat counters to reflect a cache hit or
809799
* miss.
@@ -1109,6 +1099,18 @@ PinBufferForBlock(Relation rel,
11091099

11101100
if (persistence == RELPERSISTENCE_TEMP)
11111101
{
1102+
/*
1103+
* Reject attempts to read non-local temporary relations; we would be
1104+
* likely to get wrong data since we have no visibility into the
1105+
* owning session's local buffers. We don't expect to get here
1106+
* without a relcache entry (see ReadBufferWithoutRelcache).
1107+
*/
1108+
Assert(rel);
1109+
if (RELATION_IS_OTHER_TEMP(rel))
1110+
ereport(ERROR,
1111+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1112+
errmsg("cannot access temporary tables of other sessions")));
1113+
11121114
io_context = IOCONTEXT_NORMAL;
11131115
io_object = IOOBJECT_TEMP_RELATION;
11141116
}

0 commit comments

Comments
 (0)