mirror of
https://github.com/postgres/postgres.git
synced 2025-09-08 00:47:37 +03:00
Make an editorial pass over the newly SGML-ified contrib documentation.
Fix lots of bad markup, bad English, bad explanations. Second round of commits. pgcrypto and pgstandby still to go...
This commit is contained in:
@@ -1,115 +1,122 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgrowlocks.sgml,v 1.4 2007/12/10 05:32:51 tgl Exp $ -->
|
||||
|
||||
<sect1 id="pgrowlocks">
|
||||
<title>pgrowlocks</title>
|
||||
|
||||
|
||||
<indexterm zone="pgrowlocks">
|
||||
<primary>pgrowlocks</primary>
|
||||
</indexterm>
|
||||
|
||||
<para>
|
||||
The <literal>pgrowlocks</literal> module provides a function to show row
|
||||
The <filename>pgrowlocks</filename> module provides a function to show row
|
||||
locking information for a specified table.
|
||||
</para>
|
||||
|
||||
<sect2>
|
||||
<title>Overview</title>
|
||||
<programlisting>
|
||||
pgrowlocks(text) RETURNS pgrowlocks_type
|
||||
</programlisting>
|
||||
|
||||
<synopsis>
|
||||
pgrowlocks(text) returns setof record
|
||||
</synopsis>
|
||||
|
||||
<para>
|
||||
The parameter is a name of table. And <literal>pgrowlocks_type</literal> is
|
||||
defined as:
|
||||
The parameter is the name of a table. The result is a set of records,
|
||||
with one row for each locked row within the table. The output columns
|
||||
are:
|
||||
</para>
|
||||
<programlisting>
|
||||
CREATE TYPE pgrowlocks_type AS (
|
||||
locked_row TID, -- row TID
|
||||
lock_type TEXT, -- lock type
|
||||
locker XID, -- locking XID
|
||||
multi bool, -- multi XID?
|
||||
xids xid[], -- multi XIDs
|
||||
pids INTEGER[] -- locker's process id
|
||||
);
|
||||
</programlisting>
|
||||
|
||||
<table>
|
||||
<title>pgrowlocks_type</title>
|
||||
<tgroup cols="2">
|
||||
<title><function>pgrowlocks</> output columns</title>
|
||||
|
||||
<tgroup cols="3">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<row>
|
||||
<entry>locked_row</entry>
|
||||
<entry>tuple ID(TID) of each locked rows</entry>
|
||||
<entry><structfield>locked_row</structfield></entry>
|
||||
<entry><type>tid</type></entry>
|
||||
<entry>Tuple ID (TID) of locked row</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>lock_type</entry>
|
||||
<entry>"Shared" for shared lock, "Exclusive" for exclusive lock</entry>
|
||||
<entry><structfield>lock_type</structfield></entry>
|
||||
<entry><type>text</type></entry>
|
||||
<entry><literal>Shared</> for shared lock, or
|
||||
<literal>Exclusive</> for exclusive lock</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>locker</entry>
|
||||
<entry>transaction ID of locker (Note 1)</entry>
|
||||
<entry><structfield>locker</structfield></entry>
|
||||
<entry><type>xid</type></entry>
|
||||
<entry>Transaction ID of locker, or multixact ID if multi-transaction</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>multi</entry>
|
||||
<entry>"t" if locker is a multi transaction, otherwise "f"</entry>
|
||||
<entry><structfield>multi</structfield></entry>
|
||||
<entry><type>boolean</type></entry>
|
||||
<entry>True if locker is a multi-transaction</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>xids</entry>
|
||||
<entry>XIDs of lockers (Note 2)</entry>
|
||||
<entry><structfield>xids</structfield></entry>
|
||||
<entry><type>xid[]</type></entry>
|
||||
<entry>Transaction IDs of lockers (more than one if multi-transaction)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>pids</entry>
|
||||
<entry>process ids of locking backends</entry>
|
||||
<entry><structfield>pids</structfield></entry>
|
||||
<entry><type>integer[]</type></entry>
|
||||
<entry>Process IDs of locking backends (more than one if multi-transaction)</entry>
|
||||
</row>
|
||||
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
<para>
|
||||
Note1: If the locker is multi transaction, it represents the multi ID.
|
||||
</para>
|
||||
<para>
|
||||
Note2: If the locker is multi, multiple data are shown.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The calling sequence for <literal>pgrowlocks</literal> is as follows:
|
||||
<literal>pgrowlocks</literal> grabs AccessShareLock for the target table and
|
||||
reads each row one by one to get the row locking information. You should
|
||||
notice that:
|
||||
<function>pgrowlocks</function> takes <literal>AccessShareLock</> for the
|
||||
target table and reads each row one by one to collect the row locking
|
||||
information. This is not very speedy for a large table. Note that:
|
||||
</para>
|
||||
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
if the table is exclusive locked by someone else,
|
||||
<literal>pgrowlocks</literal> will be blocked.
|
||||
If the table as a whole is exclusive-locked by someone else,
|
||||
<function>pgrowlocks</function> will be blocked.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>pgrowlocks</literal> may show incorrect information if there's a
|
||||
new lock or a lock is freeed while its execution.
|
||||
<function>pgrowlocks</function> is not guaranteed to produce a
|
||||
self-consistent snapshot. It is possible that a new row lock is taken,
|
||||
or an old lock is freed, during its execution.
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
|
||||
<para>
|
||||
<literal>pgrowlocks</literal> does not show the contents of locked rows. If
|
||||
you want to take a look at the row contents at the same time, you could do
|
||||
something like this:
|
||||
</para>
|
||||
<function>pgrowlocks</function> does not show the contents of locked
|
||||
rows. If you want to take a look at the row contents at the same time, you
|
||||
could do something like this:
|
||||
|
||||
<programlisting>
|
||||
SELECT * FROM accounts AS a, pgrowlocks('accounts') AS p WHERE p.locked_ row = a.ctid;
|
||||
SELECT * FROM accounts AS a, pgrowlocks('accounts') AS p
|
||||
WHERE p.locked_row = a.ctid;
|
||||
</programlisting>
|
||||
|
||||
Be aware however that (as of <productname>PostgreSQL</> 8.3) such a
|
||||
query will be very inefficient.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
<title>Example</title>
|
||||
<para>
|
||||
<literal>pgrowlocks</literal> returns the following columns:
|
||||
</para>
|
||||
<para>
|
||||
Here is a sample execution of pgrowlocks:
|
||||
</para>
|
||||
<title>Sample output</title>
|
||||
|
||||
<programlisting>
|
||||
test=# SELECT * FROM pgrowlocks('t1');
|
||||
locked_row | lock_type | locker | multi | xids | pids
|
||||
locked_row | lock_type | locker | multi | xids | pids
|
||||
------------+-----------+--------+-------+-----------+---------------
|
||||
(0,1) | Shared | 19 | t | {804,805} | {29066,29068}
|
||||
(0,2) | Shared | 19 | t | {804,805} | {29066,29068}
|
||||
@@ -117,7 +124,14 @@ test=# SELECT * FROM pgrowlocks('t1');
|
||||
(0,4) | Exclusive | 804 | f | {804} | {29066}
|
||||
(4 rows)
|
||||
</programlisting>
|
||||
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
<sect2>
|
||||
<title>Author</title>
|
||||
|
||||
<para>
|
||||
Tatsuo Ishii
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
|
Reference in New Issue
Block a user