/*
* Called here to retrieve an integer from the database
*/
-static int int_handler(void *ctx, int num_fields, char **row)
+int db_int_handler(void *ctx, int num_fields, char **row)
{
uint32_t *val = (uint32_t *)ctx;
return 0;
}
-
+/*
+ * Use to build a comma separated list of values from a query. "10,20,30"
+ */
+int db_list_handler(void *ctx, int num_fields, char **row)
+{
+ db_list_ctx *lctx = (db_list_ctx *)ctx;
+ if (num_fields == 1 && row[0]) {
+ if (lctx->list[0]) {
+ pm_strcat(lctx->list, ",");
+ }
+ pm_strcat(lctx->list, row[0]);
+ lctx->count++;
+ }
+ return 0;
+}
/* NOTE!!! The following routines expect that the
* calling subroutine sets and clears the mutex
const char *query = "SELECT VersionId FROM Version";
bacula_db_version = 0;
- if (!db_sql_query(mdb, query, int_handler, (void *)&bacula_db_version)) {
+ if (!db_sql_query(mdb, query, db_int_handler, (void *)&bacula_db_version)) {
Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg);
return false;
}