Re: wierd AND condition evaluation for plpgsql

Поиск
Список
Период
Сортировка
Искать
От
Joel Burton
Тема
Re: wierd AND condition evaluation for plpgsql
Дата
в 09:09:09
Msg-id
JGEPJNMCKODMDHGOBKDNKELACPAA.joel@joelburton.com
Ответ на
Список
Дерево обсуждения
wierd AND condition evaluation for plpgsql Louis-David Mitterrand <vindex@apartia.org>
Re: wierd AND condition evaluation for plpgsql Tom Lane <tgl@sss.pgh.pa.us>
Re: wierd AND condition evaluation for plpgsql "Joel Burton" <joel@joelburton.com>
Re: wierd AND condition evaluation for plpgsql Alessio Bragadini <alessio@albourne.com>
Re: wierd AND condition evaluation for plpgsql "Joel Burton" <joel@joelburton.com>
Re: wierd AND condition evaluation for plpgsql Tom Lane <tgl@sss.pgh.pa.us>
Re: wierd AND condition evaluation for plpgsql "Joel Burton" <joel@joelburton.com>
Re: wierd AND condition evaluation for plpgsql Tom Lane <tgl@sss.pgh.pa.us>
Re: wierd AND condition evaluation for plpgsql Peter Eisentraut <peter_e@gmx.net>
Re: wierd AND condition evaluation for plpgsql Peter Eisentraut <peter_e@gmx.net>
Re: wierd AND condition evaluation for plpgsql Hannu Krosing <hannu@tm.ee>
Re: wierd AND condition evaluation for plpgsql "Joel Burton" <joel@joelburton.com>
Re: wierd AND condition evaluation for plpgsql Hannu Krosing <hannu@tm.ee>
Re: wierd AND condition evaluation for plpgsql Tom Lane <tgl@sss.pgh.pa.us>
Actually, at least in some cases, PG does short-circuit logic:

create function seeme() returns bool as ' begin   raise notice ''seeme'';   return true; end'
language plpgsql;

joel@joel=# select false and seeme();?column?
----------f
(1 row)

joel@joel=# select true and seeme();
NOTICE:  seeme?column?
----------t
(1 row)


In your case, the problem is short-circuiting a test, it's that the full
statement must be parsed and prepared, and it's probably in this stage that
the illegal use of old. in an insert jumps up.

HTH.

Joel BURTON | joel@joelburton.com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant

> -----Original Message-----
> From: pgsql-hackers-owner@postgresql.org
> [mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Louis-David
> Mitterrand
> Sent: Tuesday, May 28, 2002 3:21 AM
> To: pgsql-hackers@postgresql.org
> Subject: [HACKERS] wierd AND condition evaluation for plpgsql
>
>
>
> Hi,
>
> I just noticed plpgsql evaluates all AND'ed conditions even if the first
> one fails. Example:
>
> 	elsif TG_OP = ''UPDATE'' and old.type_reponse = ''abandon''
>
> This will break stuff if the trigger is used on INSERT as
> "old.type_reponse" will be substituted and return an error.
>
> Shouldn't plpgsql shortcut AND conditions when a previous one fails, as
> perl does?
>
> --
>     OENONE: Quoi ?
>     PHEDRE: Je te l'ai prédit, mais tu n'as pas voulu.
>                                           (Phèdre, J-B Racine,
> acte 3, scène 3)
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>


В списке pgsql-hackers по дате отправления
От: Olivier PRENANT
Дата:
Сообщение: Re: WAL FILES
От: Tom Lane
Дата:
FAQ