mirror of https://gitee.com/bigwinds/arangodb
Fix AQL in cluster bugs.
This commit is contained in:
parent
7f9ae321a0
commit
5bfdca8d69
|
@ -96,7 +96,7 @@ AqlItemBlock::AqlItemBlock(VPackSlice const slice) {
|
|||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
|
||||
"data must contain only numbers");
|
||||
}
|
||||
int64_t n = data.getNumericValue<int64_t>();
|
||||
int64_t n = dataEntry.getNumericValue<int64_t>();
|
||||
if (n == 0) {
|
||||
// empty, do nothing here
|
||||
} else if (n == -1) {
|
||||
|
@ -542,12 +542,10 @@ void AqlItemBlock::toVelocyPack(arangodb::AqlTransaction* trx,
|
|||
raw.close();
|
||||
data.close();
|
||||
|
||||
result.openObject();
|
||||
result.add("nrItems", VPackValue(_nrItems));
|
||||
result.add("nrRegs", VPackValue(_nrRegs));
|
||||
result.add("data", data.slice());
|
||||
result.add("raw", raw.slice());
|
||||
result.add("error", VPackValue(false));
|
||||
result.add("exhausted", VPackValue(false));
|
||||
result.close();
|
||||
}
|
||||
|
|
|
@ -1143,9 +1143,10 @@ void Query::getStats(VPackBuilder& builder) {
|
|||
if (_engine) {
|
||||
_engine->_stats.setExecutionTime(TRI_microtime() - _startTime);
|
||||
_engine->_stats.toVelocyPack(builder);
|
||||
}
|
||||
} else {
|
||||
ExecutionStats::toVelocyPackStatic(builder);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief fetch a boolean value from the options
|
||||
|
|
|
@ -142,7 +142,8 @@ void RestAqlHandler::createQueryFromVelocyPack() {
|
|||
return;
|
||||
}
|
||||
|
||||
sendResponse(arangodb::rest::HttpResponse::ACCEPTED, answerBody.slice());
|
||||
sendResponse(arangodb::rest::HttpResponse::ACCEPTED, answerBody.slice(),
|
||||
query->trx()->transactionContext().get());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -182,7 +183,9 @@ void RestAqlHandler::parseQuery() {
|
|||
|
||||
// Now prepare the answer:
|
||||
VPackBuilder answerBuilder;
|
||||
auto transactionContext = query->trx()->transactionContext();
|
||||
try {
|
||||
{
|
||||
VPackObjectBuilder guard(&answerBuilder);
|
||||
answerBuilder.add("parsed", VPackValue(true));
|
||||
answerBuilder.add(VPackValue("collections"));
|
||||
|
@ -203,11 +206,13 @@ void RestAqlHandler::parseQuery() {
|
|||
answerBuilder.add(VPackValue("ast"));
|
||||
answerBuilder.add(res.result->slice());
|
||||
res.result = nullptr;
|
||||
}
|
||||
sendResponse(arangodb::rest::HttpResponse::OK, answerBuilder.slice(),
|
||||
transactionContext.get());
|
||||
} catch (...) {
|
||||
generateError(HttpResponse::BAD, TRI_ERROR_OUT_OF_MEMORY,
|
||||
"out of memory");
|
||||
}
|
||||
sendResponse(arangodb::rest::HttpResponse::OK, answerBuilder.slice());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -251,6 +256,7 @@ void RestAqlHandler::explainQuery() {
|
|||
// Now prepare the answer:
|
||||
VPackBuilder answerBuilder;
|
||||
try {
|
||||
{
|
||||
VPackObjectBuilder guard(&answerBuilder);
|
||||
if (res.result != nullptr) {
|
||||
if (query->allPlans()) {
|
||||
|
@ -261,11 +267,13 @@ void RestAqlHandler::explainQuery() {
|
|||
answerBuilder.add(res.result->slice());
|
||||
res.result = nullptr;
|
||||
}
|
||||
}
|
||||
sendResponse(arangodb::rest::HttpResponse::OK, answerBuilder.slice(),
|
||||
query->trx()->transactionContext().get());
|
||||
} catch (...) {
|
||||
generateError(HttpResponse::BAD, TRI_ERROR_OUT_OF_MEMORY,
|
||||
"out of memory");
|
||||
}
|
||||
sendResponse(arangodb::rest::HttpResponse::OK, answerBuilder.slice());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -683,7 +691,9 @@ void RestAqlHandler::handleUseQuery(std::string const& operation, Query* query,
|
|||
}
|
||||
|
||||
VPackBuilder answerBuilder;
|
||||
auto transactionContext = query->trx()->transactionContext();
|
||||
try {
|
||||
{
|
||||
VPackObjectBuilder guard(&answerBuilder);
|
||||
if (operation == "lock") {
|
||||
// Mark current thread as potentially blocking:
|
||||
|
@ -847,7 +857,9 @@ void RestAqlHandler::handleUseQuery(std::string const& operation, Query* query,
|
|||
generateError(HttpResponse::NOT_FOUND, TRI_ERROR_HTTP_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
sendResponse(arangodb::rest::HttpResponse::OK, answerBuilder.slice());
|
||||
}
|
||||
sendResponse(arangodb::rest::HttpResponse::OK, answerBuilder.slice(),
|
||||
transactionContext.get());
|
||||
} catch (...) {
|
||||
LOG(ERR) << "OUT OF MEMORY when handling query.";
|
||||
generateError(HttpResponse::BAD, TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
@ -890,12 +902,13 @@ std::shared_ptr<VPackBuilder> RestAqlHandler::parseVelocyPackBody() {
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestAqlHandler::sendResponse(arangodb::rest::HttpResponse::HttpResponseCode const code,
|
||||
VPackSlice const slice) {
|
||||
VPackSlice const slice,
|
||||
TransactionContext* transactionContext) {
|
||||
createResponse(code);
|
||||
_response->setContentType("application/json; charset=utf-8");
|
||||
arangodb::basics::VPackStringBufferAdapter buffer(
|
||||
_response->body().stringBuffer());
|
||||
VPackDumper dumper(&buffer);
|
||||
VPackDumper dumper(&buffer, transactionContext->getVPackOptions());
|
||||
try {
|
||||
dumper.dump(slice);
|
||||
} catch (...) {
|
||||
|
|
|
@ -134,7 +134,8 @@ class RestAqlHandler : public RestVocbaseBaseHandler {
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void sendResponse(arangodb::rest::HttpResponse::HttpResponseCode const,
|
||||
arangodb::velocypack::Slice const);
|
||||
arangodb::velocypack::Slice const,
|
||||
TransactionContext*);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief handle for useQuery
|
||||
|
|
Loading…
Reference in New Issue