From: Kern Sibbald Date: Sat, 10 Apr 2010 10:15:58 +0000 (+0200) Subject: Revert "Drop have_insert_id in mdb as its always true for all backends." X-Git-Tag: Release-5.0.2~64 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ab3f68b594864551f85bb4c4fd6782cdc5150012;p=bacula%2Fbacula Revert "Drop have_insert_id in mdb as its always true for all backends." This reverts commit e4c79f3a2a6e9eff312b474fda10e097660e131f. --- diff --git a/bacula/src/cats/cats.h b/bacula/src/cats/cats.h index 164eec325c..5bbd4d7df4 100644 --- a/bacula/src/cats/cats.h +++ b/bacula/src/cats/cats.h @@ -135,6 +135,7 @@ struct B_DB { char *db_password; int db_port; /* port for host name address */ bool connected; /* connection made to db */ + bool have_insert_id; /* do not have insert id */ bool fields_defined; /* set when fields defined */ char *sqlite_errmsg; /* error message returned by sqlite */ POOLMEM *errmsg; /* nicely edited error message */ @@ -256,6 +257,7 @@ struct B_DB { char *db_password; int db_port; /* port for host name address */ bool connected; /* connection made to db */ + bool have_insert_id; /* do not have insert id */ bool fields_defined; /* set when fields defined */ char *sqlite_errmsg; /* error message returned by sqlite */ POOLMEM *errmsg; /* nicely edited error message */ @@ -362,6 +364,7 @@ struct B_DB { char *db_address; /* host address */ char *db_socket; /* socket for local access */ int db_port; /* port of host address */ + int have_insert_id; /* do have insert_id() */ bool connected; POOLMEM *errmsg; /* nicely edited error message */ POOLMEM *cmd; /* SQL command string */ @@ -464,6 +467,7 @@ struct B_DB { char *db_address; /* host address */ char *db_socket; /* socket for local access */ int db_port; /* port of host address */ + int have_insert_id; /* do have insert_id() */ bool connected; POOLMEM *errmsg; /* nicely edited error message */ POOLMEM *cmd; /* SQL command string */ @@ -573,6 +577,7 @@ struct B_DB { char *db_socket; /* socket for local access */ int db_port; /* port of host address */ int session_id; /* unique session id */ + int have_insert_id; /* do have insert_id() */ bool connected; POOLMEM *errmsg; /* nicely edited error message */ POOLMEM *cmd; /* SQL command string */ @@ -700,6 +705,7 @@ struct B_DB { char *db_address; /* host address */ char *db_socket; /* socket for local access */ int db_port; /* port of host address */ + int have_insert_id; /* do have insert_id() */ bool connected; POOLMEM *errmsg; /* nicely edited error message */ POOLMEM *cmd; /* SQL command string */ diff --git a/bacula/src/cats/dbi.c b/bacula/src/cats/dbi.c index f721f1fbb2..dd2a9bba9c 100644 --- a/bacula/src/cats/dbi.c +++ b/bacula/src/cats/dbi.c @@ -168,6 +168,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char } mdb->db_type = db_type; mdb->db_port = db_port; + mdb->have_insert_id = TRUE; mdb->errmsg = get_pool_memory(PM_EMSG); /* get error message buffer */ *mdb->errmsg = 0; mdb->cmd = get_pool_memory(PM_EMSG); /* get command buffer */ diff --git a/bacula/src/cats/ingres.c b/bacula/src/cats/ingres.c index bc32703a0f..3553f37953 100755 --- a/bacula/src/cats/ingres.c +++ b/bacula/src/cats/ingres.c @@ -130,6 +130,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char } mdb->db_port = db_port; mdb->session_id = ++next_session_id; + mdb->have_insert_id = TRUE; mdb->errmsg = get_pool_memory(PM_EMSG); /* get error message buffer */ *mdb->errmsg = 0; mdb->cmd = get_pool_memory(PM_EMSG); /* get command buffer */ diff --git a/bacula/src/cats/mysql.c b/bacula/src/cats/mysql.c index 1045d24c5d..5f950fb5c1 100644 --- a/bacula/src/cats/mysql.c +++ b/bacula/src/cats/mysql.c @@ -113,6 +113,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char mdb->db_socket = bstrdup(db_socket); } mdb->db_port = db_port; + mdb->have_insert_id = true; mdb->errmsg = get_pool_memory(PM_EMSG); /* get error message buffer */ *mdb->errmsg = 0; mdb->cmd = get_pool_memory(PM_EMSG); /* get command buffer */ diff --git a/bacula/src/cats/postgresql.c b/bacula/src/cats/postgresql.c index 693b009d39..c5757efced 100644 --- a/bacula/src/cats/postgresql.c +++ b/bacula/src/cats/postgresql.c @@ -115,6 +115,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char mdb->db_socket = bstrdup(db_socket); } mdb->db_port = db_port; + mdb->have_insert_id = TRUE; mdb->errmsg = get_pool_memory(PM_EMSG); /* get error message buffer */ *mdb->errmsg = 0; mdb->cmd = get_pool_memory(PM_EMSG); /* get command buffer */ diff --git a/bacula/src/cats/sql.c b/bacula/src/cats/sql.c index e4fdfb512a..9d4d580224 100644 --- a/bacula/src/cats/sql.c +++ b/bacula/src/cats/sql.c @@ -269,7 +269,11 @@ InsertDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd) } return 0; } - mdb->num_rows = sql_affected_rows(mdb); + if (mdb->have_insert_id) { + mdb->num_rows = sql_affected_rows(mdb); + } else { + mdb->num_rows = 1; + } if (mdb->num_rows != 1) { char ed1[30]; m_msg(file, line, &mdb->errmsg, _("Insertion problem: affected_rows=%s\n"), diff --git a/bacula/src/cats/sqlite.c b/bacula/src/cats/sqlite.c index 84c33a2155..85bd3258f7 100644 --- a/bacula/src/cats/sqlite.c +++ b/bacula/src/cats/sqlite.c @@ -119,6 +119,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char mdb = (B_DB *) malloc(sizeof(B_DB)); memset(mdb, 0, sizeof(B_DB)); mdb->db_name = bstrdup(db_name); + mdb->have_insert_id = true; mdb->errmsg = get_pool_memory(PM_EMSG); /* get error message buffer */ *mdb->errmsg = 0; mdb->cmd = get_pool_memory(PM_EMSG); /* get command buffer */