mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'sharding' of ssh://github.com/triAGENS/ArangoDB into sharding
This commit is contained in:
commit
56ef62d5fe
|
@ -1548,6 +1548,43 @@ static v8::Handle<v8::Value> ReplaceVocbaseCol (const bool useCollection,
|
|||
|
||||
TRI_primary_collection_t* primary = trx.primaryCollection();
|
||||
TRI_memory_zone_t* zone = primary->_shaper->_memoryZone;
|
||||
|
||||
TRI_doc_mptr_t document;
|
||||
|
||||
#ifdef TRI_ENABLE_CLUSTER
|
||||
if (ServerState::instance()->isDBserver()) {
|
||||
// compare attributes in shardKeys
|
||||
const string cidString = StringUtils::itoa(primary->base._info._planId);
|
||||
|
||||
TRI_json_t* json = TRI_ObjectToJson(argv[1]);
|
||||
|
||||
if (json == 0) {
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, key);
|
||||
TRI_V8_EXCEPTION_MEMORY(scope);
|
||||
}
|
||||
|
||||
trx.lockWrite();
|
||||
res = trx.read(&document, key);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR || document._key == 0 || document._data == 0) {
|
||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, key);
|
||||
TRI_V8_EXCEPTION(scope, res);
|
||||
}
|
||||
|
||||
TRI_shaped_json_t shaped;
|
||||
TRI_EXTRACT_SHAPED_JSON_MARKER(shaped, document._data);
|
||||
TRI_json_t* old = TRI_JsonShapedJson(primary->_shaper, &shaped);
|
||||
|
||||
if (shardKeysChanged(col->_dbName, cidString, old, json, false)) {
|
||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, key);
|
||||
TRI_V8_EXCEPTION(scope, TRI_ERROR_CLUSTER_MUST_NOT_CHANGE_SHARDING_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
TRI_shaped_json_t* shaped = TRI_ShapedJsonV8Object(argv[1], primary->_shaper);
|
||||
|
||||
if (shaped == 0) {
|
||||
|
@ -1555,7 +1592,6 @@ static v8::Handle<v8::Value> ReplaceVocbaseCol (const bool useCollection,
|
|||
TRI_V8_EXCEPTION_MESSAGE(scope, TRI_errno(), "<data> cannot be converted into JSON shape");
|
||||
}
|
||||
|
||||
TRI_doc_mptr_t document;
|
||||
res = trx.updateDocument(key, &document, shaped, policy, forceSync, rid, &actualRevision);
|
||||
|
||||
res = trx.finish(res);
|
||||
|
@ -1914,6 +1950,21 @@ static v8::Handle<v8::Value> UpdateVocbaseCol (const bool useCollection,
|
|||
TRI_V8_EXCEPTION_MEMORY(scope);
|
||||
}
|
||||
|
||||
#ifdef TRI_ENABLE_CLUSTER
|
||||
if (ServerState::instance()->isDBserver()) {
|
||||
// compare attributes in shardKeys
|
||||
const string cidString = StringUtils::itoa(primary->base._info._planId);
|
||||
|
||||
if (shardKeysChanged(col->_dbName, cidString, old, json, true)) {
|
||||
TRI_FreeJson(primary->_shaper->_memoryZone, old);
|
||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
||||
FREE_STRING(TRI_CORE_MEM_ZONE, key);
|
||||
|
||||
TRI_V8_EXCEPTION(scope, TRI_ERROR_CLUSTER_MUST_NOT_CHANGE_SHARDING_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TRI_json_t* patchedJson = TRI_MergeJson(TRI_UNKNOWN_MEM_ZONE, old, json, nullMeansRemove);
|
||||
TRI_FreeJson(zone, old);
|
||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
||||
|
@ -7969,12 +8020,13 @@ static v8::Handle<v8::Value> MapGetVocBase (v8::Local<v8::String> name,
|
|||
std::string(key));
|
||||
collection = CollectionInfoToVocBaseCol(vocbase, *ci, originalDatabase);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (collection == 0) {
|
||||
// look up the collection
|
||||
else {
|
||||
collection = TRI_LookupCollectionByNameVocBase(vocbase, key);
|
||||
}
|
||||
#else
|
||||
// look up the collection
|
||||
collection = TRI_LookupCollectionByNameVocBase(vocbase, key);
|
||||
#endif
|
||||
|
||||
if (collection == 0) {
|
||||
if (*key == '_') {
|
||||
|
|
Loading…
Reference in New Issue