Re: Changes to functions and triggers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: darcy(at)druid(dot)net (D'Arcy J(dot)M(dot) Cain)
Cc: hackers(at)PostgreSQL(dot)org
Subject: Re: Changes to functions and triggers
Date: 2000-06-16 14:44:19
Message-ID: 6991.961166659@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

darcy(at)druid(dot)net (D'Arcy J.M. Cain) writes:
> Something changed in 7.02 from 6.3. I used to do this:
> CREATE FUNCTION make_date()
> RETURNS opaque
> AS '/usr/pgsql/modules/make_date.so'
> LANGUAGE 'c';
> CREATE TRIGGER make_edate
> BEFORE INSERT OR UPDATE ON bgroup
> FOR EACH ROW
> EXECUTE PROCEDURE make_date(edate, aniv, emon, eyear);

> This no longer works.

Details?

> I looked and the docs and it seems that this should work instead.

> CREATE FUNCTION make_date(date, int, int, int)
> RETURNS opaque
> AS '/usr/pgsql/modules/make_date.so'
> LANGUAGE 'c';
> CREATE TRIGGER make_edate
> BEFORE INSERT OR UPDATE ON bgroup
> FOR EACH ROW
> EXECUTE PROCEDURE make_date('edate', 'aniv', 'emon', 'eyear');

No. Trigger procedures never take explicit arguments --- whatever
you may have stated in the CREATE TRIGGER command gets passed in
in the trigger data structure. (A pretty bizarre and ugly choice
if you ask me, but not worth breaking existing code to change...)

There's surely been a lot of changes in 7.0 that could have broken
user-written triggers, but you'll need to look to your C code to
find the problem. What you've shown us looks fine.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-06-16 14:46:35 Re: [HACKERS] Re: Call for port testing on fmgr changes
Previous Message Thomas Lockhart 2000-06-16 14:37:35 Re: Re: Big 7.1 open items