提交 e8934521 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix NPE in Query.initExpression()

上级 84092ec5
......@@ -519,12 +519,10 @@ public abstract class Query extends Prepared {
}
}
if (!isAlias) {
if (mustBeInResult) {
if (session.getDatabase().getMode().getEnum() != ModeEnum.MySQL) {
if (!checkOrderOther(session, e, expressionSQL)) {
throw DbException.get(ErrorCode.ORDER_BY_NOT_IN_RESULT, e.getSQL());
}
}
if (expressionSQL == null
|| mustBeInResult && session.getDatabase().getMode().getEnum() != ModeEnum.MySQL
&& !checkOrderOther(session, e, expressionSQL)) {
throw DbException.get(ErrorCode.ORDER_BY_NOT_IN_RESULT, e.getSQL());
}
expressions.add(e);
String sql = e.getSQL();
......@@ -549,12 +547,10 @@ public abstract class Query extends Prepared {
if (expr.isConstant()) {
return true;
}
if (expressionSQL != null) {
String exprSQL = expr.getSQL();
for (String sql: expressionSQL) {
if (session.getDatabase().equalsIdentifiers(exprSQL, sql)) {
return true;
}
String exprSQL = expr.getSQL();
for (String sql: expressionSQL) {
if (session.getDatabase().equalsIdentifiers(exprSQL, sql)) {
return true;
}
}
if (expr instanceof Function) {
......
......@@ -252,3 +252,18 @@ SELECT A, COUNT(B) FROM TEST GROUP BY A OFFSET 1;
DROP TABLE TEST;
> ok
CREATE TABLE TEST1(A INT, B INT, C INT) AS SELECT 1, 2, 3;
> ok
CREATE TABLE TEST2(A INT, B INT, C INT) AS SELECT 4, 5, 6;
> ok
SELECT A, B FROM TEST1 UNION SELECT A, B FROM TEST2 ORDER BY 1.1;
> exception ORDER_BY_NOT_IN_RESULT
DROP TABLE TEST1;
> ok
DROP TABLE TEST2;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论