https://bugs.openldap.org/show_bug.cgi?id=9291
--- Comment #12 from Howard Chu hyc@openldap.org --- (In reply to Markus from comment #11)
For the second part, I think a new function that can be called optionally after the env has been opened, makes sense. Something like this draft:
/**
- Checks the database for inconsistencies, e.g. page references beyond the
- end of file.
- @param max_page_number the maximum number of pages to check.
This limits the time spent, e.g. for a quick check on opening.
Pass zero to check all pages (the entire database).
*/ int mdb_check_pages(MDB_cursor *cursor, mdb_size_t max_page_number);
Please let me know if that looks good to you and if you have any naming preferences (not so sure here, e.g. mdb_page_ function prefix would also be fitting but is only used in mdb.c).
You could simply add a check of pgno in mdb_page_get(), and check every page reference as they occur.