From 0dc756bafcefc6224fea06e1991656130362ab17 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Fri, 28 Jan 2011 15:00:46 +0100 Subject: [PATCH 1/1] Ensure that we always close the transaction in db_big_sql_query() --- bacula/src/cats/postgresql.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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; } -- 2.39.2