This is more a question than an issue.
Basically I have this little snippet which should list all named databases.
auto txn{env->start_read()};
auto map{txn.open_map(nullptr)};
auto crs{txn.open_cursor(map)};
std::cout << "Tables " << txn.get_map_stat(map).ms_entries << std::endl;
auto r = crs.move(::mdbx::cursor::move_operation::first, false);
while (!crs.eof()) {
std::cout << r.key << std::endl;
r = crs.move(::mdbx::cursor::move_operation::next, false);
}
But it keeps looping indefinitely printing the last record of the bucket/table over and over again.
So question is : is this the proper use of cursor.eof() ?
Besides I had to amend the above code checking for r.done or crs.on_last()
I'm using c++ API interfaces and am on Windows MSVC
Thank you
The text was updated successfully, but these errors were encountered:
This bug happened a long time ago, but after the last changes to the mdbx_cursor_eof() function code.
It happened due to micro-optimization and cleaning of the code that uses the internal flag C_EOF.
On the other hand, mdx_cursor_eof() was not checked by libmdbx's tests, since it was once made for use in libfpta and have been tested there by numerous unit tests.
But in turn, there were also changes and optimizations in libfpta, as a result of which the potentially incorrect behavior of mdbx_cursor_eof() ceased to affect the appreciable result, and this was done before changing the internal behavior of the C_EOF flag, which had break the mdbx_cursor_eof().
Thus this error remained unnoticed for a long time. Now I have added the mdbx_cursor_eof() check.
AndreaLanfranchi commentedJun 16, 2021
This is more a question than an issue.
Basically I have this little snippet which should list all named databases.
But it keeps looping indefinitely printing the last record of the bucket/table over and over again.
So question is : is this the proper use of
cursor.eof()
?Besides I had to amend the above code checking for
r.done
orcrs.on_last()
I'm using c++ API interfaces and am on Windows MSVC
Thank you
The text was updated successfully, but these errors were encountered: