mirror of https://gitee.com/bigwinds/arangodb
backport: address issue with inverted check for isCoordinator
This commit is contained in:
parent
b8245f9be7
commit
aece5f4e4d
|
@ -355,7 +355,7 @@ RocksDBIndexFactory::RocksDBIndexFactory() {
|
|||
return std::make_shared<RocksDBSkiplistIndex>(id, collection, definition);
|
||||
});
|
||||
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
|
||||
emplaceNormalizer("edge", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
|
@ -369,31 +369,13 @@ RocksDBIndexFactory::RocksDBIndexFactory() {
|
|||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_EDGE_INDEX)));
|
||||
|
||||
if (isCreation && !definition.hasKey("objectId")) {
|
||||
if (isCreation && !ServerState::instance()->isCoordinator() && !definition.hasKey("objectId")) {
|
||||
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
|
||||
}
|
||||
|
||||
return TRI_ERROR_INTERNAL;
|
||||
});
|
||||
} else {
|
||||
emplaceNormalizer("edge", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
bool isCreation
|
||||
)->arangodb::Result {
|
||||
if (isCreation) {
|
||||
// creating these indexes yourself is forbidden
|
||||
return TRI_ERROR_FORBIDDEN;
|
||||
}
|
||||
|
||||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_EDGE_INDEX)));
|
||||
|
||||
return TRI_ERROR_INTERNAL;
|
||||
});
|
||||
}
|
||||
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
emplaceNormalizer("fulltext", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
|
@ -402,26 +384,13 @@ RocksDBIndexFactory::RocksDBIndexFactory() {
|
|||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_FULLTEXT_INDEX)));
|
||||
|
||||
if (isCreation && !definition.hasKey("objectId")) {
|
||||
if (isCreation && !ServerState::instance()->isCoordinator() && !definition.hasKey("objectId")) {
|
||||
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
|
||||
}
|
||||
|
||||
return EnhanceJsonIndexFulltext(definition, normalized, isCreation);
|
||||
});
|
||||
} else {
|
||||
emplaceNormalizer("fulltext", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
bool isCreation
|
||||
)->arangodb::Result {
|
||||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_FULLTEXT_INDEX)));
|
||||
|
||||
return EnhanceJsonIndexFulltext(definition, normalized, isCreation);
|
||||
});
|
||||
}
|
||||
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
emplaceNormalizer("geo", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
|
@ -430,7 +399,7 @@ RocksDBIndexFactory::RocksDBIndexFactory() {
|
|||
auto current = definition.get("fields");
|
||||
TRI_ASSERT(normalized.isOpenObject());
|
||||
|
||||
if (isCreation && !definition.hasKey("objectId")) {
|
||||
if (isCreation && !ServerState::instance()->isCoordinator() && !definition.hasKey("objectId")) {
|
||||
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
|
||||
}
|
||||
|
||||
|
@ -444,6 +413,7 @@ RocksDBIndexFactory::RocksDBIndexFactory() {
|
|||
|
||||
return EnhanceJsonIndexGeo1(definition, normalized, isCreation);
|
||||
});
|
||||
|
||||
emplaceNormalizer("geo1", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
|
@ -452,12 +422,13 @@ RocksDBIndexFactory::RocksDBIndexFactory() {
|
|||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO1_INDEX)));
|
||||
|
||||
if (isCreation && !definition.hasKey("objectId")) {
|
||||
if (isCreation && !ServerState::instance()->isCoordinator() && !definition.hasKey("objectId")) {
|
||||
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
|
||||
}
|
||||
|
||||
return EnhanceJsonIndexGeo1(definition, normalized, isCreation);
|
||||
});
|
||||
|
||||
emplaceNormalizer("geo2", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
|
@ -466,54 +437,13 @@ RocksDBIndexFactory::RocksDBIndexFactory() {
|
|||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO2_INDEX)));
|
||||
|
||||
if (isCreation && !definition.hasKey("objectId")) {
|
||||
if (isCreation && !ServerState::instance()->isCoordinator() && !definition.hasKey("objectId")) {
|
||||
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
|
||||
}
|
||||
|
||||
return EnhanceJsonIndexGeo2(definition, normalized, isCreation);
|
||||
});
|
||||
} else {
|
||||
emplaceNormalizer("geo", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
bool isCreation
|
||||
)->arangodb::Result {
|
||||
auto current = definition.get("fields");
|
||||
TRI_ASSERT(normalized.isOpenObject());
|
||||
|
||||
if (current.isArray() && current.length() == 2) {
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO2_INDEX)));
|
||||
|
||||
return EnhanceJsonIndexGeo2(definition, normalized, isCreation);
|
||||
}
|
||||
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO1_INDEX)));
|
||||
|
||||
return EnhanceJsonIndexGeo1(definition, normalized, isCreation);
|
||||
});
|
||||
emplaceNormalizer("geo1", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
bool isCreation
|
||||
)->arangodb::Result {
|
||||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO1_INDEX)));
|
||||
|
||||
return EnhanceJsonIndexGeo1(definition, normalized, isCreation);
|
||||
});
|
||||
emplaceNormalizer("geo2", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
bool isCreation
|
||||
)->arangodb::Result {
|
||||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_GEO2_INDEX)));
|
||||
|
||||
return EnhanceJsonIndexGeo2(definition, normalized, isCreation);
|
||||
});
|
||||
}
|
||||
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
emplaceNormalizer("hash", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
|
@ -522,26 +452,13 @@ RocksDBIndexFactory::RocksDBIndexFactory() {
|
|||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_HASH_INDEX)));
|
||||
|
||||
if (isCreation && !definition.hasKey("objectId")) {
|
||||
if (isCreation && !ServerState::instance()->isCoordinator() && !definition.hasKey("objectId")) {
|
||||
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
|
||||
}
|
||||
|
||||
return EnhanceJsonIndexHash(definition, normalized, isCreation);
|
||||
});
|
||||
} else {
|
||||
emplaceNormalizer("hash", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
bool isCreation
|
||||
)->arangodb::Result {
|
||||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_HASH_INDEX)));
|
||||
|
||||
return EnhanceJsonIndexHash(definition, normalized, isCreation);
|
||||
});
|
||||
}
|
||||
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
emplaceNormalizer("primary", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
|
@ -555,31 +472,13 @@ RocksDBIndexFactory::RocksDBIndexFactory() {
|
|||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PRIMARY_INDEX)));
|
||||
|
||||
if (isCreation && !definition.hasKey("objectId")) {
|
||||
if (isCreation && !ServerState::instance()->isCoordinator() && !definition.hasKey("objectId")) {
|
||||
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
|
||||
}
|
||||
|
||||
return TRI_ERROR_INTERNAL;
|
||||
});
|
||||
} else {
|
||||
emplaceNormalizer("primary", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
bool isCreation
|
||||
)->arangodb::Result {
|
||||
if (isCreation) {
|
||||
// creating these indexes yourself is forbidden
|
||||
return TRI_ERROR_FORBIDDEN;
|
||||
}
|
||||
|
||||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PRIMARY_INDEX)));
|
||||
|
||||
return TRI_ERROR_INTERNAL;
|
||||
});
|
||||
}
|
||||
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
emplaceNormalizer("persistent", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
|
@ -588,26 +487,13 @@ RocksDBIndexFactory::RocksDBIndexFactory() {
|
|||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PERSISTENT_INDEX)));
|
||||
|
||||
if (isCreation && !definition.hasKey("objectId")) {
|
||||
if (isCreation && !ServerState::instance()->isCoordinator() && !definition.hasKey("objectId")) {
|
||||
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
|
||||
}
|
||||
|
||||
return EnhanceJsonIndexPersistent(definition, normalized, isCreation);
|
||||
});
|
||||
} else {
|
||||
emplaceNormalizer("persistent", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
bool isCreation
|
||||
)->arangodb::Result {
|
||||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PERSISTENT_INDEX)));
|
||||
|
||||
return EnhanceJsonIndexPersistent(definition, normalized, isCreation);
|
||||
});
|
||||
}
|
||||
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
emplaceNormalizer("rocksdb", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
|
@ -616,26 +502,13 @@ RocksDBIndexFactory::RocksDBIndexFactory() {
|
|||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PERSISTENT_INDEX)));
|
||||
|
||||
if (isCreation && !definition.hasKey("objectId")) {
|
||||
if (isCreation && !ServerState::instance()->isCoordinator() && !definition.hasKey("objectId")) {
|
||||
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
|
||||
}
|
||||
|
||||
return EnhanceJsonIndexPersistent(definition, normalized, isCreation);
|
||||
});
|
||||
} else {
|
||||
emplaceNormalizer("rocksdb", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
bool isCreation
|
||||
)->arangodb::Result {
|
||||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_PERSISTENT_INDEX)));
|
||||
|
||||
return EnhanceJsonIndexPersistent(definition, normalized, isCreation);
|
||||
});
|
||||
}
|
||||
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
emplaceNormalizer("skiplist", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
|
@ -644,24 +517,12 @@ RocksDBIndexFactory::RocksDBIndexFactory() {
|
|||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_SKIPLIST_INDEX)));
|
||||
|
||||
if (isCreation && !definition.hasKey("objectId")) {
|
||||
if (isCreation && !ServerState::instance()->isCoordinator() && !definition.hasKey("objectId")) {
|
||||
normalized.add("objectId", velocypack::Value(std::to_string(TRI_NewTickServer())));
|
||||
}
|
||||
|
||||
return EnhanceJsonIndexSkiplist(definition, normalized, isCreation);
|
||||
});
|
||||
} else {
|
||||
emplaceNormalizer("skiplist", [](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
bool isCreation
|
||||
)->arangodb::Result {
|
||||
TRI_ASSERT(normalized.isOpenObject());
|
||||
normalized.add("type", VPackValue(Index::oldtypeName(Index::TRI_IDX_TYPE_SKIPLIST_INDEX)));
|
||||
|
||||
return EnhanceJsonIndexSkiplist(definition, normalized, isCreation);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void RocksDBIndexFactory::fillSystemIndexes(
|
||||
|
|
Loading…
Reference in New Issue