From: Kern Sibbald Date: Mon, 22 Dec 2008 15:12:10 +0000 (+0000) Subject: kes Modify sql_update.c to edit zeros rather than NULL in unset X-Git-Tag: Release-2.4.4~15 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=08fed791b01e806b9fdabaf308bdd71133eccf1d;p=bacula%2Fbacula 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. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.4@8228 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index ad1116645d..60d4f53c13 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -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)); diff --git a/bacula/technotes-2.4 b/bacula/technotes-2.4 index aec87958c1..95fc9cdcf8 100644 --- a/bacula/technotes-2.4 +++ b/bacula/technotes-2.4 @@ -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