hoytech / lmdbxx

C++17 wrapper for the LMDB embedded B+ tree database library
The Unlicense
59 stars 16 forks source link

Missing support for `MDB_RESERVE` in `lmdb::dbi::put` #16

Open Julianiolo opened 1 week ago

Julianiolo commented 1 week ago

mdb_put supports the MDB_RESERVE flag which allows a user to insert a value without any actual data. The function then returns the space for the user to write to via the data parameter. (see).

lmdb::dbi::put however uses a std::string_view data for its data parameter, so the allocated space cannot be handed back to the user. (so this is also an API problem)

I'm not sure on how this should be handled, as changing it to std::string_view& data would certainly break code? Maybe an extra method or overload would be good?

hoytech commented 1 week ago

Good point! None of my applications use MDB_RESERVE so I haven't had a need to solve this yet.

I think I would favour being explicit about this and adding a new method, but I haven't thought about it much yet. Pull requests welcome!