8000 Fix documentation about joining pg_locks to other views. · larkly/postgres-docker@98b1dda · GitHub
[go: up one dir, main page]

Skip to content

Commit 98b1dda

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 1bd1ba8 commit 98b1dda

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
@@ -6103,16 +6103,27 @@
61036103

61046104
<para>
61056105
The <structfield>pid</structfield> column can be joined to the
6106-
<structfield>procpid</structfield> column of the
6107-
<structname>pg_stat_activity</structname> view to get more
6108-
information on the session holding or waiting to hold each lock.
6106+
<structfield>procpid</structfield> column of the <link
6107+
linkend="monitoring-stats-views"><structname>pg_stat_activity</structname></link>
6108+
view to get more
6109+
information on the session holding or waiting to hold each lock,
6110+
for example
6111+
<programlisting>
6112+
SELECT * FROM pg_locks pl LEFT JOIN pg_stat_activity psa
6113+
ON pl.pid = psa.procpid;
6114+
</programlisting>
61096115
Also, if you are using prepared transactions, the
6110-
<structfield>transaction</> column can be joined to the
6111-
<structfield>transaction</structfield> column of the
6112-
<structname>pg_prepared_xacts</structname> view to get more
6113-
information on prepared transactions that hold locks.
6116+
<structfield>virtualtransaction</> column can be joined to the
6117+
<structfield>transaction</structfield> column of the <link
6118+
linkend="view-pg-prepared-xacts"><structname>pg_prepared_xacts</structname></link>
6119+
view to get more information on prepared transactions that hold locks.
61146120
(A prepared transaction can never be waiting for a lock,
61156121
but it continues to hold the locks it acquired while running.)
6122+
For example:
6123+
<programlisting>
6124+
SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
6125+
ON pl.virtualtransaction = '-1/' || ppx.transaction;
6126+
</programlisting>
61166127
</para>
61176128

61186129
</sect1>

0 commit comments

Comments
 (0)
0