Re: Select Column Auditing/Logging - Mailing list pgsql-general

From Sam Mason
Subject Re: Select Column Auditing/Logging
Date
Msg-id 20090722225815.GV5407@samason.me.uk
Whole thread Raw
In response to Re: Select Column Auditing/Logging  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-general
On Wed, Jul 22, 2009 at 02:41:41PM -0700, Jeff Davis wrote:
> On Wed, 2009-07-22 at 12:04 -0700, Jeremy Brown wrote:
> > It seems that PostgreSQL can audit INSERT, UPDATE, DELETE, and
> > TRUNCATE through the use of triggers.  But SELECT triggers are
> > unsupported (it does suggest perhaps using RULES).
>
> One thing you can do is use a set-returning function that, as a side
> effect, records what happened. It's not ideal because it hides a lot of
> information from the optimizer, but if your table is small enough it
> would work.

Would something like this be more amenable to optimization:

  CREATE FUNCTION tbl_auditor() RETURNS BOOLEAN IMMUTABLE AS $$
    logquery;
    RETURN TRUE; $$;

  CREATE VIEW tbl_view AS
    SELECT * FROM tbl WHERE tbl_auditor();

--
  Sam  http://samason.me.uk/

pgsql-general by date:

Previous
From: Robert James
Date:
Subject: Re: Can LIKE under utf8 use INDEXes?
Next
From: Sam Mason
Date:
Subject: Re: Best practices for moving UTF8 databases