Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f5MCbha48496 for ; Fri, 22 Jun 2001 08:37:43 -0400 (EDT) (envelope-from pgsql-interfaces-owner@postgresql.org) Received: from gl.aser.de (gl.aser.de [213.252.128.30]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5M90pa61840; Fri, 22 Jun 2001 05:00:52 -0400 (EDT) (envelope-from gcg@gl.aser.de) Received: from pinguin.gl.aser.de (pec-161-54.tnt9.b2.uunet.de [149.225.161.54]) by gl.aser.de (Postfix) with ESMTP id 47FE921DE3; Fri, 22 Jun 2001 11:13:41 +0200 (MEST) Received: from pinguin (pinguin.gl.aser.de [192.168.1.111]) by pinguin.gl.aser.de (Postfix) with SMTP id 800D312C69; Fri, 22 Jun 2001 10:38:39 +0200 (CEST) Content-Type: text/plain; charset="iso-8859-1" From: Christof Glaser Organization: gl.aser software engineering . internet service To: Markus Wagner , pgsql-interfaces , "pgsql-sql@postgresql.org" Subject: Re: [SQL] distinguishing different database connections Date: Fri, 22 Jun 2001 10:38:39 +0200 X-Mailer: KMail [version 1.2] References: <3B32FAD3.47A5A9D@imsd.uni-mainz.de> In-Reply-To: <3B32FAD3.47A5A9D@imsd.uni-mainz.de> MIME-Version: 1.0 Message-Id: <01062210383901.00729@pinguin> Content-Transfer-Encoding: 8bit X-Archive-Number: 200106/67 X-Sequence-Number: 1730 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: - 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. HTH. Christof