]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/sql_update.c
Backport from BEE
[bacula/bacula] / bacula / src / cats / sql_update.c
index 2b5025bb62863822564c09a44f4c5b2fa7f08b0a..302d5e2337efa193cdcd77afd8a9c5b38b1ddbac 100644 (file)
@@ -1,40 +1,28 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
-   The main author of Bacula is Kern Sibbald, with contributions from
-   many others, a complete list can be found in the file AUTHORS.
-   This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version three of the GNU Affero General Public
-   License as published by the Free Software Foundation and included
-   in the file LICENSE.
+   The main author of Bacula is Kern Sibbald, with contributions from many
+   others, a complete list can be found in the file AUTHORS.
 
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU Affero General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
+   You may use this file and others of this release according to the
+   license defined in the LICENSE file, which includes the Affero General
+   Public License, v3.0 ("AGPLv3") and some additional permissions and
+   terms pursuant to its AGPLv3 Section 7.
 
    Bacula® is a registered trademark of Kern Sibbald.
-   The licensor of Bacula is the Free Software Foundation Europe
-   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
-   Switzerland, email:ftf@fsfeurope.org.
 */
 /*
  * Bacula Catalog Database Update record interface routines
  *
- *    Kern Sibbald, March 2000
+ *    Written by Kern Sibbald, March 2000
  *
  */
 
 #include "bacula.h"
 
-#if HAVE_SQLITE3 || HAVE_MYSQL || HAVE_POSTGRESQL || HAVE_INGRES || HAVE_DBI
+#if HAVE_SQLITE3 || HAVE_MYSQL || HAVE_POSTGRESQL
 
 #include "cats.h"
 #include "bdb_priv.h"
@@ -64,8 +52,8 @@ db_add_digest_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *digest,
 
    db_lock(mdb);
    mdb->esc_name = check_pool_memory_size(mdb->esc_name, len*2+1);
-   mdb->db_escape_string(jcr, mdb->esc_name, digest, len); 
-   Mmsg(mdb->cmd, "UPDATE File SET MD5='%s' WHERE FileId=%s", mdb->esc_name, 
+   mdb->db_escape_string(jcr, mdb->esc_name, digest, len);
+   Mmsg(mdb->cmd, "UPDATE File SET MD5='%s' WHERE FileId=%s", mdb->esc_name,
         edit_int64(FileId, ed1));
    ret = UPDATE_DB(jcr, mdb, mdb->cmd);
    db_unlock(mdb);
@@ -81,7 +69,7 @@ int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId)
    char ed1[50], ed2[50];
 
    db_lock(mdb);
-   Mmsg(mdb->cmd, "UPDATE File SET MarkId=%s WHERE FileId=%s", 
+   Mmsg(mdb->cmd, "UPDATE File SET MarkId=%s WHERE FileId=%s",
       edit_int64(JobId, ed1), edit_int64(FileId, ed2));
    stat = UPDATE_DB(jcr, mdb, mdb->cmd);
    db_unlock(mdb);
@@ -113,9 +101,9 @@ db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    Mmsg(mdb->cmd, "UPDATE Job SET JobStatus='%c',Level='%c',StartTime='%s',"
 "ClientId=%s,JobTDate=%s,PoolId=%s,FileSetId=%s WHERE JobId=%s",
       (char)(jcr->JobStatus),
-      (char)(jr->JobLevel), dt, 
+      (char)(jr->JobLevel), dt,
       edit_int64(jr->ClientId, ed1),
-      edit_uint64(JobTDate, ed2), 
+      edit_uint64(JobTDate, ed2),
       edit_int64(jr->PoolId, ed3),
       edit_int64(jr->FileSetId, ed4),
       edit_int64(jr->JobId, ed5));
@@ -195,7 +183,7 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
       (char)(jr->JobStatus), dt, jr->ClientId, edit_uint64(jr->JobBytes, ed1),
       edit_uint64(jr->ReadBytes, ed4),
       jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime,
-      jr->PoolId, jr->FileSetId, edit_uint64(JobTDate, ed2), 
+      jr->PoolId, jr->FileSetId, edit_uint64(JobTDate, ed2),
       rdt, PriorJobId, jr->HasBase, jr->PurgedFiles,
       edit_int64(jr->JobId, ed3));
 
@@ -304,7 +292,7 @@ db_update_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr)
    int stat;
    char ed1[50];
    db_lock(mdb);
