Re: Are rules transaction safe?

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Are rules transaction safe?
Дата
Msg-id 43DDF028.20809@magproductions.nl
обсуждение исходный текст
Ответ на Re: Are rules transaction safe?  (Oliver Fürst <ofuerst@tsak.net>)
Список pgsql-general
Oliver Fürst wrote:
>> 'currval()' is specifically written to Do The Right Thing.  See the
>> docs.
>
> My problem isn't answered in the manual, otherwise I wouldn't have
> asked. I know that sequences are working correct for transactions
> (either implicit or explicit).
>
> But is nowhere stated if (multiple) commands inside a rule are treated
> as an implicit transaction as a whole.

Sequences aren't related to transactions the way you seem to think.
Every time you request a nextval, no matter in what transaction you are,
you get a new value (higher, with the exception of the wraparound case).

I suppose currval always matches the last result of nextval in your
transaction (as manipulated by your queries). Can't say I'm certain, but
that's something that can easily be tested.

I don't know the implementation details of sequences in PostgreSQL, but
that's how sequences are supposed to work. They do (as stated before)
"The Right Thing". You don't need to worry about them.

--
Alban Hertroys
alban@magproductions.nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
    7500 AK Enschede

//Showing your Vision to the World//


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

Предыдущее
От: Sim Zacks
Дата:
Сообщение: Re: schema rename sequence issue
Следующее
От: Alban Hertroys
Дата:
Сообщение: Re: Indexes