Re: Comparing txid_current() to xmin

Поиск
Список
Период
Сортировка
От Marko Kreen
Тема Re: Comparing txid_current() to xmin
Дата
Msg-id CACMqXCK0V723TRPEsX_HZW9NiRzpMX=bF6AxhkyC6YuXHjp0gA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Comparing txid_current() to xmin  (Andres Freund <andres@anarazel.de>)
Ответы Re: Comparing txid_current() to xmin  (Andres Freund <andres@2ndquadrant.com>)
Список pgsql-general
On Wed, Nov 7, 2012 at 10:21 AM, Andres Freund <andres@anarazel.de> wrote:
> On Tue, Nov 06, 2012 at 02:55:40PM -0800, Mike Lewis wrote:
>> I am trying to make a trigger that updates a row once and only once per
>> transaction (even if this trigger gets fired multiple times).  The general
>> idea is that for a user we have a version number.  When we modify the
>> user's data, the version number is incremented then set on the object.  We
>> only need to increment the version number once.
>>
>> I am thinking about doing something like:
>>
>> update user
>> set version=version+1
>> where txid_current() != xmin and user_id = 352395;
>>
>>
>> So I guess my questions are:
>>
>> How dirty is this?
>> Will I run into issues?
>
> It won't work in the presenence of subtransactions and is a bit more
> complicated if you inserted the row in the same transaction.

This can be solved by storing txid_current() into row
and using that in comparision instead xmin/xmax.


--
marko


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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: find a substring on a text (data type) column
Следующее
От: Carlos Henrique Reimer
Дата:
Сообщение: Running out of memory while making a join