"ON COMMIT PRESERVE ROWS WITH NORECOVERY"
};
+/* ======= ua_purge.c */
+
+/* Select the first available Copy Job that must be upgraded to a Backup job when the original backup job is expired. */
+
+const char *uap_upgrade_copies_oldest_job[5] = {
+ /* Mysql */
+ "CREATE TEMPORARY TABLE cpy_tmp AS "
+ "SELECT MIN(JobId) AS JobId FROM Job "
+ "WHERE Type='%c' AND (PriorJobId IN (%s) OR PriorJobId IN ( "
+ "SELECT PriorJobId FROM Job "
+ "WHERE JobId IN (%s) AND Type='B' ))"
+ "GROUP BY PriorJobId",
+ /* Postgresql */
+ "CREATE TEMPORARY TABLE cpy_tmp AS "
+ "SELECT MIN(JobId) AS JobId FROM Job "
+ "WHERE Type='%c' AND (PriorJobId IN (%s) OR PriorJobId IN ( "
+ "SELECT PriorJobId FROM Job "
+ "WHERE JobId IN (%s) AND Type='B' ))"
+ "GROUP BY PriorJobId",
+ /* SQLite */
+ "CREATE TEMPORARY TABLE cpy_tmp AS "
+ "SELECT MIN(JobId) AS JobId FROM Job "
+ "WHERE Type='%c' AND (PriorJobId IN (%s) OR PriorJobId IN ( "
+ "SELECT PriorJobId FROM Job "
+ "WHERE JobId IN (%s) AND Type='B' ))"
+ "GROUP BY PriorJobId",
+ /* SQLite3 */
+ "CREATE TEMPORARY TABLE cpy_tmp AS "
+ "SELECT MIN(JobId) AS JobId FROM Job "
+ "WHERE Type='%c' AND (PriorJobId IN (%s) OR PriorJobId IN ( "
+ "SELECT PriorJobId FROM Job "
+ "WHERE JobId IN (%s) AND Type='B' ))"
+ "GROUP BY PriorJobId",
+ /* Ingres */
+ "DECLARE GLOBAL TEMPORARY TABLE cpy_tmp AS "
+ "SELECT MIN(JobId) AS JobId FROM Job "
+ "WHERE Type='%c' AND (PriorJobId IN (%s) OR PriorJobId IN ( "
+ "SELECT PriorJobId FROM Job "
+ "WHERE JobId IN (%s) AND Type='B' ))"
+ "GROUP BY PriorJobId "
+ "ON COMMIT PRESERVE ROWS WITH NORECOVERY"
+};
+
/* ======= ua_restore.c */
/* List Jobs where a particular file is saved */
extern const char CATS_IMP_EXP *create_temp_basefile[5];
extern const char CATS_IMP_EXP *create_temp_new_basefile[5];
extern const char CATS_IMP_EXP *create_deltabs[5];
+extern const char CATS_IMP_EXP *uap_upgrade_copies_oldest_job[5];
extern const char CATS_IMP_EXP *uar_file[5];
extern const char CATS_IMP_EXP *uar_create_temp[5];
POOL_MEM query(PM_MESSAGE);
db_lock(ua->db);
- /* Do it in two times for mysql */
- Mmsg(query, "CREATE TEMPORARY TABLE cpy_tmp AS "
- "SELECT MIN(JobId) AS JobId FROM Job " /* Choose the oldest job */
- "WHERE Type='%c' "
- "AND ( PriorJobId IN (%s) "
- "OR "
- " PriorJobId IN ( "
- "SELECT PriorJobId "
- "FROM Job "
- "WHERE JobId IN (%s) "
- " AND Type='B' "
- ") "
- ") "
- "GROUP BY PriorJobId ", /* one result per copy */
- JT_JOB_COPY, jobs, jobs);
+
+ Mmsg(query, uap_upgrade_copies_oldest_job[db_type], JT_JOB_COPY, jobs, jobs);
db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL);
Dmsg1(050, "Upgrade copies Log sql=%s\n", query.c_str());