Re: Logical expn not shortcircuiting in trigger function?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Logical expn not shortcircuiting in trigger function?
Дата
Msg-id 26356.987778876@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Logical expn not shortcircuiting in trigger function?  (Joel Burton <jburton@scw.org>)
Список pgsql-general
Joel Burton <jburton@scw.org> writes:
> If I try to INSERT into this table, I get
>    ERROR:  record old is unassigned yet
> So, why hasn't the logic short-circuited? Am I missing something?

You lose because those are parameters that plpgsql has to hand to the
SQL expression evaluator.  The expression evaluator might have
short-circuited that part of the expression when it ran it, but it never
gets to run it; plpgsql errors out while setting up for the expression
eval.

I think you'll have to split this into multiple IF statements if you
want to make it work like that.  Possibly better: use separate trigger
functions for the INSERT and UPDATE cases to begin with.

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Database Connect
Следующее
От: Travis Bauer
Дата:
Сообщение: Re: PL/Perl Question