Re: Postgresql - Currval Vs Session Pool - Mailing list pgsql-general

From David Johnston
Subject Re: Postgresql - Currval Vs Session Pool
Date
Msg-id 1370796474223-5758522.post@n5.nabble.com
Whole thread Raw
In response to Postgresql - Currval Vs Session Pool  (Gustavo Amarilla Santacruz <gusamasan@gmail.com>)
List pgsql-general
Gustavo Amarilla Santacruz wrote
>
> In the PostgreSQL documentation I found "currval: Return the value most
> recently obtained by nextval for this sequence in the current session
> ...."
>
> ....
>
> Then, I have the following question: PostgreSQL differentiates between
> sessions created for the same user?

I have little familiarity with using curval/nextval directly, and my pooler
is Java-based and basically provides a "connection checkout mechanism" which
is behaves differently than pgpool, but...

In short, yes, a single database user can have more than one single session
active concurrently.  The call to "currval" returns the (basically cached)
value that was last issued via a call to "nextval" inside the current
session.  The definition, behavior, and scope of a session will be noted in
the pooler's documentation.

Assuming transaction-level pooling then CONNECTION_01 and _02 calls to
"currval" will return different values that corresponding to whatever value
was acquired during the "nextval" call the happened during the insert into
the "head" table during the same transaction.

A pooler will, at some point, cause a connection's session to be reset.
When this happens depends on the pooler and its configuration.  While the
connection itself remains active all session-level state is discarded during
the reset so for all intents and purposes it is like a brand-new connection.
The only difference is that the underlying connection handler process is not
killed and the user is not required to login again - both of which are
time-intensive actions.

David J.






--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Postgresql-Currval-Vs-Session-Pool-tp5758517p5758522.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


pgsql-general by date:

Previous
From: Gustavo Amarilla Santacruz
Date:
Subject: Postgresql - Currval Vs Session Pool
Next
From: Tom Lane
Date:
Subject: Re: User postgres unable to revoke privileges?