Re: why does txid_current() assign new transaction-id?

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: why does txid_current() assign new transaction-id?
Дата
Msg-id CAB7nPqSVDhHWmYrc5Tt35N2WtZG88H+FGRxDF-G89mJ1DLRsEA@mail.gmail.com
обсуждение исходный текст
Ответ на why does txid_current() assign new transaction-id?  (Naoya Anzai <nao-anzai@xc.jp.nec.com>)
Ответы Re: why does txid_current() assign new transaction-id?  (Naoya Anzai <nao-anzai@xc.jp.nec.com>)
Список pgsql-hackers
On Tue, May 26, 2015 at 4:12 PM, Naoya Anzai <nao-anzai@xc.jp.nec.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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: RFC: Non-user-resettable SET SESSION AUTHORISATION
Следующее
От: Abhijit Menon-Sen
Дата:
Сообщение: Re: fsync-pgdata-on-recovery tries to write to more files than previously