Re: [HACKERS] Modulo syntax - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] Modulo syntax
Date
Msg-id 199903171621.LAA10188@candle.pha.pa.us
Whole thread Raw
In response to Modulo syntax  (Oleg Broytmann <phd@sun.med.ru>)
List pgsql-hackers
> Hello!
> 
>    I ran the query
> update producers SET cor_id = producer_id % 9 + 1;
> 
>    and found that result is eqiuvalent to
> update producers SET cor_id = producer_id % 9;
> 
>    I added parens:
> update producers SET cor_id = (producer_id % 9) + 1;
> 
>    and got what I needed.

Looks like a bug.  We have associativity for +, -, * and /, but not %.
>From gram.y:
%left       '+' '-'%left       '*' '/'

I will add '%' to that.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Sequences....
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Sequences....