Mmsg(query, "CREATE TEMPORARY TABLE btemp%s AS ", output_table);
- if (*fileid) {
+ if (*fileid) { /* Select files with their direct id */
init=true;
Mmsg(tmp,"(SELECT JobId, JobTDate, FileIndex, FilenameId, PathId, FileId "
"FROM File JOIN Job USING (JobId) WHERE FileId IN (%s))",
pm_strcat(query, tmp.c_str());
}
+ /* Add a directory content */
while (get_next_id_from_list(&dirid, &id) == 1) {
Mmsg(tmp, "SELECT Path FROM Path WHERE PathId=%lld", id);
if (init) {
query.strcat(" UNION ");
}
- /* TODO: Add basejobs here */
+
Mmsg(tmp, "(SELECT JobId, JobTDate, File.FileIndex, File.FilenameId, "
"File.PathId, FileId "
"FROM Path JOIN File USING (PathId) JOIN Job USING (JobId) "
tmp2.c_str(), jobids);
query.strcat(tmp.c_str());
init = true;
+
+ query.strcat(" UNION ");
+
+ /* A directory can have files from a BaseJob */
+ Mmsg(tmp, "(SELECT File.JobId, JobTDate, BaseFiles.FileIndex, "
+ "File.FilenameId, File.PathId, BaseFiles.FileId "
+ "FROM BaseFiles "
+ "JOIN File USING (FileId) "
+ "JOIN Job ON (BaseFiles.JobId = Job.JobId) "
+ "JOIN Path USING (PathId) "
+ "WHERE Path.Path LIKE '%s' AND BaseFiles.JobId IN (%s)) ",
+ tmp2.c_str(), jobids);
+ query.strcat(tmp.c_str());
}
/* expect jobid,fileindex */