mirror of https://gitee.com/bigwinds/arangodb
Bug fix 3.5/graph create orphan collection properly (#9842)
* added ensureCollections to orphan create method * do not move anymore * rm trx finish. will be handled automatically in error case * changelog
This commit is contained in:
parent
2123fceb7a
commit
e40d7fadd1
|
@ -1,6 +1,8 @@
|
|||
v3.5.1 (XXXX-XX-XX)
|
||||
-------------------
|
||||
|
||||
* Fixed adding an orphan collections as the first collection in a SmartGraph.
|
||||
|
||||
* Geo functions will now have better error reporting on invalid input.
|
||||
|
||||
* The graph viewer of the web interface now tries to find a vertex document of
|
||||
|
|
|
@ -284,10 +284,6 @@ OperationResult GraphOperations::addOrphanCollection(VPackSlice document, bool w
|
|||
std::shared_ptr<LogicalCollection> def;
|
||||
|
||||
OperationResult result;
|
||||
VPackBuilder collectionsOptions;
|
||||
collectionsOptions.openObject();
|
||||
_graph.createCollectionOptions(collectionsOptions, waitForSync);
|
||||
collectionsOptions.close();
|
||||
|
||||
if (_graph.hasVertexCollection(collectionName)) {
|
||||
if (_graph.hasOrphanCollection(collectionName)) {
|
||||
|
@ -299,13 +295,19 @@ OperationResult GraphOperations::addOrphanCollection(VPackSlice document, bool w
|
|||
std::string{TRI_errno_string(TRI_ERROR_GRAPH_COLLECTION_USED_IN_EDGE_DEF)}));
|
||||
}
|
||||
|
||||
// add orphan collection to graph
|
||||
_graph.addOrphanCollection(std::string(collectionName));
|
||||
|
||||
def = GraphManager::getCollectionByName(_vocbase, collectionName);
|
||||
Result res;
|
||||
|
||||
if (def == nullptr) {
|
||||
if (createCollection) {
|
||||
result = gmngr.createVertexCollection(collectionName, waitForSync,
|
||||
collectionsOptions.slice());
|
||||
if (result.fail()) {
|
||||
return result;
|
||||
// ensure that all collections are available
|
||||
res = gmngr.ensureCollections(&_graph, waitForSync);
|
||||
|
||||
if (res.fail()) {
|
||||
return OperationResult{std::move(res)};
|
||||
}
|
||||
} else {
|
||||
return OperationResult(
|
||||
|
@ -317,13 +319,11 @@ OperationResult GraphOperations::addOrphanCollection(VPackSlice document, bool w
|
|||
if (def->type() != TRI_COL_TYPE_DOCUMENT) {
|
||||
return OperationResult(TRI_ERROR_GRAPH_WRONG_COLLECTION_TYPE_VERTEX);
|
||||
}
|
||||
auto res = _graph.validateCollection(*(def.get()));
|
||||
res = _graph.validateCollection(*(def.get()));
|
||||
if (res.fail()) {
|
||||
return OperationResult{std::move(res)};
|
||||
}
|
||||
}
|
||||
// add orphan collection to graph
|
||||
_graph.addOrphanCollection(std::move(collectionName));
|
||||
|
||||
VPackBuilder builder;
|
||||
builder.openObject();
|
||||
|
@ -333,10 +333,9 @@ OperationResult GraphOperations::addOrphanCollection(VPackSlice document, bool w
|
|||
SingleCollectionTransaction trx(ctx(), StaticStrings::GraphCollection,
|
||||
AccessMode::Type::WRITE);
|
||||
|
||||
Result res = trx.begin();
|
||||
res = trx.begin();
|
||||
|
||||
if (!res.ok()) {
|
||||
trx.finish(TRI_ERROR_NO_ERROR);
|
||||
return OperationResult(res);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue