From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | Naoya Anzai <nao-anzai(at)xc(dot)jp(dot)nec(dot)com> |
Cc: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Akio Iwaasa <aki-iwaasa(at)vt(dot)jp(dot)nec(dot)com> |
Subject: | Re: why does txid_current() assign new transaction-id? |
Date: | 2015-05-27 03:39:44 |
Message-ID: | CAB7nPqSVDhHWmYrc5Tt35N2WtZG88H+FGRxDF-G89mJ1DLRsEA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, May 26, 2015 at 4:12 PM, Naoya Anzai <nao-anzai(at)xc(dot)jp(dot)nec(dot)com> wrote:
> I have a question about txid_current().
> it is "Why does txid_current() assign new transaction-id?".
>
> When we executes txid_current() outside of transaction block, it assigns new transaction-id.
> I guess it doesn't need to assign a new txid because txid_current() is just a read-only function.
>
> I found a replaceable function by walking through pg-code, that is GetStableLatestTransactionId(void).
>
> I attached a patch which changing just 1-line.
> Could you please check the code?
txid_current has had the behavior of assigning a new transaction XID
when one is not assigned since its introduction. I don't think that it
is wise to change it now the way you do as many applications surely
rely on this assumption. Perhaps we could make the documentation
clearer about those things though, changing the description of this
function to "get current transaction ID, and assign a new one if one
is not assigned yet":
http://www.postgresql.org/docs/devel/static/functions-info.html
Regards,
--
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | Abhijit Menon-Sen | 2015-05-27 06:16:39 | Re: fsync-pgdata-on-recovery tries to write to more files than previously |
Previous Message | Robert Haas | 2015-05-27 02:06:59 | Re: RFC: Non-user-resettable SET SESSION AUTHORISATION |