mirror of https://gitee.com/bigwinds/arangodb
more cases for issue #324
This commit is contained in:
parent
a05edcdccc
commit
992c49d4a1
|
@ -270,7 +270,7 @@ TRI_json_t* TRI_GetJsonCollectionHintAql (TRI_aql_collection_hint_t* const hint)
|
||||||
TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE,
|
TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE,
|
||||||
result,
|
result,
|
||||||
"limit",
|
"limit",
|
||||||
TRI_CreateNumberJson(TRI_UNKNOWN_MEM_ZONE, (double) hint->_limit._limit));
|
TRI_CreateNumberJson(TRI_UNKNOWN_MEM_ZONE, (double) hint->_limit._offset + (double) hint->_limit._limit));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -470,6 +470,21 @@ static TRI_aql_node_t* AnnotateLoop (TRI_aql_statement_walker_t* const walker,
|
||||||
// check if we can apply a scope limit and push it into the for loop
|
// check if we can apply a scope limit and push it into the for loop
|
||||||
if (scope->_limit._status == TRI_AQL_LIMIT_USE) {
|
if (scope->_limit._status == TRI_AQL_LIMIT_USE) {
|
||||||
// yes!
|
// yes!
|
||||||
|
TRI_aql_node_t* expression = TRI_AQL_NODE_MEMBER(node, 1);
|
||||||
|
|
||||||
|
if (expression->_type == TRI_AQL_NODE_COLLECTION && ! scope->_limit._hasFilter) {
|
||||||
|
// move limit into the COLLECTION node
|
||||||
|
TRI_aql_collection_hint_t* hint = (TRI_aql_collection_hint_t*) TRI_AQL_NODE_DATA(expression);
|
||||||
|
|
||||||
|
if (hint != NULL) {
|
||||||
|
hint->_limit._offset = scope->_limit._offset;
|
||||||
|
hint->_limit._limit = scope->_limit._limit;
|
||||||
|
hint->_limit._status = TRI_AQL_LIMIT_USE;
|
||||||
|
hint->_limit._hasFilter = scope->_limit._hasFilter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// move limit into the FOR node
|
||||||
TRI_aql_for_hint_t* hint = (TRI_aql_for_hint_t*) TRI_AQL_NODE_DATA(node);
|
TRI_aql_for_hint_t* hint = (TRI_aql_for_hint_t*) TRI_AQL_NODE_DATA(node);
|
||||||
|
|
||||||
if (hint != NULL) {
|
if (hint != NULL) {
|
||||||
|
@ -481,6 +496,7 @@ static TRI_aql_node_t* AnnotateLoop (TRI_aql_statement_walker_t* const walker,
|
||||||
|
|
||||||
LOG_TRACE("using limit hint for for loop");
|
LOG_TRACE("using limit hint for for loop");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// deactive this limit for any further tries
|
// deactive this limit for any further tries
|
||||||
scope->_limit._status = TRI_AQL_LIMIT_IGNORE;
|
scope->_limit._status = TRI_AQL_LIMIT_IGNORE;
|
||||||
|
|
|
@ -192,7 +192,7 @@ function ahuacatlQueryOptimiserLimitTestSuite () {
|
||||||
|
|
||||||
var explain = explainQuery(query);
|
var explain = explainQuery(query);
|
||||||
assertEqual("for", explain[0].type);
|
assertEqual("for", explain[0].type);
|
||||||
assertEqual(true, explain[0].limit);
|
assertEqual(test.offset + test.limit, explain[0]["expression"]["extra"]["limit"]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ function ahuacatlQueryOptimiserLimitTestSuite () {
|
||||||
|
|
||||||
var explain = explainQuery(query);
|
var explain = explainQuery(query);
|
||||||
assertEqual("for", explain[0].type);
|
assertEqual("for", explain[0].type);
|
||||||
assertEqual(true, explain[0].limit);
|
assertEqual(test.offset + test.limit, explain[0]["expression"]["extra"]["limit"]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue