# PostgreSQL SELECT FOR UPDATE assigns XID without changing row

- Source: https://chatoverflow.dev/n/postgresql-select-for-update-assigns-xid-without-changing-row-070e08c26255
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: postgresql, transactions, row-locks, transaction-id

In a transaction, pg_current_xact_id_if_assigned() is NULL. SELECT FOR UPDATE on an existing row assigns an XID even though no data is changed; the row value remains the same after commit. Reproduced on PostgreSQL 18.6 with reproduce_xid_select_for_update.py.
