From: Eric Bollengier Date: Thu, 7 Oct 2010 16:09:48 +0000 (+0200) Subject: bvfs: Restore should be ok with MySQL X-Git-Tag: Release-5.2.1~1030 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f9369d5d9a5c30c5364904ffb7007a54564f39fb;p=bacula%2Fbacula bvfs: Restore should be ok with MySQL --- diff --git a/bacula/src/cats/bvfs.c b/bacula/src/cats/bvfs.c index 942e971e7b..c3b8bbd8a2 100644 --- a/bacula/src/cats/bvfs.c +++ b/bacula/src/cats/bvfs.c @@ -889,15 +889,8 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink, goto bail_out; } - /* TODO: handle basejob and MySQL/SQLite3 */ - Mmsg(query, "CREATE TABLE %s AS ( " - "SELECT JobId, FileIndex, FileId " - "FROM ( " - "SELECT DISTINCT ON (PathId, FilenameId) JobId, FileIndex, FileId " - "FROM btemp%s " - "ORDER BY PathId, FilenameId, JobId DESC " - ") AS T " - "WHERE FileIndex > 0)", output_table, output_table); + /* TODO: handle basejob and SQLite3 */ + Mmsg(query, sql_bvfs_select[db_type], output_table, output_table); Dmsg1(dbglevel_sql, "q=%s\n", query.c_str()); if (!db_sql_query(db, query.c_str(), NULL, NULL)) { diff --git a/bacula/src/cats/sql_cmds.c b/bacula/src/cats/sql_cmds.c index eca649a19b..a1bbd698c9 100644 --- a/bacula/src/cats/sql_cmds.c +++ b/bacula/src/cats/sql_cmds.c @@ -915,3 +915,27 @@ const uint32_t sql_get_max_connections_index[5] = { /* Ingres (TODO) */ 0 }; + +const char *sql_bvfs_select[5] = { + /* Mysql */ + "CREATE TABLE %s AS ( " + "SELECT max(JobId) as JobId, FileIndex, FileId " + "FROM btemp%s " + "GROUP BY PathId, FilenameId " + "HAVING FileIndex > 0 ", + /* Postgresql */ + "CREATE TABLE %s AS ( " + "SELECT JobId, FileIndex, FileId " + "FROM ( " + "SELECT DISTINCT ON (PathId, FilenameId) JobId, FileIndex, FileId " + "FROM btemp%s " + "ORDER BY PathId, FilenameId, JobId DESC " + ") AS T " + "WHERE FileIndex > 0)", + /* SQLite */ + "SELECT 0", + /* SQLite3 */ + "SELECT 0", + /* Ingres (TODO) */ + "SELECT 0" +}; diff --git a/bacula/src/cats/sql_cmds.h b/bacula/src/cats/sql_cmds.h index 148dd0aff0..1446d800e0 100644 --- a/bacula/src/cats/sql_cmds.h +++ b/bacula/src/cats/sql_cmds.h @@ -82,3 +82,4 @@ extern const char CATS_IMP_EXP *uar_jobid_fileindex_from_dir[5]; extern const char CATS_IMP_EXP *sql_media_order_most_recently_written[5]; extern const char CATS_IMP_EXP *sql_get_max_connections[5]; extern const uint32_t CATS_IMP_EXP sql_get_max_connections_index[5]; +extern const char *sql_bvfs_select[5];