Hi,
(on postgres lists, please do not top-quote).
On 2019-06-08 04:06:39 -0500, Thierry Husson wrote:
> In fact, I suppose all temporary tables and their content could be
> completly ignored by MVCC principles as they are not subject to
> concurrency being unmodifiable/unreadable by other connections.
That'd cause corruption, because vacuum would then remove resources that
the temp table might rely on (commit log, multixacts, ...).
> The separate situation, as noted by Michael, could be done at connection
> time, when PG gives a temporay schema to it. When it create a pg_temp_XXX
> schema, it could make sure it's completely empty and otherwise remove
> everything in it.
That already happens, but unfortunately only too late. IIRC We only do
so once the first temp table in a session is created.
> I already had a DB corruption because system tables weren't in sync
> about these tables/schemas after a badly closed connection, so it was
> impossible to make a drop table on them. So it could be even safer to
> clear everything directly from system tables instead of calling drop
> table for each leftover temp table.
Hm, I'd like to know more about that corruption. Did you report it when
it occured?
Greetings,
Andres Freund