Re: plpgsql and logical expression evaluation - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: plpgsql and logical expression evaluation
Date
Msg-id 20080423125759.GC4768@alvh.no-ip.org
Whole thread Raw
In response to Re: plpgsql and logical expression evaluation  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: plpgsql and logical expression evaluation  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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 by date:

Previous
From: "Roberts, Jon"
Date:
Subject: Re: Deny creation of tables for a user
Next
From: Alvaro Herrera
Date:
Subject: Re: Need to update all my 60 million rows at once without transactional integrity