Re: Parameter passing in trigger function write in C

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: a <372660931(at)qq(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Parameter passing in trigger function write in C
Date: 2018-04-27 06:20:37
Message-ID: 1524810037.2382.10.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

a wrote:
> I was request to write a trigger that perform the following function:
>
> 1, The trigger will be set to exam all statement that will result change of datas
>
> 2, The trigger will exam three information other than the data updated or inserted:
> user name, password and reasons of change
>
> 3, It will record down, in some format, the time and content of the change.
>
> Therefore, I would need some way of passing parameters into the trigger function.
> Can anyone give me some instructions on how to do it or, if it is possible??

The only information you can pass to a trigger function are the old and new
values of the table row being changed and the constants you can supply to
the trigger function during CREATE TRIGGER.

Everything else will have to be drawn from the current state of the database.

One thing you can do is to define your own GUC (configuration parameter)
and set that before you run the data modifying SQL statement. Then you can
read that information in the trigger.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Olivier Macchioni 2018-04-27 07:55:34 Locks analysis after-the-fact
Previous Message a 2018-04-27 01:48:21 Re: Parameter passing in trigger function write in C