From af46b2916622029cb62c463d475e41ec7f4251b0 Mon Sep 17 00:00:00 2001 From: Hiroki Takamatsu Date: Mon, 30 Mar 2026 07:13:25 +0000 Subject: [PATCH v2] doc: clarify pg_locks object identifier columns The pg_locks descriptions for classid, objid, and objsubid said that these columns are null when the lock target is not a general database object. That is not true for all lock types: advisory locks store key fields there, speculative insertion locks store the token in objid, and apply transaction locks store subscription and subtype information there. Scope the catalog-reference descriptions to the general database object case, point readers to the lock-type-specific descriptions, and document the subscription OID shown for apply transaction locks. --- doc/src/sgml/system-views.sgml | 35 +++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/system-views.sgml b/doc/src/sgml/system-views.sgml index 5ea19d68622..a24f09dfd69 100644 --- a/doc/src/sgml/system-views.sgml +++ b/doc/src/sgml/system-views.sgml @@ -1795,7 +1795,9 @@ AND c1.path[c2.level] = c2.path[c2.level]; relation is represented as a separate lockable object, as is the right to update pg_database.datfrozenxid. Also, advisory locks can be taken on numbers that have - user-defined meanings. + user-defined meanings. Speculative insertion locks are identified by a + transaction ID and token, and apply transaction locks are used by logical + replication subscribers. @@ -1902,22 +1904,27 @@ AND c1.path[c2.level] = c2.path[c2.level]; classid oid - (references pg_class.oid) + (for a general database object, references + pg_class.oid) - OID of the system catalog containing the lock target, or null if the - target is not a general database object + For a general database object, the OID of the system catalog + containing the lock target. + This column is also used for other lock types; see the descriptions of + specific lock types below. objid oid - (references any OID column) + (for a general database object, references any OID column) - OID of the lock target within its system catalog, or null if the - target is not a general database object + For a general database object, the OID of the lock target within + its system catalog. + This column is also used for other lock types; see the descriptions of + specific lock types below. @@ -1926,11 +1933,13 @@ AND c1.path[c2.level] = c2.path[c2.level]; objsubidint2 - Column number targeted by the lock (the + For a general database object, the column number targeted by the + lock (the classid and objid refer to the table itself), - or zero if the target is some other general database object, - or null if the target is not a general database object + or zero if the target is some other general database object. + This column is also used for other lock types; see the descriptions of + specific lock types below. @@ -2053,7 +2062,11 @@ AND c1.path[c2.level] = c2.path[c2.level]; Apply transaction locks are used in parallel mode to apply the transaction in logical replication. The remote transaction ID is displayed in the - transactionid column. The objsubid + transactionid column. The OID of the subscription, + corresponding to + pg_subscription.oid, + is displayed in the objid column. + The objsubid displays the lock subtype which is 0 for the lock used to synchronize the set of changes, and 1 for the lock used to wait for the transaction to finish to ensure commit order. -- 2.55.0