First step to alternative to LevelDB.

LevelDB is basically only being used in this program as a way to
externally sort the records parsed from the PostgreSQL dump.
However, LevelDB is far more capable than that; it can handle
multi-threaded access, direct lookups by key, replacements and
deletes. All these features, which are not needed for a simple
sort, may be adding avoidable overhead.

Therefore, it seems like a good idea to try a simple external
merge sort for the tables - they're only written once, have a
definite end time, and are only read once, in full.
Remove unused code and put database writer finalisation in a non-destructor path.
Fix bug when serialising keys and values to strings.