Обсуждение: SessionID, pretty please

Поиск
Список
Период
Сортировка

SessionID, pretty please

От
tom.darci@gmail.com
Дата:
Hello All-

  I am in the process of replacing the backend for a large MS Access
project with PG.

  I really could use a Session ID. I would like to create a view like
this:

CREATE VIEW mysettings
    AS
    SELECT * FROM mysettingstable
    WHERE sessionidcolumn = CURRENTSESSIONID()

  It is essential that we be able to reference a session id without
passing it in, as this has to work within the "linked table" paradigm
of Access and a lot of Access forms that have already been developed.

  The TEMPORARY TABLE feature of PG seemed ideal for these purposes.
However, after burning many many days on 2 different attempts at
solving this using temp tables (first attempt used temp tables, second
attempt tried to use the name of the current temp schema as a unique
session id), I'm at my wits end, as I can't get this to work reliably
with Access and its linked tables...

  I see that the log_line_prefix can be set to a Session ID (using
'%c'). Is there any way to get the current value of this from a
function in PG? (current_setting() simply returns the configuration
string, not its actual value.)

  My troubles would be solved if I could reference a SessionID from
within PG. Any hope?

THANKS,
-Tom


Re: SessionID, pretty please

От
Tom Lane
Дата:
tom.darci@gmail.com writes:
>   My troubles would be solved if I could reference a SessionID from
> within PG. Any hope?

Create a sequence.  At session start, nextval() it to assign a session
ID for your session.  Then currval() returns your session ID whenever
you need it.

            regards, tom lane

Re: SessionID, pretty please

От
"Tom D"
Дата:
thanks.

Tom Lane wrote:
> tom.darci@gmail.com writes:
> >   My troubles would be solved if I could reference a SessionID from
> > within PG. Any hope?
>
> Create a sequence.  At session start, nextval() it to assign a session
> ID for your session.  Then currval() returns your session ID whenever
> you need it.
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org so that your
>        message can get through to the mailing list cleanly