Re: plpgsql and logical expression evaluation

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: plpgsql and logical expression evaluation
Дата
Msg-id 20080423125759.GC4768@alvh.no-ip.org
обсуждение исходный текст
Ответ на Re: plpgsql and logical expression evaluation  (Martijn van Oosterhout <kleptog@svana.org>)
Ответы Re: plpgsql and logical expression evaluation
Список pgsql-general
Martijn van Oosterhout escribió:
> On Tue, Apr 22, 2008 at 02:41:50AM -0700, wstrzalka wrote:
> > One of the annoying things in plpgsql is logical expression
> > evaluation.
> >
> > In most (all??) languages I know, logical expression like:
> >
> >      if ( [A_true_expression] or [B_false_expression] ) then
> >
> > will stop evaluating when the A expression will be evaluated as a
> > TRUE.
>
> I guess you should complain to the SQL design comittee, SQL is a
> declarative language not a procedural language and the order of the
> expressions in AND/OR is not important to the evaluation.

While I agree with that in principle, we should by now start getting
used to the idea that PL/pgSQL is a different language from SQL.  For
example, SELECT INTO are totally different in both languages.  So are
BEGIN and END, and then there are loads of procedural constructs not
found on SQL at all.

I think this business of non-shortcircuiting boolean operators is just
an artifact of the fact that PL/pgSQL hands off expression to the SQL
engine for evaluation.

Perhaps SQL/PSM is designed differently (I haven't checked), or PL/SQL
words differently on Oracle.  If either of these cases is true, we will
need to attack the problem sooner or later.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

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

Предыдущее
От: "Roberts, Jon"
Дата:
Сообщение: Re: Deny creation of tables for a user
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Need to update all my 60 million rows at once without transactional integrity