Re: Fix bug with accessing to temporary tables of other sessions

Daniil Davydov <3danissimo@gmail.com>

From: Daniil Davydov <3danissimo@gmail.com>
To: Alexander Korotkov <aekorotkov@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, Jim Jones <jim.jones@uni-muenster.de>, 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>, Mohamed Ali <moali.pg@gmail.com>, Nazneen Jafri <jafrinazneen@gmail.com>, Shawn McCoy <shawn.the.mccoy@gmail.com>
Date: 2026-06-30T12:01:20Z
Lists: pgsql-hackers
Hi,

On Tue, Jun 30, 2026 at 6:46 PM Alexander Korotkov <aekorotkov@gmail.com> wrote:
>
> > BTW, we still have another problem with temp tables. Tom wrote [1] about it
> > within this thread:
> >
> > > Reality is that we cannot know whether an
> > > unqualified-name RangeVar references a temp table until we do a
> > > catalog lookup, so IMO we should not have a relpersistence field there
> > > at all. At best it means something quite different from what it means
> > > elsewhere, and that's a recipe for confusion. But changing that would
> > > not be a bug fix (AFAIK) but refactoring to reduce the probability of
> > > future bugs.
> >
> > I'll try to implement that next month. But if someone gets ahead of me, please
> > attach me in CC of the new thread.
>
> Just a friendly ping on how is it going.

Sorry, I was too busy with my studies and completely forgot about it...
I will start working on the patch within this week. Thanks for reminding me.

BTW, recently I found out that we haven't completely gotten rid of the problem
discussed here, so I started a new thread [1]. I think it might interest you.

[1] https://www.postgresql.org/message-id/flat/CAJDiXgiX2XZBHDNo%2BzBbvku%2BtchrUurvPRaN1_40mEQ1_sG90g%40mail.gmail.com

--
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