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 dialect gives logical XOR the same tier as OR · Issue #2835 · JSQLParser/JSqlParser

MySQL dialect gives logical XOR the same tier as OR #2835

New issue
Copy link
New issue
Copy link
Closed
Closed
MySQL dialect gives logical XOR the same tier as OR#2835
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 void show(Expression e, String prefix) {
    System.out.println(prefix + e.getClass().getSimpleName() + ": " + e);
    if (e instanceof BinaryExpression b) {
      show(b.getLeftExpression(), prefix + "  L ");
      show(b.getRightExpression(), prefix + "  R ");
    }
  }
  public static void main(String[] args) throws Exception {
    for (String x : new String[]{"1 OR 1 XOR 1", "1 OR (1 XOR 1)"}) {
      Select s = (Select) CCJSqlParserUtil.parse("SELECT " + x + " AS x",
          p -> p.withDialect(Dialect.MYSQL));
      System.out.println("INPUT " + x);
      show(s.getPlainSelect().getSelectItem(0).getExpression(), "");
    }
  }
}

Observed on 2026-10-19: unparenthesized input has a XorExpression root with OrExpression(1, 1) on the left. The parenthesized control has an OrExpression root. MySQL puts logical XOR above OR, so the unparenthesized input should also have an OR root: 1 OR (1 XOR 1) evaluates to true, whereas (1 OR 1) XOR 1 evaluates to false.

The boolean parser loop comments that XOR should have precedence 3 and OR precedence 2, but assigns both the value 2. The resulting AST groups them left-to-right. #1070 concerns OR/AND; #2834 concerns a separate arithmetic/bitwise parser loop.

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.