]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/sql_create.c
This commit was manufactured by cvs2svn to create tag
[bacula/bacula] / bacula / src / cats / sql_create.c
index bef5a43b433c0283762269626983dd2f268dc176..fb46704122f6135f0d67e384cd026149d537130d 100644 (file)
@@ -5,24 +5,18 @@
  *
  *    Version $Id$
  */
-
 /*
    Copyright (C) 2000-2005 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    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 General Public
-   License along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -94,7 +88,7 @@ db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
       jr->JobId = 0;
       stat = 0;
    } else {
-      jr->JobId = sql_insert_id(mdb, _("Job"));
+      jr->JobId = sql_insert_id(mdb, N_("Job"));
       stat = 1;
    }
    db_unlock(mdb);
@@ -115,7 +109,8 @@ db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jm)
    db_lock(mdb);
 
    /* Now get count for VolIndex */
-   Mmsg(mdb->cmd, "SELECT count(*) from JobMedia");
+   Mmsg(mdb->cmd, "SELECT count(*) from JobMedia WHERE JobId=%s",
+        edit_int64(jm->JobId, ed1));
    count = get_sql_record_max(jcr, mdb);
    if (count < 0) {
       count = 0;
@@ -204,7 +199,7 @@ db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
       pr->PoolId = 0;
       stat = false;
    } else {
-      pr->PoolId = sql_insert_id(mdb, _("Pool"));
+      pr->PoolId = sql_insert_id(mdb, N_("Pool"));
       stat = true;
    }
    db_unlock(mdb);
@@ -251,7 +246,7 @@ db_create_device_record(JCR *jcr, B_DB *mdb, DEVICE_DBR *dr)
       dr->DeviceId = 0;
       ok = false;
    } else {
-      dr->DeviceId = sql_insert_id(mdb, _("Device"));
+      dr->DeviceId = sql_insert_id(mdb, N_("Device"));
       ok = true;
    }
    db_unlock(mdb);
@@ -309,7 +304,7 @@ bool db_create_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr)
       Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
       ok = false;
    } else {
-      sr->StorageId = sql_insert_id(mdb, _("Storage"));
+      sr->StorageId = sql_insert_id(mdb, N_("Storage"));
       sr->created = true;
       ok = true;
    }
@@ -357,7 +352,7 @@ db_create_mediatype_record(JCR *jcr, B_DB *mdb, MEDIATYPE_DBR *mr)
       mr->MediaTypeId = 0;
       stat = false;
    } else {
-      mr->MediaTypeId = sql_insert_id(mdb, _("MediaType"));
+      mr->MediaTypeId = sql_insert_id(mdb, N_("MediaType"));
       stat = true;
    }
    db_unlock(mdb);
@@ -381,7 +376,7 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    db_lock(mdb);
    Mmsg(mdb->cmd, "SELECT MediaId FROM Media WHERE VolumeName='%s'",
            mr->VolumeName);
-   Dmsg1(300, "selectpool: %s\n", mdb->cmd);
+   Dmsg1(500, "selectpool: %s\n", mdb->cmd);
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       mdb->num_rows = sql_num_rows(mdb);
@@ -401,25 +396,25 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 "VolStatus,Slot,VolBytes,InChanger,VolReadTime,VolWriteTime,VolParts,"
 "EndFile,EndBlock,LabelType,StorageId) "
 "VALUES ('%s','%s',%u,%s,%s,%d,%s,%s,%u,%u,'%s',%d,%s,%d,%s,%s,%d,0,0,%d,%s)",
