]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/tools/dbcheck.c
update version
[bacula/bacula] / bacula / src / tools / dbcheck.c
index c8d6af1e9963e3b35b2445858af43a709abfe088..a61b1c70dc03034e655e9f7a58314da3c9aac5d9 100644 (file)
@@ -108,9 +108,7 @@ static bool check_idx(const char *col_name);
 static bool create_tmp_idx(const char *idx_name, const char *table_name,
               const char *col_name);
 static bool drop_tmp_idx(const char *idx_name, const char *table_name);
-#ifdef HAVE_MYSQL
 static int check_idx_handler(void *ctx, int num_fields, char **row);
-#endif
 
 static void usage()
 {
@@ -342,7 +340,7 @@ int main (int argc, char *argv[])
 
 static void print_catalog_details(CAT *catalog, const char *working_dir)
 {
-   POOLMEM *buf = get_pool_memory(PM_MESSAGE);
+   POOLMEM *catalog_details = get_pool_memory(PM_MESSAGE);
 
    /*
     * Instantiate a B_DB class and see what db_type gets assigned to it.
@@ -353,11 +351,11 @@ static void print_catalog_details(CAT *catalog, const char *working_dir)
                          catalog->mult_db_connections,
                          catalog->disable_batch_insert);
    if (db) {
-      printf("%sdb_type=%s\nworking_dir=%s\n", catalog->display(buf),
+      printf("%sdb_type=%s\nworking_dir=%s\n", catalog->display(catalog_details),
              db->db_get_type(), working_directory);
       db_close_database(NULL, db);
    }
-   free_pool_memory(buf);
+   free_pool_memory(catalog_details);
 }
 
 static void do_interactive_mode()
@@ -507,9 +505,10 @@ static int print_name_handler(void *ctx, int num_fields, char **row)
 
 static int get_name_handler(void *ctx, int num_fields, char **row)
 {
-   POOLMEM *buf = (POOLMEM *)ctx;
+   POOLMEM *name = (POOLMEM *)ctx;
+
    if (row[0]) {
-      pm_strcpy(&buf, row[0]);
+      pm_strcpy(&name, row[0]);
    }
    return 0;
 }
@@ -1249,6 +1248,7 @@ static void repair_bad_filenames()
          }
          db_sql_query(db, buf, NULL, NULL);
       }
+      free_pool_memory(name);
    }
 }
 
@@ -1310,6 +1310,7 @@ static void repair_bad_paths()
          }
          db_sql_query(db, buf, NULL, NULL);
       }
+      free_pool_memory(name);
    }
 }
 
@@ -1348,7 +1349,6 @@ bool python_set_prog(JCR*, char const*) { return false; }
  *  that to improve the performance.
  */
 
-#ifdef HAVE_MYSQL
 #define MAXIDX          100
 typedef struct s_idx_list {
    char *key_name;
@@ -1370,6 +1370,7 @@ static int check_idx_handler(void *ctx, int num_fields, char **row)
    char *name, *key_name, *col_name;
    int i, len;
    int found = false;
+
    name = (char *)ctx;
    key_name = row[2];
    col_name = row[4];
@@ -1399,46 +1400,44 @@ static int check_idx_handler(void *ctx, int num_fields, char **row)
    }
    return 0;
 }
-#endif
 
 /*
  * Return TRUE if "one column" index over *col_name exists
  */
 static bool check_idx(const char *col_name)
 {
-#ifdef HAVE_MYSQL
    int i;
    int found = false;
-
-   memset(&idx_list, 0, sizeof(idx_list));
    const char *query = "SHOW INDEX FROM File";
-   if (!db_sql_query(db, query, check_idx_handler, (void *)col_name)) {
-      printf("%s\n", db_strerror(db));
-   }
 
-   for(i = 0; (idx_list[i].key_name != NULL) && (i < MAXIDX) ; i++) {
-      /*
-       * NOTE : if (idx_list[i].count_key > 1) then index idx_list[i].key_name is "multiple-column" index
-       */
-      if ((idx_list[i].count_key == 1) && (idx_list[i].count_col == 1)) {
+   switch (db_get_type_index(db)) {
+   case SQL_TYPE_MYSQL:
+      memset(&idx_list, 0, sizeof(idx_list));
+      if (!db_sql_query(db, query, check_idx_handler, (void *)col_name)) {
+         printf("%s\n", db_strerror(db));
+      }
+      for (i = 0; (idx_list[i].key_name != NULL) && (i < MAXIDX) ; i++) {
          /*
-          * "one column" index over *col_name found
+          * NOTE : if (idx_list[i].count_key > 1) then index idx_list[i].key_name is "multiple-column" index
           */
-         found = true;
+         if ((idx_list[i].count_key == 1) && (idx_list[i].count_col == 1)) {
+            /*
+             * "one column" index over *col_name found
+             */
+            found = true;
+         }
       }
-   }
-   if (found) {
-      if (verbose) {
-         printf(_("Ok. Index over the %s column already exists and dbcheck will work faster.\n"), col_name);
+      if (found) {
+         if (verbose) {
+            printf(_("Ok. Index over the %s column already exists and dbcheck will work faster.\n"), col_name);
+         }
+      } else {
+         printf(_("Note. Index over the %s column not found, that can greatly slow down dbcheck.\n"), col_name);
       }
-   } else {
-      printf(_("Note. Index over the %s column not found, that can greatly slow down dbcheck.\n"), col_name);
+      return found;
+   default:
+      return true;
    }
-
-   return found;
-#else
-   return true;
-#endif
 }
 
 /*