]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11989: [Core] Fix database module interface not returning statuses of some operations.
authorAndrey Volk <andywolk@gmail.com>
Fri, 9 Aug 2019 22:01:33 +0000 (02:01 +0400)
committerAndrey Volk <andywolk@gmail.com>
Fri, 9 Aug 2019 23:05:41 +0000 (03:05 +0400)
src/switch_core_sqldb.c

index c642ab3aa26bfd93d467e470380ab8b451dec05b..bda1dd22fd036d3d2fa9c8cb7faedc8389f6995b 100644 (file)
@@ -818,6 +818,7 @@ SWITCH_DECLARE(int) switch_cache_db_affected_rows(switch_cache_db_handle_t *dbh)
                        switch_database_interface_t *database_interface = dbh->native_handle.database_interface_dbh->connection_options.database_interface;
                        int affected_rows = 0;
                        database_interface->affected_rows(dbh->native_handle.database_interface_dbh, &affected_rows);
+                       return affected_rows;
                }
                break;
        }
@@ -1188,11 +1189,10 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_event_callback(switc
                case SCDB_TYPE_DATABASE_INTERFACE:
                {
                        switch_database_interface_t *database_interface = dbh->native_handle.database_interface_dbh->connection_options.database_interface;
-                       switch_status_t result;
 
-                       if ((result = database_interface_handle_callback_exec(database_interface, dbh->native_handle.database_interface_dbh, sql, helper_callback, &h, err)) != SWITCH_STATUS_SUCCESS) {
+                       if ((status = database_interface_handle_callback_exec(database_interface, dbh->native_handle.database_interface_dbh, sql, helper_callback, &h, err)) != SWITCH_STATUS_SUCCESS) {
                                char tmp[100];
-                               switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to execute_sql_event_callback", result);
+                               switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to execute_sql_event_callback", status);
                        }
                }
                break;
@@ -1249,15 +1249,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_event_callback_err(s
        case SCDB_TYPE_DATABASE_INTERFACE:
                {
                        switch_database_interface_t *database_interface = dbh->native_handle.database_interface_dbh->connection_options.database_interface;
-                       switch_status_t result;
 
-                       if ((result = database_interface_handle_callback_exec(database_interface, dbh->native_handle.database_interface_dbh, sql, helper_callback, &h, err)) != SWITCH_STATUS_SUCCESS) {
+                       if ((status = database_interface_handle_callback_exec(database_interface, dbh->native_handle.database_interface_dbh, sql, helper_callback, &h, err)) != SWITCH_STATUS_SUCCESS) {
                                char tmp[100];
-                               switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to execute_sql_event_callback_err", result);
-                       } else {
-                               if (err && *err) {
-                                       (*err_callback)(pdata, (const char*)*err);
-                               }
+                               switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to execute_sql_event_callback_err", status);
+                       }
+
+                       if (err && *err) {
+                               (*err_callback)(pdata, (const char*)*err);
                        }
                }
                break;
@@ -1316,11 +1315,10 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cach
                case SCDB_TYPE_DATABASE_INTERFACE:
                {
                        switch_database_interface_t *database_interface = dbh->native_handle.database_interface_dbh->connection_options.database_interface;
-                       switch_status_t result;
 
-                       if ((result = database_interface_handle_callback_exec(database_interface, dbh->native_handle.database_interface_dbh, sql, callback, pdata, err)) != SWITCH_STATUS_SUCCESS) {
+                       if ((status = database_interface_handle_callback_exec(database_interface, dbh->native_handle.database_interface_dbh, sql, callback, pdata, err)) != SWITCH_STATUS_SUCCESS) {
                                char tmp[100];
-                               switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to execute_sql_callback", result);
+                               switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to execute_sql_callback", status);
                        }
                }
                break;
@@ -1372,15 +1370,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback_err(switch_
        case SCDB_TYPE_DATABASE_INTERFACE:
                {
                        switch_database_interface_t *database_interface = dbh->native_handle.database_interface_dbh->connection_options.database_interface;
-                       switch_status_t result;
 
-                       if ((result = database_interface_handle_callback_exec(database_interface, dbh->native_handle.database_interface_dbh, sql, callback, pdata, err)) != SWITCH_STATUS_SUCCESS) {
+                       if ((status = database_interface_handle_callback_exec(database_interface, dbh->native_handle.database_interface_dbh, sql, callback, pdata, err)) != SWITCH_STATUS_SUCCESS) {
                                char tmp[100];
-                               switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to execute_sql_callback_err", result);
-                       } else {
-                               if (err && *err) {
-                                       (*err_callback)(pdata, (const char*)*err);
-                               }
+                               switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to execute_sql_callback_err", status);
+                       }
+                       
+                       if (err && *err) {
+                               (*err_callback)(pdata, (const char*)*err);
                        }
                }
                break;