8000 fix failing query (#11317) · arangodb/arangodb@bc13057 · GitHub
[go: up one dir, main page]

Skip to content

Commit bc13057

Browse files
authored
fix failing query (#11317)
1 parent 552a82a commit bc13057

File tree

3 files changed

+47
-19
lines changed

3 files changed

+47
-19
lines changed

arangod/Aql/MultiAqlItemBlockInputRange.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,13 @@ auto MultiAqlItemBlockInputRange::skipAllRemainingDataRows() -> size_t {
165165
// Subtract up to count rows from the local _skipped state
166166
auto MultiAqlItemBlockInputRange::skipForDependency(size_t const dependency,
167167
size_t count) -> size_t {
168+
TRI_ASSERT(dependency < _inputs.size());
168169
return _inputs.at(dependency).skip(count);
169170
}
170171

171-
// Skipp all that is available
172+
// Skip all that is available
172173
auto MultiAqlItemBlockInputRange::skipAllForDependency(size_t const dependency) -> size_t {
174+
TRI_ASSERT(dependency < _inputs.size());
173175
return _inputs.at(dependency).skipAll();
174176
}
175177

arangod/Aql/UnsortedGatherExecutor.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ auto UnsortedGatherExecutor::skipRowsRange(typename Fetcher::DataRange& input, A
9393
-> std::tuple<ExecutorState, Stats, size_t, AqlCallSet> {
9494
auto skipped = size_t{0};
9595

96+
if (done()) {
97+
return {ExecutorState::DONE, Stats{}, skipped, AqlCallSet{}};
98+
}
99+
96100
if (call.getOffset() > 0) {
97101
skipped = input.skipForDependency(currentDependency(), call.getOffset());
98102
} else {
@@ -108,15 +112,14 @@ auto UnsortedGatherExecutor::skipRowsRange(typename Fetcher::DataRange& input, A
108112
// Here we are either done, or currentDependency() still could produce more
109113
if (done()) {
110114
return {ExecutorState::DONE, Stats{}, skipped, AqlCallSet{}};
111-
} else {
112-
// If we're not done skipping, we can just request the current clientcall
113-
// from upstream
114-
auto callSet = AqlCallSet{};
115-
if (call.needSkipMore()) {
116-
callSet.calls.emplace_back(AqlCallSet::DepCallPair{currentDependency(), call});
117-
}
118-
return {ExecutorState::HASMORE, Stats{}, skipped, callSet};
115< 10000 span class="diff-text-marker">+
}
116+
// If we're not done skipping, we can just request the current clientcall
117+
// from upstream
118+
auto callSet = AqlCallSet{};
119+
if (call.needSkipMore()) {
120+
callSet.calls.emplace_back(AqlCallSet::DepCallPair{currentDependency(), call});
119121
}
122+
return {ExecutorState::HASMORE, Stats{}, skipped, callSet};
120123
}
121124

122125
auto UnsortedGatherExecutor::numDependencies() const

tests/js/server/aql/aql-fullcount.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,11 @@
2828
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
2929
////////////////////////////////////////////////////////////////////////////////
3030

31-
var jsunity = require("jsunity");
32-
var db = require("@arangodb").db;
33-
34-
////////////////////////////////////////////////////////////////////////////////
35-
/// @brief test suite
36-
////////////////////////////////////////////////////////////////////////////////
31+
const jsunity = require("jsunity");
32+
const db = require("@arangodb").db;
3733

3834
function optimizerFullcountTestSuite () {
39-
var c;
35+
let c;
4036

4137
return {
4238
setUpAll : function () {
@@ -254,11 +250,38 @@ function optimizerFullcountTestSuite () {
254250
};
255251
}
256252

257-
////////////////////////////////////////////////////////////////////////////////
258-
/// @brief executes the test suite
259-
////////////////////////////////////////////////////////////////////////////////
253+
function optimizerFullcountQueryTestSuite () {
254+
let c;
255+
256+
return {
257+
setUp : function () {
258+
db._drop("UnitTestsCollection");
259+
c = db._create("UnitTestsCollection");
260+
c.ensureIndex({ type: "geo", fields: ["location"] });
261+
c.insert([
262+
{ location: [2, 0] },
263+
{ location: [3, 0] },
264+
{ location: [4, 0] },
265+
{ location: [6, 0] }
266+
]);
267+
},
268+
269+
tearDown : function () {
270+
db._drop("UnitTestsCollection");
271+
},
272+
273+
testQueryRegression : function () {
274+
let result = db._query({ query: "FOR e IN " + c.name() + " SORT DISTANCE(e.location[0], e.location[1], 0, 0) LIMIT 2, 2 RETURN e", options: { fullCount: true }}).toArray();
275+
assertEqual(2, result.length);
276+
assertEqual([4, 0], result[0].location);
277+
assertEqual([6, 0], result[1].location);
278+
},
279+
280+
};
281+
}
260282

261283
jsunity.run(optimizerFullcountTestSuite);
284+
jsunity.run(optimizerFullcountQueryTestSuite);
262285

263286
return jsunity.done();
264287

0 commit comments

Comments
 (0)
0