legacy: fix sql compatibility with PostgreSQL
- Adds double quotes for tables and column, and single quotes for values. (closes #3212)
- Fixes MySQL specific queries: "SHOW TABLES", "DATE_FORMAT", "PRIORITY", "RLIKE", "REGEXP", cascading on truncate tables. (addresses #3214)
- Fixes call of get_user_preferences on system_email module.
- Fixes blob column transforming string in bytearray.
Signed-off-by: Leonardo Rossi <leonardo.r@cern.ch>