"AND Job.JobId=File.JobId AND File.FileIndex > 0 "
"AND Path.PathId=File.PathId AND Filename.FilenameId=File.FilenameId "
"AND Filename.Name='%s' ORDER BY StartTime DESC FETCH FIRST 20 ROWS ONLY"
- };
+};
const char *uar_create_temp[5] = {
/* Mysql */
"VolSessionId INTEGER,"
"VolSessionTime INTEGER)"
"ON COMMIT PRESERVE ROWS WITH NORECOVERY"
- };
+};
const char *uar_create_temp1[5] = {
/* Mysql */
"AND Job.ClientId=Client.ClientId "
"AND Path.PathId=File.Pathid "
"AND Filename.FilenameId=File.FilenameId"
- };
+};
+
+const char *sql_media_order_most_recently_written[5] {
+ /* Mysql */
+ "ORDER BY LastWritten IS NULL,LastWritten DESC,MediaId",
+ /* Postgresql */
+ "ORDER BY LastWritten IS NULL,LastWritten DESC,MediaId",
+ /* SQLite */
+ "ORDER BY LastWritten IS NULL,LastWritten DESC,MediaId",
+ /* SQLite3 */
+ "ORDER BY LastWritten IS NULL,LastWritten DESC,MediaId",
+ /* Ingres */
+ "ORDER BY IFNULL(LastWritten, '') DESC,MediaId"
+};
const char *sql_get_max_connections[5] = {
/* Mysql */
extern const char CATS_IMP_EXP *uar_create_temp[5];
extern const char CATS_IMP_EXP *uar_create_temp1[5];
extern const char CATS_IMP_EXP *uar_jobid_fileindex_from_dir[5];
+extern const char CATS_IMP_EXP *sql_media_order_by_leastrecently_used[5];
extern const char CATS_IMP_EXP *sql_get_max_connections[5];
extern const uint32_t CATS_IMP_EXP sql_get_max_connections_index[5];
strcmp(mr->VolStatus, "Purged") == 0) {
order = "AND Recycle=1 ORDER BY LastWritten ASC,MediaId"; /* take oldest that can be recycled */
} else {
- order = "ORDER BY LastWritten IS NULL,LastWritten DESC,MediaId"; /* take most recently written */
+ order = sql_media_order_most_recently_written[db_type]; /* take most recently written */
}
Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks,"
"VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"