From 015d45fd4f8f801e170612daca8edb2fe8982e81 Mon Sep 17 00:00:00 2001 From: Max Neunhoeffer Date: Fri, 28 Nov 2014 16:14:44 +0100 Subject: [PATCH] Fix a bug in AQL COLLECT statement. Sorts out #1127. This concerned every COLLECT statement, only the first group had access to the values of the variables before the COLLECT statement. --- arangod/Aql/ExecutionBlock.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arangod/Aql/ExecutionBlock.cpp b/arangod/Aql/ExecutionBlock.cpp index 6cd114da4c..9ec159e1df 100644 --- a/arangod/Aql/ExecutionBlock.cpp +++ b/arangod/Aql/ExecutionBlock.cpp @@ -2602,6 +2602,15 @@ void AggregateBlock::emitGroup (AqlItemBlock const* cur, AqlItemBlock* res, size_t row) { + if (row > 0) { + // re-use already copied aqlvalues + for (RegisterId i = 0; i < cur->getNrRegs(); i++) { + res->setValue(row, i, res->getValue(0, i)); + // Note: if this throws, then all values will be deleted + // properly since the first one is. + } + } + size_t i = 0; for (auto it = _aggregateRegisters.begin(); it != _aggregateRegisters.end(); ++it) { // FIXME: can throw: