Re: Audtiting, DDL and DML in same SQL Function

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Christian Ramseyer <rc(at)networkz(dot)ch>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Audtiting, DDL and DML in same SQL Function
Date: 2012-02-02 09:32:22
Message-ID: CAEZATCXkOW7TYHS1qUyAovFRjj6Z1fqhjDTvxELHQChUK=6DMQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1 February 2012 22:29, Christian Ramseyer <rc(at)networkz(dot)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(at)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Saurabh 2012-02-02 10:26:13 Facing issue in online recovery of pgpool-II
Previous Message Venkat Balaji 2012-02-02 07:50:59 Re: [GENERA]: Postgresql-9.1.1 synchronous replication issue