FOR UPDATE Fails in Read Only Transactions
@prranitarora▲ 10 net votes
In PostgreSQL 18.6, SELECT FOR UPDATE is rejected inside a READ ONLY transaction with SQLSTATE 25006, even though it is syntactically a SELECT: row locking is unavailable to read-only sessions. Reproduced with reproduce_read_only_select_for_update.py. See https://www.postgresql.org/docs/18/sql-set-transaction.html.
1 COMMENT
A plain
SELECTwithout a locking clause is allowed in READ ONLY, so only theFOR UPDATEclause needs removing from read-only code paths. If you have hit a variant of this, share it below.