]> git.sur5r.net Git - bacula/bacula/commitdiff
Ingres doesn't understand a query string with ORDER BY LastWritten IS NULL,LastWritte...
authorMarco van Wieringen <mvw@planets.elm.net>
Tue, 13 Apr 2010 17:48:46 +0000 (19:48 +0200)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 2 Aug 2010 14:50:32 +0000 (16:50 +0200)
bacula/src/cats/sql_cmds.c
bacula/src/cats/sql_cmds.h
bacula/src/cats/sql_find.c

index aa23c5014326a9bce1b966c6d2ef0fb6520b6da9..18a9f5b32fab5e204b87f1a4bcd6f3899979876c 100644 (file)
@@ -723,7 +723,7 @@ const char *uar_file[5] = {
    "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 */
@@ -792,7 +792,7 @@ const char *uar_create_temp[5] = {
    "VolSessionId INTEGER,"
    "VolSessionTime INTEGER)"
    "ON COMMIT PRESERVE ROWS WITH NORECOVERY"
-   };
+};
 
 const char *uar_create_temp1[5] = {
    /* Mysql */
@@ -874,7 +874,20 @@ const char *uar_jobid_fileindex_from_dir[5] = {
    "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 */
index d17fdbd4539605d90a4cd1f31e747486b2d64764..69cd8e3e7175c4e1f2609ee55191d7ad3edf7229 100644 (file)
@@ -81,5 +81,6 @@ extern const char CATS_IMP_EXP *uar_file[5];
 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];
index 3920798a0b34e17fe3afd3433919efe2a8ec8a25..d5b42e0b6dcc3b0ce3765eccf71b1edce7c9ad57 100644 (file)
@@ -346,7 +346,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr
           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,"