void print_dashes(B_DB *mdb);
void print_result(B_DB *mdb);
+/*
+ * Called here to retrieve an integer from the database
+ */
+static int int_handler(void *ctx, int num_fields, char **row)
+{
+ uint32_t *val = (uint32_t *)ctx;
+
+ if (row[0]) {
+ *val = atoi(row[0]);
+ } else {
+ *val = 0;
+ }
+ return 0;
+}
+
+
/* NOTE!!! The following routines expect that the
* calling subroutine sets and clears the mutex
/* Check that the tables conrrespond to the version we want */
int check_tables_version(B_DB *mdb)
{
-/*****FIXME***** implement */
+ uint32_t version;
+ char *query = "SELECT VersionId FROM Version";
+
+ version = 0;
+ db_sql_query(mdb, query, int_handler, (void *)&version);
+ if (version != BDB_VERSION) {
+ Mmsg(&mdb->errmsg, "Database version mismatch. Wanted %d, got %d\n",
+ BDB_VERSION, version);
+ return 0;
+ }
return 1;
}