From: Achilleus Mantzios <achill@matrix.gatewaynet.com>
To: Richard Huxton <dev@archonet.com>
Cc: abief_ag_-postgresql@yahoo.com, <pgsql-sql@postgresql.org>
Subject: Re: session_id
Date: Wed, 17 Nov 2004 16:33:03 +0200 (EET)
Message-ID: <Pine.LNX.4.44.0411171629170.8373-100000@matrix.gatewaynet.com> (raw)
In-Reply-To: <419B56CC.8090703@archonet.com>
O Richard Huxton Ýãñáøå óôéò Nov 17, 2004 :
> Riccardo G. Facchini wrote:
> > hi all,
> >
> > is there a way to determine the session id on a database session?
> >
> > I would need to have a unique number whenever a session is started, and
> > have this available as a function or view result.
Why not SELECT pg_backend_pid();
??
>
> Add a new sequence to your database:
> CREATE SEQUENCE my_session_id;
>
> Then, at the start of every session:
> SELECT nextval('my_session_id');
>
> and whenever you need the value:
> SELECT currval('my_session_id');
>
> Sequences are concurrency-safe, so you're OK with multiple clients. They
> return INT8 values, so you should be good for unique numbers for a while.
>
> The only thing is, you need to remember to call nextval() every time you
> connect.
>
> HTH
>
--
-Achilleus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: achill@matrix.gatewaynet.com, dev@archonet.com
Subject: Re: session_id
In-Reply-To: <Pine.LNX.4.44.0411171629170.8373-100000@matrix.gatewaynet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox