Re: currval and DISCARD ALL

From: Nigel Heron <nigel(at)psycode(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
Subject: Re: currval and DISCARD ALL
Date: 2013-04-16 15:07:44
Message-ID: 516D6940.7010004@psycode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers


On 04/15/2013 05:57 PM, Adrian Klaver wrote:
> On 04/15/2013 02:42 PM, Nigel Heron wrote:
>> 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.
>>
<snip>
> Might want to take a look at:
>
> http://www.depesz.com/2012/12/02/what-is-the-point-of-bouncing/
>
> for some hints on dealing with sequences and pgBouncer.
>

thanks, I read it (his blogs are always interesting!). I'm not disputing
that calling currval() at the wrong time is a bad idea.
I'm just wondering why DISCARD ALL clears everything but this?
from the docs:
"DISCARD ALL resets a session to its original state, discarding
temporary resources and resetting session-local configuration changes."
.. but at the beginning of a session currval(foo) would return an error,
whereas calling nexval(foo); DISCARD ALL; currval(foo); does not return
an error.. clearly something isn't getting reset to the original state.

If you create a TEMP sequence, then DISCARD ALL does clear the state,
probably because the underlying table disappears.

-nigel.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message wk 2013-04-16 15:46:30 configure --enable-dtrace (systemtap) on centos6.4 x86_32,/usr/bin/stap: invalid option -- 'C'
Previous Message Philipp Kraus 2013-04-16 14:50:23 dataset lock

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2013-04-16 15:43:59 Re: COPY and Volatile default expressions
Previous Message Bruce Momjian 2013-04-16 14:10:37 Re: COPY and Volatile default expressions