]> git.sur5r.net Git - bacula/bacula/commitdiff
Tweak previous patch on batch insert
authorEric Bollengier <eric@baculasystems.com>
Mon, 10 Sep 2012 19:44:15 +0000 (21:44 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:50:57 +0000 (14:50 +0200)
bacula/src/cats/sql_create.c

index 31e04807e06e6a7bc618f98ba0aa53a2beb98338..09fd90c386c6cfb2897b8370f90cd2749a241840 100644 (file)
@@ -891,6 +891,11 @@ bool db_create_batch_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
    Dmsg1(dbglevel, "Fname=%s\n", ar->fname);
    Dmsg0(dbglevel, "put_file_into_catalog\n");
 
+   if (jcr->batch_started && jcr->db_batch->changes > 800000) {
+      db_write_batch_file_records(jcr);
+      jcr->db_batch->changes = 0;
+   }
+
    /* Open the dedicated connexion */
    if (!jcr->batch_started) {
       if (!db_open_batch_connexion(jcr, mdb)) {
@@ -904,17 +909,10 @@ bool db_create_batch_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
       }
       jcr->batch_started = true;
    }
-   B_DB *bdb = jcr->db_batch;
 
-   split_path_and_file(jcr, bdb, ar->fname);
-
-   if (bdb->changes > 800000) {
-      db_write_batch_file_records(jcr);
-      bdb->changes = 0;
-      sql_batch_start(jcr, bdb);
-   }
+   split_path_and_file(jcr, jcr->db_batch, ar->fname);
 
-   return sql_batch_insert(jcr, bdb, ar);
+   return sql_batch_insert(jcr, jcr->db_batch, ar);
 }
 
 /**