Re: How to check whether the row was modified by this transaction before? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: How to check whether the row was modified by this transaction before?
Date
Msg-id 6067.1354816426@sss.pgh.pa.us
Whole thread Raw
In response to How to check whether the row was modified by this transaction before?  (Vlad Arkhipov <arhipov@dc.baikal.ru>)
Responses Re: How to check whether the row was modified by this transaction before?
Re: How to check whether the row was modified by this transaction before?
List pgsql-hackers
Vlad Arkhipov <arhipov@dc.baikal.ru> writes:
> In a BEFORE UPDATE trigger I need to know whether the row was previously 
> modified by this transaction. Is it safe to use xmin and txid_current() 
> for this purpose (xmin is 32-bit txid type but txid_current() returns 
> 64-bit bigint).

>    IF OLD.xmin = txid_current() THEN

Comparing to txid_current() mod 2^32 would probably work, but note this
will not think that subtransactions or parent transactions are "this
transaction", so any use of savepoints or plpgsql exception blocks is
likely to cause headaches.  Why do you think you need to know this?
        regards, tom lane



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: How to check whether the row was modified by this transaction before?
Next
From: Alvaro Herrera
Date:
Subject: Re: Fix for pg_upgrade status display