Skip site navigation (1) Skip section navigation (2)

Re: Detecting uncommitted changes

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Detecting uncommitted changes
Date: 2011-12-28 09:49:50
Message-ID: jdeong$9pk$1@dough.gmane.org (view raw or flat)
Thread:
Lists: pgsql-general
Tom Lane wrote on 28.12.2011 01:41:
> Thomas Kellerer<spam_eater(at)gmx(dot)net>  writes:
>> Tom Lane wrote on 27.12.2011 20:22:
>>> More specifically, look to see if the current transaction has assigned
>>> itself a transaction ID.  I think the easiest place to see this is in
>>> pg_locks --- it will be holding exclusive lock on a TransactionId object
>>> if so.
>
>> Thanks for the answer. I came up with the following statement:
>
>> select count(*)
>> from pg_locks
>> where pid = pg_backend_pid()
>> and locktype in ('transactionid')
>
>> does that look right to you?
>
> No.  You forgot the exclusive-lock condition.

Ah!

So this is it?

select count(*)
from pg_locks
where pid = pg_backend_pid()
and locktype in ('transactionid')
and mode = 'ExclusiveLock'

Thanks for your help

Thomas


In response to

pgsql-general by date

Next:From: hosureshDate: 2011-12-28 09:54:09
Subject: psql error: psql: symbol lookup error: psql: undefined symbol: PQconnectdbParams
Previous:From: RaghavendraDate: 2011-12-28 08:15:48
Subject: Re: Create XML elements from rows

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group