diff --git a/arangod/Aql/Types.h b/arangod/Aql/Types.h index 037af49f85..d470818750 100644 --- a/arangod/Aql/Types.h +++ b/arangod/Aql/Types.h @@ -222,7 +222,6 @@ int CompareAqlValues ( AqlValue const& left, TRI_document_collection_t const* leftcoll, AqlValue const& right, TRI_document_collection_t const* rightcoll ) { - // is this right? J thinks not. if (_type != right._type) { if (_type == EMPTY) { return -1; @@ -231,11 +230,11 @@ int CompareAqlValues ( AqlValue const& left, return 1; } if (_type == JSON && right._type == SHAPED) { - triagens::basics::Json rjson = right.toJson(collection); + triagens::basics::Json rjson = right.toJson(rightcoll); return TRI_CompareValuesJson(_json->json(), rjson.json()); } if (_type == SHAPED && right._type == JSON) { - triagens::basics::Json ljson = toJson(collection); + triagens::basics::Json ljson = toJson(leftcoll); return TRI_CompareValuesJson(ljson.json(), right._json->json()); } // No other comparisons are defined @@ -254,11 +253,12 @@ int CompareAqlValues ( AqlValue const& left, TRI_EXTRACT_SHAPED_JSON_MARKER(l, _marker); TRI_EXTRACT_SHAPED_JSON_MARKER(r, right._marker); - return TRI_CompareShapeTypes(nullptr, nullptr, &l, nullptr, nullptr, &r, - collection->getShaper()); + return TRI_CompareShapeTypes(nullptr, nullptr, &l, leftcoll->getShaper(), + nullptr, nullptr, &r, rightcoll->getShaper()); } - case DOCVEC: { //ptr to vector of AqlItemBlocks* - //use lexicographic ordering of AqlValue regardless of block... + case DOCVEC: { + // use lexicographic ordering of AqlValues regardless of block, + // DOCVECs have a single register coming from ReturnNode. size_t lblock = 0; size_t litem = 0; size_t rblock = 0; @@ -267,16 +267,16 @@ int CompareAqlValues ( AqlValue const& left, while( lblock < _vector->size() && rblock < right._vector->size() ){ AqlValue lval = ((*_vector->at(lblock)).getValue(litem, 0); AqlValue rval = right._vector->at(rblock).getValue(ritem, 0); - - if(lval.compare(rval, rval.getDocumentCollection(0))!=0){ - return this[lblock]->at(litem).compare(right[rblock]->at(ritem), - getDocumentCollection(?)); + cmp = CompareAqlValues(lval, lval.getDocumentCollection(0) + rval, rval.getDocumentCollection(0)); + if(cmp != 0){ + return cmp; } - if(litem==this[lblock].size()-1){ + if(litem == this[lblock].size()-1){ litem = 0; lblock++; } - if(ritem==right[rblock].size()-1){ + if(ritem == right[rblock].size()-1){ ritem = 0; rblock++; }