]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/sql_get.c
- Put Dmsg() on inside if() to avoid calling subroutine.
[bacula/bacula] / bacula / src / cats / sql_get.c
index 857927ac3463883474621fe843b84758970de1cb..acd1d886cfe726e0f1485d374cfe84bcabd83ec7 100644 (file)
    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 ammended 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.
 
  */
 
@@ -422,8 +417,8 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, JobId_t JobId, VOL_PARAMS
                Vols[i].EndFile = str_to_uint64(row[5]);
                Vols[i].StartBlock = str_to_uint64(row[6]);
                Vols[i].EndBlock = str_to_uint64(row[7]);
-               Vols[i].Copy = str_to_uint64(row[8]);
-               Vols[i].Stripe = str_to_uint64(row[9]);
+//             Vols[i].Copy = str_to_uint64(row[8]);
+//             Vols[i].Stripe = str_to_uint64(row[9]);
             }
          }
       }
@@ -587,16 +582,21 @@ bool db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pdbr)
             bstrncpy(pdbr->LabelFormat, row[16]!=NULL?row[16]:"", sizeof(pdbr->LabelFormat));
             ok = true;
          }
-      } else {
-         Mmsg(mdb->errmsg, _("Pool record not found in Catalog.\n"));
       }
       sql_free_result(mdb);
-   } else {
-      Mmsg(mdb->errmsg, _("Pool record not found in Catalog.\n"));
    }
    if (ok) {
-      Mmsg(mdb->cmd, "SELECT count(*) from Pool");
-      pdbr->NumVols = get_sql_record_max(jcr, mdb);
+      uint32_t NumVols;
+      Mmsg(mdb->cmd, "SELECT count(*) from Media WHERE PoolId=%s",
+         edit_int64(pdbr->PoolId, ed1));
+      NumVols = get_sql_record_max(jcr, mdb);
+      Dmsg2(400, "Actual NumVols=%d Pool NumVols=%d\n", NumVols, pdbr->NumVols);
+      if (NumVols != pdbr->NumVols) {
+         pdbr->NumVols = NumVols;
+         db_update_pool_record(jcr, mdb, pdbr);
+      }
+   } else {
+      Mmsg(mdb->errmsg, _("Pool record not found in Catalog.\n"));
    }
    db_unlock(mdb);
    return ok;
@@ -640,7 +640,7 @@ int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr)
          } else {
             cdbr->ClientId = str_to_int64(row[0]);
             bstrncpy(cdbr->Name, row[1]!=NULL?row[1]:"", sizeof(cdbr->Name));
-            bstrncpy(cdbr->Uname, row[2]!=NULL?row[1]:"", sizeof(cdbr->Uname));
+            bstrncpy(cdbr->Uname, row[2]!=NULL?row[2]:"", sizeof(cdbr->Uname));
             cdbr->AutoPrune = str_to_int64(row[3]);
             cdbr->FileRetention = str_to_int64(row[4]);
             cdbr->JobRetention = str_to_int64(row[5]);
@@ -729,7 +729,7 @@ int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
            edit_int64(fsr->FileSetId, ed1));
    } else {                           /* find by name */
       Mmsg(mdb->cmd,
-           "SELECT FileSetId,FileSet,CreateTime,MD5 FROM FileSet "
+           "SELECT FileSetId,FileSet,MD5,CreateTime FROM FileSet "
            "WHERE FileSet='%s' ORDER BY CreateTime DESC LIMIT 1", fsr->FileSet);
    }