mirror of https://gitee.com/bigwinds/arangodb
fixed issue #2404
This commit is contained in:
parent
734ed8eba5
commit
ddb83c8075
|
@ -1725,6 +1725,8 @@ int RestReplicationHandler::processRestoreIndexes(VPackSlice const& collection,
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
int res = TRI_ERROR_NO_ERROR;
|
||||
|
||||
READ_LOCKER(readLocker, _vocbase->_inventoryLock);
|
||||
|
||||
// look up the collection
|
||||
|
@ -1737,7 +1739,7 @@ int RestReplicationHandler::processRestoreIndexes(VPackSlice const& collection,
|
|||
transaction::StandaloneContext::Create(_vocbase), collection->cid(),
|
||||
AccessMode::Type::WRITE);
|
||||
|
||||
int res = trx.begin();
|
||||
res = trx.begin();
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
errorMsg =
|
||||
|
@ -1765,6 +1767,12 @@ int RestReplicationHandler::processRestoreIndexes(VPackSlice const& collection,
|
|||
}
|
||||
TRI_ASSERT(idx != nullptr);
|
||||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
return res;
|
||||
}
|
||||
res = trx.commit();
|
||||
|
||||
} catch (arangodb::basics::Exception const& ex) {
|
||||
errorMsg =
|
||||
"could not create index: " + std::string(TRI_errno_string(ex.code()));
|
||||
|
@ -1772,7 +1780,7 @@ int RestReplicationHandler::processRestoreIndexes(VPackSlice const& collection,
|
|||
errorMsg = "could not create index: unknown error";
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -191,6 +191,13 @@
|
|||
}
|
||||
catch (err) {
|
||||
}
|
||||
|
||||
c = db._create("UnitTestsDumpPersistent");
|
||||
c.ensureIndex({ type: "persistent", fields: ["value"], unique: true });
|
||||
|
||||
for (i = 0; i < 10000; ++i) {
|
||||
c.save({ _key: "test" + i, value: i });
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
|
|
|
@ -364,6 +364,32 @@ function dumpTestSuite () {
|
|||
assertEqual(1, c.count());
|
||||
|
||||
assertTrue(c.exists("foo"));
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test persistent
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testPersistent : function () {
|
||||
var c = db._collection("UnitTestsDumpPersistent");
|
||||
var p = c.properties();
|
||||
|
||||
assertEqual(2, c.getIndexes().length);
|
||||
assertEqual("primary", c.getIndexes()[0].type);
|
||||
assertEqual("persistent", c.getIndexes()[1].type);
|
||||
assertEqual(10000, c.count());
|
||||
|
||||
var res = db._query("FOR doc IN " + c.name() + " FILTER doc.value >= 0 RETURN doc").toArray();
|
||||
assertEqual(10000, res.length);
|
||||
|
||||
res = db._query("FOR doc IN " + c.name() + " FILTER doc.value >= 5000 RETURN doc").toArray();
|
||||
assertEqual(5000, res.length);
|
||||
|
||||
res = db._query("FOR doc IN " + c.name() + " FILTER doc.value >= 9000 RETURN doc").toArray();
|
||||
assertEqual(1000, res.length);
|
||||
|
||||
res = db._query("FOR doc IN " + c.name() + " FILTER doc.value >= 10000 RETURN doc").toArray();
|
||||
assertEqual(0, res.length);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue