Re: Are rules transaction safe? - Mailing list pgsql-general

From Alban Hertroys
Subject Re: Are rules transaction safe?
Date
Msg-id 43DDF028.20809@magproductions.nl
Whole thread Raw
In response to Re: Are rules transaction safe?  (Oliver Fürst <ofuerst@tsak.net>)
List 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 by date:

Previous
From: Sim Zacks
Date:
Subject: Re: schema rename sequence issue
Next
From: Alban Hertroys
Date:
Subject: Re: Indexes