Skip to content

Commit 0de9963

Browse files
committed
Fix documentation about joining pg_locks to other views.
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
1 parent 640c0d2 commit 0de9963

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

doc/src/sgml/catalogs.sgml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6415,16 +6415,27 @@
64156415

64166416
<para>
64176417
The <structfield>pid</structfield> column can be joined to the
6418-
<structfield>procpid</structfield> column of the
6419-
<structname>pg_stat_activity</structname> view to get more
6420-
information on the session holding or waiting to hold each lock.
6418+
<structfield>procpid</structfield> column of the <link
6419+
linkend="monitoring-stats-views"><structname>pg_stat_activity</structname></link>
6420+
view to get more
6421+
information on the session holding or waiting to hold each lock,
6422+
for example
6423+
<programlisting>
6424+
SELECT * FROM pg_locks pl LEFT JOIN pg_stat_activity psa
6425+
ON pl.pid = psa.procpid;
6426+
</programlisting>
64216427
Also, if you are using prepared transactions, the
6422-
<structfield>transaction</> column can be joined to the
6423-
<structfield>transaction</structfield> column of the
6424-
<structname>pg_prepared_xacts</structname> view to get more
6425-
information on prepared transactions that hold locks.
6428+
<structfield>virtualtransaction</> column can be joined to the
6429+
<structfield>transaction</structfield> column of the <link
6430+
linkend="view-pg-prepared-xacts"><structname>pg_prepared_xacts</structname></link>
6431+
view to get more information on prepared transactions that hold locks.
64266432
(A prepared transaction can never be waiting for a lock,
64276433
but it continues to hold the locks it acquired while running.)
6434+
For example:
6435+
<programlisting>
6436+
SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
6437+
ON pl.virtualtransaction = '-1/' || ppx.transaction;
6438+
</programlisting>
64286439
</para>
64296440

64306441
</sect1>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy