pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: sad <sad@bankir.ru>
To: Richard Huxton <dev@archonet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: currval() within one statement
Date: Tue, 22 Jan 2008 13:22:32 +0300
Message-ID: <4795C3E8.9080607@bankir.ru> (raw)
In-Reply-To: <4795B3D4.5020201@archonet.com>
References: <4795984E.7030904@bankir.ru>
	<20080122073637.GB21676@a-kretschmer.de>
	<4795A152.3080400@bankir.ru>
	<4795B3D4.5020201@archonet.com>

Richard Huxton 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, the page in the docs isn't hard to find -
>  http://www.postgresql.org/docs/8.2/static/functions-sequence.html
> 
> But surely it works exactly as you would expect it to.
> 
> nextval(S) advances the sequence and returns the new value
> 
> currval(S) returns the current value of sequence S, which is whatever 
> the previous call to nextval(S) returned. In the even you haven't called 
>  nextval(S) then it is undefined.

Then this is the question on the execution order of the statement 
INSERT...SELECT...

> What do you think should happen?

I had expected all the currval() calls to be called before all the 
triggers fired.





view thread (11+ messages)  latest in thread

Message-ID: <4795C3E8.9080607@bankir.ru>
Permalink:  ../4795C3E8.9080607@bankir.ru/
Also on:    postgresql.org/message-id/4795C3E8.9080607@bankir.ru

 · 

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: sad@bankir.ru, dev@archonet.com
  Subject: Re: currval() within one statement
  In-Reply-To: <4795C3E8.9080607@bankir.ru>

* 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