Else, we would unnecessarily skip one iteration even when being able to
reconnect right away.
if (PGRES_TUPLES_OK != PQresultStatus (res)) {
pthread_mutex_lock (&db->db_lock);
+ if ((CONNECTION_OK != PQstatus (db->conn))
+ && (0 == c_psql_check_connection (db))) {
+ PQclear (res);
+ return c_psql_exec_query (db, q, prep_area);
+ }
+
log_err ("Failed to execute SQL query: %s",
PQerrorMessage (db->conn));
log_info ("SQL query was: %s",