BUG #3240: Unexpected evaluation sequence

Поиск
Список
Период
Сортировка
От Kevin Macdonald
Тема BUG #3240: Unexpected evaluation sequence
Дата
Msg-id 200704182210.l3IMA3HZ066416@wwwmaster.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #3240: Unexpected evaluation sequence  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
The following bug has been logged online:

Bug reference:      3240
Logged by:          Kevin Macdonald
Email address:      kevin.macdonald@pentura.ca
PostgreSQL version: 8.2.3
Operating system:   Windows XP
Description:        Unexpected evaluation sequence
Details:

Take these two operations:

SQL> select currval ('seq')

returns 10

SQL> select currval ('seq'), nextval ('seq')

returns 10, 11

This is ok.

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). It seems that the value
of currval above should have been the value immediately before the SQL
statement was executed -- a value of 11.


Take this example for comparison:

SQL> create table foo (c1 integer, c2 integer)
SQL> insert into foo values (1, 1);
SQL> update foo set c1=c1+1, c2=c1
SQL> select c1, c2 from foo

returns (2, 1)

In this case, although the expression 'c1=c1+1' is executed before the
expression 'c2=c1', the value of 'c1' in the second expression is the value
immediately before the SQL statement was executed.

This behavior contrasts with that from the evaluation of the sequences
above.

Is this inconsistency done on purpose?

Thank you.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: ""
Дата:
Сообщение: BUG #3243: foreign key constraint not working?
Следующее
От: "William Lawrance"
Дата:
Сообщение: BUG #3244: problem with PREPARE