Browse Source

ckdb - also report postgresql version at startup

master
kanoi 10 years ago
parent
commit
5798453985
  1. 16
      src/ckdb.c

16
src/ckdb.c

@ -49,7 +49,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "0.9.2" #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 " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -8356,13 +8356,14 @@ static bool check_db_version(PGconn *conn)
PGresult *res; PGresult *res;
char *field; char *field;
char *sel; char *sel;
int fields = 2; char *pgv;
int fields = 3;
bool ok; bool ok;
int n; int n;
LOGDEBUG("%s(): select", __func__); LOGDEBUG("%s(): select", __func__);
sel = "select * from version;"; sel = "select version() as pgv,* from version;";
res = PQexec(conn, sel, CKPQ_READ); res = PQexec(conn, sel, CKPQ_READ);
rescode = PQresultStatus(res); rescode = PQresultStatus(res);
if (!PGOK(rescode)) { if (!PGOK(rescode)) {
@ -8417,10 +8418,19 @@ static bool check_db_version(PGconn *conn)
return false; 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); PQclear(res);
LOGWARNING("%s(): DB version (%s) correct (CKDB V%s)", LOGWARNING("%s(): DB version (%s) correct (CKDB V%s)",
__func__, DB_VERSION, CKDB_VERSION); __func__, DB_VERSION, CKDB_VERSION);
LOGWARNING("%s(): %s", __func__, pgv);
free(pgv);
return true; return true;
} }

Loading…
Cancel
Save