| From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)ru>, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: How to check whether the row was modified by this transaction before? |
| Date: | 2012-12-06 18:08:51 |
| Message-ID: | 20121206180851.GB4299@alvh.no-ip.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Tom Lane wrote:
> Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)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,
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.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2012-12-06 18:14:42 | Re: in-catalog Extension Scripts and Control parameters (templates?) |
| Previous Message | Tom Lane | 2012-12-06 18:01:33 | Re: Setting visibility map in VACUUM's second phase |