Re: BUG #9840: Documentation bug on pg_locks

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: BUG #9840: Documentation bug on pg_locks
Дата
Msg-id CAB7nPqRP9KUeJmJtFLkwDPg5k-EDONO2taCT6=EoQd2qtErnWQ@mail.gmail.com
обсуждение исходный текст
Ответ на BUG #9840: Documentation bug on pg_locks  (bashtanov@imap.cc)
Ответы Re: BUG #9840: Documentation bug on pg_locks  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Thu, Apr 3, 2014 at 5:04 PM,  <bashtanov@imap.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

Вложения

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Configuring Standby Server in PostgreSQL 9.3.3
Следующее
От: Mike Blackwell
Дата:
Сообщение: Re: BUG #9518: temporary login failure - "missing pg_hba entry"