Re: Fix bug with accessing to temporary tables of other sessions - Mailing list pgsql-hackers

From Daniil Davydov
Subject Re: Fix bug with accessing to temporary tables of other sessions
Date
Msg-id CAJDiXgi0JFk0f2KWWQkzLBC5P7erX9WP18qqnbi-rjZ-K-P=3w@mail.gmail.com
Whole thread
In response to Re: Fix bug with accessing to temporary tables of other sessions  (Jim Jones <jim.jones@uni-muenster.de>)
Responses Re: Fix bug with accessing to temporary tables of other sessions
Re: Fix bug with accessing to temporary tables of other sessions
List pgsql-hackers
Hi,

On Fri, Apr 10, 2026 at 12:46 AM Jim Jones <jim.jones@uni-muenster.de> wrote:
>
> I guess a check in read_stream_begin_relation()
> and in StartReadBuffersImpl() would be the best solution? If you agree,
> could you add it in v16?

Having both checks might look a bit redundant since the read stream will
eventually call the StartReadBuffersImpl function. On the other hand, there are
many places which are checking this restriction even if subsequent functions
(from bufmgr) also have this check.

So, I'll keep both checks and a bit reduce the comments in the bufmgr.c .

BTW, what do you think about making this comment less "concrete"? :
# SELECT via index scan from other session.
# Sequential scans are blocked at read_stream_begin_relation(); index scans
# bypass that path entirely and reach ReadBufferExtended() in bufmgr.c
# (nbtree's _bt_getbuf calls ReadBuffer directly for individual page fetches).
# enable_seqscan=off forces the planner to use the index.

I mean that if the described logic changes, this comment will become confusing.
We can describe the test in general words. For example :
# Index scans can use a different code path from the one sequential scans are
# following. Make sure that we cannot access other sessions' temp tables during
# index scan either.


Thank you for the comments! Please, see an updated set of patches.

--
Best regards,
Daniil Davydov

Attachment

pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: Use proc_exit() in WalRcvWaitForStartPosition
Next
From: Lukas Fittl
Date:
Subject: Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc?