From: Eric Bollengier Date: Thu, 17 Sep 2009 13:38:46 +0000 (+0200) Subject: Fix for sqlite X-Git-Tag: Release-5.0.0~305 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=33b448a045db758116d5d7b531d446a5235cb899;p=bacula%2Fbacula Fix for sqlite --- diff --git a/bacula/src/cats/sql_cmds.c b/bacula/src/cats/sql_cmds.c index 18c5362bd1..afa5276822 100644 --- a/bacula/src/cats/sql_cmds.c +++ b/bacula/src/cats/sql_cmds.c @@ -462,7 +462,8 @@ const char *uar_jobid_fileindex_from_table = */ 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 ( " @@ -475,7 +476,7 @@ const char *select_recent_version_with_basejob[4] = { "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 */ @@ -497,7 +498,8 @@ const char *select_recent_version_with_basejob[4] = { "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 ( " @@ -510,7 +512,7 @@ const char *select_recent_version_with_basejob[4] = { "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 " @@ -518,7 +520,8 @@ const char *select_recent_version_with_basejob[4] = { "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 ( " @@ -531,7 +534,7 @@ const char *select_recent_version_with_basejob[4] = { "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 " diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index 6da66a75bd..b0e795e4f8 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -1071,15 +1071,14 @@ bool db_get_file_list(JCR *jcr, B_DB *mdb, char *jobids, 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