postgresql: Set correct value to 'interval' query parameter (bugfix)
authorPavel Rochnyack <pavel2000@ngs.ru>
Wed, 4 Jul 2018 04:33:04 +0000 (11:33 +0700)
committerPavel Rochnyack <pavel2000@ngs.ru>
Wed, 4 Jul 2018 04:33:04 +0000 (11:33 +0700)
src/postgresql.c

index 7c140e0..f1c7d7e 100644 (file)
@@ -430,9 +430,9 @@ static PGresult *c_psql_exec_query_params(c_psql_database_t *db, udb_query_t *q,
       params[i] = db->user;
       break;
     case C_PSQL_PARAM_INTERVAL:
-      snprintf(interval, sizeof(interval), "%.3f",
-               (db->interval > 0) ? CDTIME_T_TO_DOUBLE(db->interval)
-                                  : plugin_get_interval());
+      ;
+      cdtime_t tmp = (db->interval > 0) ? db->interval : plugin_get_interval();
+      snprintf(interval, sizeof(interval), "%.3f", CDTIME_T_TO_DOUBLE(tmp));
       params[i] = interval;
       break;
     case C_PSQL_PARAM_INSTANCE: