From a6c5b481d3b7f50f92d8c3fe9e770d3fc21b6cfb Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 12 Feb 2004 20:34:13 +0000 Subject: [PATCH] Change IFNULL to COALESCE, which is more portable git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1049 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/cats/sql_find.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bacula/src/cats/sql_find.c b/bacula/src/cats/sql_find.c index c192b09110..1ff0a98c75 100644 --- a/bacula/src/cats/sql_find.c +++ b/bacula/src/cats/sql_find.c @@ -226,7 +226,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot," - "FirstWritten,IFNULL(LastWritten,0),VolStatus " + "FirstWritten,COALESCE(LastWritten,0),VolStatus " "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus IN ('Full'," "'Recycle','Purged','Used','Append') " "ORDER BY LastWritten LIMIT 1", mr->PoolId, mr->MediaType); @@ -298,7 +298,8 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr mr->Slot = str_to_int64(row[16]); bstrncpy(mr->cFirstWritten, row[17]!=NULL?row[17]:"", sizeof(mr->cFirstWritten)); mr->FirstWritten = (time_t)str_to_utime(mr->cFirstWritten); - bstrncpy(mr->cLastWritten, row[18]!=NULL?row[18]:"", sizeof(mr->cLastWritten)); + /* LastWritten cannot be NULL because of COALESCE() in SQL */ + bstrncpy(mr->cLastWritten, row[18], sizeof(mr->cLastWritten)); mr->LastWritten = (time_t)str_to_utime(mr->cLastWritten); bstrncpy(mr->VolStatus, row[19], sizeof(mr->VolStatus)); sql_free_result(mdb); -- 2.39.5