forked from blue/lmdbal
Some reformation, test cases and first bugfixes
This commit is contained in:
parent
e88efb458f
commit
ef86d0adf9
5 changed files with 93 additions and 47 deletions
src
|
@ -195,14 +195,12 @@ void LMDBAL::Cursor<K, V>::terminated () {
|
|||
switch (state) {
|
||||
case openedPublic:
|
||||
storage->_mdbCursorClose(cursor);
|
||||
|
||||
state = closed;
|
||||
break;
|
||||
break;
|
||||
case openedPrivate:
|
||||
storage->closeCursorTransaction(cursor);
|
||||
|
||||
storage->closeCursorTransaction(cursor, true);
|
||||
state = closed;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -228,7 +226,7 @@ void LMDBAL::Cursor<K, V>::open () {
|
|||
|
||||
switch (state) {
|
||||
case closed:
|
||||
storage->openCursorTransaction(&cursor);
|
||||
storage->openCursorTransaction(&cursor, false);
|
||||
state = openedPrivate;
|
||||
break;
|
||||
default:
|
||||
|
@ -297,30 +295,15 @@ void LMDBAL::Cursor<K, V>::renew () {
|
|||
|
||||
storage->ensureOpened(renewCursorMethodName);
|
||||
switch (state) {
|
||||
case openedPrivate: {
|
||||
TransactionID txn = storage->_mdbCursorTxn(cursor);
|
||||
storage->abortTransaction(txn);
|
||||
storage->transactionAborted(txn);
|
||||
|
||||
txn = storage->beginReadOnlyTransaction();
|
||||
int result = storage->_mdbCursorRenew(txn, cursor);
|
||||
if (result != MDB_SUCCESS)
|
||||
storage->throwUnknown(result, txn);
|
||||
|
||||
storage->transactionStarted(txn, true);
|
||||
state = openedPrivate;
|
||||
}
|
||||
case openedPublic: {
|
||||
case openedPrivate:
|
||||
storage->closeCursorTransaction(cursor, false);
|
||||
storage->openCursorTransaction(&cursor, true);
|
||||
break;
|
||||
case openedPublic:
|
||||
storage->disconnectCursorFromTransaction(id, cursor);
|
||||
TransactionID txn = storage->beginReadOnlyTransaction();
|
||||
int result = storage->_mdbCursorRenew(txn, cursor);
|
||||
if (result != MDB_SUCCESS)
|
||||
storage->throwUnknown(result, txn);
|
||||
|
||||
storage->transactionStarted(txn, true);
|
||||
storage->attachCursorToTransaction(id, cursor, this);
|
||||
storage->openCursorTransaction(&cursor, true);
|
||||
state = openedPrivate;
|
||||
} break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -355,16 +338,14 @@ void LMDBAL::Cursor<K, V>::renew (const Transaction& transaction) {
|
|||
TransactionID txn = storage->extractTransactionId(transaction, renewCursorMethodName);
|
||||
switch (state) {
|
||||
case openedPrivate: {
|
||||
TransactionID txnOld = storage->_mdbCursorTxn(cursor);
|
||||
storage->abortTransaction(txnOld);
|
||||
storage->transactionAborted(txnOld);
|
||||
|
||||
storage->closeCursorTransaction(cursor, false);
|
||||
int result = storage->_mdbCursorRenew(txn, cursor);
|
||||
if (result != MDB_SUCCESS)
|
||||
storage->throwUnknown(result);
|
||||
|
||||
storage->attachCursorToTransaction(id, cursor, this);
|
||||
state = openedPublic;
|
||||
}
|
||||
} break;
|
||||
case openedPublic: {
|
||||
storage->disconnectCursorFromTransaction(id, cursor);
|
||||
int result = storage->_mdbCursorRenew(txn, cursor);
|
||||
|
@ -372,7 +353,6 @@ void LMDBAL::Cursor<K, V>::renew (const Transaction& transaction) {
|
|||
storage->throwUnknown(result);
|
||||
|
||||
storage->attachCursorToTransaction(id, cursor, this);
|
||||
state = openedPublic;
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
|
@ -399,7 +379,7 @@ void LMDBAL::Cursor<K, V>::close () {
|
|||
state = closed;
|
||||
break;
|
||||
case openedPrivate:
|
||||
storage->closeCursorTransaction(cursor);
|
||||
storage->closeCursorTransaction(cursor, true);
|
||||
|
||||
state = closed;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue