Precedence of bitwise operators

From: Bauyrzhan Sakhariyev <baurzhansahariev(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Precedence of bitwise operators
Date: 2022-11-20 21:27:19
Message-ID: CAKpL73v_KF_x6vRS7ofZ33exkq4_FYWWz16nSdcSA5h2dPifrg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi! Do I get it right, that bitwise operations have the same precedence?

Query *SELECT 1 & 2 | 3, 3 | 1 & 2*
returns 3 and 2 respectively. See also
https://www.db-fiddle.com/f/iZHd8zG7A1HjbB6J2y8R7k/1. It looks like the
result is calculated from left to right and operators have
the same precedence.

I checked relevant documentation pages (
https://www.postgresql.org/docs/current/functions-bitstring.html and
https://www.postgresql.org/docs/current/sql-syntax-lexical.html) and
couldn't find any information about bitwise operations precedence, only
information about logical operations precedence.

I'm not saying it's a bug, rather trying to clarify as precedence of
bitwise operators is different in programming languages, say c++ (
https://en.cppreference.com/w/c/language/operator_precedence) or java (
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2022-11-20 21:31:14 Re: More efficient build farm animal wakeup?
Previous Message Thomas Munro 2022-11-20 21:13:06 Re: Reducing power consumption on idle servers