Re: BETWEEN SYMMETRIC/ASYMMETRIC - Mailing list pgsql-hackers

From Gavin Sherry
Subject Re: BETWEEN SYMMETRIC/ASYMMETRIC
Date
Msg-id Pine.LNX.4.21.0204101351050.9455-100000@linuxworld.com.au
Whole thread Raw
In response to Re: BETWEEN SYMMETRIC/ASYMMETRIC  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
List pgsql-hackers
On Wed, 10 Apr 2002, Christopher Kings-Lynne wrote:

> > Chris,
> >
> > You seem to have forgotten to update keywords.c.
> 
> OK - works perfectly now :)
> 
> Now I'm going to play with making the SYMMERIC and ASYMMETRIC keywords less
> reserved...
> 
> Can someone comment on my use of %prec BETWEEN?  Is that still correct now
> that we have the extra BETWEEN forms?

Yes. Have a look at the precedence table near the top of gram.y:

%left       UNION EXCEPT
%left       INTERSECT
%left       JOIN UNIONJOIN CROSS LEFT FULL RIGHT INNER_P NATURAL
%left       OR
%left       AND
%right      NOT
%right      '='
%nonassoc   '<' '>'
%nonassoc   LIKE ILIKE
%nonassoc   ESCAPE
%nonassoc   OVERLAPS
%nonassoc   BETWEEN
%nonassoc   IN
%left       POSTFIXOP       /* dummy for postfix Op rules */

[...]

This is the order of precedence for rules which contain these
operators. For example, if an expression contains:

a AND b AND c

it is evaluated as:

((a AND b) AND c)


On the other hand:

a OR b AND c

is evaluated as:

((a OR b) AND c)

since OR has a lower order of precedence. Now, consider:

select 2 between asymmetric 3 and 1

Without the %prec BETWEEN

3 and 1

is given precedence over between. This will break your code.

Gavin



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: timeout implementation issues
Next
From: Tom Lane
Date:
Subject: Re: timeout implementation issues