MySQL/PostgreSQL Database

Why are client messages corrupted / incompletely stored in the DB ?

Because the messages are not in XML format, and therefore incorrectly parsed. The most frequent reasons are:

1.) Your server is compiled with --enable-xml-log, but your client(s) is/are not.

2.) In your client or server configuration file, you are using the option for a custum message header, but without paying attention to preserving the XML format.

What does the log_ref field mean ?

NULL are client messages. Nonzero integer is a server timestamp for a client message (where log_ref indicates the log_index entry number of the corresponding client message). Zero indicates a message by the server itself (e.g. the server's start message).