{
POOL_MEM query;
POOL_MEM tmp, tmp2;
- int64_t id, jobid;
+ int64_t id, jobid, prev_jobid;
bool init=false;
bool ret=false;
/* check args */
return false;
}
+ db_lock(db);
+
+ /* Cleanup old tables first */
+ Mmsg(query, "DROP TABLE btemp%s", output_table);
+ db_sql_query(db, query.c_str());
+
+ Mmsg(query, "DROP TABLE %s", output_table);
+ db_sql_query(db, query.c_str());
+
Mmsg(query, "CREATE TABLE btemp%s AS ", output_table);
if (*fileid) { /* Select files with their direct id */
if (!db_sql_query(db, tmp.c_str(), get_path_handler, (void *)&tmp2)) {
Dmsg0(dbglevel, "Can't search for path\n");
/* print error */
- return false;
+ goto bail_out;
}
if (!strcmp(tmp2.c_str(), "")) { /* path not found */
Dmsg3(dbglevel, "Path not found %lld q=%s s=%s\n",
}
/* expect jobid,fileindex */
- int64_t prev_jobid=0;
+ prev_jobid=0;
while (get_next_id_from_list(&hardlink, &jobid) == 1) {
if (get_next_id_from_list(&hardlink, &id) != 1) {
Dmsg0(dbglevel, "hardlink should be two by two\n");
- return false;
+ goto bail_out;
}
if (jobid != prev_jobid) { /* new job */
if (prev_jobid == 0) { /* first jobid */
bail_out:
Mmsg(query, "DROP TABLE btemp%s", output_table);
db_sql_query(db, query.c_str(), NULL, NULL);
+ db_unlock(db);
return ret;
}