const char *cleanup_running_job =
"UPDATE Job SET JobStatus='f', EndTime=StartTime WHERE JobStatus = 'R'";
+const char *sync_jobhisto_def = "UPDATE JobHisto SET PurgedFiles=Job.PurgedFiles, HasCache=Job.HasCache,Reviewed=Job.Reviewed "
+ "FROM Job WHERE Job.JobId=JobHisto.JobId and Job.Job = JobHisto.Job "
+ "AND (Job.HasCache <> JobHisto.HasCache OR Job.PurgedFiles <> JobHisto.PurgedFiles OR Job.Reviewed <> JobHisto.Reviewed)";
+const char *sync_jobhisto[] =
+{
+ // MySQL
+ "UPDATE JobHisto JOIN Job USING (JobId) SET JobHisto.PurgedFiles=Job.PurgedFiles, JobHisto.HasCache=Job.HasCache, JobHisto.Reviewed=Job.Reviewed "
+ "WHERE Job.JobId=JobHisto.JobId and Job.Job = JobHisto.Job "
+ "AND (Job.HasCache <> JobHisto.HasCache OR Job.PurgedFiles <> JobHisto.PurgedFiles OR Job.Reviewed <> JobHisto.Reviewed)",
+ // PostgreSQL
+ sync_jobhisto_def,
+ // SQLite
+ sync_jobhisto_def
+};
+
/* For sql_update.c db_update_stats */
const char *fill_jobhisto =
"INSERT INTO JobHisto (JobId, Job, Name, Type, Level,"
extern const char CATS_IMP_EXP *get_created_running_job;
extern const char CATS_IMP_EXP *cleanup_created_job;
extern const char CATS_IMP_EXP *cleanup_running_job;
+extern const char CATS_IMP_EXP *sync_jobhisto[];
extern const char CATS_IMP_EXP *client_backups;
extern const char CATS_IMP_EXP *cnt_File;
extern const char CATS_IMP_EXP *create_delindex;
int nb = db_update_stats(ua->jcr, ua->db, since);
ua->info_msg(_("Updating %i job(s).\n"), nb);
+ /* Can be removed in 2024. This is a workaround for a minor issue
+ * about the "update stats" command.
+ */
+ db_sql_query(ua->db, sync_jobhisto[db_get_type_index(ua->db)], NULL, NULL);
+
return true;
}