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

Jim Jones <jim.jones@uni-muenster.de>

From: Jim Jones <jim.jones@uni-muenster.de>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, Alexander Korotkov <aekorotkov@gmail.com>, Soumya S Murali <soumyamurali.work@gmail.com>, Daniil Davydov <3danissimo@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-04-24T23:01:21Z
Lists: pgsql-hackers
Hi David

On 25/04/2026 00:30, David G. Johnston wrote:
> If you can run the tests against v17 (that is the behavior we are trying
> to restore here, correct?) and v18 that would help demonstrate why the
> backpatch is needed.

Tests for PG18 and PG17:

== PG 18 ==

psql (18.3 (Debian 18.3-1.pgdg13+1))
Type "help" for help.

postgres=# \d pg_temp*.*
                    Table "pg_temp_36.t"
     Column      |  Type   | Collation | Nullable | Default
-----------------+---------+-----------+----------+---------
 generate_series | integer |           |          |

postgres=# SELECT * FROM pg_temp_36.t;
 generate_series
-----------------
(0 rows)


== PG 17 ==

psql (17.7 (Debian 17.7-3.pgdg13+1))
Geben Sie »help« für Hilfe ein.

postgres=# \d pg_temp*.*
                         Tabelle »pg_temp_13.t«
     Spalte      |   Typ   | Sortierfolge | NULL erlaubt? | Vorgabewert
-----------------+---------+--------------+---------------+-------------
 generate_series | integer |              |               |

postgres=# SELECT * FROM pg_temp_13.t;
 generate_series
-----------------
(0 Zeilen)


Until PG16 an error message was raised:

psql (16.13 (Debian 16.13-1.pgdg13+1))
Type "help" for help.

postgres=# \d pg_temp*.*
                    Table "pg_temp_3.t"
     Column      |  Type   | Collation | Nullable | Default
-----------------+---------+-----------+----------+---------
 generate_series | integer |           |          |

postgres=# SELECT * FROM pg_temp_3.t;
ERROR:  cannot access temporary tables of other sessions


Best, Jim




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