Re: Are rules transaction safe?

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Oliver Fürst <ofuerst(at)tsak(dot)net>
Cc: Doug McNaught <doug(at)mcnaught(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: Are rules transaction safe?
Date: 2006-01-30 10:53:28
Message-ID: 43DDF028.20809@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)magproductions(dot)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//

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2006-01-30 11:16:18 Re: Indexes
Previous Message Sim Zacks 2006-01-30 10:24:01 Re: schema rename sequence issue