-
Problem report
-
Resolution: Unresolved
-
Trivial
-
None
-
2.0.21, 2.2.18, 3.2.6, 3.4.0alpha1
-
Sprint 15, Sprint 16, Sprint 17, Sprint 18, Sprint 19, Sprint 20
-
26
1. DBselect() blocks if database is down, but may return NULL in case of other errors.
In many functions there are correct checks like "if (NULL == (result = DBselect(....)", that is good.
In some functions DBselect() result is passed directly to DBfetch() in a code like this:
"if (NULL == (row = DBfetch(result))" or "while (NULL != (row = DBfetch(result)))".
In these cases a database error is masked as "no (more) records found", which may cause errors in program logic. This was the root cause of ZBX-12046. Another example is get_value_internal(), which will return 0 as a value instead of NOTSUPPORTED in case of DB error.
2. sasha pointed out a similar problem with DBfetch().
In case of Oracle DB the DBfetch() retrieves data in chunks from server. If a database error occurs, DBfetch() returns NULL, interpreted as "no (more) records found", which may not always be true.