]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_pgsql] Fix autocommit not flipping back to on when a transaction ends in mod_pgs...
authorAndrey Volk <andywolk@gmail.com>
Thu, 23 Jan 2020 22:19:46 +0000 (02:19 +0400)
committerAndrey Volk <andywolk@gmail.com>
Wed, 29 Jan 2020 19:55:17 +0000 (23:55 +0400)
src/mod/databases/mod_pgsql/mod_pgsql.c

index 77ac42f0941ae36cb63727c23f7e2a4ba912e0e2..b69d54f497321f6a69f02aa5ad17f04c9f7cc804 100644 (file)
@@ -853,8 +853,8 @@ switch_status_t database_commit(switch_database_interface_handle_t *dih)
                return SWITCH_STATUS_FALSE;
 
        result = pgsql_SQLEndTran(handle, SWITCH_TRUE);
-       result = result && pgsql_SQLSetAutoCommitAttr(dih, SWITCH_TRUE);
-       result = result && pgsql_finish_results(handle);
+       result = pgsql_SQLSetAutoCommitAttr(dih, SWITCH_TRUE) && result;
+       result = pgsql_finish_results(handle) && result;
 
        return result;
 }
@@ -862,6 +862,7 @@ switch_status_t database_commit(switch_database_interface_handle_t *dih)
 switch_status_t database_rollback(switch_database_interface_handle_t *dih)
 {
        switch_pgsql_handle_t *handle;
+       switch_status_t result;
 
        if (!dih) {
                return SWITCH_STATUS_FALSE;
@@ -872,10 +873,11 @@ switch_status_t database_rollback(switch_database_interface_handle_t *dih)
        if (!handle)
                return SWITCH_STATUS_FALSE;
 
-       pgsql_SQLEndTran(handle, SWITCH_FALSE);
-       // Is that enought?
+       result = pgsql_SQLEndTran(handle, SWITCH_FALSE);
+       result = pgsql_SQLSetAutoCommitAttr(dih, SWITCH_TRUE) && result;
+       result = pgsql_finish_results(handle) && result;
 
-       return SWITCH_STATUS_SUCCESS;
+       return result;
 }
 
 switch_status_t pgsql_handle_callback_exec_detailed(const char *file, const char *func, int line,