From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | wstrzalka <wstrzalka(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: plpgsql and logical expression evaluation |
Date: | 2008-04-23 12:57:59 |
Message-ID: | 20080423125759.GC4768@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2008-04-23 13:04:29 | Re: Need to update all my 60 million rows at once without transactional integrity |
Previous Message | Ivan Sergio Borgonovo | 2008-04-23 12:34:38 | Re: Debian etch, backport postgresql 8.3 experiences? |