Re: Changes to functions and triggers

Поиск
Список
Период
Сортировка
От darcy@druid.net (D'Arcy J.M. Cain)
Тема Re: Changes to functions and triggers
Дата
Msg-id m1357Vu-000AY6C@druid.net
обсуждение исходный текст
Ответ на Changes to functions and triggers  (darcy@druid.net (D'Arcy J.M. Cain))
Список pgsql-hackers
Thus spake Zeugswetter Andreas
> > darcy@druid.net (D'Arcy J.M. Cain) writes:
> > >     nargs = trigger->tgnargs;
> > >     if (nargs != 4)
> > >         elog(ERROR, "make_date (%s): %d args", relname, nargs);
> 
> The simple answer is, that your procedure does not take four arguments.
> The old and new tuple are passed implicitly to your procedure,
> they don't show up in the argument list.

Right.  That's why the function takes void as its parameter list.  (I hadn't
shown that in my message.)  The code above finds the args from the global
environment.

In fact, my problem was, I think, that I needed to use the SPI_connect() and
SPI_finish() functions which I don't think were available when I first wrote
the function.  I added those, recompiled and all now works.  It just took
me a while to realize that the problem was in the C code and not the SQL
statements to use it.

> This is also the reason your code works if you add four "dummy" string 
> arguments (you can test that by supplying random values not the column names
> in your create trigger statement).

Nope.  Without the fix above it didn't work no matter what I tried.

Thanks for everyone's help.  Now I can move on to the operator defining
problem but that's a subject for another message.

It's funny but the two areas inthe new version that I am having trouble
with are the two that I originally helped document.  :-)

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.


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

Предыдущее
От: Giles Lean
Дата:
Сообщение: Re: Big 7.1 open items
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Big 7.1 open items