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.
*/
if (jr->JobId == 0) {
Mmsg(mdb->cmd, "SELECT VolSessionId,VolSessionTime,"
"PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus,"
-"Type,Level,ClientId "
+"Type,Level,ClientId,Name "
"FROM Job WHERE Job='%s'", jr->Job);
} else {
Mmsg(mdb->cmd, "SELECT VolSessionId,VolSessionTime,"
"PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus,"
-"Type,Level,ClientId "
+"Type,Level,ClientId,Name "
"FROM Job WHERE JobId=%s",
edit_int64(jr->JobId, ed1));
}
jr->JobType = (int)*row[10];
jr->JobLevel = (int)*row[11];
jr->ClientId = str_to_uint64(row[12]!=NULL?row[12]:(char *)"");
+ bstrncpy(jr->Name, row[13]!=NULL?row[13]:"", sizeof(jr->Name));
sql_free_result(mdb);
db_unlock(mdb);
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;
} 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]);
* the current Pool.
* The caller must free ids if non-NULL.
*
- * Returns 0: on failure
- * 1: on success
+ * Returns false: on failure
+ * true: on success
*/
-int db_get_media_ids(JCR *jcr, B_DB *mdb, uint32_t PoolId, int *num_ids, uint32_t *ids[])
+bool db_get_media_ids(JCR *jcr, B_DB *mdb, uint32_t PoolId, int *num_ids, uint32_t *ids[])
{
SQL_ROW row;
- int stat = 0;
int i = 0;
uint32_t *id;
char ed1[50];
+ bool ok = false;
db_lock(mdb);
*ids = NULL;
*ids = id;
}
sql_free_result(mdb);
- stat = 1;
+ ok = true;
} else {
Mmsg(mdb->errmsg, _("Media id select failed: ERR=%s\n"), sql_strerror(mdb));
Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
- stat = 0;
+ ok = false;
}
db_unlock(mdb);
- return stat;
+ return ok;
}
/* Get Media Record
*
- * Returns: 0 on failure
- * id on success
+ * Returns: false: on failure
+ * true: on success
*/
-int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
+bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
{
SQL_ROW row;
- int stat = 0;
char ed1[50];
+ bool ok = false;
db_lock(mdb);
if (mr->MediaId == 0 && mr->VolumeName[0] == 0) {
Mmsg(mdb->cmd, "SELECT count(*) from Media");
mr->MediaId = get_sql_record_max(jcr, mdb);
db_unlock(mdb);
- return 1;
+ return true;
}
if (mr->MediaId != 0) { /* find by id */
Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks,"
bstrncpy(mr->cLabelDate, row[27]!=NULL?row[27]:"", sizeof(mr->cLabelDate));
mr->LabelDate = (time_t)str_to_utime(mr->cLabelDate);
mr->StorageId = str_to_int64(row[28]);
- stat = mr->MediaId;
+ ok = true;
}
} else {
if (mr->MediaId != 0) {
mr->VolumeName);
} }
db_unlock(mdb);
- return stat;
+ return ok;
}