Redmine #6214: Fix memory alignment errors when using LMDB/NextDB().

This was causing SPARC architecture to crash when expecting a struct
in the value, since the struct would be aligned to a byte position
which depended on the length of the key. x86 is also slower when
accessing unaligned data types, so should be an improvement there as
well.
(cherry picked from commit 34341189aea42d5ff2d4ae4ff1134ed2e1bd0817)