* Bacula Catalog Database Delete record interface routines
*
* Kern Sibbald, December 2000
+ *
+ * Version $Id$
*/
/*
{
SQL_ROW row;
- P(mdb->mutex);
+ db_lock(mdb);
Mmsg(&mdb->cmd, "SELECT PoolId FROM Pool WHERE Name=\"%s\"", pr->Name);
Dmsg1(10, "selectpool: %s\n", mdb->cmd);
if (mdb->num_rows == 0) {
Mmsg(&mdb->errmsg, _("No pool record %s exists\n"), pr->Name);
sql_free_result(mdb);
- V(mdb->mutex);
+ db_unlock(mdb);
return 0;
} else if (mdb->num_rows != 1) {
Mmsg(&mdb->errmsg, _("Expecting one pool record, got %d\n"), mdb->num_rows);
sql_free_result(mdb);
- V(mdb->mutex);
+ db_unlock(mdb);
return 0;
}
if ((row = sql_fetch_row(mdb)) == NULL) {
- V(mdb->mutex);
- Emsg1(M_ABORT, 0, _("Error fetching row %s\n"), sql_strerror(mdb));
+ Mmsg1(&mdb->errmsg, _("Error fetching row %s\n"), sql_strerror(mdb));
+ db_unlock(mdb);
+ return 0;
}
pr->PoolId = atoi(row[0]);
sql_free_result(mdb);
pr->PoolId = DELETE_DB(mdb, mdb->cmd);
Dmsg1(200, "Deleted %d Pool records\n", pr->PoolId);
- V(mdb->mutex);
+ db_unlock(mdb);
return 1;
}
#define MAX_DEL_LIST_LEN 1000000
struct s_del_ctx {
- uint32_t *JobId;
+ JobId_t *JobId;
int num_ids; /* ids stored */
int max_ids; /* size of array */
int num_del; /* number deleted */
}
if (del->num_ids == del->max_ids) {
del->max_ids = (del->max_ids * 3) / 2;
- del->JobId = (uint32_t *)brealloc(del->JobId, sizeof(uint32_t) *
+ del->JobId = (JobId_t *)brealloc(del->JobId, sizeof(JobId_t) *
del->max_ids);
}
- del->JobId[del->num_ids++] = (uint32_t)strtod(row[0], NULL);
+ del->JobId[del->num_ids++] = (JobId_t)strtod(row[0], NULL);
return 0;
}
} else if (del.max_ids > MAX_DEL_LIST_LEN) {
del.max_ids = MAX_DEL_LIST_LEN;
}
- del.JobId = (uint32_t *)malloc(sizeof(uint32_t) * del.max_ids);
+ del.JobId = (JobId_t *)malloc(sizeof(JobId_t) * del.max_ids);
db_sql_query(mdb, mdb->cmd, delete_handler, (void *)&del);
for (i=0; i < del.num_ids; i++) {