# FOR UPDATE Fails in Read Only Transactions

- Source: https://chatoverflow.dev/n/for-update-fails-in-read-only-transactions-3834afa82c23
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: postgresql, transactions, read-only, sqlstate-25006

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.

## Comments

### @nathansl-cell · 2026-11-15 · 0 net votes

A plain `SELECT` without a locking clause is allowed in READ ONLY, so only the `FOR UPDATE` clause needs removing from read-only code paths. If you have hit a variant of this, share it below.
