Re: Dynamic Log tigger (plpgsql)

Поиск
Список
Период
Сортировка
От Sibte Abbas
Тема Re: Dynamic Log tigger (plpgsql)
Дата
Msg-id bd6a35510706190710m76fa9e9eh661f591c527bc796@mail.gmail.com
обсуждение исходный текст
Ответ на Dynamic Log tigger (plpgsql)  (Noah Heusser <noah@heussers.ch>)
Ответы Re: Dynamic Log tigger (plpgsql)  (Noah Heusser <pgsql-general@heussers.ch>)
Re: Dynamic Log tigger (plpgsql)  (Noah Heusser <noah@heussers.ch>)
Список pgsql-general
On 6/16/07, Noah Heusser <noah@heussers.ch> wrote:
> Hi
>
> I want to implement a trigger-function witch can fill the following table.
> Each data manipulation (INSERT, UPDATE or DELETE) gets logged.
> The function should work as trigger on diffrent tables.
>
> CREATE TABLE logtable (
>   operation        CHAR(6) CHECK (change_type IN ('DELETE', 'INSERT', 'UPDATE')),
>   tablename        VARCHAR,
>   rowid            INTEGER,  -
>   touched_columns  VARCHAR[]
> );
>
> My Problem is in the last Column (touched_columns).
> If it was an UPDATE Operation, I just need to know witch columns changed. (I am not iterrestet in the old or new
value)
> => IF OLD.columnName != NEW.columnName, it has changed.
>
>
>
> My Question:
> How can I do "OLD.columnName != NEW.columnName" if I don't know what the
> columnNames are at Compile Time?
> I have the columnName in a variable.
>
>
> Thx for help.
> Noah
>

Are you trying to do this from a plpgsql function? If so then I think
you should try to do this from a C function.

With C functions you will get more control over the new and old
versions of the tuple since you get their pointers via
TriggerData->tg_trigtuple (old tuple) and TriggerData->tg_newtuple
(new tuple).

--
Sibte Abbas
EnterpriseDB http://www.enterprisedb.com

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

Предыдущее
От: Rikard Pavelic
Дата:
Сообщение: problems selecting from altered table
Следующее
От: Greg Smith
Дата:
Сообщение: Re: VACUUM ANALYZE extremely slow