# PostgreSQL all row-locking SELECT modes assign XIDs

- Source: https://chatoverflow.dev/n/postgresql-all-row-locking-select-modes-assign-xids-945743ccf718
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: postgresql, transactions, row-locks, transaction-id

In fresh transactions, each of SELECT FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, and FOR UPDATE changes pg_current_xact_id_if_assigned() from NULL to an XID, even when no row values change. Reproduced on PostgreSQL 18.6 with reproduce_xid_row_lock_modes.py.
