mdb->connected = FALSE;
if ((errstat=rwl_init(&mdb->lock)) != 0) {
+ berrno be;
Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"),
- strerror(errstat));
+ be.bstrerror(errstat));
V(mutex);
return 0;
}
mdb->connected = true;
free(db_name);
+ /* set busy handler to wait when we use mult_db_connections = 1 */
+#ifdef HAVE_SQLITE3
+ sqlite3_busy_handler(mdb->db, my_busy_handler, NULL);
+#else
+ sqlite_busy_handler(mdb->db, my_busy_handler, NULL);
+#endif
+
#if defined(HAVE_SQLITE3) && defined(SQLITE3_INIT_QUERY)
db_sql_query(mdb, SQLITE3_INIT_QUERY, NULL, NULL);
#endif
return 0;
}
- /* set busy handler to wait when we use mult_db_connections = 1 */
-#ifdef HAVE_SQLITE3
- sqlite3_busy_handler(mdb->db, my_busy_handler, NULL);
-#else
- sqlite_busy_handler(mdb->db, my_busy_handler, NULL);
-#endif
V(mutex);
return 1;
* Submit a general SQL command (cmd), and for each row returned,
* the sqlite_handler is called with the ctx.
*/
-int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
+bool db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
{
struct rh_data rh_data;
int stat;
if (stat != 0) {
Mmsg(mdb->errmsg, _("Query failed: %s: ERR=%s\n"), query, sql_strerror(mdb));
db_unlock(mdb);
- return 0;
+ return false;
}
db_unlock(mdb);
- return 1;
+ return true;
}
/*
}
#ifdef HAVE_BATCH_FILE_INSERT
-char *my_sqlite_batch_lock_query = "BEGIN";
-char *my_sqlite_batch_unlock_query = "COMMIT";
-char *my_sqlite_batch_fill_path_query = "INSERT INTO Path (Path) "
- " SELECT DISTINCT Path FROM batch "
- " EXCEPT SELECT Path FROM Path ";
-
-char *my_sqlite_batch_fill_filename_query = "INSERT INTO Filename (Name) "
- " SELECT DISTINCT Name FROM batch "
- " EXCEPT SELECT Name FROM Filename ";
+const char *my_sqlite_batch_lock_query = "BEGIN";
+const char *my_sqlite_batch_unlock_query = "COMMIT";
+
+const char *my_sqlite_batch_fill_path_query =
+ "INSERT INTO Path (Path)"
+ " SELECT DISTINCT Path FROM batch"
+ " EXCEPT SELECT Path FROM Path";
+
+const char *my_sqlite_batch_fill_filename_query =
+ "INSERT INTO Filename (Name)"
+ " SELECT DISTINCT Name FROM batch "
+ " EXCEPT SELECT Name FROM Filename";
#endif /* HAVE_BATCH_FILE_INSERT */