dbi plugin: Removed excessive error reporting
authorPavel Rochnyack <pavel2000@ngs.ru>
Sat, 11 Aug 2018 19:47:15 +0000 (02:47 +0700)
committerPavel Rochnyack <pavel2000@ngs.ru>
Sat, 11 Aug 2018 19:47:15 +0000 (02:47 +0700)
Latest libdbi code sets BADIDX error when no more rows is
in 'dbi_result_next_row()' (similar to 'dbi_result_prev_row()'
and to match library documentation).

There is confusing errors in Collectd logs due to this change.
Added a 'dbi_result_has_next_row()' check to solve.

Closes: #2894

src/dbi.c

index fe9bc51..899c802 100644 (file)
--- a/src/dbi.c
+++ b/src/dbi.c
@@ -603,15 +603,16 @@ static int cdbi_read_database_query(cdbi_database_t *db, /* {{{ */
     } /* }}} */
 
     /* Get the next row from the database. */
+    if (!dbi_result_has_next_row(res))
+      break;
+
     status = dbi_result_next_row(res); /* {{{ */
     if (status != 1) {
-      if (dbi_conn_error(db->connection, NULL) != 0) {
-        char errbuf[1024];
-        WARNING("dbi plugin: cdbi_read_database_query (%s, %s): "
-                "dbi_result_next_row failed: %s.",
-                db->name, udb_query_get_name(q),
-                cdbi_strerror(db->connection, errbuf, sizeof(errbuf)));
-      }
+      char errbuf[1024];
+      WARNING("dbi plugin: cdbi_read_database_query (%s, %s): "
+              "dbi_result_next_row failed: %s.",
+              db->name, udb_query_get_name(q),
+              cdbi_strerror(db->connection, errbuf, sizeof(errbuf)));
       break;
     } /* }}} */
   }   /* }}} while (42) */