1
0
Fork 0

added try...catch blocks for V8-to-CPP bindings

This commit is contained in:
Jan Steemann 2015-06-08 16:04:42 +02:00
parent 7b366ca130
commit a6b2998b5d
25 changed files with 1105 additions and 862 deletions

View File

@ -809,6 +809,14 @@ QueryResult Query::parse () {
catch (triagens::basics::Exception const& ex) {
return QueryResult(ex.code(), ex.message());
}
catch (std::bad_alloc const&) {
cleanupPlanAndEngine(TRI_ERROR_OUT_OF_MEMORY);
return QueryResult(TRI_ERROR_OUT_OF_MEMORY, TRI_errno_string(TRI_ERROR_OUT_OF_MEMORY));
}
catch (std::exception const& ex) {
cleanupPlanAndEngine(TRI_ERROR_INTERNAL);
return QueryResult(TRI_ERROR_INTERNAL, ex.what());
}
catch (...) {
return QueryResult(TRI_ERROR_OUT_OF_MEMORY, TRI_errno_string(TRI_ERROR_OUT_OF_MEMORY));
}

View File

@ -142,6 +142,7 @@ AqlValue V8Expression::execute (v8::Isolate* isolate,
}
catch (...) {
v8g->_query = old;
// bubble up exception
throw;
}

View File

@ -84,7 +84,7 @@ static void CreateAgencyException (const v8::FunctionCallbackInfo<v8::Value>& ar
////////////////////////////////////////////////////////////////////////////////
static void JS_CasAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 3) {
@ -136,6 +136,7 @@ static void JS_CasAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -143,10 +144,9 @@ static void JS_CasAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_CreateDirectoryAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
TRI_V8_THROW_EXCEPTION_USAGE("createDirectory(<key>)");
}
@ -161,6 +161,7 @@ static void JS_CreateDirectoryAgency (const v8::FunctionCallbackInfo<v8::Value>&
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -168,7 +169,7 @@ static void JS_CreateDirectoryAgency (const v8::FunctionCallbackInfo<v8::Value>&
////////////////////////////////////////////////////////////////////////////////
static void JS_IsEnabledAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate)
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -180,10 +181,8 @@ static void JS_IsEnabledAgency (const v8::FunctionCallbackInfo<v8::Value>& args)
if (! prefix.empty()) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -191,7 +190,7 @@ static void JS_IsEnabledAgency (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_IncreaseVersionAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate)
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -206,6 +205,7 @@ static void JS_IncreaseVersionAgency (const v8::FunctionCallbackInfo<v8::Value>&
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -213,7 +213,7 @@ static void JS_IncreaseVersionAgency (const v8::FunctionCallbackInfo<v8::Value>&
////////////////////////////////////////////////////////////////////////////////
static void JS_GetAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate)
v8::HandleScope scope(isolate);
if (args.Length() < 1) {
@ -279,6 +279,7 @@ static void JS_GetAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(l);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -286,7 +287,7 @@ static void JS_GetAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_ListAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate)
v8::HandleScope scope(isolate);
if (args.Length() < 1) {
@ -346,6 +347,7 @@ static void JS_ListAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(l);
}
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -353,7 +355,7 @@ static void JS_ListAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_LockReadAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1) {
@ -378,6 +380,7 @@ static void JS_LockReadAgency (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -385,7 +388,7 @@ static void JS_LockReadAgency (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_LockWriteAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1) {
@ -410,6 +413,7 @@ static void JS_LockWriteAgency (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -417,7 +421,7 @@ static void JS_LockWriteAgency (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_UnlockReadAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() > 2) {
@ -437,6 +441,7 @@ static void JS_UnlockReadAgency (const v8::FunctionCallbackInfo<v8::Value>& args
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -444,7 +449,7 @@ static void JS_UnlockReadAgency (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_UnlockWriteAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() > 2) {
@ -464,6 +469,7 @@ static void JS_UnlockWriteAgency (const v8::FunctionCallbackInfo<v8::Value>& arg
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -471,7 +477,7 @@ static void JS_UnlockWriteAgency (const v8::FunctionCallbackInfo<v8::Value>& arg
////////////////////////////////////////////////////////////////////////////////
static void JS_RemoveAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1) {
@ -493,6 +499,7 @@ static void JS_RemoveAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -500,7 +507,7 @@ static void JS_RemoveAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_SetAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2) {
@ -530,6 +537,7 @@ static void JS_SetAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -537,7 +545,7 @@ static void JS_SetAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_WatchAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1) {
@ -588,6 +596,7 @@ static void JS_WatchAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(l);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -595,7 +604,7 @@ static void JS_WatchAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_EndpointsAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -616,6 +625,7 @@ static void JS_EndpointsAgency (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN(l);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -623,7 +633,7 @@ static void JS_EndpointsAgency (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_PrefixAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() > 1) {
@ -642,6 +652,7 @@ static void JS_PrefixAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_STD_STRING(prefix);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -649,7 +660,7 @@ static void JS_PrefixAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_SetPrefixAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -662,6 +673,7 @@ static void JS_SetPrefixAgency (const v8::FunctionCallbackInfo<v8::Value>& args)
TRI_V8_RETURN_TRUE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -669,7 +681,7 @@ static void JS_SetPrefixAgency (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_UniqidAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1 || args.Length() > 3) {
@ -702,6 +714,7 @@ static void JS_UniqidAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
const std::string value = StringUtils::itoa(result._index);
TRI_V8_RETURN_STD_STRING(value);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -709,7 +722,7 @@ static void JS_UniqidAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_VersionAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -720,6 +733,7 @@ static void JS_VersionAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
const std::string version = comm.getVersion();
TRI_V8_RETURN_STD_STRING(version);
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------
@ -731,7 +745,7 @@ static void JS_VersionAgency (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_DoesDatabaseExistClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -743,9 +757,8 @@ static void JS_DoesDatabaseExistClusterInfo (const v8::FunctionCallbackInfo<v8::
if (result) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -753,7 +766,7 @@ static void JS_DoesDatabaseExistClusterInfo (const v8::FunctionCallbackInfo<v8::
////////////////////////////////////////////////////////////////////////////////
static void JS_ListDatabases (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -768,6 +781,7 @@ static void JS_ListDatabases (const v8::FunctionCallbackInfo<v8::Value>& args) {
a->Set((uint32_t) count++, TRI_V8_STD_STRING((*it)));
}
TRI_V8_RETURN(a);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -775,7 +789,7 @@ static void JS_ListDatabases (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_FlushClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -785,6 +799,7 @@ static void JS_FlushClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& args
ClusterInfo::instance()->flush();
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -792,7 +807,7 @@ static void JS_FlushClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_GetCollectionInfoClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 2) {
@ -842,6 +857,7 @@ static void JS_GetCollectionInfoClusterInfo (const v8::FunctionCallbackInfo<v8::
v8::Handle<v8::Array> indexes = v8::Array::New(isolate);
result->Set(TRI_V8_ASCII_STRING("indexes"), indexes);
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -849,7 +865,7 @@ static void JS_GetCollectionInfoClusterInfo (const v8::FunctionCallbackInfo<v8::
////////////////////////////////////////////////////////////////////////////////
static void JS_GetCollectionInfoCurrentClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 3) {
@ -905,6 +921,7 @@ static void JS_GetCollectionInfoCurrentClusterInfo (const v8::FunctionCallbackIn
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -912,7 +929,7 @@ static void JS_GetCollectionInfoCurrentClusterInfo (const v8::FunctionCallbackIn
////////////////////////////////////////////////////////////////////////////////
static void JS_GetResponsibleServerClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -922,6 +939,7 @@ static void JS_GetResponsibleServerClusterInfo (const v8::FunctionCallbackInfo<v
std::string const result = ClusterInfo::instance()->getResponsibleServer(TRI_ObjectToString(args[0]));
TRI_V8_RETURN_STD_STRING(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -929,7 +947,7 @@ static void JS_GetResponsibleServerClusterInfo (const v8::FunctionCallbackInfo<v
////////////////////////////////////////////////////////////////////////////////
static void JS_GetResponsibleShardClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2 || args.Length() > 3) {
@ -949,7 +967,7 @@ static void JS_GetResponsibleShardClusterInfo (const v8::FunctionCallbackInfo<v8
documentIsComplete = TRI_ObjectToBoolean(args[2]);
}
TRI_json_t* json = TRI_ObjectToJson(isolate, args[1]);
std::unique_ptr<TRI_json_t> json(TRI_ObjectToJson(isolate, args[1]));
if (json == nullptr) {
TRI_V8_THROW_EXCEPTION_MEMORY();
@ -958,9 +976,7 @@ static void JS_GetResponsibleShardClusterInfo (const v8::FunctionCallbackInfo<v8
ShardID shardId;
CollectionID collectionId = TRI_ObjectToString(args[0]);
bool usesDefaultShardingAttributes;
int res = ClusterInfo::instance()->getResponsibleShard(collectionId, json, documentIsComplete, shardId, usesDefaultShardingAttributes);
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
int res = ClusterInfo::instance()->getResponsibleShard(collectionId, json.get(), documentIsComplete, shardId, usesDefaultShardingAttributes);
if (res != TRI_ERROR_NO_ERROR) {
TRI_V8_THROW_EXCEPTION(res);
@ -971,6 +987,7 @@ static void JS_GetResponsibleShardClusterInfo (const v8::FunctionCallbackInfo<v8
result->Set(TRI_V8_ASCII_STRING("usesDefaultShardingAttributes"), v8::Boolean::New(isolate, usesDefaultShardingAttributes));
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -978,7 +995,7 @@ static void JS_GetResponsibleShardClusterInfo (const v8::FunctionCallbackInfo<v8
////////////////////////////////////////////////////////////////////////////////
static void JS_GetServerEndpointClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -988,6 +1005,7 @@ static void JS_GetServerEndpointClusterInfo (const v8::FunctionCallbackInfo<v8::
const std::string result = ClusterInfo::instance()->getServerEndpoint(TRI_ObjectToString(args[0]));
TRI_V8_RETURN_STD_STRING(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -995,7 +1013,7 @@ static void JS_GetServerEndpointClusterInfo (const v8::FunctionCallbackInfo<v8::
////////////////////////////////////////////////////////////////////////////////
static void JS_GetServerNameClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -1005,6 +1023,7 @@ static void JS_GetServerNameClusterInfo (const v8::FunctionCallbackInfo<v8::Valu
const std::string result = ClusterInfo::instance()->getServerName(TRI_ObjectToString(args[0]));
TRI_V8_RETURN_STD_STRING(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1012,7 +1031,7 @@ static void JS_GetServerNameClusterInfo (const v8::FunctionCallbackInfo<v8::Valu
////////////////////////////////////////////////////////////////////////////////
static void JS_GetDBServers (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1030,6 +1049,7 @@ static void JS_GetDBServers (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(l);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1037,7 +1057,7 @@ static void JS_GetDBServers (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_ReloadDBServers (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1046,6 +1066,7 @@ static void JS_ReloadDBServers (const v8::FunctionCallbackInfo<v8::Value>& args)
ClusterInfo::instance()->loadCurrentDBServers();
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1053,7 +1074,7 @@ static void JS_ReloadDBServers (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_GetCoordinators (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1071,6 +1092,7 @@ static void JS_GetCoordinators (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN(l);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1078,7 +1100,7 @@ static void JS_GetCoordinators (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_UniqidClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() > 1) {
@ -1103,6 +1125,7 @@ static void JS_UniqidClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& arg
const std::string id = StringUtils::itoa(value);
TRI_V8_RETURN_STD_STRING(id);
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------
@ -1114,7 +1137,7 @@ static void JS_UniqidClusterInfo (const v8::FunctionCallbackInfo<v8::Value>& arg
////////////////////////////////////////////////////////////////////////////////
static void JS_AddressServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1123,6 +1146,7 @@ static void JS_AddressServerState (const v8::FunctionCallbackInfo<v8::Value>& ar
const std::string address = ServerState::instance()->getAddress();
TRI_V8_RETURN_STD_STRING(address);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1130,7 +1154,7 @@ static void JS_AddressServerState (const v8::FunctionCallbackInfo<v8::Value>& ar
////////////////////////////////////////////////////////////////////////////////
static void JS_FlushServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1140,6 +1164,7 @@ static void JS_FlushServerState (const v8::FunctionCallbackInfo<v8::Value>& args
ServerState::instance()->flush();
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1147,7 +1172,7 @@ static void JS_FlushServerState (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_LocalInfoServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1156,6 +1181,7 @@ static void JS_LocalInfoServerState (const v8::FunctionCallbackInfo<v8::Value>&
const std::string li = ServerState::instance()->getLocalInfo();
TRI_V8_RETURN_STD_STRING(li);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1163,7 +1189,7 @@ static void JS_LocalInfoServerState (const v8::FunctionCallbackInfo<v8::Value>&
////////////////////////////////////////////////////////////////////////////////
static void JS_IdServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1172,6 +1198,7 @@ static void JS_IdServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
const std::string id = ServerState::instance()->getId();
TRI_V8_RETURN_STD_STRING(id);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1179,7 +1206,7 @@ static void JS_IdServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_DescriptionServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1188,6 +1215,7 @@ static void JS_DescriptionServerState (const v8::FunctionCallbackInfo<v8::Value>
const std::string description = ServerState::instance()->getDescription();
TRI_V8_RETURN_STD_STRING(description);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1195,7 +1223,7 @@ static void JS_DescriptionServerState (const v8::FunctionCallbackInfo<v8::Value>
////////////////////////////////////////////////////////////////////////////////
static void JS_DataPathServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1204,6 +1232,7 @@ static void JS_DataPathServerState (const v8::FunctionCallbackInfo<v8::Value>& a
const std::string path = ServerState::instance()->getDataPath();
TRI_V8_RETURN_STD_STRING(path);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1211,7 +1240,7 @@ static void JS_DataPathServerState (const v8::FunctionCallbackInfo<v8::Value>& a
////////////////////////////////////////////////////////////////////////////////
static void JS_LogPathServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1220,6 +1249,7 @@ static void JS_LogPathServerState (const v8::FunctionCallbackInfo<v8::Value>& ar
const std::string path = ServerState::instance()->getLogPath();
TRI_V8_RETURN_STD_STRING(path);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1227,7 +1257,7 @@ static void JS_LogPathServerState (const v8::FunctionCallbackInfo<v8::Value>& ar
////////////////////////////////////////////////////////////////////////////////
static void JS_AgentPathServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1236,6 +1266,7 @@ static void JS_AgentPathServerState (const v8::FunctionCallbackInfo<v8::Value>&
const std::string path = ServerState::instance()->getAgentPath();
TRI_V8_RETURN_STD_STRING(path);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1243,7 +1274,7 @@ static void JS_AgentPathServerState (const v8::FunctionCallbackInfo<v8::Value>&
////////////////////////////////////////////////////////////////////////////////
static void JS_ArangodPathServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1252,6 +1283,7 @@ static void JS_ArangodPathServerState (const v8::FunctionCallbackInfo<v8::Value>
const std::string path = ServerState::instance()->getArangodPath();
TRI_V8_RETURN_STD_STRING(path);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1259,7 +1291,7 @@ static void JS_ArangodPathServerState (const v8::FunctionCallbackInfo<v8::Value>
////////////////////////////////////////////////////////////////////////////////
static void JS_JavaScriptPathServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1268,6 +1300,7 @@ static void JS_JavaScriptPathServerState (const v8::FunctionCallbackInfo<v8::Val
const std::string path = ServerState::instance()->getJavaScriptPath();
TRI_V8_RETURN_STD_STRING(path);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1275,7 +1308,7 @@ static void JS_JavaScriptPathServerState (const v8::FunctionCallbackInfo<v8::Val
////////////////////////////////////////////////////////////////////////////////
static void JS_DBserverConfigServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1284,6 +1317,7 @@ static void JS_DBserverConfigServerState (const v8::FunctionCallbackInfo<v8::Val
const std::string path = ServerState::instance()->getDBserverConfig();
TRI_V8_RETURN_STD_STRING(path);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1291,7 +1325,7 @@ static void JS_DBserverConfigServerState (const v8::FunctionCallbackInfo<v8::Val
////////////////////////////////////////////////////////////////////////////////
static void JS_CoordinatorConfigServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1300,6 +1334,7 @@ static void JS_CoordinatorConfigServerState (const v8::FunctionCallbackInfo<v8::
const std::string path = ServerState::instance()->getCoordinatorConfig();
TRI_V8_RETURN_STD_STRING(path);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1307,7 +1342,7 @@ static void JS_CoordinatorConfigServerState (const v8::FunctionCallbackInfo<v8::
////////////////////////////////////////////////////////////////////////////////
static void JS_DisableDipatcherFrontendServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1317,9 +1352,8 @@ static void JS_DisableDipatcherFrontendServerState (const v8::FunctionCallbackIn
if (ServerState::instance()->getDisableDispatcherFrontend()) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1327,7 +1361,7 @@ static void JS_DisableDipatcherFrontendServerState (const v8::FunctionCallbackIn
////////////////////////////////////////////////////////////////////////////////
static void JS_DisableDipatcherKickstarterServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1337,9 +1371,8 @@ static void JS_DisableDipatcherKickstarterServerState (const v8::FunctionCallbac
if (ServerState::instance()->getDisableDispatcherKickstarter()) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1347,7 +1380,7 @@ static void JS_DisableDipatcherKickstarterServerState (const v8::FunctionCallbac
////////////////////////////////////////////////////////////////////////////////
static void JS_InitialisedServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1357,9 +1390,8 @@ static void JS_InitialisedServerState (const v8::FunctionCallbackInfo<v8::Value>
if (ServerState::instance()->initialised()) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1367,7 +1399,7 @@ static void JS_InitialisedServerState (const v8::FunctionCallbackInfo<v8::Value>
////////////////////////////////////////////////////////////////////////////////
static void JS_IsCoordinatorServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1377,9 +1409,8 @@ static void JS_IsCoordinatorServerState (const v8::FunctionCallbackInfo<v8::Valu
if (ServerState::instance()->getRole() == ServerState::ROLE_COORDINATOR) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1387,7 +1418,7 @@ static void JS_IsCoordinatorServerState (const v8::FunctionCallbackInfo<v8::Valu
////////////////////////////////////////////////////////////////////////////////
static void JS_RoleServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1397,6 +1428,7 @@ static void JS_RoleServerState (const v8::FunctionCallbackInfo<v8::Value>& args)
const std::string role = ServerState::roleToString(ServerState::instance()->getRole());
TRI_V8_RETURN_STD_STRING(role);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1404,7 +1436,7 @@ static void JS_RoleServerState (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_SetLocalInfoServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -1415,6 +1447,7 @@ static void JS_SetLocalInfoServerState (const v8::FunctionCallbackInfo<v8::Value
ServerState::instance()->setLocalInfo(li);
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1422,7 +1455,7 @@ static void JS_SetLocalInfoServerState (const v8::FunctionCallbackInfo<v8::Value
////////////////////////////////////////////////////////////////////////////////
static void JS_SetIdServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -1433,6 +1466,7 @@ static void JS_SetIdServerState (const v8::FunctionCallbackInfo<v8::Value>& args
ServerState::instance()->setId(id);
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1440,7 +1474,7 @@ static void JS_SetIdServerState (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_SetRoleServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -1457,6 +1491,7 @@ static void JS_SetRoleServerState (const v8::FunctionCallbackInfo<v8::Value>& ar
ServerState::instance()->setRole(r);
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1464,7 +1499,7 @@ static void JS_SetRoleServerState (const v8::FunctionCallbackInfo<v8::Value>& ar
////////////////////////////////////////////////////////////////////////////////
static void JS_StatusServerState (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1474,6 +1509,7 @@ static void JS_StatusServerState (const v8::FunctionCallbackInfo<v8::Value>& arg
const std::string state = ServerState::stateToString(ServerState::instance()->getState());
TRI_V8_RETURN_STD_STRING(state);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1481,7 +1517,7 @@ static void JS_StatusServerState (const v8::FunctionCallbackInfo<v8::Value>& arg
////////////////////////////////////////////////////////////////////////////////
static void JS_GetClusterAuthentication (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -1495,6 +1531,7 @@ static void JS_GetClusterAuthentication (const v8::FunctionCallbackInfo<v8::Valu
}
TRI_V8_RETURN_STD_STRING(auth);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1726,7 +1763,7 @@ static void Return_PrepareClusterCommResultForJS (const v8::FunctionCallbackInfo
////////////////////////////////////////////////////////////////////////////////
static void JS_AsyncRequest (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 4 || args.Length() > 7) {
@ -1778,6 +1815,7 @@ static void JS_AsyncRequest (const v8::FunctionCallbackInfo<v8::Value>& args) {
Return_PrepareClusterCommResultForJS(args, res);
delete res;
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1785,7 +1823,7 @@ static void JS_AsyncRequest (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_SyncRequest (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 4 || args.Length() > 7) {
@ -1837,6 +1875,7 @@ static void JS_SyncRequest (const v8::FunctionCallbackInfo<v8::Value>& args) {
Return_PrepareClusterCommResultForJS(args, res);
delete res;
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1844,7 +1883,7 @@ static void JS_SyncRequest (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_Enquire (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -1875,6 +1914,7 @@ static void JS_Enquire (const v8::FunctionCallbackInfo<v8::Value>& args) {
Return_PrepareClusterCommResultForJS(args, res);
delete res;
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1882,7 +1922,7 @@ static void JS_Enquire (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_Wait (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
TRI_V8_CURRENT_GLOBALS_AND_SCOPE;
if (args.Length() != 1) {
@ -1956,6 +1996,7 @@ static void JS_Wait (const v8::FunctionCallbackInfo<v8::Value>& args) {
Return_PrepareClusterCommResultForJS(args, res);
delete res;
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1963,7 +2004,7 @@ static void JS_Wait (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_Drop (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
TRI_V8_CURRENT_GLOBALS_AND_SCOPE;
if (args.Length() != 1) {
@ -2021,6 +2062,7 @@ static void JS_Drop (const v8::FunctionCallbackInfo<v8::Value>& args) {
cc->drop(myclientTransactionID, mycoordTransactionID, myoperationID, myshardID);
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------

View File

@ -1353,19 +1353,34 @@ int ArangoServer::runScript (TRI_vocbase_t* vocbase) {
}
else {
v8::Handle<v8::Value> args[] = { params };
v8::Handle<v8::Value> result = main->Call(main, 1, args);
if (tryCatch.HasCaught()) {
if (tryCatch.CanContinue()) {
TRI_LogV8Exception(isolate, &tryCatch);
try {
v8::Handle<v8::Value> result = main->Call(main, 1, args);
if (tryCatch.HasCaught()) {
if (tryCatch.CanContinue()) {
TRI_LogV8Exception(isolate, &tryCatch);
}
else {
// will stop, so need for v8g->_canceled = true;
TRI_ASSERT(! ok);
}
}
else {
// will stop, so need for v8g->_canceled = true;
TRI_ASSERT(! ok);
ok = TRI_ObjectToDouble(result) == 0;
}
}
else {
ok = TRI_ObjectToDouble(result) == 0;
catch (triagens::basics::Exception const& ex) {
LOG_ERROR("caught exception %s: %s", TRI_errno_string(ex.code()), ex.what());
ok = false;
}
catch (std::bad_alloc const&) {
LOG_ERROR("caught exception %s", TRI_errno_string(TRI_ERROR_OUT_OF_MEMORY));
ok = false;
}
catch (...) {
LOG_ERROR("caught unknown exception");
ok = false;
}
}
}

View File

@ -220,7 +220,7 @@ void ApplicationV8::V8Context::handleGlobalContextMethods () {
_globalMethods.clear();
}
for (auto type : copy) {
for (auto& type : copy) {
string const& func = GlobalContextMethods::getCode(type);
LOG_DEBUG("executing global context methods '%s' for context %d", func.c_str(), (int) _id);

View File

@ -136,8 +136,8 @@ Job::status_t V8Job::work () {
fArgs = v8::Undefined(isolate);
}
// call the function wihtin a try/catch
{
// call the function within a try/catch
try {
v8::TryCatch tryCatch;
action->Call(current, 1, &fArgs);
@ -154,6 +154,15 @@ Job::status_t V8Job::work () {
}
}
}
catch (triagens::basics::Exception const& ex) {
LOG_ERROR("caught exception in V8 job: %s %s", TRI_errno_string(ex.code()), ex.what());
}
catch (std::bad_alloc const&) {
LOG_ERROR("caught exception in V8 job: %s", TRI_errno_string(TRI_ERROR_OUT_OF_MEMORY));
}
catch (...) {
LOG_ERROR("caught unknown exception in V8 job");
}
}
_v8Dealer->exitContext(context);

View File

@ -136,20 +136,31 @@ Job::status_t V8QueueJob::work () {
}
// call the function
v8::TryCatch tryCatch;
main->Call(current, 1, &fArgs);
try {
v8::TryCatch tryCatch;
main->Call(current, 1, &fArgs);
if (tryCatch.HasCaught()) {
if (tryCatch.CanContinue()) {
TRI_LogV8Exception(isolate, &tryCatch);
}
else {
TRI_GET_GLOBALS();
if (tryCatch.HasCaught()) {
if (tryCatch.CanContinue()) {
TRI_LogV8Exception(isolate, &tryCatch);
}
else {
TRI_GET_GLOBALS();
v8g->_canceled = true;
LOG_WARNING("caught non-catchable exception (aka termination) in V8 queue job");
v8g->_canceled = true;
LOG_WARNING("caught non-catchable exception (aka termination) in V8 queue job");
}
}
}
catch (triagens::basics::Exception const& ex) {
LOG_ERROR("caught exception in V8 queue job: %s %s", TRI_errno_string(ex.code()), ex.what());
}
catch (std::bad_alloc const&) {
LOG_ERROR("caught exception in V8 queue job: %s", TRI_errno_string(TRI_ERROR_OUT_OF_MEMORY));
}
catch (...) {
LOG_ERROR("caught unknown exception in V8 queue job");
}
}
_v8Dealer->exitContext(context);

View File

@ -717,8 +717,6 @@ static TRI_action_result_t ExecuteActionVocbase (TRI_vocbase_t* vocbase,
TRI_action_t const* action,
v8::Handle<v8::Function> callback,
HttpRequest* request) {
TRI_action_result_t result;
v8::TryCatch tryCatch;
v8::HandleScope scope(isolate);
@ -758,17 +756,46 @@ static TRI_action_result_t ExecuteActionVocbase (TRI_vocbase_t* vocbase,
// execute the callback
v8::Handle<v8::Value> args[2] = { req, res };
callback->Call(callback, 2, args);
// handle C++ exceptions that happen during dynamic script execution
int errorCode;
std::string errorMessage;
try {
callback->Call(callback, 2, args);
errorCode = TRI_ERROR_NO_ERROR;
}
catch (triagens::basics::Exception const& ex) {
errorCode = ex.code();
errorMessage = ex.what();
}
catch (std::bad_alloc const&) {
errorCode = TRI_ERROR_OUT_OF_MEMORY;
}
catch (...) {
errorCode = TRI_ERROR_INTERNAL;
}
// invalidate request / response objects
v8g->_currentRequest = v8::Undefined(isolate);
v8g->_currentResponse = v8::Undefined(isolate);
// convert the result
TRI_action_result_t result;
result.isValid = true;
if (v8g->_canceled) {
result.isValid = false;
if (errorCode != TRI_ERROR_NO_ERROR) {
result.isValid = false;
result.canceled = false;
HttpResponse* response = new HttpResponse(HttpResponse::SERVER_ERROR, request->compatibility());
if (errorMessage.empty()) {
errorMessage = TRI_errno_string(errorCode);
}
response->body().appendText(errorMessage);
}
else if (v8g->_canceled) {
result.isValid = false;
result.canceled = true;
}
@ -784,17 +811,15 @@ static TRI_action_result_t ExecuteActionVocbase (TRI_vocbase_t* vocbase,
result.sleep = TRI_ObjectToDouble(exception->ToObject()->Get(SleepKey));
}
else {
string msg = TRI_StringifyV8Exception(isolate, &tryCatch);
HttpResponse* response = new HttpResponse(HttpResponse::SERVER_ERROR, request->compatibility());
response->body().appendText(msg);
response->body().appendText(TRI_StringifyV8Exception(isolate, &tryCatch));
result.response = response;
}
}
else {
v8g->_canceled = true;
result.isValid = false;
v8g->_canceled = true;
result.isValid = false;
result.canceled = true;
}
}
@ -817,7 +842,7 @@ static TRI_action_result_t ExecuteActionVocbase (TRI_vocbase_t* vocbase,
////////////////////////////////////////////////////////////////////////////////
static void JS_DefineAction (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_GET_GLOBALS();
@ -874,6 +899,7 @@ static void JS_DefineAction (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -883,7 +909,7 @@ static void JS_DefineAction (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_ExecuteGlobalContextFunction (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -905,6 +931,7 @@ static void JS_ExecuteGlobalContextFunction (const v8::FunctionCallbackInfo<v8::
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -914,7 +941,7 @@ static void JS_ExecuteGlobalContextFunction (const v8::FunctionCallbackInfo<v8::
////////////////////////////////////////////////////////////////////////////////
static void JS_GetCurrentRequest (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_GET_GLOBALS();
@ -923,6 +950,7 @@ static void JS_GetCurrentRequest (const v8::FunctionCallbackInfo<v8::Value>& arg
}
TRI_V8_RETURN(v8g->_currentRequest);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -932,7 +960,7 @@ static void JS_GetCurrentRequest (const v8::FunctionCallbackInfo<v8::Value>& arg
////////////////////////////////////////////////////////////////////////////////
static void JS_RawRequestBody (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -956,6 +984,7 @@ static void JS_RawRequestBody (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -965,7 +994,7 @@ static void JS_RawRequestBody (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_RequestParts (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -1121,6 +1150,7 @@ static void JS_RequestParts (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1130,7 +1160,7 @@ static void JS_RequestParts (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_GetCurrentResponse (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_GET_GLOBALS();
@ -1139,6 +1169,7 @@ static void JS_GetCurrentResponse (const v8::FunctionCallbackInfo<v8::Value>& ar
}
TRI_V8_RETURN(v8g->_currentResponse);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1162,7 +1193,7 @@ class CallbackTest : public ClusterCommCallback {
};
static void JS_ClusterTest (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_GET_GLOBALS();
@ -1380,6 +1411,7 @@ static void JS_ClusterTest (const v8::FunctionCallbackInfo<v8::Value>& args) {
delete res;
TRI_V8_RETURN(r);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1387,7 +1419,7 @@ static void JS_ClusterTest (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_SendChunk (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 2) {
@ -1406,6 +1438,7 @@ static void JS_SendChunk (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(res == TRI_ERROR_NO_ERROR ? v8::True(isolate) : v8::False(isolate));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1413,7 +1446,7 @@ static void JS_SendChunk (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_CreateSid (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 2) {
@ -1434,6 +1467,7 @@ static void JS_CreateSid (const v8::FunctionCallbackInfo<v8::Value>& args) {
VocbaseContext::createSid(v8g->_vocbase->_name, *sidStr, *username);
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1441,7 +1475,7 @@ static void JS_CreateSid (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_ClearSid (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -1460,6 +1494,7 @@ static void JS_ClearSid (const v8::FunctionCallbackInfo<v8::Value>& args) {
VocbaseContext::clearSid(v8g->_vocbase->_name, *sidStr);
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1467,7 +1502,7 @@ static void JS_ClearSid (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_AccessSid (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -1486,6 +1521,7 @@ static void JS_AccessSid (const v8::FunctionCallbackInfo<v8::Value>& args) {
double lastAccess = VocbaseContext::accessSid(v8g->_vocbase->_name, *sidStr);
TRI_V8_RETURN(v8::Number::New(isolate, lastAccess));
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------

View File

@ -1530,7 +1530,9 @@ static void RemoveVocbaseCol (bool useCollection,
////////////////////////////////////////////////////////////////////////////////
static void JS_DocumentVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
DocumentVocbaseCol(true, args);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1584,7 +1586,7 @@ static void DropVocbaseColCoordinator (const v8::FunctionCallbackInfo<v8::Value>
////////////////////////////////////////////////////////////////////////////////
static void JS_DropVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -1608,6 +1610,7 @@ static void JS_DropVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1640,7 +1643,9 @@ static void JS_DropVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_ExistsVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
return ExistsVocbaseCol(true, args);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1783,7 +1788,7 @@ static TRI_doc_collection_info_t* GetFigures (TRI_vocbase_col_t* collection) {
////////////////////////////////////////////////////////////////////////////////
static void JS_FiguresVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -1871,6 +1876,7 @@ static void JS_FiguresVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& arg
TRI_Free(TRI_UNKNOWN_MEM_ZONE, info);
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1894,7 +1900,7 @@ static void JS_FiguresVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& arg
////////////////////////////////////////////////////////////////////////////////
static void JS_LoadVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -1930,6 +1936,7 @@ static void JS_LoadVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args)
ReleaseCollection(collection);
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1937,7 +1944,7 @@ static void JS_LoadVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_NameVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t const* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -1964,10 +1971,15 @@ static void JS_NameVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args)
TRI_Free(TRI_UNKNOWN_MEM_ZONE, name);
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return the collection's cluster plan id
////////////////////////////////////////////////////////////////////////////////
static void JS_PlanIdVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t const* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -1981,6 +1993,7 @@ static void JS_PlanIdVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
}
TRI_V8_RETURN(V8CollectionId(isolate, collection->_planId));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2075,7 +2088,7 @@ static void JS_PlanIdVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_PropertiesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_GET_GLOBALS();
@ -2344,6 +2357,7 @@ static void JS_PropertiesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>&
ReleaseCollection(collection);
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2407,7 +2421,9 @@ static void JS_PropertiesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>&
////////////////////////////////////////////////////////////////////////////////
static void JS_RemoveVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
return RemoveVocbaseCol(true, args);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2438,7 +2454,7 @@ static void JS_RemoveVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_RenameVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1) {
@ -2488,6 +2504,7 @@ static void JS_RenameVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2559,7 +2576,9 @@ static void JS_RenameVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_ReplaceVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
return ReplaceVocbaseCol(true, args);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2623,7 +2642,7 @@ static int GetRevisionCoordinator (TRI_vocbase_col_t* collection,
////////////////////////////////////////////////////////////////////////////////
static void JS_RevisionVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -2647,6 +2666,7 @@ static void JS_RevisionVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& ar
}
TRI_V8_RETURN(V8RevisionId(isolate, rid));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2665,7 +2685,7 @@ static void JS_RevisionVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& ar
////////////////////////////////////////////////////////////////////////////////
static void JS_RotateVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (ServerState::instance()->isCoordinator()) {
@ -2694,6 +2714,7 @@ static void JS_RotateVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2801,7 +2822,9 @@ static void JS_RotateVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_UpdateVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
return UpdateVocbaseCol(true, args);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3222,7 +3245,7 @@ static void InsertEdgeColCoordinator (TRI_vocbase_col_t* collection,
////////////////////////////////////////////////////////////////////////////////
static void JS_InsertVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -3249,6 +3272,7 @@ static void JS_InsertVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
else {
InsertEdgeCol(collection, args);
}
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3256,7 +3280,7 @@ static void JS_InsertVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_StatusVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -3284,6 +3308,7 @@ static void JS_StatusVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
TRI_READ_UNLOCK_STATUS_VOCBASE_COL(collection);
TRI_V8_RETURN(v8::Number::New(isolate, (int) status));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3291,7 +3316,7 @@ static void JS_StatusVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_TruncateVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
bool const forceSync = ExtractWaitForSync(args, 1);
@ -3323,6 +3348,7 @@ static void JS_TruncateVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& ar
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3330,7 +3356,7 @@ static void JS_TruncateVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& ar
////////////////////////////////////////////////////////////////////////////////
static void JS_TruncateDatafileVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -3365,6 +3391,7 @@ static void JS_TruncateDatafileVocbaseCol (const v8::FunctionCallbackInfo<v8::Va
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3372,7 +3399,7 @@ static void JS_TruncateDatafileVocbaseCol (const v8::FunctionCallbackInfo<v8::Va
////////////////////////////////////////////////////////////////////////////////
static void JS_TryRepairDatafileVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -3406,6 +3433,7 @@ static void JS_TryRepairDatafileVocbaseCol (const v8::FunctionCallbackInfo<v8::V
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3420,7 +3448,7 @@ static void JS_TryRepairDatafileVocbaseCol (const v8::FunctionCallbackInfo<v8::V
////////////////////////////////////////////////////////////////////////////////
static void JS_TypeVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -3450,6 +3478,7 @@ static void JS_TypeVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args)
TRI_READ_UNLOCK_STATUS_VOCBASE_COL(collection);
TRI_V8_RETURN(v8::Number::New(isolate, (int) type));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3474,7 +3503,7 @@ static void JS_TypeVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_UnloadVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -3499,6 +3528,7 @@ static void JS_UnloadVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3506,7 +3536,7 @@ static void JS_UnloadVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_VersionVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -3533,6 +3563,7 @@ static void JS_VersionVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& arg
}
TRI_V8_RETURN(v8::Number::New(isolate, (int) info._version));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3541,7 +3572,7 @@ static void JS_VersionVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& arg
#ifdef TRI_ENABLE_MAINTAINER_MODE
static void JS_CheckPointersVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -3580,11 +3611,10 @@ static void JS_CheckPointersVocbaseCol (const v8::FunctionCallbackInfo<v8::Value
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief changes the operation mode of the server
/// @startDocuBock TODO
@ -3607,7 +3637,7 @@ static void JS_CheckPointersVocbaseCol (const v8::FunctionCallbackInfo<v8::Value
////////////////////////////////////////////////////////////////////////////////
static void JS_ChangeOperationModeVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_GET_GLOBALS();
@ -3653,6 +3683,7 @@ static void JS_ChangeOperationModeVocbase (const v8::FunctionCallbackInfo<v8::Va
TRI_ChangeOperationModeServer(newMode);
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3710,7 +3741,7 @@ static TRI_vocbase_col_t* GetCollectionFromArgument (TRI_vocbase_t* vocbase,
////////////////////////////////////////////////////////////////////////////////
static void JS_CollectionVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -3754,6 +3785,7 @@ static void JS_CollectionVocbase (const v8::FunctionCallbackInfo<v8::Value>& arg
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3775,7 +3807,7 @@ static void JS_CollectionVocbase (const v8::FunctionCallbackInfo<v8::Value>& arg
////////////////////////////////////////////////////////////////////////////////
static void JS_CollectionsVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -3819,6 +3851,7 @@ static void JS_CollectionsVocbase (const v8::FunctionCallbackInfo<v8::Value>& ar
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3826,7 +3859,7 @@ static void JS_CollectionsVocbase (const v8::FunctionCallbackInfo<v8::Value>& ar
////////////////////////////////////////////////////////////////////////////////
static void JS_CompletionsVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -3890,6 +3923,7 @@ static void JS_CompletionsVocbase (const v8::FunctionCallbackInfo<v8::Value>& ar
result->Set(j++, TRI_V8_ASCII_STRING("_version()"));
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------
@ -3967,7 +4001,9 @@ static void JS_CompletionsVocbase (const v8::FunctionCallbackInfo<v8::Value>& ar
////////////////////////////////////////////////////////////////////////////////
static void JS_RemoveVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
return RemoveVocbaseCol(false, args);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -4008,7 +4044,9 @@ static void JS_RemoveVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_DocumentVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
return DocumentVocbaseCol(false, args);
TRI_V8_TRY_CATCH_BEGIN(isolate);
DocumentVocbaseCol(false, args);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -4033,7 +4071,9 @@ static void JS_DocumentVocbase (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_ExistsVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
return ExistsVocbaseCol(false, args);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -4089,7 +4129,9 @@ static void JS_ExistsVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_ReplaceVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
return ReplaceVocbaseCol(false, args);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -4153,7 +4195,9 @@ static void JS_ReplaceVocbase (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_UpdateVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
return UpdateVocbaseCol(false, args);
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------
@ -4179,7 +4223,7 @@ static void JS_UpdateVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_CountVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -4228,6 +4272,7 @@ static void JS_CountVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args)
// READ-LOCK end
TRI_V8_RETURN(v8::Number::New(isolate, (double) s));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -4238,7 +4283,7 @@ static void JS_CountVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_DatafilesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -4293,6 +4338,7 @@ static void JS_DatafilesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& a
TRI_DestroyFileStructureCollection(&structure);
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------
@ -4312,7 +4358,7 @@ static void JS_DatafilesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& a
////////////////////////////////////////////////////////////////////////////////
static void JS_DatafileScanVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -4374,6 +4420,7 @@ static void JS_DatafileScanVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>
TRI_READ_UNLOCK_STATUS_VOCBASE_COL(collection);
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
// .............................................................................
@ -4444,3 +4491,4 @@ void TRI_InitV8collection (v8::Handle<v8::Context> context,
v8g->VocbaseColTempl.Reset(isolate, rt);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("ArangoCollection"), ft->GetFunction());
}

View File

@ -108,7 +108,7 @@ static DispatcherThread* CreateV8DispatcherThread (DispatcherQueue* queue, void*
////////////////////////////////////////////////////////////////////////////////
static void JS_RegisterTask (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (GlobalScheduler == nullptr || GlobalDispatcher == nullptr) {
@ -262,6 +262,7 @@ static void JS_RegisterTask (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Handle<v8::Value> result = TRI_ObjectJson(isolate, json.get());
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -271,7 +272,7 @@ static void JS_RegisterTask (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_UnregisterTask (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -291,6 +292,7 @@ static void JS_UnregisterTask (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -300,7 +302,7 @@ static void JS_UnregisterTask (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_GetTask (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() > 1) {
@ -330,6 +332,7 @@ static void JS_GetTask (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Handle<v8::Value> result = TRI_ObjectJson(isolate, json.get());
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -344,7 +347,7 @@ static void JS_GetTask (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_CreateNamedQueue (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (GlobalDispatcher == nullptr) {
@ -417,6 +420,7 @@ static void JS_CreateNamedQueue (const v8::FunctionCallbackInfo<v8::Value>& args
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -426,7 +430,7 @@ static void JS_CreateNamedQueue (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_AddJob (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 2 || ! args[1]->IsObject()) {
@ -456,6 +460,7 @@ static void JS_AddJob (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------

View File

@ -920,7 +920,7 @@ static void EdgesQuery (TRI_edge_direction_e direction,
////////////////////////////////////////////////////////////////////////////////
static void JS_AllQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
// expecting two arguments
@ -986,6 +986,7 @@ static void JS_AllQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
result->Set(TRI_V8_ASCII_STRING("count"), v8::Number::New(isolate, count));
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -994,7 +995,7 @@ static void JS_AllQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_NthQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
// expecting two arguments
@ -1062,6 +1063,7 @@ static void JS_NthQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
result->Set(TRI_V8_ASCII_STRING("count"), v8::Number::New(isolate, count));
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1070,7 +1072,7 @@ static void JS_NthQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_Nth2Query (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
// expecting two arguments
@ -1132,6 +1134,7 @@ static void JS_Nth2Query (const v8::FunctionCallbackInfo<v8::Value>& args) {
result->Set(TRI_V8_ASCII_STRING("count"), v8::Number::New(isolate, count));
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1139,7 +1142,7 @@ static void JS_Nth2Query (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_Nth3Query (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
// expecting two arguments
@ -1157,6 +1160,7 @@ static void JS_Nth3Query (const v8::FunctionCallbackInfo<v8::Value>& args) {
uint64_t hash = TRI_FnvHashPointer(static_cast<void const*>(key.c_str()), key.size());
TRI_V8_RETURN(v8::Number::New(isolate, static_cast<int>(hash % numberOfPartitions)));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1165,7 +1169,7 @@ static void JS_Nth3Query (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_OffsetQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
// expecting two arguments
@ -1235,6 +1239,7 @@ static void JS_OffsetQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
result->Set(TRI_V8_ASCII_STRING("skip"), v8::Number::New(isolate, internalSkip));
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1254,7 +1259,7 @@ static void JS_OffsetQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_AnyQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t const* col;
@ -1294,6 +1299,7 @@ static void JS_AnyQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(doc);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1301,7 +1307,7 @@ static void JS_AnyQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_ByExampleQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
// expecting example, skip, limit
@ -1352,7 +1358,8 @@ static void JS_ByExampleQuery (const v8::FunctionCallbackInfo<v8::Value>& args)
std::unique_ptr<ExampleMatcher> matcher;
try {
matcher.reset(new ExampleMatcher(isolate, example, shaper, errorMessage));
} catch (int e) {
}
catch (int e) {
if (e == TRI_RESULT_ELEMENT_NOT_FOUND) {
// empty result
TRI_V8_RETURN(EmptyResult(isolate));
@ -1416,99 +1423,15 @@ static void JS_ByExampleQuery (const v8::FunctionCallbackInfo<v8::Value>& args)
}
}
result->Set(TRI_V8_ASCII_STRING("total"), v8::Integer::New(isolate, (int32_t) total));
result->Set(TRI_V8_ASCII_STRING("count"), v8::Integer::New(isolate, (int32_t) count));
if (error) {
TRI_V8_THROW_EXCEPTION_MEMORY();
}
TRI_V8_RETURN(result);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief aggregate(count) value of a single attribute, experiment
////////////////////////////////////////////////////////////////////////////////
static void JS_AggregateCount (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
// expecting example, skip, limit
if (args.Length() < 1) {
TRI_V8_THROW_EXCEPTION_USAGE("AGGREGATE_COUNT(<attribute>)");
}
// extract the attribute name
if (! args[0]->IsString()) {
TRI_V8_THROW_TYPE_ERROR("<attribute> must be a string");
}
std::string attName = TRI_ObjectToString(args[0]);
TRI_vocbase_col_t const* col;
col = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), TRI_GetVocBaseColType());
if (col == nullptr) {
TRI_V8_THROW_EXCEPTION_INTERNAL("cannot extract collection");
}
TRI_THROW_SHARDING_COLLECTION_NOT_YET_IMPLEMENTED(col);
SingleCollectionReadOnlyTransaction trx(new V8TransactionContext(true), col->_vocbase, col->_cid);
int res = trx.begin();
if (res != TRI_ERROR_NO_ERROR) {
TRI_V8_THROW_EXCEPTION(res);
}
TRI_document_collection_t* document = trx.documentCollection();
TRI_shaper_t* shaper = document->getShaper();
// to extract sub-documents in the attribute:
TRI_shape_pid_t pid
= shaper->lookupAttributePathByName(shaper, attName.c_str());
// ...........................................................................
// inside a read transaction
// ...........................................................................
CountingAggregation* agg;
trx.lockRead();
// find documents by example
try {
agg = TRI_AggregateBySingleAttribute(trx.trxCollection(), pid);
}
catch (std::exception&) {
TRI_V8_THROW_EXCEPTION_MEMORY();
}
trx.finish(res);
// ...........................................................................
// outside a read transaction
// ...........................................................................
// setup result
v8::Handle<v8::Object> result = v8::Object::New(isolate);
v8::Handle<v8::Array> documents = v8::Array::New(isolate);
result->Set(TRI_V8_ASCII_STRING("documents"), documents);
uint32_t count = 0;
for (auto& x : *agg) {
v8::Handle<v8::Object> w = v8::Object::New(isolate);
Json json(shaper->_memoryZone, TRI_JsonShapedJson(shaper, &x.first));
w->Set(TRI_V8_ASCII_STRING("value"),
TRI_ObjectJson(isolate, json.json()));
w->Set(TRI_V8_ASCII_STRING("count"),
v8::Number::New(isolate, static_cast<double>(x.second)));
documents->Set(count++, w);
}
delete agg;
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1631,7 +1554,7 @@ static void ByExampleHashIndexQuery (SingleCollectionReadOnlyTransaction& trx,
////////////////////////////////////////////////////////////////////////////////
static void JS_ByExampleHashIndex (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t const* col;
@ -1665,6 +1588,7 @@ static void JS_ByExampleHashIndex (const v8::FunctionCallbackInfo<v8::Value>& ar
// outside a write transaction
// .............................................................................
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1672,9 +1596,11 @@ static void JS_ByExampleHashIndex (const v8::FunctionCallbackInfo<v8::Value>& ar
////////////////////////////////////////////////////////////////////////////////
static void JS_ByConditionSkiplist (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
std::string const signature("BY_CONDITION_SKIPLIST(<index>, <conditions>, <skip>, <limit>, <reverse>)");
return ExecuteSkiplistQuery(args, signature, QUERY_CONDITION);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1682,9 +1608,11 @@ static void JS_ByConditionSkiplist (const v8::FunctionCallbackInfo<v8::Value>& a
////////////////////////////////////////////////////////////////////////////////
static void JS_ByExampleSkiplist (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
std::string const signature("BY_EXAMPLE_SKIPLIST(<index>, <example>, <skip>, <limit>, <reverse>)");
return ExecuteSkiplistQuery(args, signature, QUERY_EXAMPLE);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1788,7 +1716,7 @@ template<bool WR, bool WD> static bool ChecksumCalculator (TRI_doc_mptr_t const*
////////////////////////////////////////////////////////////////////////////////
static void JS_ChecksumCollection (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (ServerState::instance()->isCoordinator()) {
@ -1871,6 +1799,7 @@ static void JS_ChecksumCollection (const v8::FunctionCallbackInfo<v8::Value>& ar
result->Set(TRI_V8_ASCII_STRING("revision"), TRI_V8_STD_STRING(rid));
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1907,7 +1836,9 @@ static void JS_ChecksumCollection (const v8::FunctionCallbackInfo<v8::Value>& ar
////////////////////////////////////////////////////////////////////////////////
static void JS_EdgesQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
return EdgesQuery(TRI_EDGE_ANY, args);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1943,7 +1874,9 @@ static void JS_EdgesQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_InEdgesQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
return EdgesQuery(TRI_EDGE_IN, args);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1951,7 +1884,7 @@ static void JS_InEdgesQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_FirstQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() > 1) {
@ -2025,6 +1958,7 @@ static void JS_FirstQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_RETURN(result);
}
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2149,7 +2083,7 @@ static void FulltextQuery (SingleCollectionReadOnlyTransaction& trx,
////////////////////////////////////////////////////////////////////////////////
static void JS_FulltextQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t const* col;
@ -2182,6 +2116,8 @@ static void JS_FulltextQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
// .............................................................................
// outside a write transaction
// .............................................................................
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2189,7 +2125,7 @@ static void JS_FulltextQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_LastQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() > 1) {
@ -2265,6 +2201,7 @@ static void JS_LastQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_RETURN(result);
}
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2327,7 +2264,7 @@ static void NearQuery (SingleCollectionReadOnlyTransaction& trx,
////////////////////////////////////////////////////////////////////////////////
static void JS_NearQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t const* col;
@ -2360,6 +2297,8 @@ static void JS_NearQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
// .............................................................................
// outside a write transaction
// .............................................................................
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2395,7 +2334,9 @@ static void JS_NearQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_OutEdgesQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
return EdgesQuery(TRI_EDGE_OUT, args);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2458,7 +2399,7 @@ static void WithinQuery (SingleCollectionReadOnlyTransaction& trx,
////////////////////////////////////////////////////////////////////////////////
static void JS_WithinQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t const* col;
@ -2491,6 +2432,7 @@ static void JS_WithinQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
// .............................................................................
// outside a read transaction
// .............................................................................
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2521,7 +2463,7 @@ static void JS_WithinQuery (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_LookupByKeys (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t const* col = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), TRI_GetVocBaseColType());
@ -2535,45 +2477,38 @@ static void JS_LookupByKeys (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_THROW_EXCEPTION_USAGE("documents(<keys>)");
}
try {
triagens::basics::Json bindVars(triagens::basics::Json::Object, 2);
bindVars("@collection", triagens::basics::Json(std::string(col->_name)));
bindVars("keys", triagens::basics::Json(TRI_UNKNOWN_MEM_ZONE, TRI_ObjectToJson(isolate, args[0])));
triagens::basics::Json bindVars(triagens::basics::Json::Object, 2);
bindVars("@collection", triagens::basics::Json(std::string(col->_name)));
bindVars("keys", triagens::basics::Json(TRI_UNKNOWN_MEM_ZONE, TRI_ObjectToJson(isolate, args[0])));
std::string const aql("FOR doc IN @@collection FILTER doc._key IN @keys RETURN doc");
std::string const aql("FOR doc IN @@collection FILTER doc._key IN @keys RETURN doc");
TRI_GET_GLOBALS();
triagens::aql::Query query(v8g->_applicationV8,
true,
col->_vocbase,
aql.c_str(),
aql.size(),
bindVars.steal(),
nullptr,
triagens::aql::PART_MAIN);
auto queryResult = query.executeV8(isolate, static_cast<triagens::aql::QueryRegistry*>(v8g->_queryRegistry));
TRI_GET_GLOBALS();
triagens::aql::Query query(v8g->_applicationV8,
true,
col->_vocbase,
aql.c_str(),
aql.size(),
bindVars.steal(),
nullptr,
triagens::aql::PART_MAIN);
if (queryResult.code != TRI_ERROR_NO_ERROR) {
if (queryResult.code == TRI_ERROR_REQUEST_CANCELED ||
queryResult.code == TRI_ERROR_QUERY_KILLED) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_REQUEST_CANCELED);
}
auto queryResult = query.executeV8(isolate, static_cast<triagens::aql::QueryRegistry*>(v8g->_queryRegistry));
THROW_ARANGO_EXCEPTION_MESSAGE(queryResult.code, queryResult.details);
if (queryResult.code != TRI_ERROR_NO_ERROR) {
if (queryResult.code == TRI_ERROR_REQUEST_CANCELED ||
queryResult.code == TRI_ERROR_QUERY_KILLED) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_REQUEST_CANCELED);
}
v8::Handle<v8::Object> result = v8::Object::New(isolate);
result->Set(TRI_V8_ASCII_STRING("documents"), queryResult.result);
THROW_ARANGO_EXCEPTION_MESSAGE(queryResult.code, queryResult.details);
}
TRI_V8_RETURN(result);
}
catch (triagens::basics::Exception const& ex) {
TRI_V8_THROW_EXCEPTION_MESSAGE(ex.code(), ex.what());
}
catch (...) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_INTERNAL);
}
v8::Handle<v8::Object> result = v8::Object::New(isolate);
result->Set(TRI_V8_ASCII_STRING("documents"), queryResult.result);
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2608,7 +2543,7 @@ static void JS_LookupByKeys (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_RemoveByKeys (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t const* col = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), TRI_GetVocBaseColType());
@ -2622,61 +2557,54 @@ static void JS_RemoveByKeys (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_THROW_EXCEPTION_USAGE("removeByKeys(<keys>)");
}
try {
triagens::basics::Json bindVars(triagens::basics::Json::Object, 2);
bindVars("@collection", triagens::basics::Json(std::string(col->_name)));
bindVars("keys", triagens::basics::Json(TRI_UNKNOWN_MEM_ZONE, TRI_ObjectToJson(isolate, args[0])));
triagens::basics::Json bindVars(triagens::basics::Json::Object, 2);
bindVars("@collection", triagens::basics::Json(std::string(col->_name)));
bindVars("keys", triagens::basics::Json(TRI_UNKNOWN_MEM_ZONE, TRI_ObjectToJson(isolate, args[0])));
std::string const aql("FOR key IN @keys REMOVE key IN @@collection OPTIONS { ignoreErrors: true }");
TRI_GET_GLOBALS();
triagens::aql::Query query(v8g->_applicationV8,
true,
col->_vocbase,
aql.c_str(),
aql.size(),
bindVars.steal(),
nullptr,
triagens::aql::PART_MAIN);
auto queryResult = query.executeV8(isolate, static_cast<triagens::aql::QueryRegistry*>(v8g->_queryRegistry));
std::string const aql("FOR key IN @keys REMOVE key IN @@collection OPTIONS { ignoreErrors: true }");
TRI_GET_GLOBALS();
triagens::aql::Query query(v8g->_applicationV8,
true,
col->_vocbase,
aql.c_str(),
aql.size(),
bindVars.steal(),
nullptr,
triagens::aql::PART_MAIN);
if (queryResult.code != TRI_ERROR_NO_ERROR) {
if (queryResult.code == TRI_ERROR_REQUEST_CANCELED ||
queryResult.code == TRI_ERROR_QUERY_KILLED) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_REQUEST_CANCELED);
}
auto queryResult = query.executeV8(isolate, static_cast<triagens::aql::QueryRegistry*>(v8g->_queryRegistry));
THROW_ARANGO_EXCEPTION_MESSAGE(queryResult.code, queryResult.details);
if (queryResult.code != TRI_ERROR_NO_ERROR) {
if (queryResult.code == TRI_ERROR_REQUEST_CANCELED ||
queryResult.code == TRI_ERROR_QUERY_KILLED) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_REQUEST_CANCELED);
}
THROW_ARANGO_EXCEPTION_MESSAGE(queryResult.code, queryResult.details);
}
size_t ignored = 0;
size_t removed = 0;
size_t ignored = 0;
size_t removed = 0;
if (queryResult.stats != nullptr) {
auto found = TRI_LookupObjectJson(queryResult.stats, "writesIgnored");
if (TRI_IsNumberJson(found)) {
ignored = static_cast<size_t>(found->_value._number);
}
if (queryResult.stats != nullptr) {
auto found = TRI_LookupObjectJson(queryResult.stats, "writesIgnored");
if (TRI_IsNumberJson(found)) {
ignored = static_cast<size_t>(found->_value._number);
}
found = TRI_LookupObjectJson(queryResult.stats, "writesExecuted");
if (TRI_IsNumberJson(found)) {
removed = static_cast<size_t>(found->_value._number);
}
found = TRI_LookupObjectJson(queryResult.stats, "writesExecuted");
if (TRI_IsNumberJson(found)) {
removed = static_cast<size_t>(found->_value._number);
}
v8::Handle<v8::Object> result = v8::Object::New(isolate);
result->Set(TRI_V8_ASCII_STRING("removed"), v8::Number::New(isolate, static_cast<double>(removed)));
result->Set(TRI_V8_ASCII_STRING("ignored"), v8::Number::New(isolate, static_cast<double>(ignored)));
TRI_V8_RETURN(result);
}
catch (triagens::basics::Exception const& ex) {
TRI_V8_THROW_EXCEPTION_MESSAGE(ex.code(), ex.what());
}
catch (...) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_INTERNAL);
}
v8::Handle<v8::Object> result = v8::Object::New(isolate);
result->Set(TRI_V8_ASCII_STRING("removed"), v8::Number::New(isolate, static_cast<double>(removed)));
result->Set(TRI_V8_ASCII_STRING("ignored"), v8::Number::New(isolate, static_cast<double>(ignored)));
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------
@ -2723,7 +2651,6 @@ void TRI_InitV8Queries (v8::Isolate* isolate,
TRI_AddMethodVocbase(isolate, VocbaseColTempl, TRI_V8_ASCII_STRING("removeByKeys"), JS_RemoveByKeys, true);
// internal methods. not intended to be used by end-users
TRI_AddMethodVocbase(isolate, VocbaseColTempl, TRI_V8_ASCII_STRING("AGGREGATE_COUNT"), JS_AggregateCount, true);
TRI_AddMethodVocbase(isolate, VocbaseColTempl, TRI_V8_ASCII_STRING("NTH"), JS_NthQuery, true);
TRI_AddMethodVocbase(isolate, VocbaseColTempl, TRI_V8_ASCII_STRING("NTH2"), JS_Nth2Query, true);
TRI_AddMethodVocbase(isolate, VocbaseColTempl, TRI_V8_ASCII_STRING("NTH3"), JS_Nth3Query, true);

View File

@ -31,6 +31,7 @@
#include "v8-vocbaseprivate.h"
#include "Replication/InitialSyncer.h"
#include "V8/v8-conv.h"
#include "V8/v8-globals.h"
#include "V8/v8-utils.h"
#include "Wal/LogfileManager.h"
#include "VocBase/replication-dump.h"
@ -49,7 +50,7 @@ using namespace triagens::rest;
////////////////////////////////////////////////////////////////////////////////
static void JS_StateLoggerReplication (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
triagens::wal::LogfileManagerState s = triagens::wal::LogfileManager::instance()->state();
@ -72,6 +73,7 @@ static void JS_StateLoggerReplication (const v8::FunctionCallbackInfo<v8::Value>
result->Set(TRI_V8_ASCII_STRING("clients"), clients);
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -80,7 +82,7 @@ static void JS_StateLoggerReplication (const v8::FunctionCallbackInfo<v8::Value>
#ifdef TRI_ENABLE_MAINTAINER_MODE
static void JS_LastLoggerReplication (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -113,6 +115,7 @@ static void JS_LastLoggerReplication (const v8::FunctionCallbackInfo<v8::Value>&
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
#endif
@ -121,7 +124,7 @@ static void JS_LastLoggerReplication (const v8::FunctionCallbackInfo<v8::Value>&
////////////////////////////////////////////////////////////////////////////////
static void JS_SynchroniseReplication (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1 || ! args[0]->IsObject()) {
@ -251,6 +254,7 @@ static void JS_SynchroniseReplication (const v8::FunctionCallbackInfo<v8::Value>
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -258,11 +262,12 @@ static void JS_SynchroniseReplication (const v8::FunctionCallbackInfo<v8::Value>
////////////////////////////////////////////////////////////////////////////////
static void JS_ServerIdReplication (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
const string serverId = StringUtils::itoa(TRI_GetIdServer());
TRI_V8_RETURN_STD_STRING(serverId);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -270,7 +275,7 @@ static void JS_ServerIdReplication (const v8::FunctionCallbackInfo<v8::Value>& a
////////////////////////////////////////////////////////////////////////////////
static void JS_ConfigureApplierReplication (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -476,6 +481,7 @@ static void JS_ConfigureApplierReplication (const v8::FunctionCallbackInfo<v8::V
TRI_V8_RETURN(result);
}
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -483,7 +489,7 @@ static void JS_ConfigureApplierReplication (const v8::FunctionCallbackInfo<v8::V
////////////////////////////////////////////////////////////////////////////////
static void JS_StartApplierReplication (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -517,6 +523,7 @@ static void JS_StartApplierReplication (const v8::FunctionCallbackInfo<v8::Value
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -524,7 +531,7 @@ static void JS_StartApplierReplication (const v8::FunctionCallbackInfo<v8::Value
////////////////////////////////////////////////////////////////////////////////
static void JS_ShutdownApplierReplication (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -548,6 +555,7 @@ static void JS_ShutdownApplierReplication (const v8::FunctionCallbackInfo<v8::Va
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -555,7 +563,7 @@ static void JS_ShutdownApplierReplication (const v8::FunctionCallbackInfo<v8::Va
////////////////////////////////////////////////////////////////////////////////
static void JS_StateApplierReplication (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -582,6 +590,7 @@ static void JS_StateApplierReplication (const v8::FunctionCallbackInfo<v8::Value
TRI_FreeJson(TRI_CORE_MEM_ZONE, json);
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -589,7 +598,7 @@ static void JS_StateApplierReplication (const v8::FunctionCallbackInfo<v8::Value
////////////////////////////////////////////////////////////////////////////////
static void JS_ForgetApplierReplication (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -613,6 +622,7 @@ static void JS_ForgetApplierReplication (const v8::FunctionCallbackInfo<v8::Valu
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
void TRI_InitV8Replication (v8::Isolate* isolate,

View File

@ -859,10 +859,9 @@ static KeySpace* GetKeySpace (TRI_vocbase_t* vocbase,
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyspaceCreate (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1 || ! args[0]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEYSPACE_CREATE(<name>, <size>, <ignoreExisting>)");
}
@ -914,6 +913,7 @@ static void JS_KeyspaceCreate (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -921,7 +921,7 @@ static void JS_KeyspaceCreate (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyspaceDrop (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1 || ! args[0]->IsString()) {
@ -952,6 +952,7 @@ static void JS_KeyspaceDrop (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -959,10 +960,9 @@ static void JS_KeyspaceDrop (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyspaceCount (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1 || ! args[0]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEYSPACE_COUNT(<name>, <prefix>)");
}
@ -997,6 +997,7 @@ static void JS_KeyspaceCount (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(v8::Number::New(isolate, static_cast<int>(count)));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1004,10 +1005,9 @@ static void JS_KeyspaceCount (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyspaceExists (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1 || ! args[0]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEYSPACE_EXISTS(<name>)");
}
@ -1028,9 +1028,8 @@ static void JS_KeyspaceExists (const v8::FunctionCallbackInfo<v8::Value>& args)
if (hash != nullptr) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1038,10 +1037,9 @@ static void JS_KeyspaceExists (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyspaceKeys (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1 || ! args[0]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEYSPACE_KEYS(<name>, <prefix>)");
}
@ -1070,6 +1068,7 @@ static void JS_KeyspaceKeys (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(hash->keyspaceKeys(isolate));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1077,10 +1076,9 @@ static void JS_KeyspaceKeys (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyspaceGet (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1 || ! args[0]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEYSPACE_GET(<name>, <prefix>)");
}
@ -1109,18 +1107,17 @@ static void JS_KeyspaceGet (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(hash->keyspaceGet(isolate));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
/// @brief removes all keys from the keyspace
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyspaceRemove (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1 || ! args[0]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEYSPACE_REMOVE(<name>, <prefix>)");
}
@ -1149,18 +1146,17 @@ static void JS_KeyspaceRemove (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN(hash->keyspaceRemove(isolate));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the value for a key in the keyspace
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyGet (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_GET(<name>, <key>)");
}
@ -1190,6 +1186,7 @@ static void JS_KeyGet (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1197,10 +1194,9 @@ static void JS_KeyGet (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeySet (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 3 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_SET(<name>, <key>, <value>, <replace>)");
}
@ -1237,9 +1233,8 @@ static void JS_KeySet (const v8::FunctionCallbackInfo<v8::Value>& args) {
if (result) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1247,10 +1242,9 @@ static void JS_KeySet (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeySetCas (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 4 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_SET_CAS(<name>, <key>, <value>, <compare>)");
}
@ -1292,9 +1286,8 @@ static void JS_KeySetCas (const v8::FunctionCallbackInfo<v8::Value>& args) {
if (match) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1302,10 +1295,9 @@ static void JS_KeySetCas (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyRemove (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_REMOVE(<name>, <key>)");
}
@ -1337,9 +1329,8 @@ static void JS_KeyRemove (const v8::FunctionCallbackInfo<v8::Value>& args) {
if (result) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1347,10 +1338,9 @@ static void JS_KeyRemove (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyExists (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_EXISTS(<name>, <key>)");
}
@ -1382,9 +1372,8 @@ static void JS_KeyExists (const v8::FunctionCallbackInfo<v8::Value>& args) {
if (result) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1392,10 +1381,9 @@ static void JS_KeyExists (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyIncr (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_INCR(<name>, <key>, <value>)");
}
@ -1439,6 +1427,7 @@ static void JS_KeyIncr (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(v8::Number::New(isolate, result));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1446,10 +1435,9 @@ static void JS_KeyIncr (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyUpdate (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 3 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_UPDATE(<name>, <key>, <object>, <nullMeansRemove>)");
}
@ -1479,6 +1467,7 @@ static void JS_KeyUpdate (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
hash->keyMerge(args, key, args[2], nullMeansRemove);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1486,10 +1475,9 @@ static void JS_KeyUpdate (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyKeys (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_KEYS(<name>, <key>)");
}
@ -1514,6 +1502,7 @@ static void JS_KeyKeys (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(hash->keyKeys(isolate, key));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1521,10 +1510,9 @@ static void JS_KeyKeys (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyValues (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_VALUES(<name>, <key>)");
}
@ -1549,6 +1537,7 @@ static void JS_KeyValues (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(hash->keyValues(isolate, key));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1556,10 +1545,9 @@ static void JS_KeyValues (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyPush (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 3 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_PUSH(<name>, <key>, <value>)");
}
@ -1590,6 +1578,7 @@ static void JS_KeyPush (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1597,10 +1586,9 @@ static void JS_KeyPush (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyPop (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_POP(<name>, <key>)");
}
@ -1625,6 +1613,7 @@ static void JS_KeyPop (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
hash->keyPop(args, key);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1632,10 +1621,9 @@ static void JS_KeyPop (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyTransfer (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 3 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_TRANSFER(<name>, <key-from>, <key-to>)");
}
@ -1661,6 +1649,7 @@ static void JS_KeyTransfer (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
hash->keyTransfer(args, keyFrom, keyTo);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1668,10 +1657,9 @@ static void JS_KeyTransfer (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyGetAt (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 3 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_GET_AT(<name>, <key>, <index>)");
}
@ -1697,6 +1685,7 @@ static void JS_KeyGetAt (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
hash->keyGetAt(args, key, offset);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1704,10 +1693,9 @@ static void JS_KeyGetAt (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeySetAt (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 4 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_SET_AT(<name>, <key>, <index>, <value>)");
}
@ -1738,6 +1726,7 @@ static void JS_KeySetAt (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1745,10 +1734,9 @@ static void JS_KeySetAt (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyType (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_TYPE(<name>, <key>)");
}
@ -1778,6 +1766,7 @@ static void JS_KeyType (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_STRING(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1785,10 +1774,9 @@ static void JS_KeyType (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_KeyCount (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2 || ! args[0]->IsString() || ! args[1]->IsString()) {
TRI_V8_THROW_EXCEPTION_USAGE("KEY_COUNT(<name>, <key>)");
}
@ -1823,6 +1811,7 @@ static void JS_KeyCount (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------

View File

@ -31,10 +31,11 @@
#include "Aql/Query.h"
#include "Aql/QueryList.h"
#include "Aql/QueryRegistry.h"
#include "Basics/Utf8Helper.h"
#include "Basics/conversions.h"
#include "Basics/json-utilities.h"
#include "Basics/MutexLocker.h"
#include "Basics/ScopeGuard.h"
#include "Basics/Utf8Helper.h"
#include "Cluster/AgencyComm.h"
#include "Cluster/ClusterComm.h"
#include "Cluster/ClusterInfo.h"
@ -157,7 +158,7 @@ static v8::Handle<v8::Object> WrapClass (v8::Isolate *isolate,
////////////////////////////////////////////////////////////////////////////////
static void JS_Transaction (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1 || ! args[0]->IsObject()) {
@ -356,7 +357,7 @@ static void JS_Transaction (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
v8::Handle<v8::Value> result;
{
try {
v8::TryCatch tryCatch;
v8::Handle<v8::Value> arguments = params;
result = action->Call(current, 1, &arguments);
@ -374,6 +375,18 @@ static void JS_Transaction (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
}
}
catch (triagens::basics::Exception const& ex) {
TRI_V8_THROW_EXCEPTION_MESSAGE(ex.code(), ex.what());
}
catch (std::bad_alloc const& ex) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY);
}
catch (std::exception const& ex) {
TRI_V8_THROW_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, ex.what());
}
catch (...) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_INTERNAL);
}
res = trx.commit();
@ -382,6 +395,7 @@ static void JS_Transaction (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -444,7 +458,7 @@ static void JS_Transaction (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_PropertiesWal (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() > 1 || (args.Length() == 1 && ! args[0]->IsObject())) {
@ -497,6 +511,7 @@ static void JS_PropertiesWal (const v8::FunctionCallbackInfo<v8::Value>& args) {
result->Set(TRI_V8_ASCII_STRING("throttleWhenPending"), v8::Number::New(isolate, (double) l->throttleWhenPending()));
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -529,7 +544,7 @@ static void JS_PropertiesWal (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_FlushWal (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
bool waitForSync = false;
@ -564,14 +579,15 @@ static void JS_FlushWal (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
/// @brief normalize UTF 16 strings
////////////////////////////////////////////////////////////////////////////////
static void JS_normalize_string (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
static void JS_NormalizeString (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -579,6 +595,7 @@ static void JS_normalize_string (const v8::FunctionCallbackInfo<v8::Value>& args
}
TRI_normalize_V8_Obj(args, args[0]);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -586,7 +603,7 @@ static void JS_normalize_string (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_EnableNativeBacktraces (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 1) {
@ -596,6 +613,7 @@ static void JS_EnableNativeBacktraces (const v8::FunctionCallbackInfo<v8::Value>
triagens::basics::Exception::SetVerbose(TRI_ObjectToBoolean(args[0]));
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
extern triagens::V8LineEditor* theConsole;
@ -605,7 +623,7 @@ extern triagens::V8LineEditor* theConsole;
////////////////////////////////////////////////////////////////////////////////
static void JS_Debug (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::Local<v8::String> name(TRI_V8_ASCII_STRING("debug loop"));
v8::Local<v8::String> debug(TRI_V8_ASCII_STRING("debug"));
@ -651,14 +669,15 @@ static void JS_Debug (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
/// @brief compare two UTF 16 strings
////////////////////////////////////////////////////////////////////////////////
static void JS_compare_string (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
static void JS_CompareString (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 2) {
@ -676,14 +695,15 @@ static void JS_compare_string (const v8::FunctionCallbackInfo<v8::Value>& args)
int result = Utf8Helper::DefaultUtf8Helper.compareUtf16(*left, left.length(), *right, right.length());
TRI_V8_RETURN(v8::Integer::New(isolate, result));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
/// @brief get list of timezones
////////////////////////////////////////////////////////////////////////////////
static void JS_getIcuTimezones (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
static void JS_GetIcuTimezones (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -708,14 +728,15 @@ static void JS_getIcuTimezones (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
/// @brief get list of locales
////////////////////////////////////////////////////////////////////////////////
static void JS_getIcuLocales (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
static void JS_GetIcuLocales (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -737,14 +758,15 @@ static void JS_getIcuLocales (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
/// @brief format datetime
////////////////////////////////////////////////////////////////////////////////
static void JS_formatDatetime (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
static void JS_FormatDatetime (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2) {
@ -796,14 +818,15 @@ static void JS_formatDatetime (const v8::FunctionCallbackInfo<v8::Value>& args)
delete tz;
TRI_V8_RETURN_STD_STRING(resultString);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
/// @brief parse datetime
////////////////////////////////////////////////////////////////////////////////
static void JS_parseDatetime (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
static void JS_ParseDatetime (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2) {
@ -854,6 +877,7 @@ static void JS_parseDatetime (const v8::FunctionCallbackInfo<v8::Value>& args) {
delete tz;
TRI_V8_RETURN(v8::Number::New(isolate, udate / 1000));
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -888,12 +912,12 @@ static bool ReloadAuthCoordinator (TRI_vocbase_t* vocbase) {
////////////////////////////////////////////////////////////////////////////////
static void JS_ReloadAuth (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
if (vocbase == 0) {
if (vocbase == nullptr) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
}
@ -911,12 +935,10 @@ static void JS_ReloadAuth (const v8::FunctionCallbackInfo<v8::Value>& args) {
if (result) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------
// --SECTION-- AQL
// -----------------------------------------------------------------------------
@ -926,7 +948,7 @@ static void JS_ReloadAuth (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_ParseAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -986,6 +1008,7 @@ static void JS_ParseAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -994,7 +1017,7 @@ static void JS_ParseAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_WarningAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 2) {
@ -1020,6 +1043,7 @@ static void JS_WarningAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1027,7 +1051,7 @@ static void JS_WarningAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_ExplainAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -1116,6 +1140,7 @@ static void JS_ExplainAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1123,7 +1148,7 @@ static void JS_ExplainAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_ExecuteAqlJson (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -1189,6 +1214,7 @@ static void JS_ExecuteAqlJson (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1196,7 +1222,8 @@ static void JS_ExecuteAqlJson (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_ExecuteAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -1287,6 +1314,7 @@ static void JS_ExecuteAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1294,7 +1322,7 @@ static void JS_ExecuteAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_QueriesPropertiesAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -1346,6 +1374,7 @@ static void JS_QueriesPropertiesAql (const v8::FunctionCallbackInfo<v8::Value>&
result->Set(TRI_V8_ASCII_STRING("maxQueryStringLength"), v8::Number::New(isolate, static_cast<double>(queryList->maxQueryStringLength())));
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1353,7 +1382,7 @@ static void JS_QueriesPropertiesAql (const v8::FunctionCallbackInfo<v8::Value>&
////////////////////////////////////////////////////////////////////////////////
static void JS_QueriesCurrentAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -1395,6 +1424,7 @@ static void JS_QueriesCurrentAql (const v8::FunctionCallbackInfo<v8::Value>& arg
catch (...) {
TRI_V8_THROW_EXCEPTION_MEMORY();
}
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1402,7 +1432,7 @@ static void JS_QueriesCurrentAql (const v8::FunctionCallbackInfo<v8::Value>& arg
////////////////////////////////////////////////////////////////////////////////
static void JS_QueriesSlowAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -1447,6 +1477,7 @@ static void JS_QueriesSlowAql (const v8::FunctionCallbackInfo<v8::Value>& args)
catch (...) {
TRI_V8_THROW_EXCEPTION_MEMORY();
}
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1454,7 +1485,7 @@ static void JS_QueriesSlowAql (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_QueriesKillAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -1479,6 +1510,7 @@ static void JS_QueriesKillAql (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_THROW_EXCEPTION(res);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1486,14 +1518,16 @@ static void JS_QueriesKillAql (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_QueryIsKilledAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_GET_GLOBALS();
if (v8g->_query != nullptr && static_cast<triagens::aql::Query*>(v8g->_query)->killed()) {
TRI_V8_RETURN_TRUE();
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1632,40 +1666,31 @@ static ExplicitTransaction* BeginTransaction (TRI_vocbase_t* vocbase,
bool waitForSync = false;
// Start Transaction to collect all parts of the path
ExplicitTransaction* trx = new ExplicitTransaction(
std::unique_ptr<ExplicitTransaction> trx(new ExplicitTransaction(
vocbase,
readCollections,
writeCollections,
lockTimeout,
waitForSync,
embed
);
));
int res = trx->begin();
if (res != TRI_ERROR_NO_ERROR) {
trx->finish(res);
delete trx;
throw res;
}
try {
// Get all ditches at once
for (auto const& it : readCollections) {
AddDitch(trx, it, ditches);
}
for (auto const& it : writeCollections) {
AddDitch(trx, it, ditches);
}
}
catch (int&) {
// Could not get a ditch
// Abort the collection and free the pointers
trx->abort();
delete trx;
throw;
// Get all ditches at once
for (auto const& it : readCollections) {
AddDitch(trx.get(), it, ditches);
}
return trx;
for (auto const& it : writeCollections) {
AddDitch(trx.get(), it, ditches);
}
return trx.release();
}
////////////////////////////////////////////////////////////////////////////////
@ -1692,16 +1717,16 @@ static v8::Handle<v8::Value> PathIdsToV8 (v8::Isolate* isolate,
ExtractCidsFromPath(vocbase, p, readCollections);
vector<TRI_voc_cid_t> writeCollections;
unordered_map<TRI_voc_cid_t, CollectionDitchInfo> ditches;
ExplicitTransaction* trx = BeginTransaction(vocbase, readCollections,
writeCollections, resolver, ditches);
std::unique_ptr<ExplicitTransaction> trx(BeginTransaction(vocbase, readCollections,
writeCollections, resolver, ditches));
for (uint32_t j = 0; j < vn; ++j) {
vertices->Set(j, VertexIdToData(isolate, resolver, trx, ditches, p.vertices[j]));
vertices->Set(j, VertexIdToData(isolate, resolver, trx.get(), ditches, p.vertices[j]));
}
for (uint32_t j = 0; j < en; ++j) {
edges->Set(j, EdgeIdToData(isolate, resolver, trx, ditches, p.edges[j]));
edges->Set(j, EdgeIdToData(isolate, resolver, trx.get(), ditches, p.edges[j]));
}
trx->finish(0);
delete trx;
trx->finish(TRI_ERROR_NO_ERROR);
}
else {
for (uint32_t j = 0; j < vn; ++j) {
@ -1821,7 +1846,7 @@ static VertexId IdStringToVertexId (CollectionNameResolver const* resolver,
throw TRI_ERROR_ARANGO_INVALID_KEY_GENERATOR;
}
string collectionName = vertex.substr(0, split);
string const collectionName = vertex.substr(0, split);
auto coli = resolver->getCollectionStruct(collectionName);
if (coli == nullptr) {
@ -1836,7 +1861,7 @@ static VertexId IdStringToVertexId (CollectionNameResolver const* resolver,
////////////////////////////////////////////////////////////////////////////////
static void JS_QueryShortestPath (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 4 || args.Length() > 5) {
@ -1924,18 +1949,18 @@ static void JS_QueryShortestPath (const v8::FunctionCallbackInfo<v8::Value>& arg
}
// Parse filterEdges
// note: only works with edge examples and not with user-defined AQL functions
v8::Local<v8::String> keyFilterEdges = TRI_V8_ASCII_STRING("filterEdges");
if (options->Has(keyFilterEdges)) {
opts.useEdgeFilter = true;
// TODO: User defined AQL function !!
edgeExample = v8::Handle<v8::Object>::Cast(options->Get(keyFilterEdges));
}
// Parse vertexFilter
// note: only works with vertex examples and not with user-defined AQL functions
v8::Local<v8::String> keyFilterVertices = TRI_V8_ASCII_STRING("filterVertices");
if (options->Has(keyFilterVertices)) {
opts.useVertexFilter = true;
// TODO: User defined AQL function !!
vertexExample = v8::Handle<v8::Object>::Cast(options->Get(keyFilterVertices));
}
}
@ -1957,25 +1982,21 @@ static void JS_QueryShortestPath (const v8::FunctionCallbackInfo<v8::Value>& arg
// Start the transaction and order ditches
unordered_map<TRI_voc_cid_t, CollectionDitchInfo> ditches;
ExplicitTransaction* trx = nullptr;
try {
trx = BeginTransaction(vocbase, readCollections, writeCollections, resolver, ditches);
}
catch (int e) {
// Nothing to clean up. Throw the error to V8
TRI_V8_THROW_EXCEPTION(e);
}
std::unique_ptr<ExplicitTransaction> trx(BeginTransaction(vocbase, readCollections, writeCollections, resolver, ditches));
vector<EdgeCollectionInfo*> edgeCollectionInfos;
vector<VertexCollectionInfo*> vertexCollectionInfos;
auto cleanup = [&] () -> void {
for (auto& p : edgeCollectionInfos) {
delete p;
}
for (auto& p : vertexCollectionInfos) {
delete p;
triagens::basics::ScopeGuard guard{
[]() -> void { },
[&edgeCollectionInfos, &vertexCollectionInfos]() -> void {
for (auto& p : edgeCollectionInfos) {
delete p;
}
for (auto& p : vertexCollectionInfos) {
delete p;
}
}
};
@ -2022,7 +2043,7 @@ static void JS_QueryShortestPath (const v8::FunctionCallbackInfo<v8::Value>& arg
catch (int e) {
// ELEMENT not found is expected, if there is no shape of this type in this collection
if (e != TRI_RESULT_ELEMENT_NOT_FOUND) {
// TODO Max fragen was mit Fehlern passieren muss
TRI_V8_THROW_EXCEPTION(e);
}
}
}
@ -2032,13 +2053,12 @@ static void JS_QueryShortestPath (const v8::FunctionCallbackInfo<v8::Value>& arg
string errorMessage;
for (auto const& it: vertexCollectionInfos) {
try {
opts.addVertexFilter(isolate, vertexExample, trx, it->getCollection(), it->getShaper(), it->getCid(), errorMessage);
opts.addVertexFilter(isolate, vertexExample, trx.get(), it->getCollection(), it->getShaper(), it->getCid(), errorMessage);
}
catch (int e) {
cout << "ARG!!!" << endl;
// ELEMENT not found is expected, if there is no shape of this type in this collection
if (e != TRI_RESULT_ELEMENT_NOT_FOUND) {
// TODO Max fragen was mit Fehlern passieren muss
TRI_V8_THROW_EXCEPTION(e);
}
}
}
@ -2051,8 +2071,6 @@ static void JS_QueryShortestPath (const v8::FunctionCallbackInfo<v8::Value>& arg
catch (int e) {
// Id string might have illegal collection name
trx->finish(e);
cleanup();
delete trx;
TRI_V8_THROW_EXCEPTION(e);
}
@ -2067,8 +2085,6 @@ static void JS_QueryShortestPath (const v8::FunctionCallbackInfo<v8::Value>& arg
}
catch (int e) {
trx->finish(e);
cleanup();
delete trx;
TRI_V8_THROW_EXCEPTION(e);
}
@ -2076,19 +2092,20 @@ static void JS_QueryShortestPath (const v8::FunctionCallbackInfo<v8::Value>& arg
if (path.get() == nullptr) {
v8::EscapableHandleScope scope(isolate);
trx->finish(res);
cleanup();
delete trx;
TRI_V8_RETURN(scope.Escape<v8::Value>(v8::Null(isolate)));
}
trx->finish(res);
cleanup();
delete trx;
// must finish "old" transaction first before starting a new in PathIdsToV8
delete trx.release();
// Potential inconsistency here. Graph is outside a transaction in this very second.
// Adding additional locks on vertex collections at this point to the transaction
// would cause dead-locks.
// Will be fixed automatically with new MVCC version.
auto result = PathIdsToV8(isolate, vocbase, resolver, *path, ditches, includeData);
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2123,7 +2140,7 @@ static v8::Handle<v8::Value> VertexIdsToV8 (v8::Isolate* isolate,
////////////////////////////////////////////////////////////////////////////////
static void JS_QueryNeighbors (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 3 || args.Length() > 4) {
@ -2215,7 +2232,7 @@ static void JS_QueryNeighbors (const v8::FunctionCallbackInfo<v8::Value>& args)
v8::Local<v8::String> keyFilterVertices = TRI_V8_ASCII_STRING("filterVertices");
if (options->Has(keyFilterVertices)) {
opts.useVertexFilter = true;
// TODO: User defined AQL function !!
// note: only works with vertex examples and not with user-defined AQL functions
vertexExample = v8::Handle<v8::Object>::Cast(options->Get(keyFilterVertices));
}
@ -2237,7 +2254,6 @@ static void JS_QueryNeighbors (const v8::FunctionCallbackInfo<v8::Value>& args)
V8ResolverGuard resolverGuard(vocbase);
ExplicitTransaction* trx = nullptr;
int res = TRI_ERROR_NO_ERROR;
CollectionNameResolver const* resolver = resolverGuard.getResolver();
@ -2250,16 +2266,23 @@ static void JS_QueryNeighbors (const v8::FunctionCallbackInfo<v8::Value>& args)
unordered_map<TRI_voc_cid_t, CollectionDitchInfo> ditches;
// Start the transaction
try {
trx = BeginTransaction(vocbase, readCollections, writeCollections,
resolver, ditches);
}
catch (int e) {
// Nothing to clean up. Throw the error to V8
TRI_V8_THROW_EXCEPTION(e);
}
std::unique_ptr<ExplicitTransaction> trx(BeginTransaction(vocbase, readCollections, writeCollections, resolver, ditches));
vector<EdgeCollectionInfo*> edgeCollectionInfos;
vector<VertexCollectionInfo*> vertexCollectionInfos;
triagens::basics::ScopeGuard guard{
[]() -> void { },
[&edgeCollectionInfos, &vertexCollectionInfos]() -> void {
for (auto& p : edgeCollectionInfos) {
delete p;
}
for (auto& p : vertexCollectionInfos) {
delete p;
}
}
};
for (auto const& it : edgeCollectionNames) {
auto cid = resolver->getCollectionId(it);
auto colObj = ditches.find(cid)->second.col->_collection->_collection;
@ -2270,8 +2293,7 @@ static void JS_QueryNeighbors (const v8::FunctionCallbackInfo<v8::Value>& args)
));
}
vector<VertexCollectionInfo*> vertexCollectionInfos;
for(auto it : vertexCollectionNames) {
for (auto it : vertexCollectionNames) {
auto cid = resolver->getCollectionId(it);
auto colObj = ditches.find(cid)->second.col;
vertexCollectionInfos.emplace_back(new VertexCollectionInfo(
@ -2281,14 +2303,6 @@ static void JS_QueryNeighbors (const v8::FunctionCallbackInfo<v8::Value>& args)
// Explicitly allow all collections.
opts.addCollectionRestriction(cid);
}
auto cleanup = [&] () -> void {
for (auto& p : edgeCollectionInfos) {
delete p;
}
for (auto& p : vertexCollectionInfos) {
delete p;
}
};
unordered_set<VertexId> distinctNeighbors;
vector<VertexId> neighbors;
@ -2302,7 +2316,7 @@ static void JS_QueryNeighbors (const v8::FunctionCallbackInfo<v8::Value>& args)
catch (int e) {
// ELEMENT not found is expected, if there is no shape of this type in this collection
if (e != TRI_RESULT_ELEMENT_NOT_FOUND) {
// TODO Max fragen was mit Fehlern passieren muss
TRI_V8_THROW_EXCEPTION(e);
}
}
}
@ -2312,12 +2326,12 @@ static void JS_QueryNeighbors (const v8::FunctionCallbackInfo<v8::Value>& args)
string errorMessage;
for (auto const& it: vertexCollectionInfos) {
try {
opts.addVertexFilter(isolate, vertexExample, trx, it->getCollection(), it->getShaper(), it->getCid(), errorMessage);
opts.addVertexFilter(isolate, vertexExample, trx.get(), it->getCollection(), it->getShaper(), it->getCid(), errorMessage);
}
catch (int e) {
// ELEMENT not found is expected, if there is no shape of this type in this collection
if (e != TRI_RESULT_ELEMENT_NOT_FOUND) {
// TODO Max fragen was mit Fehlern passieren muss
TRI_V8_THROW_EXCEPTION(e);
}
}
}
@ -2329,9 +2343,7 @@ static void JS_QueryNeighbors (const v8::FunctionCallbackInfo<v8::Value>& args)
}
catch (int e) {
// Id string might have illegal collection name
cleanup();
trx->finish(e);
delete trx;
TRI_V8_THROW_EXCEPTION(e);
}
try {
@ -2343,19 +2355,17 @@ static void JS_QueryNeighbors (const v8::FunctionCallbackInfo<v8::Value>& args)
);
}
catch (int e) {
cleanup();
trx->finish(e);
delete trx;
TRI_V8_THROW_EXCEPTION(e);
}
}
auto result = VertexIdsToV8(isolate, trx, resolver, neighbors, ditches, includeData);
auto result = VertexIdsToV8(isolate, trx.get(), resolver, neighbors, ditches, includeData);
cleanup();
trx->finish(res);
delete trx;
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -2363,7 +2373,7 @@ static void JS_QueryNeighbors (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_QuerySleepAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
// extract arguments
@ -2393,6 +2403,7 @@ static void JS_QuerySleepAql (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------
@ -3308,7 +3319,7 @@ static void JS_DropDatabase (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_ConfigureEndpoint (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1 || args.Length() > 2) {
@ -3372,6 +3383,7 @@ static void JS_ConfigureEndpoint (const v8::FunctionCallbackInfo<v8::Value>& arg
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3381,7 +3393,7 @@ static void JS_ConfigureEndpoint (const v8::FunctionCallbackInfo<v8::Value>& arg
////////////////////////////////////////////////////////////////////////////////
static void JS_RemoveEndpoint (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 1 || args.Length() > 2) {
@ -3414,6 +3426,7 @@ static void JS_RemoveEndpoint (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN_TRUE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -3423,7 +3436,7 @@ static void JS_RemoveEndpoint (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_ListEndpoints (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 0) {
@ -3470,6 +3483,7 @@ static void JS_ListEndpoints (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------
@ -3691,12 +3705,12 @@ void TRI_InitV8VocBridge (v8::Isolate* isolate,
TRI_InitV8Replication(isolate, context, server, vocbase, loader, threadNumber, v8g);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("COMPARE_STRING"), JS_compare_string);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("NORMALIZE_STRING"), JS_normalize_string);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("TIMEZONES"), JS_getIcuTimezones);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("LOCALES"), JS_getIcuLocales);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("FORMAT_DATETIME"), JS_formatDatetime);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("PARSE_DATETIME"), JS_parseDatetime);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("COMPARE_STRING"), JS_CompareString);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("NORMALIZE_STRING"), JS_NormalizeString);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("TIMEZONES"), JS_GetIcuTimezones);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("LOCALES"), JS_GetIcuLocales);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("FORMAT_DATETIME"), JS_FormatDatetime);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("PARSE_DATETIME"), JS_ParseDatetime);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("CONFIGURE_ENDPOINT"), JS_ConfigureEndpoint, true);
TRI_AddGlobalFunctionVocbase(isolate, context, TRI_V8_ASCII_STRING("REMOVE_ENDPOINT"), JS_RemoveEndpoint, true);

View File

@ -49,7 +49,7 @@ using namespace triagens::rest;
////////////////////////////////////////////////////////////////////////////////
static void JS_CreateCursor (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -110,6 +110,7 @@ static void JS_CreateCursor (const v8::FunctionCallbackInfo<v8::Value>& args) {
catch (...) {
TRI_V8_THROW_EXCEPTION_MEMORY();
}
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -117,7 +118,7 @@ static void JS_CreateCursor (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_JsonCursor (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
@ -197,6 +198,7 @@ static void JS_JsonCursor (const v8::FunctionCallbackInfo<v8::Value>& args) {
cursors->release(cursor);
TRI_V8_THROW_EXCEPTION_MEMORY();
}
TRI_V8_TRY_CATCH_END
}
// .............................................................................

View File

@ -1146,12 +1146,13 @@ static void CreateCollectionCoordinator (const v8::FunctionCallbackInfo<v8::Valu
////////////////////////////////////////////////////////////////////////////////
static void JS_EnsureIndexVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
PREVENT_EMBEDDED_TRANSACTION();
EnsureIndex(args, true, "ensureIndex");
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1159,10 +1160,11 @@ static void JS_EnsureIndexVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>&
////////////////////////////////////////////////////////////////////////////////
static void JS_LookupIndexVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
EnsureIndex(args, false, "lookupIndex");
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
/// @brief drops an index, coordinator case
@ -1215,9 +1217,7 @@ static void DropIndexCoordinator (const v8::FunctionCallbackInfo<v8::Value>& arg
if (res == TRI_ERROR_NO_ERROR) {
TRI_V8_RETURN_TRUE();
}
else {
TRI_V8_RETURN_FALSE();
}
TRI_V8_RETURN_FALSE();
}
////////////////////////////////////////////////////////////////////////////////
@ -1262,10 +1262,9 @@ static void DropIndexCoordinator (const v8::FunctionCallbackInfo<v8::Value>& arg
////////////////////////////////////////////////////////////////////////////////
static void JS_DropIndexVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
PREVENT_EMBEDDED_TRANSACTION();
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
@ -1323,6 +1322,7 @@ static void JS_DropIndexVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& a
}
TRI_V8_RETURN_FALSE();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1405,10 +1405,9 @@ static void GetIndexesCoordinator (const v8::FunctionCallbackInfo<v8::Value>& ar
////////////////////////////////////////////////////////////////////////////////
static void JS_GetIndexesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
TRI_vocbase_col_t* collection = TRI_UnwrapClass<TRI_vocbase_col_t>(args.Holder(), WRP_VOCBASE_COL_TYPE);
if (collection == nullptr) {
@ -1456,6 +1455,7 @@ static void JS_GetIndexesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>&
TRI_FreeVectorPointer(TRI_UNKNOWN_MEM_ZONE, indexes);
TRI_V8_RETURN(result);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1527,7 +1527,6 @@ static void CreateVocBase (const v8::FunctionCallbackInfo<v8::Value>& args,
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
if (vocbase == nullptr) {
@ -1819,7 +1818,9 @@ static void CreateVocBase (const v8::FunctionCallbackInfo<v8::Value>& args,
////////////////////////////////////////////////////////////////////////////////
static void JS_CreateVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
CreateVocBase(args, TRI_COL_TYPE_DOCUMENT);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1833,7 +1834,9 @@ static void JS_CreateVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_CreateDocumentCollectionVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
CreateVocBase(args, TRI_COL_TYPE_DOCUMENT);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -1860,25 +1863,25 @@ static void JS_CreateDocumentCollectionVocbase (const v8::FunctionCallbackInfo<v
////////////////////////////////////////////////////////////////////////////////
static void JS_CreateEdgeCollectionVocbase (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
CreateVocBase(args, TRI_COL_TYPE_EDGE);
TRI_V8_TRY_CATCH_END
}
void TRI_InitV8indexArangoDB (v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> rt){
v8::Handle<v8::ObjectTemplate> rt) {
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("_create"), JS_CreateVocbase, true);
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("_createEdgeCollection"), JS_CreateEdgeCollectionVocbase);
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("_createDocumentCollection"), JS_CreateDocumentCollectionVocbase);
}
void TRI_InitV8indexCollection (v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> rt){
v8::Handle<v8::ObjectTemplate> rt) {
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("dropIndex"), JS_DropIndexVocbaseCol);
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("ensureIndex"), JS_EnsureIndexVocbaseCol);
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("lookupIndex"), JS_LookupIndexVocbaseCol);
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("getIndexes"), JS_GetIndexesVocbaseCol);
}

View File

@ -517,91 +517,96 @@ static void CopyAttributes (v8::Isolate* isolate,
static void MapGetNamedShapedJson (v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
try {
v8::HandleScope scope(isolate);
// sanity check
v8::Handle<v8::Object> self = args.Holder();
// sanity check
v8::Handle<v8::Object> self = args.Holder();
if (self->InternalFieldCount() <= SLOT_DITCH) {
// we better not throw here... otherwise this will cause a segfault
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
// get shaped json
void* marker = TRI_UnwrapClass<void*>(self, WRP_SHAPED_JSON_TYPE);
if (marker == nullptr) {
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
// convert the JavaScript string to a string
// we take the fast path here and don't normalize the string
v8::String::Utf8Value const str(name);
string const key(*str, (size_t) str.length());
if (key.empty()) {
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
if (key[0] == '_') {
char buffer[TRI_VOC_KEY_MAX_LENGTH + 1];
if (key == TRI_VOC_ATTRIBUTE_KEY) {
char const* docKey = TRI_EXTRACT_MARKER_KEY(static_cast<TRI_df_marker_t const*>(marker));
TRI_ASSERT(docKey != nullptr);
size_t keyLength = strlen(docKey);
memcpy(buffer, docKey, keyLength);
TRI_V8_RETURN_PAIR_STRING(buffer, (int) keyLength);
}
else if (key == TRI_VOC_ATTRIBUTE_REV) {
TRI_voc_rid_t rid = TRI_EXTRACT_MARKER_RID(static_cast<TRI_df_marker_t const*>(marker));
TRI_ASSERT(rid > 0);
size_t len = TRI_StringUInt64InPlace((uint64_t) rid, (char*) &buffer);
TRI_V8_RETURN_PAIR_STRING((char const*) buffer, (int) len);
}
if (key == TRI_VOC_ATTRIBUTE_ID ||
key == TRI_VOC_ATTRIBUTE_FROM ||
key == TRI_VOC_ATTRIBUTE_TO) {
// strip reserved attributes
if (self->InternalFieldCount() <= SLOT_DITCH) {
// we better not throw here... otherwise this will cause a segfault
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
}
// TODO: check whether accessing an attribute with a dot is actually possible,
// e.g. doc.a.b vs. doc["a.b"]
if (strchr(key.c_str(), '.') != nullptr) {
// get shaped json
void* marker = TRI_UnwrapClass<void*>(self, WRP_SHAPED_JSON_TYPE);
if (marker == nullptr) {
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
// convert the JavaScript string to a string
// we take the fast path here and don't normalize the string
v8::String::Utf8Value const str(name);
string const key(*str, (size_t) str.length());
if (key.empty()) {
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
if (key[0] == '_') {
char buffer[TRI_VOC_KEY_MAX_LENGTH + 1];
if (key == TRI_VOC_ATTRIBUTE_KEY) {
char const* docKey = TRI_EXTRACT_MARKER_KEY(static_cast<TRI_df_marker_t const*>(marker));
TRI_ASSERT(docKey != nullptr);
size_t keyLength = strlen(docKey);
memcpy(buffer, docKey, keyLength);
TRI_V8_RETURN_PAIR_STRING(buffer, (int) keyLength);
}
else if (key == TRI_VOC_ATTRIBUTE_REV) {
TRI_voc_rid_t rid = TRI_EXTRACT_MARKER_RID(static_cast<TRI_df_marker_t const*>(marker));
TRI_ASSERT(rid > 0);
size_t len = TRI_StringUInt64InPlace((uint64_t) rid, (char*) &buffer);
TRI_V8_RETURN_PAIR_STRING((char const*) buffer, (int) len);
}
if (key == TRI_VOC_ATTRIBUTE_ID ||
key == TRI_VOC_ATTRIBUTE_FROM ||
key == TRI_VOC_ATTRIBUTE_TO) {
// strip reserved attributes
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
}
// TODO: check whether accessing an attribute with a dot is actually possible,
// e.g. doc.a.b vs. doc["a.b"]
if (strchr(key.c_str(), '.') != nullptr) {
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
// get the underlying collection
auto ditch = static_cast<triagens::arango::DocumentDitch*>(v8::Handle<v8::External>::Cast(self->GetInternalField(SLOT_DITCH))->Value());
TRI_ASSERT(ditch != nullptr);
TRI_document_collection_t* collection = ditch->collection();
// get shape accessor
TRI_shaper_t* shaper = collection->getShaper(); // PROTECTED by trx here
TRI_shape_pid_t pid = shaper->lookupAttributePathByName(shaper, key.c_str());
if (pid == 0) {
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
TRI_shaped_json_t document;
TRI_EXTRACT_SHAPED_JSON_MARKER(document, marker);
TRI_shaped_json_t json;
TRI_shape_t const* shape;
bool ok = TRI_ExtractShapedJsonVocShaper(shaper, &document, 0, pid, &json, &shape);
if (ok && shape != nullptr) {
TRI_V8_RETURN(TRI_JsonShapeData(isolate, shaper, shape, json._data.data, json._data.length));
}
// we must not throw a v8 exception here because this will cause follow up errors
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
// get the underlying collection
auto ditch = static_cast<triagens::arango::DocumentDitch*>(v8::Handle<v8::External>::Cast(self->GetInternalField(SLOT_DITCH))->Value());
TRI_ASSERT(ditch != nullptr);
TRI_document_collection_t* collection = ditch->collection();
// get shape accessor
TRI_shaper_t* shaper = collection->getShaper(); // PROTECTED by trx here
TRI_shape_pid_t pid = shaper->lookupAttributePathByName(shaper, key.c_str());
if (pid == 0) {
catch (...) {
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
TRI_shaped_json_t document;
TRI_EXTRACT_SHAPED_JSON_MARKER(document, marker);
TRI_shaped_json_t json;
TRI_shape_t const* shape;
bool ok = TRI_ExtractShapedJsonVocShaper(shaper, &document, 0, pid, &json, &shape);
if (ok && shape != nullptr) {
TRI_V8_RETURN(TRI_JsonShapeData(isolate, shaper, shape, json._data.data, json._data.length));
}
// we must not throw a v8 exception here because this will cause follow up errors
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
////////////////////////////////////////////////////////////////////////////////
@ -614,38 +619,43 @@ static void MapSetNamedShapedJson (v8::Local<v8::String> name,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
try {
v8::HandleScope scope(isolate);
// sanity check
v8::Handle<v8::Object> self = args.Holder();
// sanity check
v8::Handle<v8::Object> self = args.Holder();
if (self->InternalFieldCount() <= SLOT_DITCH) {
// we better not throw here... otherwise this will cause a segfault
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
if (self->InternalFieldCount() <= SLOT_DITCH) {
// we better not throw here... otherwise this will cause a segfault
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
// get shaped json
void* marker = TRI_UnwrapClass<void*>(self, WRP_SHAPED_JSON_TYPE);
// get shaped json
void* marker = TRI_UnwrapClass<void*>(self, WRP_SHAPED_JSON_TYPE);
if (marker == nullptr) {
return;
}
if (marker == nullptr) {
return;
}
if (self->HasRealNamedProperty(name)) {
// object already has the property. use the regular property setter
if (self->HasRealNamedProperty(name)) {
// object already has the property. use the regular property setter
self->ForceSet(name, value);
TRI_V8_RETURN_TRUE();
}
// copy all attributes from the shaped json into the object
CopyAttributes(isolate, self, marker);
// remove pointer to marker, so the object becomes stand-alone
self->SetInternalField(SLOT_CLASS, v8::External::New(isolate, nullptr));
// and now use the regular property setter
self->ForceSet(name, value);
TRI_V8_RETURN_TRUE();
}
// copy all attributes from the shaped json into the object
CopyAttributes(isolate, self, marker);
// remove pointer to marker, so the object becomes stand-alone
self->SetInternalField(SLOT_CLASS, v8::External::New(isolate, nullptr));
// and now use the regular property setter
self->ForceSet(name, value);
TRI_V8_RETURN_TRUE();
catch (...) {
TRI_V8_RETURN(v8::Handle<v8::Value>());
}
}
////////////////////////////////////////////////////////////////////////////////
@ -657,32 +667,37 @@ static void MapSetNamedShapedJson (v8::Local<v8::String> name,
static void MapDeleteNamedShapedJson (v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Boolean>& args) {
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
// sanity check
v8::Handle<v8::Object> self = args.Holder();
try {
v8::HandleScope scope(isolate);
// sanity check
v8::Handle<v8::Object> self = args.Holder();
if (self->InternalFieldCount() <= SLOT_DITCH) {
// we better not throw here... otherwise this will cause a segfault
return;
}
if (self->InternalFieldCount() <= SLOT_DITCH) {
// we better not throw here... otherwise this will cause a segfault
return;
}
// get shaped json
void* marker = TRI_UnwrapClass<void*>(self, WRP_SHAPED_JSON_TYPE);
// get shaped json
void* marker = TRI_UnwrapClass<void*>(self, WRP_SHAPED_JSON_TYPE);
if (marker == nullptr) {
self->ForceDelete(name);
TRI_V8_RETURN_TRUE();
}
// copy all attributes from the shaped json into the object
CopyAttributes(isolate, self, marker);
// remove pointer to marker, so the object becomes stand-alone
self->SetInternalField(SLOT_CLASS, v8::External::New(isolate, nullptr));
if (marker == nullptr) {
self->ForceDelete(name);
TRI_V8_RETURN_TRUE();
}
// copy all attributes from the shaped json into the object
CopyAttributes(isolate, self, marker);
// remove pointer to marker, so the object becomes stand-alone
self->SetInternalField(SLOT_CLASS, v8::External::New(isolate, nullptr));
self->ForceDelete(name);
TRI_V8_RETURN_TRUE();
catch (...) {
return;
}
}
////////////////////////////////////////////////////////////////////////////////
@ -692,70 +707,75 @@ static void MapDeleteNamedShapedJson (v8::Local<v8::String> name,
static void PropertyQueryShapedJson (v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Integer>& args) {
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
try {
v8::HandleScope scope(isolate);
v8::Handle<v8::Object> self = args.Holder();
v8::Handle<v8::Object> self = args.Holder();
// sanity check
if (self->InternalFieldCount() <= SLOT_DITCH) {
TRI_V8_RETURN(v8::Handle<v8::Integer>());
}
// get shaped json
void* marker = TRI_UnwrapClass<TRI_shaped_json_t>(self, WRP_SHAPED_JSON_TYPE);
if (marker == nullptr) {
TRI_V8_RETURN(v8::Handle<v8::Integer>());
}
// convert the JavaScript string to a string
string const&& key = TRI_ObjectToString(name);
if (key.empty()) {
TRI_V8_RETURN(v8::Handle<v8::Integer>());
}
if (key[0] == '_') {
if (key == TRI_VOC_ATTRIBUTE_KEY ||
key == TRI_VOC_ATTRIBUTE_REV ||
key == TRI_VOC_ATTRIBUTE_ID ||
key == TRI_VOC_ATTRIBUTE_FROM ||
key == TRI_VOC_ATTRIBUTE_TO) {
TRI_V8_RETURN(v8::Handle<v8::Integer>(v8::Integer::New(isolate, v8::None)));
// sanity check
if (self->InternalFieldCount() <= SLOT_DITCH) {
TRI_V8_RETURN(v8::Handle<v8::Integer>());
}
}
// get underlying collection
auto ditch = static_cast<triagens::arango::DocumentDitch*>(v8::Handle<v8::External>::Cast(self->GetInternalField(SLOT_DITCH))->Value());
TRI_document_collection_t* collection = ditch->collection();
// get shaped json
void* marker = TRI_UnwrapClass<TRI_shaped_json_t>(self, WRP_SHAPED_JSON_TYPE);
// get shape accessor
TRI_shaper_t* shaper = collection->getShaper(); // PROTECTED by BARRIER, checked by RUNTIME
TRI_shape_pid_t pid = shaper->lookupAttributePathByName(shaper, key.c_str());
if (marker == nullptr) {
TRI_V8_RETURN(v8::Handle<v8::Integer>());
}
if (pid == 0) {
TRI_V8_RETURN(v8::Handle<v8::Integer>());
}
// convert the JavaScript string to a string
string const&& key = TRI_ObjectToString(name);
TRI_shape_sid_t sid;
TRI_EXTRACT_SHAPE_IDENTIFIER_MARKER(sid, marker);
if (key.empty()) {
TRI_V8_RETURN(v8::Handle<v8::Integer>());
}
if (sid == TRI_SHAPE_ILLEGAL) {
// invalid shape
if (key[0] == '_') {
if (key == TRI_VOC_ATTRIBUTE_KEY ||
key == TRI_VOC_ATTRIBUTE_REV ||
key == TRI_VOC_ATTRIBUTE_ID ||
key == TRI_VOC_ATTRIBUTE_FROM ||
key == TRI_VOC_ATTRIBUTE_TO) {
TRI_V8_RETURN(v8::Handle<v8::Integer>(v8::Integer::New(isolate, v8::None)));
}
}
// get underlying collection
auto ditch = static_cast<triagens::arango::DocumentDitch*>(v8::Handle<v8::External>::Cast(self->GetInternalField(SLOT_DITCH))->Value());
TRI_document_collection_t* collection = ditch->collection();
// get shape accessor
TRI_shaper_t* shaper = collection->getShaper(); // PROTECTED by BARRIER, checked by RUNTIME
TRI_shape_pid_t pid = shaper->lookupAttributePathByName(shaper, key.c_str());
if (pid == 0) {
TRI_V8_RETURN(v8::Handle<v8::Integer>());
}
TRI_shape_sid_t sid;
TRI_EXTRACT_SHAPE_IDENTIFIER_MARKER(sid, marker);
if (sid == TRI_SHAPE_ILLEGAL) {
// invalid shape
#ifdef TRI_ENABLE_MAINTAINER_MODE
LOG_WARNING("invalid shape id '%llu' found for key '%s'", (unsigned long long) sid, key.c_str());
LOG_WARNING("invalid shape id '%llu' found for key '%s'", (unsigned long long) sid, key.c_str());
#endif
TRI_V8_RETURN(v8::Handle<v8::Integer>());
}
TRI_shape_access_t const* acc = TRI_FindAccessorVocShaper(shaper, sid, pid);
// key not found
if (acc == nullptr || acc->_resultSid == TRI_SHAPE_ILLEGAL) {
TRI_V8_RETURN(v8::Handle<v8::Integer>());
}
TRI_V8_RETURN(v8::Handle<v8::Integer>(v8::Integer::New(isolate, v8::None)));
}
catch (...) {
TRI_V8_RETURN(v8::Handle<v8::Integer>());
}
TRI_shape_access_t const* acc = TRI_FindAccessorVocShaper(shaper, sid, pid);
// key not found
if (acc == nullptr || acc->_resultSid == TRI_SHAPE_ILLEGAL) {
TRI_V8_RETURN(v8::Handle<v8::Integer>());
}
TRI_V8_RETURN(v8::Handle<v8::Integer>(v8::Integer::New(isolate, v8::None)));
}
////////////////////////////////////////////////////////////////////////////////
@ -839,9 +859,9 @@ void TRI_InitV8ShapedJson (v8::Isolate *isolate,
// accessor for indexed properties (e.g. doc[1])
rt->SetIndexedPropertyHandler(MapGetIndexedShapedJson, // IndexedPropertyGetter,
MapSetIndexedShapedJson, // IndexedPropertySetter,
0, // IndexedPropertyQuery,
nullptr, // IndexedPropertyQuery,
MapDeleteIndexedShapedJson, // IndexedPropertyDeleter,
0 // IndexedPropertyEnumerator,
nullptr // IndexedPropertyEnumerator,
// Handle<Value> data = Handle<Value>());
);

View File

@ -258,7 +258,7 @@ struct TRI_doc_mptr_copy_t : public TRI_doc_mptr_t {
TRI_doc_mptr_copy_t (TRI_doc_mptr_copy_t&& that) {
copy(that);
}
TRI_doc_mptr_copy_t&& operator= (TRI_doc_mptr_copy_t&& that) {
copy(that);
return std::move(*this);

View File

@ -210,7 +210,7 @@ static bool VoiceMode = false;
////////////////////////////////////////////////////////////////////////////////
static void JS_PagerOutput (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
for (int i = 0; i < args.Length(); i++) {
@ -223,6 +223,7 @@ static void JS_PagerOutput (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -230,7 +231,7 @@ static void JS_PagerOutput (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_StartOutputPager (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (BaseClient.usePager()) {
@ -242,6 +243,7 @@ static void JS_StartOutputPager (const v8::FunctionCallbackInfo<v8::Value>& args
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -249,7 +251,7 @@ static void JS_StartOutputPager (const v8::FunctionCallbackInfo<v8::Value>& args
////////////////////////////////////////////////////////////////////////////////
static void JS_StopOutputPager (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (BaseClient.usePager()) {
@ -262,6 +264,7 @@ static void JS_StopOutputPager (const v8::FunctionCallbackInfo<v8::Value>& args)
BaseClient.setUsePager(false);
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------
@ -283,10 +286,9 @@ static void JS_StopOutputPager (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_ImportCsvFile (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2) {
TRI_V8_THROW_EXCEPTION_USAGE("importCsvFile(<filename>, <collection>[, <options>])");
}
@ -351,6 +353,7 @@ static void JS_ImportCsvFile (const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TRI_V8_THROW_EXCEPTION_MESSAGE(TRI_ERROR_FAILED, ih.getErrorMessage().c_str());
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -363,10 +366,9 @@ static void JS_ImportCsvFile (const v8::FunctionCallbackInfo<v8::Value>& args) {
////////////////////////////////////////////////////////////////////////////////
static void JS_ImportJsonFile (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2) {
TRI_V8_THROW_EXCEPTION_USAGE("importJsonFile(<filename>, <collection>)");
}
@ -401,13 +403,15 @@ static void JS_ImportJsonFile (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_THROW_EXCEPTION_MESSAGE(TRI_ERROR_FAILED, ih.getErrorMessage().c_str());
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
/// @brief normalizes UTF 16 strings
////////////////////////////////////////////////////////////////////////////////
static void JS_normalize_string (const v8::FunctionCallbackInfo<v8::Value>& args) {
static void JS_NormalizeString (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
@ -417,17 +421,17 @@ static void JS_normalize_string (const v8::FunctionCallbackInfo<v8::Value>& args
}
TRI_normalize_V8_Obj(args, args[0]);
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
/// @brief compare two UTF 16 strings
////////////////////////////////////////////////////////////////////////////////
static void JS_compare_string (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
static void JS_CompareString (const v8::FunctionCallbackInfo<v8::Value>& args) {
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() != 2) {
TRI_V8_THROW_EXCEPTION_USAGE("COMPARE_STRING(<left string>, <right string>)");
}
@ -438,6 +442,7 @@ static void JS_compare_string (const v8::FunctionCallbackInfo<v8::Value>& args)
int result = Utf8Helper::DefaultUtf8Helper.compareUtf16(*left, left.length(), *right, right.length());
TRI_V8_RETURN(v8::Integer::New(isolate, result));
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------
@ -2217,8 +2222,8 @@ static void InitCallbacks (v8::Isolate *isolate,
TRI_AddGlobalVariableVocbase(isolate, context, TRI_V8_ASCII_STRING("SYS_STOP_PAGER"), v8::FunctionTemplate::New(isolate, JS_StopOutputPager)->GetFunction());
TRI_AddGlobalVariableVocbase(isolate, context, TRI_V8_ASCII_STRING("SYS_IMPORT_CSV_FILE"), v8::FunctionTemplate::New(isolate, JS_ImportCsvFile)->GetFunction());
TRI_AddGlobalVariableVocbase(isolate, context, TRI_V8_ASCII_STRING("SYS_IMPORT_JSON_FILE"), v8::FunctionTemplate::New(isolate, JS_ImportJsonFile)->GetFunction());
TRI_AddGlobalVariableVocbase(isolate, context, TRI_V8_ASCII_STRING("NORMALIZE_STRING"), v8::FunctionTemplate::New(isolate, JS_normalize_string)->GetFunction());
TRI_AddGlobalVariableVocbase(isolate, context, TRI_V8_ASCII_STRING("COMPARE_STRING"), v8::FunctionTemplate::New(isolate, JS_compare_string)->GetFunction());
TRI_AddGlobalVariableVocbase(isolate, context, TRI_V8_ASCII_STRING("NORMALIZE_STRING"), v8::FunctionTemplate::New(isolate, JS_NormalizeString)->GetFunction());
TRI_AddGlobalVariableVocbase(isolate, context, TRI_V8_ASCII_STRING("COMPARE_STRING"), v8::FunctionTemplate::New(isolate, JS_CompareString)->GetFunction());
TRI_AddGlobalVariableVocbase(isolate, context, TRI_V8_ASCII_STRING("ARANGO_QUIET"), v8::Boolean::New(isolate, BaseClient.quiet()));
TRI_AddGlobalVariableVocbase(isolate, context, TRI_V8_ASCII_STRING("VALGRIND"), v8::Boolean::New(isolate, (RUNNING_ON_VALGRIND > 0)));
@ -2330,7 +2335,7 @@ static int Run (v8::Isolate* isolate, eRunMode runMode, bool promptError) {
cerr << "caught unknown exception" << endl;
ok = false;
}
return (ok)? EXIT_SUCCESS : EXIT_FAILURE;
return (ok) ? EXIT_SUCCESS : EXIT_FAILURE;
}
class BufferAllocator : public v8::ArrayBuffer::Allocator {
@ -2483,7 +2488,17 @@ int main (int argc, char* args[]) {
if (ret == EXIT_SUCCESS) {
BaseClient.openLog();
ret = Run(isolate, runMode, promptError);
try {
ret = Run(isolate, runMode, promptError);
}
catch (std::bad_alloc const&) {
LOG_ERROR("caught exception %s", TRI_errno_string(TRI_ERROR_OUT_OF_MEMORY));
ret = EXIT_FAILURE;
}
catch (...) {
LOG_ERROR("caught unknown exception");
ret = EXIT_FAILURE;
}
}
isolate->LowMemoryNotification();

View File

@ -2716,6 +2716,7 @@ function ahuacatlQueryMultiCollectionMadnessTestSuite() {
////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
////////////////////////////////////////////////////////////////////////////////
jsunity.run(ahuacatlQueryGeneralCommonTestSuite);
jsunity.run(ahuacatlQueryGeneralCyclesSuite);
jsunity.run(ahuacatlQueryGeneralTraversalTestSuite);

View File

@ -524,6 +524,15 @@ namespace triagens {
return *this;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief appends string
////////////////////////////////////////////////////////////////////////////////
StringBuffer& appendText (std::string&& str) {
TRI_AppendString2StringBuffer(&_buffer, str.c_str(), str.length());
return *this;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief appends a string buffer
////////////////////////////////////////////////////////////////////////////////

View File

@ -255,10 +255,16 @@ void V8Completer::getAlternatives (char const * text,
if (funcVal->IsFunction()) {
v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(funcVal);
v8::Handle<v8::Value> args;
v8::Handle<v8::Value> cpls = func->Call(current, 0, &args);
if (cpls->IsArray()) {
properties = v8::Handle<v8::Array>::Cast(cpls);
try {
v8::Handle<v8::Value> cpls = func->Call(current, 0, &args);
if (cpls->IsArray()) {
properties = v8::Handle<v8::Array>::Cast(cpls);
}
}
catch (...) {
// silently ignore errors here
}
}
}

View File

@ -58,6 +58,30 @@ static const uint32_t V8DataSlot = 0;
#define ISOLATE v8::Isolate* isolate = v8::Isolate::GetCurrent()
////////////////////////////////////////////////////////////////////////////////
/// @brief macro to initiate a try-catch sequence for V8 callbacks
////////////////////////////////////////////////////////////////////////////////
#define TRI_V8_TRY_CATCH_BEGIN(isolateVar) \
auto isolateVar = args.GetIsolate(); \
try {
////////////////////////////////////////////////////////////////////////////////
/// @brief macro to terminate a try-catch sequence for V8 callbacks
////////////////////////////////////////////////////////////////////////////////
#define TRI_V8_TRY_CATCH_END \
} \
catch (triagens::basics::Exception const& ex) { \
TRI_V8_THROW_EXCEPTION_MESSAGE(ex.code(), ex.what()); \
} \
catch (std::exception const& ex) { \
TRI_V8_THROW_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, ex.what()); \
} \
catch (...) { \
TRI_V8_THROW_EXCEPTION(TRI_ERROR_INTERNAL); \
}
////////////////////////////////////////////////////////////////////////////////
/// @brief shortcut for creating a v8 symbol for the specified string
/// implicites isolate available.

View File

@ -31,6 +31,7 @@
#include "Basics/conversions.h"
#include "Basics/csv.h"
#include "Basics/Exceptions.h"
#include "Basics/logging.h"
#include "Basics/shell-colors.h"
#include "Basics/string-buffer.h"
@ -120,7 +121,7 @@ static void ProcessCsvEnd (TRI_csv_parser_t* parser, const char* field, size_t,
////////////////////////////////////////////////////////////////////////////////
static void JS_ProcessCsvFile (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2) {
@ -216,6 +217,7 @@ static void JS_ProcessCsvFile (const v8::FunctionCallbackInfo<v8::Value>& args)
TRI_CLOSE(fd);
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
////////////////////////////////////////////////////////////////////////////////
@ -237,7 +239,7 @@ static void JS_ProcessCsvFile (const v8::FunctionCallbackInfo<v8::Value>& args)
////////////////////////////////////////////////////////////////////////////////
static void JS_ProcessJsonFile (const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
TRI_V8_TRY_CATCH_BEGIN(isolate);
v8::HandleScope scope(isolate);
if (args.Length() < 2) {
@ -308,6 +310,7 @@ static void JS_ProcessJsonFile (const v8::FunctionCallbackInfo<v8::Value>& args)
}
TRI_V8_RETURN_UNDEFINED();
TRI_V8_TRY_CATCH_END
}
// -----------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff