Fix documentation about joining pg_locks to other views.
authorTom Lane
Thu, 3 Apr 2014 18:18:31 +0000 (14:18 -0400)
committerTom Lane
Thu, 3 Apr 2014 18:18:31 +0000 (14:18 -0400)
The advice to join to pg_prepared_xacts via the transaction column was not
updated when the transaction column was replaced by virtualtransaction.
Since it's not quite obvious how to do that join, give an explicit example.
For consistency also give an example for the adjacent case of joining to
pg_stat_activity.  And link-ify the view references too, just because we
can.  Per bug #9840 from Alexey Bashtanov.

Michael Paquier and Tom Lane

doc/src/sgml/catalogs.sgml

index 945f5754cef1e68ba93d6b9f98542da39df75c0c..9a9b3c4f5a36373fb097822b9d5375919950c483 100644 (file)
 
   
    The pid column can be joined to the
-   pid column of the
-   pg_stat_activity view to get more
-   information on the session holding or waiting to hold each lock.
+   pid column of the 
+   linkend="pg-stat-activity-view">pg_stat_activity
+   view to get more
+   information on the session holding or waiting to hold each lock,
+   for example
+
+SELECT * FROM pg_locks pl LEFT JOIN pg_stat_activity psa
+    ON pl.pid = psa.pid;
+
    Also, if you are using prepared transactions, the
-   transaction column can be joined to the
-   transaction column of the
-   pg_prepared_xacts view to get more
-   information on prepared transactions that hold locks.
+   virtualtransaction column can be joined to the
+   transaction column of the 
+   linkend="view-pg-prepared-xacts">pg_prepared_xacts
+   view to get more information on prepared transactions that hold locks.
    (A prepared transaction can never be waiting for a lock,
    but it continues to hold the locks it acquired while running.)
+   For example:
+
+SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
+    ON pl.virtualtransaction = '-1/' || ppx.transaction;
+