int db_update_stats(JCR *jcr, B_DB *mdb, utime_t age);
-bool db_get_used_base_jobids(JCR *jcr, B_DB *mdb, POOLMEM *jobids, POOLMEM *result);
+bool db_get_used_base_jobids(JCR *jcr, B_DB *mdb, POOLMEM *jobids, db_list_ctx *result);
bool db_create_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
bool db_create_base_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
bool db_commit_base_file_attributes_record(JCR *jcr, B_DB *mdb);
* This procedure gets the base jobid list used by jobids,
* You can specify jobids == result to concat base jobids to current jobids
*/
-bool db_get_used_base_jobids(JCR *jcr, B_DB *mdb, POOLMEM *jobids, POOLMEM *result)
+bool db_get_used_base_jobids(JCR *jcr, B_DB *mdb, POOLMEM *jobids, db_list_ctx *result)
{
POOL_MEM buf;
Mmsg(buf,
" FROM Job JOIN BaseFiles USING (JobId) "
" WHERE Job.HasBase = 1 "
" AND JobId IN (%s) ", jobids);
- return db_sql_query(mdb, buf.c_str(), db_get_int_handler, result);
+ return db_sql_query(mdb, buf.c_str(), db_list_handler, result);
}
/* The decision do change an incr/diff was done before
/* Take all base jobs from job resource and find the
* last L_BASE jobid.
*/
-static bool get_base_jobids(JCR *jcr, POOLMEM *jobids)
+static bool get_base_jobids(JCR *jcr, db_list_ctx *jobids)
{
JOB_DBR jr;
JOB *job;
db_get_base_jobid(jcr, jcr->db, &jr, &id);
if (id) {
- if (jobids[0]) {
- pm_strcat(jobids, ",");
+ if (jobids->count) {
+ pm_strcat(jobids->list, ",");
}
- pm_strcat(jobids, edit_uint64(id, str_jobid));
+ pm_strcat(jobids->list, edit_uint64(id, str_jobid));
+ jobids->count++;
}
}
- return *jobids != '\0';
+ return jobids->count > 0;
}
/*
if (jcr->get_JobLevel() == L_FULL) {
/* On Full mode, if no previous base job, no accurate things */
- if (!get_base_jobids(jcr, jobids)) {
+ if (!get_base_jobids(jcr, &jobids)) {
goto bail_out;
}
jcr->HasBase = true;
- Jmsg(jcr, M_INFO, 0, _("Using BaseJobId(s): %s\n"), jobids);
+ Jmsg(jcr, M_INFO, 0, _("Using BaseJobId(s): %s\n"), jobids.list);
} else {
/* For Incr/Diff level, we search for older jobs */
- db_accurate_get_jobids(jcr, jcr->db, &jcr->jr, jobids);
+ db_accurate_get_jobids(jcr, jcr->db, &jcr->jr, &jobids);
/* We are in Incr/Diff, but no Full to build the accurate list... */
- if (*jobids == 0) {
+ if (jobids.count == 0) {
ret=false;
Jmsg(jcr, M_FATAL, 0, _("Cannot find previous jobids.\n"));
goto bail_out;
}
if (jcr->HasBase) {
- jcr->nb_base_files = str_to_int64(nb);
- db_create_base_file_list(jcr, jcr->db, jobids);
+ jcr->nb_base_files = str_to_int64(nb.list);
+ db_create_base_file_list(jcr, jcr->db, jobids.list);
db_get_base_file_list(jcr, jcr->db,
accurate_list_handler, (void *)jcr);
} else {
- db_get_file_list(jcr, jcr->db_batch, jobids,
+ db_get_file_list(jcr, jcr->db_batch, jobids.list,
accurate_list_handler, (void *)jcr);
}
*/
static void get_and_display_basejobs(UAContext *ua, RESTORE_CTX *rx)
{
- rx->BaseJobIds[0] = '\0';
+ db_list_ctx jobids;
- if (!db_get_used_base_jobids(ua->jcr, ua->db, rx->JobIds, rx->BaseJobIds)) {
+ if (!db_get_used_base_jobids(ua->jcr, ua->db, rx->JobIds, &jobids)) {
ua->warning_msg("%s", db_strerror(ua->db));
}
- if (*rx->BaseJobIds) {
+ if (jobids.count) {
POOL_MEM q;
- Mmsg(q, uar_print_jobs, rx->BaseJobIds);
+ Mmsg(q, uar_print_jobs, jobids.list);
ua->send_msg(_("The restore will use the following job(s) as Base\n"));
db_list_sql_query(ua->jcr, ua->db, q.c_str(), prtit, ua, 1, HORZ_LIST);
}
+ pm_strcpy(rx->BaseJobIds, jobids.list);
}
static void free_rx(RESTORE_CTX *rx)