Re: rows modified in current transaction

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Miroslav Šimulčík <simulcik(dot)miro(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: rows modified in current transaction
Date: 2012-08-30 16:17:17
Message-ID: 19815.1346343437@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Thu, Aug 30, 2012 at 10:36 AM, Miroslav imulk
> <simulcik(dot)miro(at)gmail(dot)com> wrote:
>> is there any way to check if row have already been modified by the current
>> transaction? I tried condition txid_current() = xmin, but there is problem
>> with the savepoints. After every savepoint rows are getting higher xmin
>> values, but txid_current() remains the same.

> It sounds like you're looking for a function that will give an array
> of all XIDs for the current transcation, rather than just the XID of
> the current sub-transaction. I don't think we currently expose that.

IIRC, txid_current() actually reflects the current *top* transaction,
which is why rows inserted by subtransactions aren't matching it.
But yeah, there's no exported way to identify all the XIDs belonging
to the current transaction.

A larger problem with the above is that txid isn't an XID anyway,
so the comparisons would fail altogether once the XID epoch becomes
more than zero. So if we did want to support this, it would be a
lot more useful to provide something along the lines of
xid_belongs_to_current_transaction(xid) returns bool
than to expose the XIDs as such.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2012-08-30 16:20:50 Re: rows modified in current transaction
Previous Message Andres Freund 2012-08-30 16:14:24 Re: splitting *_desc routines