Re: txid_current() forces a real xid

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Marko Kreen <markokr(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: txid_current() forces a real xid
Date: 2011-07-12 00:33:04
Message-ID: 201107120033.p6C0X4628656@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Marko Kreen wrote:
> On Mon, Jul 11, 2011 at 5:59 PM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > Right now, calling txid_current() causes a session to create a
> > non-virtual xid if not already assigned, so observing the xid creates
> > it, which seems kind of odd. ?Is that intended? ?Here is the C code:
>
> Yes, it was intentional, the value will be written out.
>
> It could be even called before actual writing statement is run
> so returning anything that will become invalid later during
> transaction is dangerous.
>
> If you have use-case that requires frequent calling of that function
> in read-only transaction, and prefer to see virtual txids
> I suggest implementing it as new function.

No, I just considered it strange that it assigned a permenant xid by
asking for the value.

I have added a C comment documenting this behavior.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2011-07-12 01:03:05 Re: ToDo: list of active channels
Previous Message Andrew Dunstan 2011-07-12 00:10:42 Re: marking old branches as no longer maintained