| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Chris Angelico <rosuav(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Consecutive operators not recognized without whitespace |
| Date: | 2011-12-13 00:01:18 |
| Message-ID: | 14445.1323734478@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Chris Angelico <rosuav(at)gmail(dot)com> writes:
> 1) Set a bit:
> UPDATE tablename SET flags=flags|8 WHERE id=1234
> 2) Clear a bit:
> UPDATE tablename SET flags=flags&~8 WHERE id=1234
> However, the second statement fails; the Postgres parser tries to find
> a single "&~" operator, instead of using the unary ~ and then the
> binary &. Putting a space between the two symbols makes it work fine,
> but I was wondering: Is this intentional behavior?
Yes. Postgres allows multi-character operator names, so you need a
space in general. There are exceptions for certain single-character
operator names that are defined in the SQL spec (eg, a+-b is required
by spec to parse as two operators), but & and ~ are not in that list.
You can find the details in the fine manual, probably somewhere in
the "Syntax" chapter.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dong Han | 2011-12-13 00:42:48 | Re: WAL file accumulation on log shipping primary node |
| Previous Message | Craig Ringer | 2011-12-12 23:47:46 | Re: Having Issue Getting the Postgresql Service to Start |