Re: [SQL] distinguishing different database connections

From: Christof Glaser <gcg(at)gl(dot)aser(dot)de>
To: Markus Wagner <wagner(at)imsd(dot)uni-mainz(dot)de>, pgsql-interfaces <pgsql-interfaces(at)postgresql(dot)org>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: [SQL] distinguishing different database connections
Date: 2001-06-22 08:38:39
Message-ID: 01062210383901.00729@pinguin
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces pgsql-sql

Hi Markus,

On Friday, 22. June 2001 09:59, Markus Wagner wrote:
> Hi,
>
> can I access information on the current connection from within a
> trigger function?
> I need to identify different server connections somehow. Something
> like a "connection id" would be enough.

I think, there is no such thing like a connection id.

> The background:
>
> When a user starts a frontend application (NT, Access) he starts a
> new connection to our Linux database server. But for all users the
> "postgres user" is the same, since the ODBC connection is hard linked
> into the application. The problem is that we need the NT user name
> within our trigger (C) functions.
>
> The idea:
> Let's execute a function "logon" whenever an instance of the
> application is started. This function will get the NT user name as a
> parameter. It will recognize the current connection id and it would
> store the pair (connection id, NT user name) in a table. Then,
> whenever some trigger needs to know the user name (for logging
> actions), it could lookup the user name with the current connection
> id.

What about looking how web applications handle this? A "session id",
which you have to manage yourself, might do what you want:

<just_an_idea>
- logon creates a session id
- actions that need to keep track of users should be done within
functions called by the client, providing the session id as a parameter.
</idea>

HTH.
Christof

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Alex Pilosov 2001-06-22 11:57:10 Re: [SQL] distinguishing different database connections
Previous Message Markus Wagner 2001-06-22 07:59:15 distinguishing different database connections

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2001-06-22 10:51:05 Re: pl/pgsql question (functions)
Previous Message Dariusz Pietrzak 2001-06-22 08:25:30 Re: Difference between insert a tuple in a table by function and by datasheet