]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Modify sql_update.c to edit zeros rather than NULL in unset
authorKern Sibbald <kern@sibbald.com>
Mon, 22 Dec 2008 15:12:10 +0000 (15:12 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 22 Dec 2008 15:12:10 +0000 (15:12 +0000)
     fields. This should fix bug #1206, where apparently the user
     has modified the Bacula schema.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.4@8228 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/cats/sql_update.c
bacula/technotes-2.4

index ad1116645d26df6a9240a6f29d174d6373a5a037..60d4f53c134bdfc6f9718ffdadab50b728d19ed0 100644 (file)
@@ -125,16 +125,6 @@ db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    return stat;
 }
 
-/*
- * Given an incoming integer, set the string buffer to either NULL or the value
- *
- */
-static void edit_num_or_null(char *s, size_t n, uint64_t id) {
-   char ed1[50];
-   bsnprintf(s, n, id ? "%s" : "NULL", edit_int64(id, ed1));
-}
-
-
 /*
  * Update the Job record at end of Job
  *
@@ -151,13 +141,7 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    int stat;
    char ed1[30], ed2[30], ed3[50];
    btime_t JobTDate;
-   char PoolId[50], FileSetId[50], ClientId[50], PriorJobId[50];
-
-
-   /* some values are set to zero, which translates to NULL in SQL */
-   edit_num_or_null(PoolId,    sizeof(PoolId),    jr->PoolId);
-   edit_num_or_null(FileSetId, sizeof(FileSetId), jr->FileSetId);
-   edit_num_or_null(ClientId,  sizeof(ClientId),  jr->ClientId);
+   char PriorJobId[50];
 
    if (jr->PriorJobId) {
       bstrncpy(PriorJobId, edit_int64(jr->PriorJobId, ed1), sizeof(PriorJobId));
@@ -181,12 +165,12 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    db_lock(mdb);
    Mmsg(mdb->cmd,
       "UPDATE Job SET JobStatus='%c',EndTime='%s',"
-"ClientId=%s,JobBytes=%s,JobFiles=%u,JobErrors=%u,VolSessionId=%u,"
-"VolSessionTime=%u,PoolId=%s,FileSetId=%s,JobTDate=%s,"
+"ClientId=%u,JobBytes=%s,JobFiles=%u,JobErrors=%u,VolSessionId=%u,"
+"VolSessionTime=%u,PoolId=%u,FileSetId=%u,JobTDate=%s,"
 "RealEndTime='%s',PriorJobId=%s WHERE JobId=%s",
-      (char)(jr->JobStatus), dt, ClientId, edit_uint64(jr->JobBytes, ed1),
+      (char)(jr->JobStatus), dt, jr->ClientId, edit_uint64(jr->JobBytes, ed1),
       jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime,
-      PoolId, FileSetId, edit_uint64(JobTDate, ed2), 
+      jr->PoolId, jr->FileSetId, edit_uint64(JobTDate, ed2), 
       rdt,
       PriorJobId,
       edit_int64(jr->JobId, ed3));
index aec87958c1e3a4ec6f7143221d325d3992e316f5..95fc9cdcf85545152bc7e2dae1346ba27f0ae17e 100644 (file)
@@ -1,6 +1,10 @@
               Technical notes on version 2.4
 
 General:
+22Dec08
+kes  Modify sql_update.c to edit zeros rather than NULL in unset
+     fields. This should fix bug #1206, where apparently the user
+     has modified the Bacula schema.
 20Dec08
 kes  Backport most recent changes to compat.h and compat.cpp.
 13Dec08