Re: capturing and storing query statement with rules

Поиск
Список
Период
Сортировка
От Guillaume LELARGE
Тема Re: capturing and storing query statement with rules
Дата
Msg-id 200306242240.28986.gleu@wanadoo.fr
обсуждение исходный текст
Ответ на capturing and storing query statement with rules  (Andrew Gould <andrewgould@yahoo.com>)
Ответы Re: capturing and storing query statement with rules  (Joe Conway <mail@joeconway.com>)
Список pgsql-general
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 don't think... or wasn't able to find something like this one in the
documentation.

Regards.


--
Guillaume <!-- http://absfr.tuxfamily.org/ -->.

В списке pgsql-general по дате отправления:

Предыдущее
От: Andrew Gould
Дата:
Сообщение: pg_dumping schemes (not schema)
Следующее
От: Steve Crawford
Дата:
Сообщение: Re: 7.3.3 install under way