]> git.sur5r.net Git - bacula/bacula/commitdiff
Ensure that we always close the transaction in db_big_sql_query()
authorEric Bollengier <eric@eb.homelinux.org>
Fri, 28 Jan 2011 14:00:46 +0000 (15:00 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:39:56 +0000 (14:39 +0200)
bacula/src/cats/postgresql.c

index 1371aa5df9d5923fca19e0425e83278d45e65a09..a0cb1302a1612e87d98c75280e324dbc356b6a1d 100644 (file)
@@ -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;
 }