From a9c4c9cd52b3fde9aed016cbc5d684ab2ad968ef Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 17 May 2005 21:46:11 +0000 Subject: Extend the pg_locks system view so that it can fully display all lock types, as per recent discussion. --- doc/src/sgml/catalogs.sgml | 113 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 96 insertions(+), 17 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 0aa12d4eae5..544f9b758d3 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1,6 +1,6 @@ @@ -4040,15 +4040,18 @@ lockable object may appear many times, if multiple transactions are holding or waiting for locks on it. However, an object that currently has no locks on it - will not appear at all. A lockable object is either a relation (e.g., a - table) or a transaction ID. + will not appear at all. - Note that this view includes only table-level - locks, not row-level ones. If a transaction is waiting for a - row-level lock, it will appear in the view as waiting for the - transaction ID of the current holder of that row lock. + There are several distinct types of lockable objects: + whole relations (e.g., tables), individual pages of relations, + individual tuples of relations, + transaction IDs, + and general database objects (identified by class OID and object OID, + in the same way as in pg_description or + pg_depend). Also, the right to extend a + relation is represented as a separate lockable object. @@ -4065,12 +4068,18 @@ - relation - oid - pg_class.oid + locktype + text + - OID of the locked relation, or NULL if the lockable object - is a transaction ID + type of the lockable object: + relation, + extend, + page, + tuple, + transaction, + object, or + userlock @@ -4078,9 +4087,35 @@ oid pg_database.oid - OID of the database in which the locked relation exists, or - zero if the locked relation is a globally-shared table, or - NULL if the lockable object is a transaction ID + OID of the database in which the object exists, or + zero if the object is a globally-shared object, or + NULL if the object is a transaction ID + + + + relation + oid + pg_class.oid + + OID of the relation, or NULL if the object is not + a relation or part of a relation + + + + page + integer + + + page number within the relation, or NULL if the object + is not a tuple or relation page + + + + tuple + smallint + + + tuple number within the page, or NULL if the object is not a tuple @@ -4088,14 +4123,43 @@ xid - ID of a transaction, or NULL if the lockable object is a relation + ID of a transaction, or NULL if the object is not a transaction ID + + + + classid + oid + pg_class.oid + + OID of the system catalog containing the object, or NULL if the + object is not a general database object + + + + objid + oid + any OID column + + OID of the object within its system catalog, or NULL if the + object is not a general database object + + + + objsubid + smallint + + + For a table column, this is the column number (the + classid and objid refer to the + table itself). For all other object types, this column is + zero. NULL if the object is not a general database object pid integer - process ID of a server process holding or awaiting this + process ID of the server process holding or awaiting this lock @@ -4133,6 +4197,21 @@ terminates and releases its locks. + + Although tuples are a lockable type of object, + information about row-level locks is stored on disk, not in memory, + and therefore row-level locks normally do not appear in this view. + If a transaction is waiting for a + row-level lock, it will usually appear in the view as waiting for the + transaction ID of the current holder of that row lock. + + + + If user-defined locks are in use, they are displayed using the columns + for general database objects. However, the actual meaning of the lock + fields in such cases is up to the user. + + When the pg_locks view is accessed, the internal lock manager data structures are momentarily locked, and -- cgit v1.2.3