-   Mmsg(mdb->cmd, "UPDATE Storage SET AutoChanger=%d WHERE StorageId=%s", 
+   Mmsg(mdb->cmd, "UPDATE Storage SET AutoChanger=%d WHERE StorageId=%s",
       sr->AutoChanger, edit_int64(sr->StorageId, ed1));
 
    stat = UPDATE_DB(jcr, mdb, mdb->cmd);
@@ -326,9 +314,10 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    time_t ttime;
    struct tm tm;
    int stat;
-   char ed1[50], ed2[50],  ed3[50],  ed4[50]; 
+   char ed1[50], ed4[50];
    char ed5[50], ed6[50],  ed7[50],  ed8[50];
-   char ed9[50], ed10[50], ed11[50];
+   char ed9[50], ed10[50], ed11[50], ed12[50];
+   char ed13[50];
    char esc_name[MAX_ESCAPE_NAME_LENGTH];
    char esc_status[MAX_ESCAPE_NAME_LENGTH];
 
@@ -379,29 +368,31 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    }
 
    Mmsg(mdb->cmd, "UPDATE Media SET VolJobs=%u,"
-        "VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u,"
+        "VolFiles=%u,VolBlocks=%u,VolBytes=%s,"
+        "VolMounts=%u,VolErrors=%u,"
         "VolWrites=%u,MaxVolBytes=%s,VolStatus='%s',"
         "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s,VolParts=%d,"
         "LabelType=%d,StorageId=%s,PoolId=%s,VolRetention=%s,VolUseDuration=%s,"
         "MaxVolJobs=%d,MaxVolFiles=%d,Enabled=%d,LocationId=%s,"
         "ScratchPoolId=%s,RecyclePoolId=%s,RecycleCount=%d,Recycle=%d,ActionOnPurge=%d"
         " WHERE VolumeName='%s'",
-        mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1),
+        mr->VolJobs, mr->VolFiles, mr->VolBlocks,
+        edit_uint64(mr->VolBytes, ed1),
         mr->VolMounts, mr->VolErrors, mr->VolWrites,
-        edit_uint64(mr->MaxVolBytes, ed2),
+        edit_uint64(mr->MaxVolBytes, ed4),
         esc_status, mr->Slot, mr->InChanger,
-        edit_int64(mr->VolReadTime, ed3),
-        edit_int64(mr->VolWriteTime, ed4),
+        edit_int64(mr->VolReadTime, ed5),
+        edit_int64(mr->VolWriteTime, ed6),
         mr->VolParts,
         mr->LabelType,
-        edit_int64(mr->StorageId, ed5),
-        edit_int64(mr->PoolId, ed6),
-        edit_uint64(mr->VolRetention, ed7),
-        edit_uint64(mr->VolUseDuration, ed8),
+        edit_int64(mr->StorageId, ed7),
+        edit_int64(mr->PoolId, ed8),
+        edit_uint64(mr->VolRetention, ed9),
+        edit_uint64(mr->VolUseDuration, ed10),
         mr->MaxVolJobs, mr->MaxVolFiles,
-        mr->Enabled, edit_uint64(mr->LocationId, ed9),
-        edit_uint64(mr->ScratchPoolId, ed10),
-        edit_uint64(mr->RecyclePoolId, ed11),
+        mr->Enabled, edit_uint64(mr->LocationId, ed11),
+        edit_uint64(mr->ScratchPoolId, ed12),
+        edit_uint64(mr->RecyclePoolId, ed13),
         mr->RecycleCount,mr->Recycle, mr->ActionOnPurge,
         esc_name);
 
@@ -480,25 +471,25 @@ db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
        if (mr->MediaId != 0) {
           Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0, Slot=0 WHERE "
                "Slot=%d AND StorageId=%s AND MediaId!=%s",
-               mr->Slot, 
+               mr->Slot,
                edit_int64(mr->StorageId, ed1), edit_int64(mr->MediaId, ed2));
 
        } else if (*mr->VolumeName) {
           mdb->db_escape_string(jcr, esc,mr->VolumeName,strlen(mr->VolumeName));
           Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0, Slot=0 WHERE "
                "Slot=%d AND StorageId=%s AND VolumeName!='%s'",
-               mr->Slot, 
+               mr->Slot,
                edit_int64(mr->StorageId, ed1), esc);
 
        } else {  /* used by ua_label to reset all volume with this slot */
           Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0, Slot=0 WHERE "
                "Slot=%d AND StorageId=%s",
-               mr->Slot, 
-               edit_int64(mr->StorageId, ed1), mr->VolumeName);          
+               mr->Slot,
+               edit_int64(mr->StorageId, ed1), mr->VolumeName);
        }
        Dmsg1(100, "%s\n", mdb->cmd);
        UPDATE_DB(jcr, mdb, mdb->cmd);
    }
 }
 
-#endif /* HAVE_SQLITE3 || HAVE_MYSQL || HAVE_POSTGRESQL || HAVE_INGRES || HAVE_DBI */
+#endif /* HAVE_SQLITE3 || HAVE_MYSQL || HAVE_POSTGRESQL */