From eebd0698a7b671dfcdbbb02b05d9c8a3bd9a7828 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 16 Sep 2009 21:54:34 +0200 Subject: [PATCH] Fix sqlite3 syntax --- bacula/src/cats/sql_cmds.c | 1 + bacula/src/cats/sql_create.c | 10 +++++----- bacula/src/cats/sql_get.c | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bacula/src/cats/sql_cmds.c b/bacula/src/cats/sql_cmds.c index bd7c5bf5e3..2556ab6c34 100644 --- a/bacula/src/cats/sql_cmds.c +++ b/bacula/src/cats/sql_cmds.c @@ -488,6 +488,7 @@ const char *select_recent_version_with_basejob[4] = { /* SQLite3 */ "SELECT max(StartTime), JobId, FileIndex, PathId, FilenameId, LStat, MD5 " + "FROM " "(SELECT FileId, JobId, PathId, FilenameId, FileIndex, LStat, MD5 FROM File WHERE JobId IN (%s) " "UNION ALL " "SELECT File.FileId, BaseFiles.JobId, PathId, FilenameId, File.FileIndex, LStat, MD5 " diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index f6b182f902..591a910889 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -1192,13 +1192,13 @@ bool db_commit_base_file_attributes_record(JCR *jcr, B_DB *mdb) db_lock(mdb); Mmsg(mdb->cmd, - "INSERT INTO BaseFiles (BaseJobId, JobId, FileId, FileIndex) ( " + "INSERT INTO BaseFiles (BaseJobId, JobId, FileId, FileIndex) " "SELECT B.JobId AS BaseJobId, %s AS JobId, " "B.FileId, B.FileIndex " "FROM basefile%s AS A, new_basefile%s AS B " "WHERE A.Path = B.Path " "AND A.Name = B.Name " - "ORDER BY B.FileId)", + "ORDER BY B.FileId", edit_uint64(jcr->JobId, ed1), ed1, ed1); ret = QUERY_DB(jcr, mdb, mdb->cmd); jcr->nb_base_files_used = sql_affected_rows(mdb); @@ -1235,15 +1235,15 @@ bool db_create_base_file_list(JCR *jcr, B_DB *mdb, char *jobids) Mmsg(buf, select_recent_version[db_type], jobids); Mmsg(mdb->cmd, -"CREATE TEMPORARY TABLE new_basefile%lld AS ( " -//"CREATE TABLE new_basefile%lld AS ( " +"CREATE TEMPORARY TABLE new_basefile%lld AS " +//"CREATE TABLE new_basefile%lld AS " "SELECT Path.Path AS Path, Filename.Name AS Name, Temp.FileIndex AS FileIndex," "Temp.JobId AS JobId, Temp.LStat AS LStat, Temp.FileId AS FileId, " "Temp.MD5 AS MD5 " "FROM ( %s ) AS Temp " "JOIN Filename ON (Filename.FilenameId = Temp.FilenameId) " "JOIN Path ON (Path.PathId = Temp.PathId) " - "WHERE Temp.FileIndex > 0)", + "WHERE Temp.FileIndex > 0", (uint64_t)jcr->JobId, buf.c_str()); ret = QUERY_DB(jcr, mdb, mdb->cmd); bail_out: diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index ffadb55be7..7063fd2397 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -1078,6 +1078,7 @@ bool db_get_file_list(JCR *jcr, B_DB *mdb, char *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 -- 2.39.5