"Name BLOB NOT NULL)",
/* Postgresql */
- "CREATE TEMPORARY TABLE basefile%lld ("
+// "CREATE TEMPORARY TABLE basefile%lld ("
+ "CREATE TABLE basefile%lld ("
"Path TEXT,"
"Name TEXT)",
"Name TEXT)"
};
-bool db_init_base_file(JCR *jcr, B_DB *mdb)
-{
- POOL_MEM q(PM_MESSAGE);
- Mmsg(q, create_temp_basefile[db_type], (uint64_t) jcr->JobId);
- return db_sql_query(mdb, q.c_str(), NULL, NULL);
-}
-
/*
* Create Base File record in B_DB
*
{
POOL_MEM buf(PM_MESSAGE);
Mmsg(buf, "DROP TABLE new_basefile%lld", (uint64_t) jcr->JobId);
- db_sql_query(mdb, buf.c_str(), NULL, NULL);
+// db_sql_query(mdb, buf.c_str(), NULL, NULL);
Mmsg(buf, "DROP TABLE basefile%lld", (uint64_t) jcr->JobId);
- db_sql_query(mdb, buf.c_str(), NULL, NULL);
+// db_sql_query(mdb, buf.c_str(), NULL, NULL);
}
/*
*/
bool db_create_base_file_list(JCR *jcr, B_DB *mdb, char *jobids)
{
+ POOL_MEM buf(PM_MESSAGE);
+
if (!*jobids) {
db_lock(mdb);
Mmsg(mdb->errmsg, _("ERR=JobIds are empty\n"));
db_unlock(mdb);
return false;
}
- POOL_MEM buf(PM_MESSAGE);
-
+
+ Mmsg(buf, create_temp_basefile[db_type], (uint64_t) jcr->JobId);
+ if (!db_sql_query(mdb, buf.c_str(), NULL, NULL)) {
+ return false;
+ }
+
Mmsg(buf,
- "CREATE TEMPORARY TABLE new_basefile%lld AS ( "
+// "CREATE TEMPORARY TABLE new_basefile%lld AS ( "
+ "CREATE TABLE new_basefile%lld AS ( "
"SELECT Path.Path AS Path, Filename.Name AS Name, File.FileIndex AS FileIndex, "
"File.JobId AS JobId, File.LStat AS LStat, File.FileId AS FileId "
"FROM ( "
return ret;
}
+bool db_get_base_file_list(JCR *jcr, B_DB *mdb,
+ DB_RESULT_HANDLER *result_handler, void *ctx)
+{
+ POOL_MEM buf(PM_MESSAGE);
+
+ Mmsg(buf,
+ "SELECT Path, Name, FileIndex, JobId, LStat "
+ "FROM new_basefile%lld ORDER BY JobId, FileIndex ASC",
+ (uint64_t) jcr->JobId);
+
+ return db_sql_query(mdb, buf.c_str(), result_handler, ctx);
+}
bool db_get_base_jobid(JCR *jcr, B_DB *mdb, JOB_DBR *jr, JobId_t *jobid)
{
char date[MAX_TIME_LENGTH];
/* Take all base jobs from job resource and find the
* last L_BASE jobid.
*/
-static void get_base_jobids(JCR *jcr, POOLMEM *jobids)
+static bool get_base_jobids(JCR *jcr, POOLMEM *jobids)
{
JOB_DBR jr;
JOB *job;
char str_jobid[50];
if (!jcr->job->base) {
- return;
+ return false; /* no base job, stop accurate */
}
memset(&jr, 0, sizeof(JOB_DBR));
pm_strcat(jobids, edit_uint64(id, str_jobid));
}
}
+
+ return *jobids != '\0';
}
/*
POOLMEM *jobids = get_pool_memory(PM_FNAME);
nb[0] = jobids[0] = '\0';
- get_base_jobids(jcr, jobids);
-
- /* On Full mode, if no previous base job, no accurate things */
- if (jcr->get_JobLevel() == L_FULL && *jobids == 0) {
- goto bail_out;
- }
-
- if (jcr->get_JobLevel() == L_FULL && *jobids != 0) {
- db_init_base_file(jcr, jcr->db);
- }
+ if (jcr->get_JobLevel() == L_FULL) {
+ /* On Full mode, if no previous base job, no accurate things */
+ if (!get_base_jobids(jcr, jobids)) {
+ goto bail_out;
+ }
+ db_create_base_file_list(jcr, jcr->db, jobids);
- /* For Incr/Diff level, we search for older jobs */
- if (jcr->get_JobLevel() != L_FULL) {
+ } else {
+ /* For Incr/Diff level, we search for older jobs */
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) {
ret=false;
Jmsg(jcr, M_FATAL, 0, _("Cannot find previous jobids.\n"));
db_sql_query(jcr->db, buf.c_str(), db_get_int_handler, nb);
Dmsg2(200, "jobids=%s nb=%s\n", jobids, nb);
jcr->file_bsock->fsend("accurate files=%s\n", nb);
+
+ if (jcr->get_JobLevel() == L_FULL) {
+ db_get_base_file_list(jcr, jcr->db, accurate_list_handler, (void *)jcr);
- if (!db_open_batch_connexion(jcr, jcr->db)) {
- ret = false;
- Jmsg0(jcr, M_FATAL, 0, "Can't get dedicate sql connexion");
- goto bail_out;
- }
-
- db_get_file_list(jcr, jcr->db_batch, jobids, accurate_list_handler, (void *)jcr);
+ } else {
+ if (!db_open_batch_connexion(jcr, jcr->db)) {
+ ret = false;
+ Jmsg0(jcr, M_FATAL, 0, "Can't get dedicate sql connexion");
+ goto bail_out;
+ }
+ db_get_file_list(jcr, jcr->db_batch, jobids, accurate_list_handler, (void *)jcr);
+ }
/* TODO: close the batch connexion ? (can be used very soon) */
/* Pickup Job termination data */
stat = wait_for_job_termination(jcr);
db_write_batch_file_records(jcr); /* used by bulk batch file insert */
+
+ if (jcr->get_JobLevel() == L_FULL && jcr->job->base) {
+ db_commit_base_file_attributes_record(jcr, jcr->db);
+ db_cleanup_base_file(jcr, jcr->db);
+ }
+
if (stat == JS_Terminated) {
backup_cleanup(jcr, stat);
return true;