From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Kevin Macdonald" <kevin(dot)macdonald(at)pentura(dot)ca> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #3240: Unexpected evaluation sequence |
Date: | 2007-04-20 04:58:57 |
Message-ID: | 16887.1177045137@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
"Kevin Macdonald" <kevin(dot)macdonald(at)pentura(dot)ca> writes:
> Now, take these two operations:
> SQL> select currval ('seq')
> returns 11
> SQL> select nextval ('seq'), currval ('seq')
> returns (12, 12)
> I would have expected it to have returned (12, 11).
No, because currval reports the latest nextval result in your session,
and the nextval has already been executed. This is dependent on order
of execution of select-list items, but at the moment that's always
left-to-right.
> It seems that the value
> of currval above should have been the value immediately before the SQL
> statement was executed -- a value of 11.
Since sequence operations are non-transactional by definition, I'm not
really sure why you'd expect that.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-04-20 05:06:48 | Re: BUG #3243: foreign key constraint not working? |
Previous Message | Tom Lane | 2007-04-19 20:36:13 | Re: BUG #3245: PANIC: failed to re-find shared lock object |