]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/sql_delete.c
Remove old code from bdb.c
[bacula/bacula] / bacula / src / cats / sql_delete.c
index d8c7fdfbd7a81adab323e7f7f1ae947d35f7eafd..c3c51c7bc66019692991c9c98e1f11c37b2858e2 100644 (file)
@@ -2,6 +2,8 @@
  * Bacula Catalog Database Delete record interface routines
  * 
  *    Kern Sibbald, December 2000
+ *
+ *    Version $Id$
  */
 
 /*
@@ -63,7 +65,7 @@ db_delete_pool_record(B_DB *mdb, POOL_DBR *pr)
 {
    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);
 
@@ -76,17 +78,18 @@ db_delete_pool_record(B_DB *mdb, POOL_DBR *pr)
       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);
@@ -105,14 +108,14 @@ db_delete_pool_record(B_DB *mdb, POOL_DBR *pr)
    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 */
@@ -135,10 +138,10 @@ static int delete_handler(void *ctx, int num_fields, char **row)
    }
    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;
 }
 
@@ -165,7 +168,7 @@ static int do_media_purge(B_DB *mdb, MEDIA_DBR *mr)
    } 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++) {