currval and DISCARD ALL

Поиск
Список
Период
Сортировка
От Nigel Heron
Тема currval and DISCARD ALL
Дата
Msg-id 516C7439.7040008@psycode.com
обсуждение исходный текст
Ответы Re: currval and DISCARD ALL  (Adrian Klaver <adrian.klaver@gmail.com>)
Список pgsql-general
Hi,
is there a way to clear the session state of sequence values fetched by
currval(regclass)? "DISCARD ALL" doesn't seem to do it.

eg. (w/ pg 9.2.4)
test=# CREATE SEQUENCE foo_seq;
CREATE SEQUENCE
test=# SELECT nextval('foo_seq');
-[ RECORD 1 ]
nextval | 1

test=# SELECT currval('foo_seq');
-[ RECORD 1 ]
currval | 1

test=# DISCARD ALL;
DISCARD ALL
test=# SELECT currval('foo_seq');
-[ RECORD 1 ]
currval | 1


I'm trying to migrate a large web app to work with pgbouncer's
transaction pool mode and it would be easier to identify issues if
currval() would return the usual "ERROR:  currval of sequence "foo_seq"
is not yet defined in this session" if nextval() wasn't called in the
same pgbouncer session instead of getting old numbers from past
transactions.


thanks,
-nigel.


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Role Authentication Failure
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: currval and DISCARD ALL