diff --git a/src/postgresql.c b/src/postgresql.c
index e7b247e77e8fa983d131012d1149c869c24e5ff9..1eaf6bd3877570a56c0e50c045b7e90cc888cda2 100644 (file)
--- a/src/postgresql.c
+++ b/src/postgresql.c
c_psql_connect (db);
}
- /* "ping" */
- PQclear (PQexec (db->conn, "SELECT 42;"));
-
if (CONNECTION_OK != PQstatus (db->conn)) {
PQreset (db->conn);
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",
size_t i;
if ((ud != NULL) && (ud->data != NULL)) {
- dbs = (c_psql_database_t **)&ud->data;
+ dbs = (void *)&ud->data;
dbs_num = 1;
}