Re: BUG with accessing to temporary tables of other sessions still exists
Daniil Davydov <3danissimo@gmail.com>
From: Daniil Davydov <3danissimo@gmail.com>
To: ZizhuanLiu X-MAN <44973863@qq.com>
Cc: Jim Jones <jim.jones@uni-muenster.de>, pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-06-20T18:52:06Z
Lists: pgsql-hackers
Hi, On Sat, Jun 20, 2026 at 10:48 PM ZizhuanLiu X-MAN <44973863@qq.com> wrote: > > Just as described in the comment of RELATION_IS_OTHER_TEMP macro in rel.h, > existing buffer manager routines including ReadBuffer_common(), StartReadBuffersImpl() > and PrefetchBuffer() have already invoked this macro to check cross-session temporary > table access. All these functions are located in bufmgr.c. > > For code consistency, I suggest adding the same RELATION_IS_OTHER_TEMP check in > ExtendBufferedRelCommon() (also in bufmgr.c), right before calling ExtendBufferedRelLocal(). Thank you for your feedback! Do you mean that this check should be moved to "ExtendBufferedRelCommon" because this function is in the bufmgr.c file? If so, I don't see the point in that. Buffer manager is not only the bufmgr.c file, but also all the files in the "storage/buffer" folder. So we can say that localbuf.c also contains logic related to the buffer manager. Moreover, ExtendBufferedRelCommon should contain only the logic that is really common for both ordinary and temp tables. All other specific code is encapsulated inside the ExtendBufferedRelLocal and ExtendBufferedRelShared. It allows us to keep the ExtendBufferedRelCommon function pretty short. So, I suggest leaving RELATION_IS_OTHER_TEMP as it is. > Meanwhile, we should also update the comment of RELATION_IS_OTHER_TEMP > accordingly to keep the documentation synchronized with code changes. This comment is already updated - it now mentions the ExtendBufferedRelLocal function. -- Best regards, Daniil Davydov
Commits
-
Prevent access to other sessions' empty temp tables
- c40819ebf954 master landed
- 8021cdceb018 19 (unreleased) landed
- 3aaefe8924f4 18 (unreleased) landed
- 4e49f68b72de 17 (unreleased) landed
- cc3fe7e2a747 16 (unreleased) landed
-
Add tests for cross-session temp table access
- 40927d458fe1 17 (unreleased) cited
-
Prevent access to other sessions' temp tables
- ce146621f786 19 (unreleased) cited