Only txn_commit in read-write mode.

Don't txn_commit a DB on close if it was in read-only mode.
Make written value in WriteName const.

Make the vector<CNameIndex> value passed to WriteName const, as it
should be (since it won't be changed).