]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Reject modifying a temp table of another session with ALTER TABLE.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 7 Jun 2024 18:50:09 +0000 (14:50 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 7 Jun 2024 18:50:09 +0000 (14:50 -0400)
commitb8efd756dfc7be368d9dc679e367c66cf815e4d8
tree9a4f8bf2fde2232b0de5065fe42f94568d981ff6
parent0be81dd71c854eaea506100765a0a52b9e54b461
Reject modifying a temp table of another session with ALTER TABLE.

Normally this case isn't even reachable by non-superusers, since
permissions checks prevent naming such a table.  However, it is
possible to make it happen by altering a parent table whose child
is another session's temp table.

We definitely can't support any such ALTER that requires modifying
the contents of such a table, since we lack access to the other
session's temporary-buffer pool.  But there seems no good reason
to allow it even if it'd only require changing catalog contents.
One reason not to allow it is that we'd rather not expose the
implementation-dependent behavior of whether a specific ALTER
requires touching the table contents.  Another is that there may
be (in future, even if not today) optimizations that assume that
a session's own temp tables won't be modified by other sessions.

Hence, add a RELATION_IS_OTHER_TEMP() check to all the places
where ALTER TABLE currently does CheckTableNotInUse().  (I looked
through all other callers of CheckTableNotInUse(), and they seem
OK already.)

Per bug #18492 from Alexander Lakhin.  Back-patch to all supported
branches.

Discussion: https://postgr.es/m/18492-c7a2634bf4968763@postgresql.org
src/backend/commands/tablecmds.c