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-21 22:07:11
Message-ID: 6191.961625231@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:
> I must have done this wrong. The actual error I get when I start from
> scratch is this:
> ERROR: make_date (bgroup): 0 args

> That message comes from my program at the start of the function.

> [ blah blah blah ]

> trigger = CurrentTriggerData->tg_trigger;

> nargs = trigger->tgnargs;
> if (nargs != 4)
> elog(ERROR, "make_date (%s): %d args", relname, nargs);

Hmm. Not sure if this is the root of the problem or not, but it's
*real* dangerous to assume that the global CurrentTriggerData stays
set (the same way!) throughout your function. You should copy
CurrentTriggerData into a local TriggerData * variable immediately
upon being called and then just use that variable. I wonder if you
could be losing because some other trigger is getting invoked before
your routine returns...

CurrentTriggerData doesn't even exist anymore in current sources,
so doing it that way will also ease the pain of updating to 7.1 ;-)

Another thing to keep in mind is that the data structures pointed to
by CurrentTriggerData had better be treated as read-only.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Randall Parker 2000-06-21 22:36:36 tablespace managed by system vs managed by database
Previous Message Tom Lane 2000-06-21 21:44:57 Re: limit?