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-10T15:28:01Z
Lists: pgsql-hackers

Attachments

Hi,

On Fri, Apr 10, 2026 at 5:29 PM Jim Jones <jim.jones@uni-muenster.de> wrote:
>
> > 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.
>
> +1
>
> Yeah, it's indeed too verbose. I guess these comments were originally
> just for me so I wouldn't get too confused along the way :)

OK :)

>
> I don't have anything else to add at this point. Unless there are any
> objections, I'll mark the CF entry as 'Ready for Committer.'
>

Great, thank you!

Please, see an updated set of patches (only perl test has been changed) :
1) Rephrase the discussed comment.
2) Use safe_psql whenever possible.
3) Run pgperltidy.

--
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 →
  1. Prevent access to other sessions' temp tables

  2. Add tests for cross-session temp table access

  3. Doc: use "an SQL" consistently rather than "a SQL"

  4. Modify the relcache to record the temp status of both local and nonlocal