From: Marco van Wieringen Date: Wed, 5 Sep 2012 07:22:52 +0000 (+0200) Subject: Final fix for #1859 missed one query. X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f245e351a97818fdd4aedd53fa63d2eae57f5b39;p=bacula%2Fbacula Final fix for #1859 missed one query. --- diff --git a/bacula/src/cats/sql_cmds.c b/bacula/src/cats/sql_cmds.c index b60be1f96f..860def19e3 100644 --- a/bacula/src/cats/sql_cmds.c +++ b/bacula/src/cats/sql_cmds.c @@ -1016,6 +1016,27 @@ const char *match_query[] = { "~" }; +static const char *insert_counter_values_default = + "INSERT INTO Counters (Counter, MinValue, " + "MaxValue, CurrentValue, WrapCounter) " + "VALUES ('%s','%d','%d','%d','%s')"; + +const char *insert_counter_values[] = { + /* Mysql */ + "INSERT INTO Counters (Counter, Counters.MinValue, " + "Counters.MaxValue, CurrentValue, WrapCounter) " + "VALUES ('%s','%d','%d','%d','%s')", + + /* Postgresql */ + insert_counter_values_default, + + /* SQLite3 */ + insert_counter_values_default, + + /* Ingres */ + insert_counter_values_default +}; + static const char *select_counter_values_default = "SELECT MinValue, MaxValue, CurrentValue, WrapCounter " "FROM Counters WHERE Counter='%s'"; diff --git a/bacula/src/cats/sql_cmds.h b/bacula/src/cats/sql_cmds.h index ed7c26f7e9..9ffbc9d93f 100644 --- a/bacula/src/cats/sql_cmds.h +++ b/bacula/src/cats/sql_cmds.h @@ -84,5 +84,6 @@ extern const char CATS_IMP_EXP *batch_unlock_tables_query[]; extern const char CATS_IMP_EXP *batch_fill_path_query[]; extern const char CATS_IMP_EXP *batch_fill_filename_query[]; extern const char CATS_IMP_EXP *match_query[]; +extern const char CATS_IMP_EXP *insert_counter_values[]; extern const char CATS_IMP_EXP *select_counter_values[]; extern const char CATS_IMP_EXP *update_counter_values[]; diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index a4a6f47222..cdd7d1aa22 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -655,9 +655,9 @@ int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr) return 1; } mdb->db_escape_string(jcr, esc, cr->Counter, strlen(cr->Counter)); + /* Must create it */ - Mmsg(mdb->cmd, "INSERT INTO Counters (Counter,Counters.MinValue,Counters.MaxValue,CurrentValue," - "WrapCounter) VALUES ('%s','%d','%d','%d','%s')", + Mmsg(mdb->cmd, insert_counter_values[db_get_type_index(mdb)], esc, cr->MinValue, cr->MaxValue, cr->CurrentValue, cr->WrapCounter); @@ -673,7 +673,6 @@ int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr) return stat; } - /** * Create a FileSet record. This record is unique in the * name and the MD5 signature of the include/exclude sets.