From 762c0fd7c60bc9047e7f60520a944b9cc5ee00c4 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 2 Jan 2019 11:09:06 +0100 Subject: [PATCH] fixed issue #7834 (#7845) --- CHANGELOG | 6 ++++++ arangod/Aql/Scopes.cpp | 15 ++------------- tests/js/server/aql/aql-modify-noncluster.js | 9 +++++++++ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fa19aa7f7d..c654097d86 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +v3.4.2 (XXXX-XX-XX) +------------------- + +* fixed issue #7834: AQL Query crashes instance + + v3.4.1 (2018-12-19) ------------------- diff --git a/arangod/Aql/Scopes.cpp b/arangod/Aql/Scopes.cpp index a400207b95..b020ed14fd 100644 --- a/arangod/Aql/Scopes.cpp +++ b/arangod/Aql/Scopes.cpp @@ -191,19 +191,8 @@ void Scopes::addVariable(Variable* variable) { void Scopes::replaceVariable(Variable* variable) { TRI_ASSERT(!_activeScopes.empty()); TRI_ASSERT(variable != nullptr); - - for (auto it = _activeScopes.rbegin(); it != _activeScopes.rend(); ++it) { - auto scope = (*it); - - if (scope->existsVariable(variable->name)) { - // replace existing variable - scope->addVariable(variable); - return; - } - } - - THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, - "unable to find AQL variable in scopes"); + + _activeScopes.back()->addVariable(variable); } /// @brief checks whether a variable exists in any scope diff --git a/tests/js/server/aql/aql-modify-noncluster.js b/tests/js/server/aql/aql-modify-noncluster.js index 237dbd3baf..1df9573563 100644 --- a/tests/js/server/aql/aql-modify-noncluster.js +++ b/tests/js/server/aql/aql-modify-noncluster.js @@ -155,6 +155,15 @@ function ahuacatlModifySuite () { c1 = null; c2 = null; }, + + testVariableScope : function () { + let query = "INSERT {value: 1} INTO " + cn1 + " LET id1 = (UPDATE 'foo' WITH {value: 2} IN " + cn2 + ") RETURN NEW"; + let result = AQL_EXECUTE(query).json; + assertEqual(1, result[0].value); + assertEqual(2, c1.count()); + assertEqual(1, c2.count()); + assertEqual(2, c2.document("foo").value); + }, //////////////////////////////////////////////////////////////////////////////// /// @brief test subquery