From: Eric Bollengier Date: Fri, 28 Jan 2011 14:00:46 +0000 (+0100) Subject: Ensure that we always close the transaction in db_big_sql_query() X-Git-Tag: Release-7.0.0~1191 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=03fc78e62a544cb1e1157349868bdbf6ef0288b4;p=bacula%2Fbacula Ensure that we always close the transaction in db_big_sql_query() --- diff --git a/bacula/src/cats/postgresql.c b/bacula/src/cats/postgresql.c index 1371aa5df9..a0cb1302a1 100644 --- a/bacula/src/cats/postgresql.c +++ b/bacula/src/cats/postgresql.c @@ -478,12 +478,12 @@ bool B_DB_POSTGRESQL::db_big_sql_query(const char *query, return db_sql_query(query, result_handler, ctx); } - db_lock(this); - if (!result_handler) { /* no need of big_query without handler */ - goto bail_out; + return false; } + db_lock(this); + if (!in_transaction) { /* CURSOR needs transaction */ sql_query("BEGIN"); } @@ -512,14 +512,14 @@ bool B_DB_POSTGRESQL::db_big_sql_query(const char *query, sql_free_result(); - if (!in_transaction) { - sql_query("COMMIT"); /* end transaction */ - } - Dmsg0(500, "db_big_sql_query finished\n"); retval = true; bail_out: + if (!in_transaction) { + sql_query("COMMIT"); /* end transaction */ + } + db_unlock(this); return retval; }