Skip site navigation (1) Skip section navigation (2)

Re: User Context Variables

From: Keith Worthington <KeithW(at)NarrowPathInc(dot)com>
To: Shawn Garbett <shawn_garbett(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: User Context Variables
Date: 2005-07-16 12:40:34
Message-ID: 42D90042.6000808@NarrowPathInc.com (view raw or flat)
Thread:
Lists: pgsql-novice
Shawn Garbett wrote:
> I need to trap some audit information in PostgreSQL.
> Currently we have it working Oracle and it stores the
> authenticated user in the sys_context so that a
> trigger just does a "select userenv('client_info')
> from dual;" and all the necessary magic is handled.
> The reasons for this are complex, it involves
> connection pooling, detached web sessions, etc. It's a
> very elegant solution when using Oracle.
> 
> I'm having trouble figuring out how to do it in
> PostgreSQL. So what I need is a way to save a single
> value in a connection for a set of triggers to use
> that is only valid during a transaction. A place to
> store a user variable like sys context would work, a
> temporary table would work, or some mysterious
> function that did the equivalent would work. I can't
> figure out if these are possible under PostgreSQL. 
> 
> Shawn

Shawn,

How about using current_user and session_user?

http://www.postgresql.org/docs/8.0/interactive/functions-info.html

-- 
Kind Regards,
Keith

In response to

pgsql-novice by date

Next:From: Tom LaneDate: 2005-07-16 14:58:01
Subject: Re: Preserving Timestamp Information
Previous:From: Lola LeeDate: 2005-07-16 11:52:41
Subject: Preserving Timestamp Information

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group