]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Prevent access to other sessions' empty temp tables
authorAlexander Korotkov <akorotkov@postgresql.org>
Fri, 3 Jul 2026 12:53:03 +0000 (15:53 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Fri, 3 Jul 2026 15:01:00 +0000 (18:01 +0300)
commitcc3fe7e2a7471c541df7ff168bc41a3435f61fb0
tree7b9f99304766e65e3bf7efb606ba68d6ca899e4a
parentf9afdb6d1a2851c5301a9ae962d1d1b3e8bd5a29
Prevent access to other sessions' empty temp tables

Commit ce146621 ensures that ERROR is raised if a session tries to read
pages of another session's temp table.  But there is a corner case where
the other session's temp table is empty -- in this case the INSERT
command bypasses our checks and executes without any errors.

Such behavior is inconsistent and erroneous: it leaves an invalid buffer
in the temp buffers pool.  Since the buffer was created for another
session's temp table, we get an error "no such file or directory" when
trying to flush it.

This commit fixes it by adding a RELATION_IS_OTHER_TEMP check in the
relation-extension path.

Backpatch to 16, because it is the first release after 31966b151e6, which
introduced a separate local relation extension function
ExtendBufferedRelLocal(), which lacks of RELATION_IS_OTHER_TEMP() check.
As this fix introduces more checks to 013_temp_obj_multisession.pl, backpatch
the whole test script to 16.

Discussion: https://postgr.es/m/CAJDiXgiX2XZBHDNo%2BzBbvku%2BtchrUurvPRaN1_40mEQ1_sG90g%40mail.gmail.com
Author: Daniil Davydov <3danissimo@gmail.com>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Reviewed-by: Imran Zaheer <imran.zhir@gmail.com>
Reviewed-by: ZizhuanLiu X-MAN <44973863@qq.com>
Backpatch-through: 16
src/backend/storage/buffer/bufmgr.c
src/test/modules/test_misc/t/013_temp_obj_multisession.pl [new file with mode: 0644]