[HACKERS] How to check whether the row was modified by this transaction before?

2012-12-06 Thread Vlad Arkhipov
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). CREATE FUNCTION test_trigger() RETURNS TRIGGER AS $$ BEGIN

Re: [HACKERS] How to check whether the row was modified by this transaction before?

2012-12-06 Thread Robert Haas
On Thu, Dec 6, 2012 at 3:58 AM, Vlad Arkhipov arhi...@dc.baikal.ru wrote: 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

Re: [HACKERS] How to check whether the row was modified by this transaction before?

2012-12-06 Thread Tom Lane
Vlad Arkhipov arhi...@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

Re: [HACKERS] How to check whether the row was modified by this transaction before?

2012-12-06 Thread Alvaro Herrera
Tom Lane wrote: Vlad Arkhipov arhi...@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

Re: [HACKERS] How to check whether the row was modified by this transaction before?

2012-12-06 Thread Tom Lane
Alvaro Herrera alvhe...@2ndquadrant.com writes: I think we should be setting the initial epoch to something other than zero. That way, some quick testing would have revealed this problem immediately. Yeah, having initdb start the epoch at 1 doesn't seem unreasonable.

Re: [HACKERS] How to check whether the row was modified by this transaction before?

2012-12-06 Thread Tom Lane
Andres Freund and...@2ndquadrant.com writes: On 2012-12-06 15:08:51 -0300, Alvaro Herrera wrote: Vlad Arkhipov arhi...@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

Re: [HACKERS] How to check whether the row was modified by this transaction before?

2012-12-06 Thread Vlad Arkhipov
On 12/07/2012 02:53 AM, Tom Lane wrote: Vlad Arkhipov arhi...@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()