Re: [HACKERS] Modulo syntax

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: phd2(at)earthling(dot)net
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Modulo syntax
Date: 1999-03-17 16:21:41
Message-ID: 199903171621.LAA10188@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-03-17 16:54:17 Re: [HACKERS] Sequences....
Previous Message Bruce Momjian 1999-03-17 16:18:32 Re: [HACKERS] Sequences....