Re: Fix bug with accessing to temporary tables of other sessions
Daniil Davydov <3danissimo@gmail.com>
From: Daniil Davydov <3danissimo@gmail.com>
To: Jim Jones <jim.jones@uni-muenster.de>
Cc: Soumya S Murali <soumyamurali.work@gmail.com>,
Tom Lane <tgl@sss.pgh.pa.us>, Stepan Neretin <slpmcf@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2026-04-10T07:10:02Z
Lists: pgsql-hackers
Attachments
- v16-0002-Test-cross-session-access-on-temporary-tables.patch (text/x-patch) patch v16-0002
- v16-0001-Prevent-access-to-other-sessions-temp-tables.patch (text/x-patch) patch v16-0001
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
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Prevent access to other sessions' temp tables
- 4dfae59a1d31 17 (unreleased) landed
- 1b0dd08157bf 18 (unreleased) landed
- ce146621f786 19 (unreleased) landed
-
Add tests for cross-session temp table access
- 40927d458fe1 17 (unreleased) landed
- 1cd37a7a8dc6 18 (unreleased) landed
- 1fee0e857e33 19 (unreleased) landed
-
Doc: use "an SQL" consistently rather than "a SQL"
- b51f86e49a7f 18.0 cited
-
Modify the relcache to record the temp status of both local and nonlocal
- 948d6ec90fd3 8.4.0 cited