/* sql_get.c */
bool db_get_volume_jobids(JCR *jcr, B_DB *mdb,
MEDIA_DBR *mr, db_list_ctx *lst);
-bool db_get_base_file_list(JCR *jcr, B_DB *mdb,
+bool db_get_base_file_list(JCR *jcr, B_DB *mdb, bool use_md5,
DB_RESULT_HANDLER *result_handler,void *ctx);
int db_get_path_record(JCR *jcr, B_DB *mdb);
bool db_get_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pdbr);
int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr);
int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr);
bool db_get_query_dbids(JCR *jcr, B_DB *mdb, POOL_MEM &query, dbid_list &ids);
-bool db_get_file_list(JCR *jcr, B_DB *mdb, char *jobids, DB_RESULT_HANDLER *result_handler, void *ctx);
+bool db_get_file_list(JCR *jcr, B_DB *mdb, char *jobids, bool use_md5, DB_RESULT_HANDLER *result_handler, void *ctx);
bool db_get_base_jobid(JCR *jcr, B_DB *mdb, JOB_DBR *jr, JobId_t *jobid);
bool db_accurate_get_jobids(JCR *jcr, B_DB *mdb, JOB_DBR *jr, db_list_ctx *jobids);
bool db_get_used_base_jobids(JCR *jcr, B_DB *mdb, POOLMEM *jobids, db_list_ctx *result);
return ok;
}
+/* Remove all MD5 from a query (can save lot of memory with many files) */
+static void replace_md5(char *q)
+{
+ char *p = q;
+ while ((p = strstr(p, ", MD5"))) {
+ memset(p, ' ', 5 * sizeof(char));
+ }
+}
+
/**
* Find the last "accurate" backup state (that can take deleted files in
* account)
*
* TODO: See if we can do the SORT only if needed (as an argument)
*/
-bool db_get_file_list(JCR *jcr, B_DB *mdb, char *jobids,
+bool db_get_file_list(JCR *jcr, B_DB *mdb, char *jobids, bool use_md5,
DB_RESULT_HANDLER *result_handler, void *ctx)
{
if (!*jobids) {
Mmsg(buf2, select_recent_version_with_basejob[db_type],
jobids, jobids, jobids, jobids);
Mmsg(buf,
-"SELECT Path.Path, Filename.Name, T1.FileIndex, T1.JobId, LStat, MD5, MarkId "
+"SELECT Path.Path, Filename.Name, T1.FileIndex, T1.JobId, LStat, MarkId, MD5 "
"FROM ( %s ) AS T1 "
"JOIN Filename ON (Filename.FilenameId = T1.FilenameId) "
"JOIN Path ON (Path.PathId = T1.PathId) "
"ORDER BY T1.JobTDate, FileIndex ASC",/* Return sorted by JobId, */
/* FileIndex for restore code */
buf2.c_str());
+ if (!use_md5) {
+ replace_md5(buf.c_str());
+ }
Dmsg1(100, "q=%s\n", buf.c_str());
#else
/*
return ret;
}
-bool db_get_base_file_list(JCR *jcr, B_DB *mdb,
+bool db_get_base_file_list(JCR *jcr, B_DB *mdb, bool use_md5,
DB_RESULT_HANDLER *result_handler, void *ctx)
{
POOL_MEM buf(PM_MESSAGE);
Mmsg(buf,
- "SELECT Path, Name, FileIndex, JobId, LStat, MD5, 0 As MarkId "
+ "SELECT Path, Name, FileIndex, JobId, LStat, 0 As MarkId, MD5 "
"FROM new_basefile%lld ORDER BY JobId, FileIndex ASC",
(uint64_t) jcr->JobId);
-
+
+ if (!use_md5) {
+ replace_md5(buf.c_str());
+ }
return db_sql_query(mdb, buf.c_str(), result_handler, ctx);
}
/*
* Foreach files in currrent list, send "/path/fname\0LStat\0MD5\0Delta" to FD
+ * row[0]=Path, row[1]=Filename, row[2]=FileIndex
+ * row[3]=JobId row[4]=LStat row[5]=MarkId row[6]=MD5
*/
static int accurate_list_handler(void *ctx, int num_fields, char **row)
{
/* sending with checksum */
if (jcr->use_accurate_chksum
&& num_fields == 7
- && row[5][0] /* skip checksum = '0' */
- && row[5][1])
+ && row[6][0] /* skip checksum = '0' */
+ && row[6][1])
{
jcr->file_bsock->fsend("%s%s%c%s%c%s%c%s",
- row[0], row[1], 0, row[4], 0, row[5], 0, row[6]);
+ row[0], row[1], 0, row[4], 0, row[6], 0, row[5]);
} else {
jcr->file_bsock->fsend("%s%s%c%s%c%c%s",
- row[0], row[1], 0, row[4], 0, 0, row[6]);
+ row[0], row[1], 0, row[4], 0, 0, row[5]);
}
return 0;
}
if (jcr->HasBase) {
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,
+ db_get_base_file_list(jcr, jcr->db, jcr->use_accurate_chksum,
accurate_list_handler, (void *)jcr);
} else {
- db_get_file_list(jcr, jcr->db_batch, jobids.list,
+ db_get_file_list(jcr, jcr->db_batch,
+ jobids.list, jcr->use_accurate_chksum,
accurate_list_handler, (void *)jcr);
}
#define new_get_file_list
#ifdef new_get_file_list
- if (!db_get_file_list(ua->jcr, ua->db, rx->JobIds, insert_tree_handler, (void *)&tree)) {
+ if (!db_get_file_list(ua->jcr, ua->db,
+ rx->JobIds, false /* do not use md5 */,
+ insert_tree_handler, (void *)&tree))
+ {
ua->error_msg("%s", db_strerror(ua->db));
}
if (*rx->BaseJobIds) {
*
* See uar_sel_files in sql_cmds.c for query that calls us.
* row[0]=Path, row[1]=Filename, row[2]=FileIndex
- * row[3]=JobId row[4]=LStat
+ * row[3]=JobId row[4]=LStat row[5]=MarkId
*/
int insert_tree_handler(void *ctx, int num_fields, char **row)
{
return false;
}
- if (!db_get_file_list(jcr, jcr->db_batch, jobids,
+ if (!db_get_file_list(jcr, jcr->db_batch, jobids, false /* don't use md5 */,
insert_bootstrap_handler, (void *)rx.bsr))
{
Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db_batch));
}
start = get_current_btime();
- db_get_file_list(NULL, db, restore_list, list_handler, &nb_file);
+ db_get_file_list(NULL, db, restore_list, false, list_handler, &nb_file);
end = get_current_btime();
Pmsg3(0, _("Computing file list for jobid=%s files=%lld secs=%d\n"),