Error: 'cache lookup failed' w/trigger

Started by Marcel Gsteigerabout 25 years ago2 messagesgeneral
Jump to latest
#1Marcel Gsteiger
Marcel.Gsteiger@milprog.ch

Hello,

I'm new to Postgresql and just tried to write my very first pgsql
trigger procedure. So
please forgive me if this is a stupid question.

This is what I did:
1. using bash as user postgres (my db superuser) on my RH6.2 linux box:
bash$ export PGLIB=/usr/lib/pgsql
bash$ createlang plpgsql mydb

2. using phpPgAdmin, I then could create the following procedure:

CREATE FUNCTION "datetimestamp"() RETURNS OPAQUE AS
'BEGIN NEW.modificationdatetime := \'now\' END;'
LANGUAGE 'plpgsql'

3. Then I created a trigger:
CREATE TRIGGER "accounts_datetimestamp" BEFORE INSERT OR UPDATE ON
"accounts" FOR EACH ROW EXECUTE PROCEDURE datetimestamp();

Now everytime I try to update something in my accounts table I get the
message:
ERROR: fmgr_info: function 51232: cache lookup failed

What's wrong here?
BTW: is there a source for trigger procedure examples? These trigger
procedures could help me solve a lot of problems.

Thanks for any suggestions
Greetings from switzerland
--Marcel

#2Marcel Gsteiger
Marcel.Gsteiger@milprog.ch
In reply to: Marcel Gsteiger (#1)
Re: Error: 'cache lookup failed' w/trigger

Meanwhile, I've found the source of my problem myself. When I drop a
function and re-create it (this is what phpPgAdmin does when "modifying" a
function), I also have to drop and re-create the corresponding trigger.
Again one of these 'gotchas' for beginners...

mg schrieb:

Show quoted text

Hello,

I'm new to Postgresql and just tried to write my very first pgsql
trigger procedure. So
please forgive me if this is a stupid question.

This is what I did:
1. using bash as user postgres (my db superuser) on my RH6.2 linux box:
bash$ export PGLIB=/usr/lib/pgsql
bash$ createlang plpgsql mydb

2. using phpPgAdmin, I then could create the following procedure:

CREATE FUNCTION "datetimestamp"() RETURNS OPAQUE AS
'BEGIN NEW.modificationdatetime := \'now\' END;'
LANGUAGE 'plpgsql'

3. Then I created a trigger:
CREATE TRIGGER "accounts_datetimestamp" BEFORE INSERT OR UPDATE ON
"accounts" FOR EACH ROW EXECUTE PROCEDURE datetimestamp();

Now everytime I try to update something in my accounts table I get the
message:
ERROR: fmgr_info: function 51232: cache lookup failed

What's wrong here?
BTW: is there a source for trigger procedure examples? These trigger
procedures could help me solve a lot of problems.

Thanks for any suggestions
Greetings from switzerland
--Marcel