Skip to content

Commit 447e237

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 7af116d commit 447e237

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
@@ -7092,16 +7092,27 @@
70927092

70937093
<para>
70947094
The <structfield>pid</structfield> column can be joined to the
7095-
<structfield>procpid</structfield> column of the
7096-
<structname>pg_stat_activity</structname> view to get more
7097-
information on the session holding or waiting to hold each lock.
7095+
<structfield>procpid</structfield> column of the <link
7096+
linkend="monitoring-stats-views"><structname>pg_stat_activity</structname></link>
7097+
view to get more
7098+
information on the session holding or waiting to hold each lock,
7099+
for example
7100+
<programlisting>
7101+
SELECT * FROM pg_locks pl LEFT JOIN pg_stat_activity psa
7102+
ON pl.pid = psa.procpid;
7103+
</programlisting>
70987104
Also, if you are using prepared transactions, the
7099-
<structfield>transaction</> column can be joined to the
7100-
<structfield>transaction</structfield> column of the
7101-
<structname>pg_prepared_xacts</structname> view to get more
7102-
information on prepared transactions that hold locks.
7105+
<structfield>virtualtransaction</> column can be joined to the
7106+
<structfield>transaction</structfield> column of the <link
7107+
linkend="view-pg-prepared-xacts"><structname>pg_prepared_xacts</structname></link>
7108+
view to get more information on prepared transactions that hold locks.
71037109
(A prepared transaction can never be waiting for a lock,
71047110
but it continues to hold the locks it acquired while running.)
7111+
For example:
7112+
<programlisting>
7113+
SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
7114+
ON pl.virtualtransaction = '-1/' || ppx.transaction;
7115+
</programlisting>
71057116
</para>
71067117

71077118
<para>

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