PL/PgSQL Boolean Comparison Operator Binding - Mailing list pgsql-general

From Thomas F.O'Connell
Subject PL/PgSQL Boolean Comparison Operator Binding
Date
Msg-id 500EE0C5-6716-11D9-8CD3-000D93AE0944@sitening.com
Whole thread Raw
Responses Re: PL/PgSQL Boolean Comparison Operator Binding  (Thomas F.O'Connell <tfo@sitening.com>)
List pgsql-general
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


pgsql-general by date:

Previous
From: Bo Lorentsen
Date:
Subject: Re: OID Usage
Next
From: Bo Lorentsen
Date:
Subject: Re: OID Usage