Re: Implementing a change log - Mailing list pgsql-general

From Mike Rylander
Subject Re: Implementing a change log
Date
Msg-id b918cf3d050920050029d8149e@mail.gmail.com
Whole thread Raw
In response to Re: Implementing a change log  (Berend Tober <btober@seaworthysys.com>)
Responses Re: Implementing a change log
List pgsql-general
On 9/20/05, Berend Tober <btober@seaworthysys.com> wrote:
> /*
> The following is based on suggestion by Mike Rylander posted on
> Postgresql-General
> Sun, 18 Sep 2005 23:29:51 +0000
>
> Rylander's original suggestion employed a trigger and tracked
> only row updates. My implementation makes use of rules and
> handles both updates and deletions.
> */

I'm glad that was inspirational for you.  Not to nit pick, but my
trigger based version did in fact track deletions:

CREATE TRIGGER audit_$$ || sch || $$_$$ || tbl || $$_update_trigger
    AFTER UPDATE OR DELETE ON $$ || sch || $$.$$ || tbl || $$ FOR EACH ROW
              ^^^^^^^
    EXECUTE PROCEDURE auditor.audit_$$ || sch || $$_$$ || tbl || $$_func ();

You may want to consider using the LIKE style of table copying, as it
strips all constraints from the new table.  It's safer IMHO, as this
way you wouldn't have to worry about the primary key being propagated
to the new table (and accidentally forgetting to remove it).

--
Mike Rylander
mrylander@gmail.com
GPLS -- PINES Development
Database Developer
http://open-ils.org

pgsql-general by date:

Previous
From: Daniel Schuchardt
Date:
Subject: Re: shared Locks
Next
From: "Belinda M. Giardine"
Date:
Subject: running vacuum in scripts