Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add a way to list named databases #253

Open
NightTsarina opened this issue Sep 22, 2020 · 1 comment
Open

Please add a way to list named databases #253

NightTsarina opened this issue Sep 22, 2020 · 1 comment

Comments

@NightTsarina
Copy link

NightTsarina commented Sep 22, 2020

Hi,

I have been trying to find a way to list all the named databases present in an environment, but neither here nor in the C library there seems to be any functionality to do so. The naive solution of iterating all keys in the unnamed database only works if you don't store any normal keys there. The closest I've got is to try and db_open every key found, but that would not be practical in the general case, and I am not sure if it would work depending on the flags used to create the DB.

The only reliable way I've found to do this requires accessing the internal C structures and check the Node flags ((node->mn_flags & (F_DUPDATA|F_SUBDATA)) != F_SUBDATA) as the mdb_dbi_open function does (code).

The mdb_stat tool has a way to iterate databases, which seems to be to iterate all keys in the main DB and check for the absence of a \x00 value (?): https://sources.debian.org/src/lmdb/0.9.24-1/libraries/liblmdb/mdb_stat.c/#L229

It would be great to have this functionality added to the python bindings.

@jnwatson
Copy link
Owner

While it isn't explicitly said anywhere, my opinion is that it is bad form to use both named databases and populate keys in the main database.

Regardless, your point stands. I agree this would be useful functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants