pbottine opened a new issue, #40295:
URL: https://github.com/apache/shardingsphere/issues/40295
## Reproduction
With Java 17 and Maven dependencies
`shardingsphere-parser-sql-engine-mysql:5.5.3` and
`shardingsphere-sql-federation-compiler:5.5.3`, run:
```java
import org.apache.shardingsphere.sql.parser.engine.api.*;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.*;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.SelectStatement;
import
org.apache.shardingsphere.sqlfederation.compiler.sql.ast.converter.segment.expression.ExpressionConverter;
public class Repro {
static String shape(ExpressionSegment e) {
if (e instanceof BinaryOperationExpression b)
return "(" + shape(b.getLeft()) + " " + b.getOperator() + " " +
shape(b.getRight()) + ")";
return e.getText();
}
public static void main(String[] args) {
var parser = new SQLParserEngine("MySQL", new CacheOption(128, 1024L));
var visitor = new SQLStatementVisitorEngine("MySQL");
var statement = (SelectStatement) visitor.visit(parser.parse(
"SELECT * FROM t WHERE 1 OR 1 XOR 1", false));
var expression = statement.getWhere().orElseThrow().getExpr();
System.out.println(shape(expression));
System.out.println(ExpressionConverter.convert(expression).orElseThrow());
}
}
```
Observed on 2026-10-16: the 5.5.3 parser and SQL Federation converter
represent `(1 OR 1) XOR 1`. [MySQL's precedence
table](https://dev.mysql.com/doc/refman/8.4/en/operator-precedence.html)
requires `1 OR (1 XOR 1)`, which evaluates to true rather than false for these
constants. The released [MySQL
grammar](https://github.com/apache/shardingsphere/blob/5.5.3/parser/sql/engine/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4#L390-L455)
appears to put `OR` ahead of `XOR`; the
[visitor](https://github.com/apache/shardingsphere/blob/5.5.3/parser/sql/engine/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/engine/mysql/visitor/statement/MySQLStatementVisitor.java#L449-L470)
preserves the tree.
[PR #39744](https://github.com/apache/shardingsphere/pull/39744) fixes a
different MySQL `!` precedence case. The observed grouping appears in both
parser and SQL Federation compiler nodes. The arithmetic/bitwise grammar issue
is separate.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]