diff options
author | George Hazan <ghazan@miranda.im> | 2021-02-13 14:56:13 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-02-13 14:56:13 +0300 |
commit | fcbfc265c3631cbf5acba9552a23968d1ee4edd6 (patch) | |
tree | ee1d0465cafd0f97d7b95d28ed98c4ab328be19c /plugins/Dbx_mdbx/src | |
parent | 2f031aa7f17352bc345765c6094a54fe29796818 (diff) |
fixes #2721 (Dbx_mdbx: direct cursors skip the first record found)
Diffstat (limited to 'plugins/Dbx_mdbx/src')
-rw-r--r-- | plugins/Dbx_mdbx/src/dbevents.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/plugins/Dbx_mdbx/src/dbevents.cpp b/plugins/Dbx_mdbx/src/dbevents.cpp index 7e895c7e0b..cbbc3faa58 100644 --- a/plugins/Dbx_mdbx/src/dbevents.cpp +++ b/plugins/Dbx_mdbx/src/dbevents.cpp @@ -649,17 +649,25 @@ public: {
mdbx_cursor_bind(m_pOwner->StartTran(), m_pOwner->m_curEventsSort, m_pOwner->m_dbEventsSort);
+ MDBX_cursor_op op = (m_bForward) ? MDBX_NEXT : MDBX_PREV;
+
MDBX_val key = { &m_key, sizeof(m_key) }, data;
switch (mdbx_cursor_get(m_pOwner->m_curEventsSort, &key, &data, MDBX_SET)) {
- case MDBX_SUCCESS:
case MDBX_NOTFOUND:
+ // for forward cursors we're already on the first record after set
+ // for reverse cursors that means that we moved a pointer after last record, so we need to fetch
+ if (m_bForward)
+ op = MDBX_GET_CURRENT;
+ break;
+
+ case MDBX_SUCCESS:
break;
default:
return 0;
}
- if (mdbx_cursor_get(m_pOwner->m_curEventsSort, &key, &data, (m_bForward) ? MDBX_NEXT : MDBX_PREV) != MDBX_SUCCESS)
+ if (mdbx_cursor_get(m_pOwner->m_curEventsSort, &key, &data, op) != MDBX_SUCCESS)
return 0;
DBEventSortingKey dbKey = *(const DBEventSortingKey *)key.iov_base;
|