Re: Audtiting, DDL and DML in same SQL Function - Mailing list pgsql-general

From Dean Rasheed
Subject Re: Audtiting, DDL and DML in same SQL Function
Date
Msg-id CAEZATCXkOW7TYHS1qUyAovFRjj6Z1fqhjDTvxELHQChUK=6DMQ@mail.gmail.com
Whole thread Raw
In response to Audtiting, DDL and DML in same SQL Function  (Christian Ramseyer <rc@networkz.ch>)
List pgsql-general
On 1 February 2012 22:29, Christian Ramseyer <rc@networkz.ch> wrote:
> Hello list
>
> I'm trying to build a little trigger-based auditing for various web
> applications. They have many users in the application layer, but they
> all use the same Postgres DB and DB user.
>
> So I need some kind of session storage to save this application level
> username for usage in my triggers, which AFAIK doesn't exist in
> Postgres. Googling suggested to use a temporary table to achieve
> something similar.
>
> Question 1: Is this really the right approach to implement this, or are
> there other solutions, e.g. setting application_name to user@application
> and using this in the triggers or similar workarounds?
>

There's an example in the manual of another way to keep
session-specific data:
http://www.postgresql.org/docs/current/static/plperl-global.html

You can do similar things in other procedural languages too, just not
in PL/pgSQL.

Regards,
Dean

pgsql-general by date:

Previous
From: Venkat Balaji
Date:
Subject: Re: [GENERA]: Postgresql-9.1.1 synchronous replication issue
Next
From: Saurabh
Date:
Subject: Facing issue in online recovery of pgpool-II