diff options
author | George Hazan <ghazan@miranda.im> | 2021-01-20 17:05:15 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-01-20 17:05:15 +0300 |
commit | 8976d32a2eda47013573c7e32132b19cf2949c15 (patch) | |
tree | 5e39c94b3c56bcf15d2eb2c26ac50dbb4d97c71e /plugins/Dbx_mdbx/src | |
parent | 6ba39da289306e1a1db3ee122add5f2dbc4aaee4 (diff) |
fixes #2707 (MDBX: reversed event cursors don't work at the end of table
Diffstat (limited to 'plugins/Dbx_mdbx/src')
-rw-r--r-- | plugins/Dbx_mdbx/src/dbevents.cpp | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/plugins/Dbx_mdbx/src/dbevents.cpp b/plugins/Dbx_mdbx/src/dbevents.cpp index bcbc8f6b51..7e895c7e0b 100644 --- a/plugins/Dbx_mdbx/src/dbevents.cpp +++ b/plugins/Dbx_mdbx/src/dbevents.cpp @@ -623,7 +623,7 @@ class CMdbxEventCursor : public DB::EventCursor friend class CDbxMDBX;
CDbxMDBX *m_pOwner;
- bool m_bForward, m_bFirst = true;
+ bool m_bForward;
DBCachedContact *m_cc;
DBEventSortingKey m_key;
@@ -650,32 +650,19 @@ public: mdbx_cursor_bind(m_pOwner->StartTran(), m_pOwner->m_curEventsSort, m_pOwner->m_dbEventsSort);
MDBX_val key = { &m_key, sizeof(m_key) }, data;
- DBEventSortingKey dbKey;
- if (m_bFirst) {
- m_bFirst = false;
-
- if (mdbx_cursor_get(m_pOwner->m_curEventsSort, &key, &data, MDBX_SET_RANGE) != MDBX_SUCCESS)
- return 0;
- dbKey = *(const DBEventSortingKey *)key.iov_base;
-
- // we could easily move position to the next contact, if it exists
- if (!m_bForward && dbKey.hContact != hContact) {
- if (mdbx_cursor_get(m_pOwner->m_curEventsSort, &key, &data, MDBX_PREV) != MDBX_SUCCESS)
- return 0;
+ switch (mdbx_cursor_get(m_pOwner->m_curEventsSort, &key, &data, MDBX_SET)) {
+ case MDBX_SUCCESS:
+ case MDBX_NOTFOUND:
+ break;
- dbKey = *(const DBEventSortingKey *)key.iov_base;
- }
+ default:
+ return 0;
}
- else {
- if (mdbx_cursor_get(m_pOwner->m_curEventsSort, &key, &data, MDBX_SET) != MDBX_SUCCESS)
- return 0;
-
- if (mdbx_cursor_get(m_pOwner->m_curEventsSort, &key, &data, (m_bForward) ? MDBX_NEXT : MDBX_PREV) != MDBX_SUCCESS)
- return 0;
- dbKey = *(const DBEventSortingKey *)key.iov_base;
- }
+ if (mdbx_cursor_get(m_pOwner->m_curEventsSort, &key, &data, (m_bForward) ? MDBX_NEXT : MDBX_PREV) != MDBX_SUCCESS)
+ return 0;
+ DBEventSortingKey dbKey = *(const DBEventSortingKey *)key.iov_base;
if (dbKey.hContact != hContact)
return 0;
|