diff --git a/CHANGELOG b/CHANGELOG index c75c79418ecb..bb069c337bbf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ devel ----- +* Fix numeric overflow in AQL WINDOW node cost estimation if the number of + preceding rows was set to `unbounded`. + * Updated ArangoDB Starter to 0.15.1-preview-3. * Added garbage collection for finished and failed Pregel conductors. diff --git a/arangod/Aql/WindowNode.cpp b/arangod/Aql/WindowNode.cpp index 88c0972ae0d4..dd0f8a089615 100644 --- a/arangod/Aql/WindowNode.cpp +++ b/arangod/Aql/WindowNode.cpp @@ -492,8 +492,14 @@ CostEstimate WindowNode::estimateCost() const { // we never return more rows than above CostEstimate estimate = _dependencies.at(0)->getCost(); if (_rangeVariable == nullptr) { - int64_t numRows = 1 + _bounds.numPrecedingRows() + _bounds.numFollowingRows(); - estimate.estimatedCost += double(numRows * numRows) * _aggregateVariables.size(); + uint64_t numRows = 1; + if ( _bounds.unboundedPreceding()) { + numRows += estimate.estimatedNrItems; + } else { + numRows += std::min(estimate.estimatedNrItems, _bounds.numPrecedingRows()); + } + numRows += _bounds.numFollowingRows(); + estimate.estimatedCost += double(numRows) * double(numRows) * _aggregateVariables.size(); } else { // guestimate estimate.estimatedCost += 4 * _aggregateVariables.size(); }