GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MySQL bitwise |, &, and shifts still share one parser precedence tier · Issue #2834 · JSQLParser/JSqlParser

MySQL bitwise |, &, and shifts still share one parser precedence tier #2834

New issue
Copy link
New issue
Copy link
Closed
Closed
MySQL bitwise |, &, and shifts still share one parser precedence tier#2834
Copy link

Description

@pbottine
pbottine
opened on Oct 20, 2026
Issue body actions

Reproduction

At current master commit f6ac2571e6e9777d6a5ee942a4ea53cd91153e4d, compile and run this with the built JAR on the classpath:

import net.sf.jsqlparser.expression.BinaryExpression;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.parser.AbstractJSqlParser.Dialect;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import net.sf.jsqlparser.statement.select.Select;
public class Repro {
  static String shape(Expression e) {
    if (e instanceof BinaryExpression b)
      return "(" + shape(b.getLeftExpression()) + " " + e.getClass().getSimpleName()
          + " " + shape(b.getRightExpression()) + ")";
    return e.toString();
  }
  public static void main(String[] args) throws Exception {
    for (String x : new String[]{"1 | 2 & 4", "3 & 1 << 2"}) {
      Select s = (Select) CCJSqlParserUtil.parse("SELECT " + x + " AS x",
          p -> p.withDialect(Dialect.MYSQL));
      System.out.println(x + " => " + shape(s.getPlainSelect().getSelectItem(0).getExpression()));
    }
  }
}

Observed on 2026-10-19: 1 | 2 & 4 becomes (1 | 2) & 4, and 3 & 1 << 2 becomes (3 & 1) << 2. MySQL's precedence table requires 1 | (2 & 4) and 3 & (1 << 2). These paired groupings evaluate to 0 versus 1, and 4 versus 0, respectively.

The arithmetic parser loop assigns precedence 4 to |, &, <<, and >> under the MySQL dialect. PR #2833 corrected their tier relative to addition and explicitly notes that MySQL separates these bitwise operators. This issue tracks that remaining MySQL-specific grouping difference.

Activity

  1. manticore-projects
    closed this as completedin bfafeaaon Oct 22, 2026
  2. minleejae
    added a commit that references this issue on Oct 22, 2026

    Match MySQL operator precedence for XOR and bitwise operators (JSQLPa…

    This issue will close once commit bfafeaa is merged into the 'master' branch.
    bfafeaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.