*/
const char *select_recent_version_with_basejob[4] = {
/* MySQL */
-"SELECT FileId, Job.JobId, FileIndex, File.PathId, File.FilenameId, LStat, MD5 "
+"SELECT FileId, Job.JobId AS JobId, FileIndex, File.PathId AS PathId, "
+ "File.FilenameId AS FilenameId, LStat, MD5 "
"FROM Job, File, ( "
"SELECT MAX(JobTDate) AS JobTDate, PathId, FilenameId "
"FROM ( "
"JOIN File USING (FileId) "
"JOIN Job ON (BaseJobId = Job.JobId) "
"WHERE BaseFiles.JobId IN (%s) "
- ") AS temp GROUP BY PathId, FilenameId " /* Use Max(JobTDate) to find */
+ ") AS tmp GROUP BY PathId, FilenameId " /* Use Max(JobTDate) to find */
") AS T1 " /* the latest version */
"WHERE Job.JobId IN (%s) "
"AND Job.JobTDate = T1.JobTDate " /* Join on JobTDate to get the orginal */
"ORDER BY FilenameId, PathId, StartTime DESC ",
/* SQLite */ /* See Mysql section for doc */
-"SELECT FileId, Job.JobId, FileIndex, File.PathId, File.FilenameId, LStat, MD5 "
+"SELECT FileId, Job.JobId AS JobId, FileIndex, File.PathId AS PathId, "
+ "File.FilenameId AS FilenameId, LStat, MD5 "
"FROM Job, File, ( "
"SELECT MAX(JobTDate) AS JobTDate, PathId, FilenameId "
"FROM ( "
"JOIN File USING (FileId) "
"JOIN Job ON (BaseJobId = Job.JobId) "
"WHERE BaseFiles.JobId IN (%s) "
- ") AS temp GROUP BY PathId, FilenameId "
+ ") AS tmp GROUP BY PathId, FilenameId "
") AS T1 "
"WHERE Job.JobId IN (%s) "
"AND Job.JobTDate = T1.JobTDate "
"AND File.FilenameId = T1.PathId ",
/* SQLite3 */ /* See Mysql section for doc */
-"SELECT FileId, Job.JobId, FileIndex, File.PathId, File.FilenameId, LStat, MD5 "
+"SELECT FileId, Job.JobId AS JobId, FileIndex, File.PathId AS PathId, "
+ "File.FilenameId AS FilenameId, LStat, MD5 "
"FROM Job, File, ( "
"SELECT MAX(JobTDate) AS JobTDate, PathId, FilenameId "
"FROM ( "
"JOIN File USING (FileId) "
"JOIN Job ON (BaseJobId = Job.JobId) "
"WHERE BaseFiles.JobId IN (%s) "
- ") AS temp GROUP BY PathId, FilenameId "
+ ") AS tmp GROUP BY PathId, FilenameId "
") AS T1 "
"WHERE Job.JobId IN (%s) "
"AND Job.JobTDate = T1.JobTDate "
Mmsg(buf2, select_recent_version_with_basejob[db_type],
jobids, jobids, jobids);
Mmsg(buf,
- "SELECT Path.Path, Filename.Name, FileIndex, JobId, "
- "LStat, MD5 "
+"SELECT Path.Path, Filename.Name, Temp.FileIndex, Temp.JobId, LStat, MD5 "
"FROM ( %s ) AS Temp "
"JOIN Filename ON (Filename.FilenameId = Temp.FilenameId) "
"JOIN Path ON (Path.PathId = Temp.PathId) "
-"WHERE FileIndex > 0 ORDER BY JobId, FileIndex ASC",/* Return sorted by JobId, */
- /* FileIndex for restore code */
+"WHERE FileIndex > 0 "
+"ORDER BY Temp.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