E5F3 fixed issue #14592: IS_NULL(@x) isn't recognized as a constant expression by jsteemann · Pull Request #14603 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
devel
-----

* Fixed issue #14592: IS_NULL(@x) isn't recognized as a constant expression.

* Fixed issue BTS-539 "Unsynchronized query kill while it's being finalized in
another thread was uncovered through `test-kill.js` of `communication_ssl`
suite". Fixed possible (but unlikely) crash when killing an AQL query.

* Add optimization rule for AqlAnalyzer/
* Add optimization rule for AqlAnalyzer.

* Append physical compaction of log collection to every Raft log
compaction (BTS-542).
Expand Down
5 changes: 3 additions & 2 deletions arangod/Aql/Ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3480,8 +3480,9 @@ AstNode* Ast::optimizeFunctionCall(transaction::Methods& trx,
auto args = node->getMember(0);
if (args->numMembers() == 1) {
// replace IS_NULL(x) function call with `x == null`
return createNodeBinaryOperator(NODE_TYPE_OPERATOR_BINARY_EQ,
args->getMemberUnchecked(0), createNodeValueNull());
return this->optimizeBinaryOperatorRelational(trx, aqlFunctionsInternalCache,
createNodeBinaryOperator(NODE_TYPE_OPERATOR_BINARY_EQ,
args->getMemberUnchecked(0), createNodeValueNull()));
}
#if 0
} else if (func->name == "LIKE") {
Expand Down
32 changes: 31 additions & 1 deletion tests/js/server/aql/aql-queries-simple.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*jshint globalstrict:false, strict:false, maxlen: 500 */
/*global assertEqual, AQL_EXECUTE */
/*global assertEqual, assertTrue, assertFalse, AQL_EXECUTE, AQL_EXPLAIN */

////////////////////////////////////////////////////////////////////////////////
/// @brief tests for query language, simple queries
Expand Down Expand Up @@ -1406,6 +1406,36 @@ function ahuacatlQuerySimpleTestSuite () {
}
assertQueryError(errors.ERROR_QUERY_TOO_MUCH_NESTING.code, q);
},

testIsNullConversion : function() {
let q = `RETURN IS_NULL(42)`;
let nodes = AQL_EXPLAIN(q).plan.nodes.filter((n) => n.type === 'CalculationNode');
assertEqual(1, nodes.length);
let expr = nodes[0].expression;
assertEqual("value", expr.type);
assertFalse(expr.value);

q = `RETURN IS_NULL(null)`;
nodes = AQL_EXPLAIN(q).plan.nodes.filter((n) => n.type === 'CalculationNode');
assertEqual(1, nodes.length);
expr = nodes[0].expression;
assertEqual("value", expr.type);
assertTrue(expr.value);

q = `RETURN IS_NULL(@value)`;
nodes = AQL_EXPLAIN(q, {value: 42}).plan.nodes.filter((n) => n.type === 'CalculationNode');
assertEqual(1, nodes.length);
expr = nodes[0].expression;
assertEqual("value", expr.type);
assertFalse(expr.value);

nodes = AQL_EXPLAIN(q, {value: null}).plan.nodes.filter((n) => n.type === 'CalculationNode');
assertEqual(1, nodes.length);
expr = nodes[0].expression;
assertEqual("value", expr.type);
assertTrue(expr.value);
},

};
}

Expand Down
0