From: Kern Sibbald Date: Sat, 8 Sep 2012 12:20:02 +0000 (+0200) Subject: Clean up error message generation during update attributes -- should fix bug #1823 X-Git-Tag: Release-7.0.0~129 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6ab87b8f29631612d4150c37475d5ddb2d367d80;p=bacula%2Fbacula Clean up error message generation during update attributes -- should fix bug #1823 --- diff --git a/bacula/src/cats/sql.c b/bacula/src/cats/sql.c index 2c4fa431ee..9d589fda18 100644 --- a/bacula/src/cats/sql.c +++ b/bacula/src/cats/sql.c @@ -713,15 +713,12 @@ bool db_open_batch_connexion(JCR *jcr, B_DB *mdb) { bool multi_db; - if (mdb->batch_insert_available()) - multi_db = true; /* we force a new connection only if batch insert is enabled */ - else - multi_db = false; + multi_db = mdb->batch_insert_available(); if (!jcr->db_batch) { jcr->db_batch = db_clone_database_connection(mdb, jcr, multi_db); if (!jcr->db_batch) { - Mmsg0(&mdb->errmsg, _("Could not init database batch connection")); + Mmsg0(&mdb->errmsg, _("Could not init database batch connection\n")); Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg); return false; } diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index cdd7d1aa22..76a976ec3f 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -570,6 +570,7 @@ int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) int stat; int num_rows; + mdb->errmsg[0] = 0; mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->pnl+2); db_escape_string(jcr, mdb, mdb->esc_name, mdb->path, mdb->pnl); @@ -1006,6 +1007,7 @@ static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) SQL_ROW row; int num_rows; + mdb->errmsg[0] = 0; mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->fnl+2); db_escape_string(jcr, mdb, mdb->esc_name, mdb->fname, mdb->fnl); @@ -1052,25 +1054,30 @@ bool db_create_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) { bool ret; + mdb->errmsg[0] = 0; /* * Make sure we have an acceptable attributes record. */ if (!(ar->Stream == STREAM_UNIX_ATTRIBUTES || ar->Stream == STREAM_UNIX_ATTRIBUTES_EX)) { - Jmsg(jcr, M_FATAL, 0, _("Attempt to put non-attributes into catalog. Stream=%d\n")); + Mmsg1(&mdb->errmsg, _("Attempt to put non-attributes into catalog. Stream=%d\n"), + ar->Stream); + Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg); return false; } if (ar->FileType != FT_BASE) { if (mdb->batch_insert_available()) { ret = db_create_batch_file_attributes_record(jcr, mdb, ar); + /* Error message already printed */ } else { ret = db_create_file_attributes_record(jcr, mdb, ar); } } else if (jcr->HasBase) { ret = db_create_base_file_attributes_record(jcr, mdb, ar); } else { - Jmsg0(jcr, M_FATAL, 0, _("Cannot Copy/Migrate job using BaseJob")); + Mmsg0(&mdb->errmsg, _("Cannot Copy/Migrate job using BaseJob.\n")); + Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg); ret = true; /* in copy/migration what do we do ? */ } diff --git a/bacula/src/cats/sql_glue.c b/bacula/src/cats/sql_glue.c index a86195ce36..8042ec33f5 100644 --- a/bacula/src/cats/sql_glue.c +++ b/bacula/src/cats/sql_glue.c @@ -113,16 +113,19 @@ void db_end_transaction(JCR *jcr, B_DB *mdb) bool db_sql_query(B_DB *mdb, const char *query, int flags) { + mdb->errmsg[0] = 0; return mdb->db_sql_query(query, flags); } bool db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx) { + mdb->errmsg[0] = 0; return mdb->db_sql_query(query, result_handler, ctx); } bool db_big_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx) { + mdb->errmsg[0] = 0; return mdb->db_big_sql_query(query, result_handler, ctx); } @@ -138,6 +141,7 @@ SQL_ROW sql_fetch_row(B_DB *mdb) bool sql_query(B_DB *mdb, const char *query, int flags) { + mdb->errmsg[0] = 0; return ((B_DB_PRIV *)mdb)->sql_query(query, flags); } diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 8fab887fc9..0cf0b6d92f 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -440,7 +440,7 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen) if (jcr->cached_attribute) { Dmsg2(400, "Cached attr. Stream=%d fname=%s\n", ar->Stream, ar->fname); if (!db_create_attributes_record(jcr, jcr->db, ar)) { - Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db)); + Jmsg1(jcr, M_FATAL, 0, _("Attribute create error: ERR=%s"), db_strerror(jcr->db)); } jcr->cached_attribute = false; }