From 5798453985c724455f9914230b9dd54db6638d5d Mon Sep 17 00:00:00 2001 From: kanoi Date: Wed, 17 Sep 2014 12:03:20 +1000 Subject: [PATCH] ckdb - also report postgresql version at startup --- src/ckdb.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index 7cbb21c5..2b5f4db1 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -49,7 +49,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.2" -#define CKDB_VERSION DB_VERSION"-0.310" +#define CKDB_VERSION DB_VERSION"-0.311" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -8356,13 +8356,14 @@ static bool check_db_version(PGconn *conn) PGresult *res; char *field; char *sel; - int fields = 2; + char *pgv; + int fields = 3; bool ok; int n; LOGDEBUG("%s(): select", __func__); - sel = "select * from version;"; + sel = "select version() as pgv,* from version;"; res = PQexec(conn, sel, CKPQ_READ); rescode = PQresultStatus(res); if (!PGOK(rescode)) { @@ -8417,10 +8418,19 @@ static bool check_db_version(PGconn *conn) return false; } + PQ_GET_FLD(res, 0, "pgv", field, ok); + if (ok) + pgv = strdup(field); + else + pgv = strdup("Failed to get postgresql version information"); + PQclear(res); LOGWARNING("%s(): DB version (%s) correct (CKDB V%s)", __func__, DB_VERSION, CKDB_VERSION); + LOGWARNING("%s(): %s", __func__, pgv); + + free(pgv); return true; }