function to return pg_user.usesysid - Mailing list pgsql-hackers

From Dr. Ernst Molitor
Subject function to return pg_user.usesysid
Date
Msg-id 1044619436.13636.53.camel@mibi02
Whole thread Raw
Responses Re: function to return pg_user.usesysid
Re: function to return pg_user.usesysid
List pgsql-hackers
Dear PostgreSQL developers, 

as far as I know, there is no function available to directly access the
user id (pg_(shadow|user).usesysid) 
of the current database user, while the user's name is easily available
(function current_user). 

For a couple of databases I'm using or designing, it is necessary to
keep track of who has changed what and when - a job perfectly easy with
the timetravel add-on (contrib/spi). Using usesysid instead of a user
name to keep track of who has entered/changed/deleted data in a certain
record offers saving a few bytes per record, so I wrote a _very small_
add-on to directly access the usesysid information, using the function
GetUserId(). 

This is hardly worth mentioning since it consists of just a few lines of
code, but maybe some other users might find it useful. If so, please
feel free to make it available publicly. The few lines are available at
http://mibi03.meb.uni-bonn.de/~ernst/pgsql_userid.tar.gz

Hm, by the way, what about adding a function like current_userid to the
core functionality of PostgreSQL?

Best regards, 

Ernst







pgsql-hackers by date:

Previous
From: Elias Athanasopoulos
Date:
Subject: cvs (7/2/2003) is broken?
Next
From: greg@turnstep.com
Date:
Subject: Re: PGP signing releases