-                  mr->VolumeName,
-                  mr->MediaType, mr->PoolId,
-                  edit_uint64(mr->MaxVolBytes,ed1),
-                  edit_uint64(mr->VolCapacityBytes, ed2),
-                  mr->Recycle,
-                  edit_uint64(mr->VolRetention, ed3),
-                  edit_uint64(mr->VolUseDuration, ed4),
-                  mr->MaxVolJobs,
-                  mr->MaxVolFiles,
-                  mr->VolStatus,
-                  mr->Slot,
-                  edit_uint64(mr->VolBytes, ed5),
-                  mr->InChanger,
-                  edit_uint64(mr->VolReadTime, ed6),
-                  edit_uint64(mr->VolWriteTime, ed7),
-                  mr->VolParts,
-                  mr->LabelType,
-                  edit_int64(mr->StorageId, ed8) 
-                  );
+          mr->VolumeName,
+          mr->MediaType, mr->PoolId,
+          edit_uint64(mr->MaxVolBytes,ed1),
+          edit_uint64(mr->VolCapacityBytes, ed2),
+          mr->Recycle,
+          edit_uint64(mr->VolRetention, ed3),
+          edit_uint64(mr->VolUseDuration, ed4),
+          mr->MaxVolJobs,
+          mr->MaxVolFiles,
+          mr->VolStatus,
+          mr->Slot,
+          edit_uint64(mr->VolBytes, ed5),
+          mr->InChanger,
+          edit_uint64(mr->VolReadTime, ed6),
+          edit_uint64(mr->VolWriteTime, ed7),
+          mr->VolParts,
+          mr->LabelType,
+          edit_int64(mr->StorageId, ed8) 
+          );
 
 
    Dmsg1(500, "Create Volume: %s\n", mdb->cmd);
@@ -428,7 +423,7 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
             mdb->cmd, sql_strerror(mdb));
       stat = 0;
    } else {
-      mr->MediaId = sql_insert_id(mdb, _("Media"));
+      mr->MediaId = sql_insert_id(mdb, N_("Media"));
       stat = 1;
       if (mr->set_label_date) {
          char dt[MAX_TIME_LENGTH];
@@ -510,7 +505,7 @@ int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
       cr->ClientId = 0;
       stat = 0;
    } else {
-      cr->ClientId = sql_insert_id(mdb, _("Client"));
+      cr->ClientId = sql_insert_id(mdb, N_("Client"));
       stat = 1;
    }
    db_unlock(mdb);
@@ -621,7 +616,7 @@ bool db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
       fsr->FileSetId = 0;
       stat = false;
    } else {
-      fsr->FileSetId = sql_insert_id(mdb, _("FileSet"));
+      fsr->FileSetId = sql_insert_id(mdb, N_("FileSet"));
       fsr->created = true;
       stat = true;
    }
@@ -672,7 +667,8 @@ int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
     */
    if (!(ar->Stream == STREAM_UNIX_ATTRIBUTES ||
          ar->Stream == STREAM_UNIX_ATTRIBUTES_EX)) {
-      Mmsg0(&mdb->errmsg, _("Attempt to put non-attributes into catalog\n"));
+      Mmsg1(&mdb->errmsg, _("Attempt to put non-attributes into catalog. Stream=%d\n"),
+         ar->Stream);
       Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
       goto bail_out;
    }
@@ -740,7 +736,7 @@ static int db_create_file_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
       ar->FileId = 0;
       stat = 0;
    } else {
-      ar->FileId = sql_insert_id(mdb, _("File"));
+      ar->FileId = sql_insert_id(mdb, N_("File"));
       stat = 1;
    }
    return stat;
@@ -804,7 +800,7 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
       ar->PathId = 0;
       stat = 0;
    } else {
-      ar->PathId = sql_insert_id(mdb, _("Path"));
+      ar->PathId = sql_insert_id(mdb, N_("Path"));
       stat = 1;
    }
 
@@ -858,7 +854,7 @@ static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
       Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg);
       ar->FilenameId = 0;
    } else {
-      ar->FilenameId = sql_insert_id(mdb, _("Filename"));
+      ar->FilenameId = sql_insert_id(mdb, N_("Filename"));
    }
    return ar->FilenameId > 0;
 }