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

From: Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Subject: How to check whether the row was modified by this transaction before?
Date: 2012-12-06 08:58:22
Message-ID: 50C05E2E.4080602@dc.baikal.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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
IF OLD.xmin = txid_current() THEN
-- Do something.
ELSE
-- Do something else.
END IF;
END;
$$ LANGUAGE plpgsql;

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavan Deolasee 2012-12-06 09:31:21 Setting visibility map in VACUUM's second phase
Previous Message Pavel Stehule 2012-12-06 05:31:16 Re: why can't plpgsql return a row-expression?