Re: capturing and storing query statement with rules

From: Joe Conway <mail(at)joeconway(dot)com>
To: Guillaume LELARGE <gleu(at)wanadoo(dot)fr>
Cc: pgsql-general(at)postgresql(dot)org, Andrew Gould <andrewgould(at)yahoo(dot)com>
Subject: Re: capturing and storing query statement with rules
Date: 2003-06-24 20:53:20
Message-ID: 3EF8BA40.7060408@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Guillaume LELARGE wrote:
> Le Mardi 24 Juin 2003 20:17, Andrew Gould a écrit :
>>I would like to create a audit log of update and
>>delete queries against a table. I want the log on the
>>server side, since access will be done using various
>>clients via ODBC. I would like to capture the user,
>>current datetime and the query statement. My thought
>>was to accomplish this by creating a rule that will
>>insert the information into a log table.
>
> To be server side, you need to use a trigger and a plpgsql function. On this
> page you will find more informations on trigger related functions:
> http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=plpgsql-trigger.html
> Perhaps you can compare OLD and NEW rows to know which rows will be updated.
> And you'll find at the end of the page how to get current user (current_user
> keyword) and current datetime (function now).
>
>>How can I captures the query statement so that I can
>>place it in a insert query? Is there a variable in
>>the server that holds the query statement as a string?

I think this shows how to do what you want:
http://archives.postgresql.org/pgsql-sql/2003-05/msg00301.php

HTH,

Joe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Crawford 2003-06-24 20:54:11 Re: 7.3.3 install under way
Previous Message Daniel Mahler 2003-06-24 20:34:45 Optimizer/Planner levels

Browse pgsql-hackers by date

  From Date Subject
Next Message Mike Mascari 2003-06-24 21:05:25 Re: capturing and storing query statement with rules
Previous Message Robert Treat 2003-06-24 20:20:18 Re: Two weeks to feature freeze