* Bacula Catalog Database Update record interface routines
*
* Kern Sibbald, March 2000
+ *
+ * Version $Id$
*/
/*
*/
-/* *****FIXME**** fix fixed length of select_cmd[] and insert_cmd[] */
-
/* The following is necessary so that we do not include
* the dummy external definition of DB.
*/
extern void print_result(B_DB *mdb);
extern int UpdateDB(char *file, int line, B_DB *db, char *update_cmd);
-static int do_update(B_DB *mdb, char *cmd)
-{
- int stat;
-
- stat = UPDATE_DB(mdb, cmd);
- return stat;
-}
-
/* -----------------------------------------------------------------------
*
* Generic Routines (or almost generic)
{
int stat;
- P(mdb->mutex);
+ db_lock(mdb);
Mmsg(&mdb->cmd, "UPDATE File SET MD5=\"%s\" WHERE FileId=%d", MD5, FileId);
stat = UPDATE_DB(mdb, mdb->cmd);
- V(mdb->mutex);
+ db_unlock(mdb);
return stat;
}
{
int stat;
- P(mdb->mutex);
+ db_lock(mdb);
Mmsg(&mdb->cmd, "UPDATE File SET FileIndex=%d WHERE FileId=%d", JobId, FileId);
stat = UPDATE_DB(mdb, mdb->cmd);
- V(mdb->mutex);
+ db_unlock(mdb);
return stat;
}
strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
JobTDate = (btime_t)stime;
- P(mdb->mutex);
+ db_lock(mdb);
Mmsg(&mdb->cmd, "UPDATE Job SET Level='%c', StartTime=\"%s\", \
ClientId=%d, JobTDate=%s WHERE JobId=%d",
(char)(jr->Level), dt, jr->ClientId, edit_uint64(JobTDate, ed1), jr->JobId);
stat = UPDATE_DB(mdb, mdb->cmd);
- V(mdb->mutex);
+ db_unlock(mdb);
return stat;
}
strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
JobTDate = ttime;
- P(mdb->mutex);
+ db_lock(mdb);
Mmsg(&mdb->cmd,
"UPDATE Job SET JobStatus='%c', EndTime='%s', \
ClientId=%d, JobBytes=%s, JobFiles=%d, JobErrors=%d, VolSessionId=%d, \
jr->PoolId, jr->FileSetId, edit_uint64(JobTDate, ed2), jr->JobId);
stat = UPDATE_DB(mdb, mdb->cmd);
- V(mdb->mutex);
+ db_unlock(mdb);
return stat;
}
{
int stat;
- P(mdb->mutex);
+ db_lock(mdb);
Mmsg(&mdb->cmd,
"UPDATE Pool SET NumVols=%d, MaxVols=%d, UseOnce=%d, UseCatalog=%d, \
AcceptAnyVolume=%d, LabelFormat=\"%s\" WHERE PoolId=%d",
pr->AcceptAnyVolume, pr->LabelFormat, pr->PoolId);
stat = UPDATE_DB(mdb, mdb->cmd);
- V(mdb->mutex);
+ db_unlock(mdb);
return stat;
}
strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
Dmsg1(100, "update_media: FirstWritten=%d\n", mr->FirstWritten);
- P(mdb->mutex);
+ db_lock(mdb);
if (mr->VolMounts == 1) {
Mmsg(&mdb->cmd, "UPDATE Media SET FirstWritten=\"%s\"\
WHERE VolumeName=\"%s\"", dt, mr->VolumeName);
- if (do_update(mdb, mdb->cmd) == 0) {
- V(mdb->mutex);
- return 0;
- }
+ UPDATE_DB(mdb, mdb->cmd);
}
Mmsg(&mdb->cmd, "UPDATE Media SET VolJobs=%d,\
mr->VolStatus, mr->VolumeName);
stat = UPDATE_DB(mdb, mdb->cmd);
- V(mdb->mutex);
+ db_unlock(mdb);
return stat;
}