1
0
Fork 0

Improved stability of AQL Traverser. Also added checks for illegal edge cases

This commit is contained in:
Michael Hackstein 2015-12-18 15:12:39 +01:00
parent ba3fe43a4e
commit c00d0cbc4d
3 changed files with 31 additions and 7 deletions

View File

@ -648,6 +648,26 @@ ExecutionNode* ExecutionPlan::fromNodeTraversal (ExecutionNode* previous,
AstNode const* start = node->getMember(1);
AstNode const* graph = node->getMember(2);
if (start->type == NODE_TYPE_OBJECT &&
start->isConstant()) {
size_t n = start->numMembers();
for (size_t i = 0; i < n; ++i) {
auto member = start->getMember(i);
if (member->type == NODE_TYPE_OBJECT_ELEMENT &&
strncmp(member->getStringValue(), TRI_VOC_ATTRIBUTE_ID, member->getStringLength()) == 0) {
start = member->getMember(0);
break;
}
}
}
if (start->type != NODE_TYPE_REFERENCE &&
start->type != NODE_TYPE_VALUE) {
// operand is some misc expression
auto calc = createTemporaryCalculation(start, previous);
start = _ast->createNodeReference(getOutVariable(calc));
previous = calc;
}
// First create the node
auto travNode = new TraversalNode(this, nextId(), _ast->query()->vocbase(),
direction, start, graph);

View File

@ -115,7 +115,7 @@ TraversalBlock::TraversalBlock (ExecutionEngine* engine,
_trx,
_expressions));
}
if (!ep->usesInVariable()) {
if (! ep->usesInVariable()) {
_vertexId = ep->getStartVertex();
}
else {
@ -365,12 +365,16 @@ void TraversalBlock::initializePaths (AqlItemBlock const* items) {
}
}
}
else if (in._type == AqlValue::DOCVEC) {
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_QUERY_PARSE,
std::string("Only one start vertex allowed. Embed it in a FOR loop."));
else if (in.isString()) {
_vertexId = in.toString();
VertexId v = triagens::arango::traverser::IdStringToVertexId (
_resolver,
_vertexId
);
_traverser->setStartVertex(v);
}
else {
TRI_ASSERT(in.getTypeString() == "");
_engine->getQuery()->registerWarning(TRI_ERROR_BAD_PARAMETER, "Invalid input for traversal: Only strings or objects with _id are allowed");
}
}
}

View File

@ -269,7 +269,7 @@ namespace triagens {
: _readDocuments(0),
_filteredPaths(0),
_pruneNext(false),
_done(false),
_done(true),
_expressions(nullptr) {
}
@ -282,7 +282,7 @@ namespace triagens {
: _readDocuments(0),
_filteredPaths(0),
_pruneNext(false),
_done(false),
_done(true),
_opts(opts),
_expressions(expressions) {
}