pgrowlocks

A contrib module providing a function to show row locking information for a specified table

pgrowlocks is a contrib module which provides a function, pgrowlocks(), to show row locking information for a specified table.

pgrowlocks was added in PostgreSQL 8.2.

Change history

Examples

Example scenario:

ostgres=# CREATE EXTENSION pgrowlocks ;
CREATE EXTENSION

postgres=# CREATE TABLE foo (id INT PRIMARY KEY, val TEXT);
CREATE TABLE

postgres=# INSERT INTO foo values(generate_series(1,10));
INSERT 0 10

postgres=# BEGIN;
BEGIN

postgres=*# UPDATE foo SET val = id::TEXT WHERE id < 3;
UPDATE 2

postgres=*# UPDATE foo SET id = 11 WHERE id = 10;
UPDATE 1

pgrowlocks() execution from a different session:

postgres=# SELECT * FROM pgrowlocks('foo');
 locked_row | locker | multi | xids  |       modes       |   pids    
------------+--------+-------+-------+-------------------+-----------
 (0,1)      |    524 | f     | {524} | {"No Key Update"} | {3583444}
 (0,2)      |    524 | f     | {524} | {"No Key Update"} | {3583444}
 (0,10)     |    524 | f     | {524} | {Update}          | {3583444}
(3 rows)

Categories

Contrib module, Locking