Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f5MCaca48003 for ; Fri, 22 Jun 2001 08:36:38 -0400 (EDT) (envelope-from pgsql-interfaces-owner@postgresql.org) Received: from spider.pilosoft.com (p55-222.acedsl.com [160.79.55.222]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5MBlBa25798; Fri, 22 Jun 2001 07:47:11 -0400 (EDT) (envelope-from alex@acecape.com) Received: from localhost (alexmail@localhost) by spider.pilosoft.com (8.9.3/8.9.3) with ESMTP id HAA13674; Fri, 22 Jun 2001 07:57:10 -0400 (EDT) X-Authentication-Warning: spider.pilosoft.com: alexmail owned process doing -bs Date: Fri, 22 Jun 2001 07:57:10 -0400 (EDT) From: Alex Pilosov X-Sender: alexmail@spider.pilosoft.com To: Markus Wagner cc: pgsql-interfaces , "pgsql-sql@postgresql.org" Subject: Re: [SQL] distinguishing different database connections In-Reply-To: <3B32FAD3.47A5A9D@imsd.uni-mainz.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200106/65 X-Sequence-Number: 1728 You can use backend's PID from a trigger, it is unique. On Fri, 22 Jun 2001, 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. > > 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. > > Can we do this? Please help. > > Thank you very much, > > Markus > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > > -- -- Alex Pilosov | http://www.acedsl.com/home.html CTO - Acecape, Inc. | AceDSL:The best ADSL in Bell Atlantic area 325 W 38 St. Suite 1005 | (Stealth Marketing Works! :) New York, NY 10018 |