Re: Changes to functions and triggers - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Changes to functions and triggers
Date
Msg-id 29424.961509312@sss.pgh.pa.us
Whole thread Raw
In response to Re: Changes to functions and triggers  (darcy@druid.net (D'Arcy J.M. Cain))
Responses Re: Changes to functions and triggers  (darcy@druid.net (D'Arcy J.M. Cain))
List pgsql-hackers
darcy@druid.net (D'Arcy J.M. Cain) writes:
> OK, so I went back to basically what I had before.

> CREATE FUNCTION make_date()                   
>     RETURNS opaque
>     AS '/usr/pgsql/modules/make_date.so'    
>     LANGUAGE 'c';

> CREATE TRIGGER make_dates
>     BEFORE INSERT OR UPDATE ON bgroup
>     FOR EACH ROW
>     EXECUTE PROCEDURE make_date (edate, aniv, emon, eyear);

> INSERT INTO bgroup (bname, client_id, actypid, aniv, emon, eyear, pmon, pyear)
>     VALUES ('guest', 1000, 1, 1, 1, 2000, 1, 2000);

Looks OK to me.

> And here is what I get.
> ERROR:  fmgr_info: function 24224: cache lookup failed

You sure you didn't fall into the same old trap of you-must-create-
the-trigger-after-the-function?  If you drop and recreate the function,
it has a new OID, so you have to drop and recreate the trigger because
it links to the function by OID.

(Someday we ought to make that work better.)
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Big 7.1 open items
Next
From: "Philip J. Warner"
Date:
Subject: Re: Big 7.1 open items