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 — Match MySQL operator precedence for XOR and bitwise operators by princejain756 · Pull Request #2838 · JSQLParser/JSqlParser

Conversation

@princejain756

@princejain756 princejain756 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Summary

The Pratt expression loops give XOR the same precedence as OR and place |, &, <<, >> on one left-associative level, in every dialect. MySQL's table differs on both counts:

  • XOR sits between AND and OR, so 1 OR 1 XOR 1 must parse as 1 OR (1 XOR 1) and not (1 OR 1) XOR 1 (MySQL dialect gives logical XOR the same tier as OR #2835)
  • << and >> bind tighter than &, which binds tighter than |, so 1 | 2 & 4 must parse as 1 | (2 & 4) and 3 & 1 << 2 as 3 & (1 << 2) (MySQL bitwise |, &, and shifts still share one parser precedence tier #2834)

Both tiers are gated on Dialect.MYSQL. Every other dialect keeps the shared, left-associative levels that #2833 established, so the default behavior and its regression tests are untouched. Under MySQL SimpleExpression now enters the arithmetic loop at floor 2 so | is admitted at all.

One subtlety this uncovered: the javacc plugin can leave target/generated-sources stale across incremental compiles, which made the fix look broken locally until a full regen.

Test plan

  • 1 | 2 & 4 under MySQL parses as BitwiseOr(1, BitwiseAnd(2, 4))
  • 3 & 1 << 2 under MySQL parses as BitwiseAnd(3, BitwiseLeftShift(1, 2))
  • 1 OR 1 XOR 1 under MySQL parses as OrExpression(1, XorExpression(1, 1))
  • 1 XOR 1 AND 1 under MySQL parses as XorExpression(1, AndExpression(1, 1))
  • Default dialect 4 | 1 & 0 still parses as (4 | 1) & 0 (fix: bind bitwise operators looser than + and - #2833 test intact)
  • New regression tests in ExpressionPrecedenceTest
  • Full suite: 10,663 tests, 0 failures

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@princejain756
Match MySQL operator precedence for XOR and bitwise operators
877e628
XOR sat on the same level as OR, and |, &, <<, >> shared one
left-associative level, in every dialect. MySQL puts XOR between AND
and OR, and tiers the bitwise operators as <<, >> above & above |.

Gate the tiers on Dialect.MYSQL so the default dialect keeps the
shared levels established in JSQLParser#2833. SimpleExpression now enters the
arithmetic loop at floor 2 under MySQL so | is admitted.

Fixes JSQLParser#2834, fixes JSQLParser#2835
@manticore-projects
manticore-projects merged commit bfafeaa into JSQLParser:master Oct 22, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects

manticore-projects commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Thank you much!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@princejain756 @manticore-projects
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.