From c901591f651d1f2d7d59278d0a1812c9b4fe268c Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Mon, 10 Sep 2012 21:44:15 +0200 Subject: [PATCH] Tweak previous patch on batch insert --- bacula/src/cats/sql_create.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index 31e04807e0..09fd90c386 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -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); } /** -- 2.39.5