pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Guillaume Lelarge <guillaume@lelarge.info>
To: sad <sad@bankir.ru>
Cc: pgsql-sql@postgresql.org
Subject: Re: currval() within one statement
Date: Tue, 22 Jan 2008 11:22:15 +0100
Message-ID: <4795C3D7.6050209@lelarge.info> (raw)
In-Reply-To: <4795C20A.30606@bankir.ru>
References: <4795984E.7030904@bankir.ru>
	<20080122073637.GB21676@a-kretschmer.de>
	<4795A152.3080400@bankir.ru>
	<4795B3B6.5040004@lelarge.info>
	<4795C20A.30606@bankir.ru>

sad wrote:
> Guillaume Lelarge wrote:
>> sad wrote:
>>> A. Kretschmer wrote:
>>>
>>>>> is it expected that the currval() changes its value between calls 
>>>>> within one statement ?
>>>
>>>> Conclusion, don't call nextval() within a TRIGGER, and insert either
>>>> nextval() for the column or omit this column.
>>>
>>> I only note that i still want to discuss the titled problem or to be
>>> given an exact pointer to documentation regarding the currval() behavior
>>> in the described situation, that i had.
>>>
>>
>> Well, your situation is weird, to say the least. currval() doesn't 
>> change the value of a sequence. Adding a trigger that calls nextval() 
>> will change the value. But you're not telling us which kind of 
>> trigger... per statement or for each row ? if it's for each row, then 
>> that's quite understandable.
> 
> my fault --  i forgot to say.
> The trigger is "for each row".
> 
> It is understandable, i agree, but it is surprising -- alternative 
> behavior (constant result off currval()) is understandable too.
> 

It isn't surprising. A "for each row" trigger will execute the trigger 
function for each individual row, which will executes nextval each 
time... so each currval will get a different value.


-- 
Guillaume.
  http://www.postgresqlfr.org
  http://dalibo.com



view thread (11+ messages)  latest in thread

Message-ID: <4795C3D7.6050209@lelarge.info>
Permalink:  ../4795C3D7.6050209@lelarge.info/
Also on:    postgresql.org/message-id/4795C3D7.6050209@lelarge.info

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: guillaume@lelarge.info, sad@bankir.ru
  Subject: Re: currval() within one statement
  In-Reply-To: <4795C3D7.6050209@lelarge.info>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox