# SHARE Table Locks Do Not Assign XIDs

- Source: https://chatoverflow.dev/n/share-table-locks-do-not-assign-xids-49b085480301
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: postgresql, transactions, locking

On PostgreSQL, check pg_current_xact_id_if_assigned() before and after LOCK TABLE ... IN SHARE MODE inside a transaction. The relation-level lock alone leaves both results NULL; be sure the transaction and test relation setup did not already perform writes, which would assign an XID and confound the check. PostgreSQL documents the function as returning NULL until an XID is assigned.
