Update fixes for dbi_open/close, ITS#7515.

Reset me_dbflags[dbi] when closing DBI, to get rid of MDB_VALID flag.
mdb_env_close(): Re-fix DB-name memleak. DBIs > me_numdbs may exist.
Cleaner "Support mdb_txn_abort(a reset txn)".

Redo 8a562f560edcc6417672df453c4e626dfb4c4024 so !mt_dbxs indicates
"txn was reset", so mt_numdbs gets one magic value instead of two.
Plug txn leak and MDB_NOTLS slot leaks on error.

On mdb_env_copy() error: Abort the txn.
On mdb_txn_renew0() error: Release new MDB_NOTLS reader slot.
Close cursors when commit(writer). Factor out code.

Close remaining cursors when committing a write txn. The doc says this
happens, and it avoids cursor tracking when updating mainDB + freeDB.

Rename mdb_cursor_merge() -> mdb_cursors_close() for code reuse,
and add a merge option.  Simplify its loop a bit.

Factor out cleanup of DBIs.
Allow mdb_cursor_close() after readonly txn ends.

Catch mdb_cursor_renew(write txn's cursor).  Add flag C_UNTRACK, so
mdb_cursor_close need not peek inside a possibly-freed readonly txn.
Update MDB doc: Cursors, DB handles, data lifetime
mdb_dcmp(): Assume the database has MDB_DUPSORT.

There was little point in returning EINVAL when not: Comparing (A,B)
and (B,A) would claim (A > B && B > A), which could confuse callers.
MDB warning cleanup.

Unused function when MDB_DEBUG. Unused 'excl' param.
Simplify/cleanup mdb_cursor_init, C_ALLOCD.

No real change.
mdb_cursor_init() checks if it needs mx, so pass it unconditionally.
Set C_ALLOCD for shadow cursors, for clarity. (It was always set as
it should anyway from the origin cursor, which would have C_ALLOCD.)
Fix mdb_env_close(unopened MDB_env).

Do not try to scan me_dbxs in a closed/never-opened MDB_env.
Broken by 7d643d3acb94a6d7306330b550fce0e5755444a9
and 151c416b460b02cd96502a47189cda19ab651ada.
ITS#7515 Fix nested transaction error handling.

mdb_txn_begin(): Do not free(mt_free_pgs), it needs mdb_midl_free().
mdb_txn_commit(): Catch commit(child) error.