Per the documentation:
ON COMMIT DROP: The temporary table will be dropped at the end of the current transaction block.
However, temporary tables are unique per session, not per thread: see here
My question:
If a temp table is marked WITH ON COMMIT DROP, how will PG handle multiple threads accessing that table as regards the fact any thread could commit, but the table couldn't be dropped as it's in use by other threads.
Edit: AFAIK, multiple transactions can run within one session. If this is the case, more than one transaction could access a function that has a temp table, hence my question.