From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
Cc: | "Pavel Stehule *EXTERN*" <pavel(dot)stehule(at)gmail(dot)com>, Durumdara <durumdara(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Unique Session ID in PGSQL? |
Date: | 2011-05-20 00:07:39 |
Message-ID: | BANLkTi=SsDEsEgoSqGyhyOC_5S=dVMVBbg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, May 19, 2011 at 4:21 AM, Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> wrote:
> Pavel Stehule wrote:
>>> Is there any function in PGSQL that returns an unique Session
>>> identifier of the actual session?
>>> For example a Bigint, or GUID, or etc?
>>> Can I get the living Session identifiers from PG?
>>
>> try
>>
>> postgres=# select pg_backend_pid();
>> pg_backend_pid
>> ----------------
>> 17327
>> (1 row)
>
> I don't totally understand the intended use, but process IDs have the
> problem that they will get reused eventually.
>
> So if that's not good enough, you can construct a session ID like
> %c in log_line_prefix with the query found in the documentation:
no, but pid + backend_start_time *is* enough -- the backend session is
generated directly from them. I personally wouldn't use the hex
version -- pointless obfuscation -- I would just maintain pid+start
time as the session if I wasn't worried about the session being
guessed, and a salted digest of those two values if I was.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2011-05-20 06:26:44 | Re: Memcached for Database server |
Previous Message | Bosco Rama | 2011-05-19 21:14:06 | Re: ECPG selecting into char arrays |