diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c
index 4b204530fb..e336d1f542 100644
--- a/src/libs/zbxdbhigh/db.c
+++ b/src/libs/zbxdbhigh/db.c
@@ -26,8 +26,12 @@
 #include "dbcache.h"
 #include "zbxalgo.h"
 
+#if defined(HAVE_MYSQL) || defined(HAVE_ORACLE) || defined(HAVE_POSTGRESQL)
 #define ZBX_SUPPORTED_DB_CHARACTER_SET	"utf8"
+#endif
+#if defined(HAVE_MYSQL)
 #define ZBX_SUPPORTED_DB_COLLATION	"utf8_bin"
+#endif
 
 typedef struct
 {
@@ -42,7 +46,7 @@ typedef struct
 }
 zbx_autoreg_host_t;
 
-#if HAVE_POSTGRESQL
+#if defined(HAVE_POSTGRESQL)
 extern char	ZBX_PG_ESCAPE_BACKSLASH;
 #endif
 
@@ -482,7 +486,7 @@ static size_t	get_string_field_size(unsigned char type)
 			exit(EXIT_FAILURE);
 	}
 }
-#elif HAVE_ORACLE
+#elif defined(HAVE_ORACLE)
 static size_t	get_string_field_size(unsigned char type)
 {
 	switch(type)
@@ -507,7 +511,7 @@ static size_t	get_string_field_size(unsigned char type)
  ******************************************************************************/
 char	*DBdyn_escape_string_len(const char *src, size_t length)
 {
-#if HAVE_IBM_DB2	/* IBM DB2 fields are limited by bytes rather than characters */
+#if defined(HAVE_IBM_DB2)	/* IBM DB2 fields are limited by bytes rather than characters */
 	return zbx_db_dyn_escape_string(src, length, ZBX_SIZE_T_MAX, ESCAPE_SEQUENCE_ON);
 #else
 	return zbx_db_dyn_escape_string(src, ZBX_SIZE_T_MAX, length, ESCAPE_SEQUENCE_ON);
@@ -540,7 +544,7 @@ static char	*DBdyn_escape_field_len(const ZBX_FIELD *field, const char *src, zbx
 
 #if defined(HAVE_MYSQL) || defined(HAVE_ORACLE)
 	return zbx_db_dyn_escape_string(src, get_string_field_size(field->type), length, flag);
-#elif HAVE_IBM_DB2	/* IBM DB2 fields are limited by bytes rather than characters */
+#elif defined(HAVE_IBM_DB2)	/* IBM DB2 fields are limited by bytes rather than characters */
 	return zbx_db_dyn_escape_string(src, length, ZBX_SIZE_T_MAX, flag);
 #else
 	return zbx_db_dyn_escape_string(src, ZBX_SIZE_T_MAX, length, flag);
@@ -734,9 +738,10 @@ zbx_uint64_t	DBget_maxid_num(const char *tablename, int num)
 }
 
 #define MAX_EXPRESSIONS	950
-#define MIN_NUM_BETWEEN	5	/* minimum number of consecutive values for using "between <id1> and <idN>" */
 
 #ifdef HAVE_ORACLE
+#define MIN_NUM_BETWEEN	5	/* minimum number of consecutive values for using "between <id1> and <idN>" */
+
 /******************************************************************************
  *                                                                            *
  * Function: DBadd_condition_alloc_btw                                        *
@@ -961,7 +966,9 @@ void	DBadd_condition_alloc(char **sql, size_t *sql_alloc, size_t *sql_offset, co
 		zbx_chrcpy_alloc(sql, sql_alloc, sql_offset, ')');
 
 #undef MAX_EXPRESSIONS
+#ifdef HAVE_ORACLE
 #undef MIN_NUM_BETWEEN
+#endif
 }
 
 /******************************************************************************
@@ -2154,7 +2161,7 @@ void	DBcheck_character_set(void)
 	DBconnect(ZBX_DB_CONNECT_NORMAL);
 
 	result = DBselect(
-			"select default_character_set_name, default_collation_name"
+			"select default_character_set_name,default_collation_name"
 			" from information_schema.SCHEMATA"
 			" where schema_name='%s'", database_name_esc);
 
@@ -2184,7 +2191,7 @@ void	DBcheck_character_set(void)
 			"select count(*)"
 			" from information_schema.`COLUMNS`"
 			" where table_schema='%s'"
-				" and data_type in ('text', 'varchar', 'longtext')"
+				" and data_type in ('text','varchar','longtext')"
 				" and (character_set_name<>'%s' or collation_name<>'%s')",
 			database_name_esc, ZBX_SUPPORTED_DB_CHARACTER_SET, ZBX_SUPPORTED_DB_COLLATION);
 
@@ -2209,9 +2216,9 @@ void	DBcheck_character_set(void)
 
 	DBconnect(ZBX_DB_CONNECT_NORMAL);
 	result = DBselect(
-			"select parameter, value"
+			"select parameter,value"
 			" from NLS_DATABASE_PARAMETERS"
-			" where parameter in ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET')");
+			" where parameter in ('NLS_CHARACTERSET','NLS_NCHAR_CHARACTERSET')");
 
 	if (NULL == result)
 	{
@@ -2247,9 +2254,7 @@ void	DBcheck_character_set(void)
 #elif defined(HAVE_POSTGRESQL)
 #define OID_LENGTH_MAX		20
 
-	char		*database_name_esc = NULL;
-	char		*schema_name_esc = NULL;
-	char		oid[OID_LENGTH_MAX] = "";
+	char		*database_name_esc, *schema_name_esc, oid[OID_LENGTH_MAX];
 	DB_RESULT	result;
 	DB_ROW		row;
 
@@ -2283,21 +2288,23 @@ void	DBcheck_character_set(void)
 			" where nspname='%s'",
 			schema_name_esc);
 
-	if (NULL == result || NULL == (row = DBfetch(result)) || 0 >= zbx_strlcpy(oid, row[0], sizeof(oid)))
+	if (NULL == result || NULL == (row = DBfetch(result)) || '\0' == **row)
 	{
 		zabbix_log(LOG_LEVEL_WARNING, "cannot get character set of database \"%s\" fields", CONFIG_DBNAME);
 		goto out;
 	}
 
+	strscpy(oid, *row);
+
 	DBfree_result(result);
 
 	result = DBselect(
 			"select count(*)"
-				" from pg_attribute as a"
-					" left join pg_class as c"
-						" on c.relfilenode=a.attrelid"
-					" left join pg_collation as l"
-						" on l.oid=a.attcollation"
+			" from pg_attribute as a"
+				" left join pg_class as c"
+					" on c.relfilenode=a.attrelid"
+				" left join pg_collation as l"
+					" on l.oid=a.attcollation"
 			" where atttypid in (25,1043)"
 				" and c.relnamespace=%s"
 				" and c.relam=0"
