From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | bashtanov(at)imap(dot)cc |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #9840: Documentation bug on pg_locks |
Date: | 2014-04-03 11:58:42 |
Message-ID: | CAB7nPqRP9KUeJmJtFLkwDPg5k-EDONO2taCT6=EoQd2qtErnWQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Thu, Apr 3, 2014 at 5:04 PM, <bashtanov(at)imap(dot)cc> wrote:
> However, there is no "transaction" column in pg_locks.
>
> Neither transactionid nor virtualtransaction could be the mentioned column
> as transactionid is "null if the target is not a transaction ID" and
> virtualtransaction has different column data type.
Yes, documentation is unclear, but even if virtualtransaction has text
as data type, it is the combination of backendID/TransactionID so you
could use that for a join with pg_prepared_xacts like that:
=# create table aa (a int);
CREATE TABLE
=# begin;
BEGIN
=# insert into aa values (1);
INSERT 0 1
=# prepare transaction 'toto';
PREPARE TRANSACTION
=# select locktype, mode, gid, relation
from pg_locks pl
join pg_prepared_xacts ppx on
ppx.transaction = split_part(pl.virtualtransaction, '/', 2)::xid;
locktype | mode | gid | relation
---------------+------------------+------+----------
relation | RowExclusiveLock | toto | 16385
transactionid | ExclusiveLock | toto | null
(2 rows)
At the same time, I am attaching a doc patch recommending using
virtualtransaction instead of transaction in pg_locks when doing a
join with pg_prepared_xacts.
Regards,
--
Michael
Attachment | Content-Type | Size |
---|---|---|
20140403_pg_locks_docfix.patch | text/plain | 679 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Mike Blackwell | 2014-04-03 14:39:52 | Re: BUG #9518: temporary login failure - "missing pg_hba entry" |
Previous Message | Heikki Linnakangas | 2014-04-03 10:43:30 | Re: Configuring Standby Server in PostgreSQL 9.3.3 |