Обсуждение: Pgsql conditions do not short circuit?

Поиск
Список
Период
Сортировка

Pgsql conditions do not short circuit?

От
"Guy Rouillier"
Дата:
I have the following condition in a trigger function:
 IF (TG_OP = 'INSERT') OR (TG_OP = 'UPDATE' AND NEW.aggregate_flag !=
OLD.aggregate_flag)

When I cause this trigger to execute on an insert, it complains that OLD
is not defined yet.  If I reformat this so I check the last condition in
an IF nested in the "UPDATE" case, it works fine.  From this, I'm
concluding that pgsql conditions do not short circuit?

--
Guy Rouillier



Re: Pgsql conditions do not short circuit?

От
Peter Eisentraut
Дата:
Guy Rouillier wrote:
> I have the following condition in a trigger function:
>
>   IF (TG_OP = 'INSERT') OR (TG_OP = 'UPDATE' AND NEW.aggregate_flag
> != OLD.aggregate_flag)
>
> When I cause this trigger to execute on an insert, it complains that
> OLD is not defined yet.  If I reformat this so I check the last
> condition in an IF nested in the "UPDATE" case, it works fine.  From
> this, I'm concluding that pgsql conditions do not short circuit?

That is true, but it wouldn't have helped you anyway, because the error 
is caught during the semantic analysis before the execution phase.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/


Re: Pgsql conditions do not short circuit?

От
"Guy Rouillier"
Дата:
Peter Eisentraut wrote:
>
> That is true, but it wouldn't have helped you anyway, because the
> error is caught during the semantic analysis before the execution
> phase.

Thanks, Peter.  Now that I understand the rules, I can follow them.

--
Guy Rouillier