]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/sql_get.c
Fix and document new queries
[bacula/bacula] / bacula / src / cats / sql_get.c
index 2e32882baf0521b89c2141455f12d4d2f83057ee..6da66a75bdfc184e81b91290029e62cc285daca3 100644 (file)
@@ -1067,25 +1067,19 @@ bool db_get_file_list(JCR *jcr, B_DB *mdb, char *jobids,
          
 #define new_db_get_file_list
 #ifdef new_db_get_file_list
+   POOL_MEM buf2(PM_MESSAGE);
+   Mmsg(buf2, select_recent_version_with_basejob[db_type], 
+        jobids, jobids, jobids);
    Mmsg(buf,
- "SELECT Path.Path, Filename.Name, File.FileIndex, File.JobId, "
-        "File.LStat, File.MD5 "
- "FROM ( "
-  "SELECT max(FileId) as FileId, PathId, FilenameId "
-    "FROM (SELECT FileId, PathId, FilenameId FROM File WHERE JobId IN (%s) "
-           "UNION ALL "         /* we already sort after */
-          "SELECT File.FileId, PathId, FilenameId "
-            "FROM BaseFiles JOIN File USING (FileId) "
-           "WHERE BaseFiles.JobId IN (%s) "
-          ") AS F "
-   "GROUP BY PathId, FilenameId "
-  ") AS Temp "
+ "SELECT Path.Path, Filename.Name, FileIndex, JobId, "
+        "LStat, MD5 "
+ "FROM ( %s ) AS Temp "
  "JOIN Filename ON (Filename.FilenameId = Temp.FilenameId) "
  "JOIN Path ON (Path.PathId = Temp.PathId) "
- "JOIN File ON (File.FileId = Temp.FileId) "
-"WHERE File.FileIndex > 0 ORDER BY JobId, FileIndex ASC",/* Return sorted by JobId, */
-                                                         /* FileIndex for restore code */ 
-        jobids, jobids);
+"WHERE FileIndex > 0 ORDER BY JobId, FileIndex ASC",/* Return sorted by JobId, */
+                                                    /* FileIndex for restore code */ 
+        buf2.c_str());
+   Dmsg1(0, "sql=%s\n", buf.c_str());
 #else
    /*  
     * I am not sure that this works the same as the code in ua_restore.c but it
@@ -1224,6 +1218,7 @@ bool db_get_base_file_list(JCR *jcr, B_DB *mdb,
 
    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];