Re: history tables with only one function? - Mailing list pgsql-general

From Raphael Bauduin
Subject Re: history tables with only one function?
Date
Msg-id 411B8A5E.1040207@be.easynet.net
Whole thread Raw
In response to Re: history tables with only one function?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Tom Lane wrote:
> Raphael Bauduin <raphael.bauduin@be.easynet.net> writes:
>
>>>Could you please confirm that your function works as you described?
>
>
>>It works as expected:
>
>
>>log=# DROP TRIGGER "customers_update_log_t" on "customers";
>>DROP TRIGGER
>>log=# DROP FUNCTION "update_log"();
>>ERROR:  function update_log() does not exist
>>log=# CREATE FUNCTION "update_log"(text) RETURNS trigger AS '
>>log'#  BEGIN
>>log'#         insert into $1_log select new.*,''UPDATE'';
>>log'#         return new;
>>log'#  END;
>>log'#  ' LANGUAGE 'plpgsql';
>>CREATE FUNCTION
>>log=#
>>log=# CREATE TRIGGER "customers_update_log_t" after UPDATE on "customers" for each row execute procedure
"customers_update_log"('customers');
>>CREATE TRIGGER
>
>
> That trigger is not executing that function, and would not be executing
> it even if you had used the same function name.  Trigger functions are
> always parameterless.

I tested it again and it worked, but the fact you were as categoric made me start from scratch, and you are absolutely
right.
As you can even see in the code above, the trigger uses "customers_update_log"('customers') but I define the function
"update_log"().....
There was a parameterless function customers_update_log I had defined in previous tests which hadn't been dropped....
Andthat 
was the function used by the trigger, even if I passed a parameter. The fact that it worked made me think it used the
parameter.

Thanks for the clarification!

Raph



>
>             regards, tom lane


pgsql-general by date:

Previous
From: Karam Chand
Date:
Subject: Strange pg_hba.conf error (repost)
Next
From: Paramveer.Singh@trilogy.com
Date:
Subject: Re: pl pgsql grammer file contains error