mdb_dbi_open(named database) and thus "mdb_stat -a" crash if the main database has the MDB_DUPSORT flag: It hits assert(mx != NULL) in mdb_cursor_init().
Fixing to reject mdb_dbi_open(named database) in this case, (...)
But then mdb_stat crashes anyway when calling: mdb_cursor_get(cursor, &key, NULL, MDB_NEXT) if a key has several data values. mdb_cursor_get(,,,MDB_NEXT) expects a non-NULL data argument for an MDB_DUPSORT database.
It works with MDB_NEXT_NODUP. I think we can drop the doc which says MDB_<NEXT,PREV>_NODUP is only for DUPSORT databases. mdb.c will need no changes that I can see.
Or, it works to pass a pointer to an otherwise unused data. But that leaves mdb_stat doing more work than it needs.
Another mdb_stat nitpick: It exits with failure after mdb_cursor_get returns an expected MDB_NOTFOUND. Fixing.