Re: wierd AND condition evaluation for plpgsql - Mailing list pgsql-hackers

From Joel Burton
Subject Re: wierd AND condition evaluation for plpgsql
Date
Msg-id JGEPJNMCKODMDHGOBKDNCENICPAA.joel@joelburton.com
Whole thread Raw
In response to Re: wierd AND condition evaluation for plpgsql  (Alessio Bragadini <alessio@albourne.com>)
Responses Re: wierd AND condition evaluation for plpgsql  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> -----Original Message-----
> From: pgsql-hackers-owner@postgresql.org
> [mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Alessio
> Bragadini
> Sent: Thursday, May 30, 2002 9:04 AM
> To: PostgreSQL Hackers
> Subject: Re: [HACKERS] wierd AND condition evaluation for plpgsql
>
>
> On Tue, 2002-05-28 at 16:09, Joel Burton wrote:
>
> > Actually, at least in some cases, PG does short-circuit logic:
>
> > joel@joel=# select false and seeme();
>
> > joel@joel=# select true and seeme();
>
> If seeme() returns NULL, shouldn't both SELECTs return NULL, and
> therefore not be short-circuit-able?
>
> Sorry, I am a little confused.

In my example, seeme() returns true, not NULL. However, the short-circuiting
came from the other part (the simple true or false) being evaluated first.
So, regardless of the returned value of seeme(), "SELECT FALSE AND seeme()"
would short-circuit, since "FALSE AND ___" can never be true. Of course, if
seemme() returns NULL, then the end result would be false.

- J.

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



pgsql-hackers by date:

Previous
From: Alessio Bragadini
Date:
Subject: Re: wierd AND condition evaluation for plpgsql
Next
From: Tom Lane
Date:
Subject: Re: Null values in indexes