Re: PL/PgSQL Boolean Comparison Operator Binding

From: Thomas F(dot)O'Connell <tfo(at)sitening(dot)com>
To: PgSql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: PL/PgSQL Boolean Comparison Operator Binding
Date: 2005-01-15 17:13:57
Message-ID: D7AE87E2-6718-11D9-8CD3-000D93AE0944@sitening.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Never mind. I think I had some data that hadn't been calibrated lying
around prior to testing. I think my test case was flawed.

Sorry for the noise.

-tfo

--
Thomas F. O'Connell
Co-Founder, Information Architect
Sitening, LLC
http://www.sitening.com/
110 30th Avenue North, Suite 6
Nashville, TN 37203-6320
615-260-0005

On Jan 15, 2005, at 10:55 AM, Thomas F.O'Connell wrote:

> I was recently testing some logic based on columns of type boolean and
> noticed some unintuitive behavior in PL/PgSQL.
>
> I had a construct like the following:
>
> IF NOT col1 AND NOT col2 THEN ...
>
> In a scenario where both col1 and col2 were false, this condition was
> not triggered. If I rewrote it as:
>
> IF ( NOT col1 ) AND ( NOT col2 ) THEN ...
>
> the condition was triggered as expected.
>
> I would expect NOT to bind more closely than AND. The docs on what
> behavior to expect here are pretty sparse in both the Logical
> Operators section (9.1) and Expression Evaluation Rules (4.2.11). I
> couldn't find anything either confirming or contradicting my
> expectations. Also, I didn't try this in standard SQL in a case
> construct, but I would assume the behavior would be the same?
>
> If this is known and expected behavior, what would be the most
> appropriate section of the docs for further explanation of order of
> evaluation?
>
> PostgreSQL 7.4.6 on i686-pc-linux-gnu, compiled by GCC 2.95.4.
>
> -tfo
>
> --
> Thomas F. O'Connell
> Co-Founder, Information Architect
> Sitening, LLC
> http://www.sitening.com/
> 110 30th Avenue North, Suite 6
> Nashville, TN 37203-6320
> 615-260-0005

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2005-01-15 17:14:17 Re: serial increments on failed insert
Previous Message Martijn van Oosterhout 2005-01-15 17:06:50 Re: OID Usage