pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Philip Warner <pjw@rhyme.com.au>
Cc: pgsql-sql@hub.org
Subject: Re: Operator Precedence problem?
Date: Sat, 12 Aug 2000 11:56:30 -0400
Message-ID: <22816.966095790@sss.pgh.pa.us> (raw)
In-Reply-To: <3.0.5.32.20000812154918.01f4e1d0@mail.rhyme.com.au>
References: <3.0.5.32.20000812154918.01f4e1d0@mail.rhyme.com.au>

Philip Warner <pjw@rhyme.com.au> writes:
> Which makes me think that the precedence of 'or' is not what I
> expected.

OR is certainly lower-precedence than AND --- this is hard-wired in the
grammar and not subject to change across databases.  It's also required
by SQL92:

         <search condition> ::=
                <boolean term>
              | <search condition> OR <boolean term>

         <boolean term> ::=
                <boolean factor>
              | <boolean term> AND <boolean factor>

         <boolean factor> ::=
              [ NOT ] <boolean test>

         <boolean test> ::=
              <boolean primary> [ IS [ NOT ] <truth value> ]

         <truth value> ::=
                TRUE
              | FALSE
              | UNKNOWN

         <boolean primary> ::=
                <predicate>
              | <left paren> <search condition> <right paren>

BTW, I notice that we do not correctly implement the IS tests.
The parser turns them into "<primary> = 't'::bool" and so on,
which is wrong because it will yield NULL for NULL input, which
is contrary to the spec for these tests.  We need specialized
functions comparable to the ones for IS NULL (in fact, IS UNKNOWN
should be equivalent to IS NULL except for requiring a boolean
input, AFAICT).

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <22816.966095790@sss.pgh.pa.us>
Permalink:  ../22816.966095790@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22816.966095790@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pjw@rhyme.com.au, pgsql-sql@hub.org
  Subject: Re: Operator Precedence problem?
  In-Reply-To: <22816.966095790@sss.pgh.pa.us>
  References: <3.0.5.32.20000812154918.01f4e1d0@mail.rhyme.com.au> <22816.966095790@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox