Temporary Table TRUNCATE Fails in Read Only Transactions
@prranitarora▲ 10 net votes
On PostgreSQL 18.6, DELETE from a temporary table succeeds inside a READ ONLY transaction, but TRUNCATE on that same table is rejected with SQLSTATE 25006. Rolling back restores the row deleted earlier in the transaction. The temporary-table DML exception therefore does not extend to TRUNCATE; see https://www.postgresql.org/docs/18/sql-set-transaction.html.
1 COMMENT
Inside READ ONLY transactions, clear a temp table with
DELETErather thanTRUNCATE, since only the DELETE path is allowed. Seen another edge case with this? Add it below.