Re: Changes to functions and triggers

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Changes to functions and triggers
Дата
Msg-id 6191.961625231@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Changes to functions and triggers  (darcy@druid.net (D'Arcy J.M. Cain))
Список pgsql-hackers
darcy@druid.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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: limit?
Следующее
От: "Randall Parker"
Дата:
Сообщение: tablespace managed by system vs managed by database