diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index 196f10e4f2..f1d58688e4 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -261,6 +261,8 @@ struct switch_runtime { uint32_t db_handle_timeout; int cpu_count; uint32_t time_sync; + char *core_db_pre_trans_execute; + char *core_db_post_trans_execute; }; extern struct switch_runtime runtime; diff --git a/src/switch_core.c b/src/switch_core.c index a7259ce18d..5f47c68f0e 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1723,6 +1723,10 @@ static void switch_load_core_config(const char *file) switch_set_flag((&runtime), SCF_EARLY_HANGUP); } else if (!strcasecmp(var, "colorize-console") && switch_true(val)) { runtime.colorize_console = SWITCH_TRUE; + } else if (!strcasecmp(var, "core-db-pre-trans-execute") && !zstr(val)) { + runtime.core_db_pre_trans_execute = switch_core_strdup(runtime.memory_pool, val); + } else if (!strcasecmp(var, "core-db-post-trans-execute") && !zstr(val)) { + runtime.core_db_post_trans_execute = switch_core_strdup(runtime.memory_pool, val); } else if (!strcasecmp(var, "mailer-app") && !zstr(val)) { runtime.mailer_app = switch_core_strdup(runtime.memory_pool, val); } else if (!strcasecmp(var, "mailer-app-args") && val) { diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index d436c60596..eed753b840 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -731,6 +731,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_ if (io_mutex) switch_mutex_lock(io_mutex); + if (!zstr(runtime.core_db_pre_trans_execute)) { + switch_cache_db_execute_sql_real(dbh, runtime.core_db_pre_trans_execute, &errmsg); + if (errmsg) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL PRE TRANS EXEC [%s]\n", errmsg); + free(errmsg); + } + } + again: while (begin_retries > 0) { @@ -810,6 +818,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_ switch_odbc_SQLSetAutoCommitAttr(dbh->native_handle.odbc_dbh, 1); } + if (!zstr(runtime.core_db_post_trans_execute)) { + switch_cache_db_execute_sql_real(dbh, runtime.core_db_post_trans_execute, &errmsg); + if (errmsg) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL POST TRANS EXEC [%s]\n", errmsg); + free(errmsg); + } + } + if (io_mutex) switch_mutex_unlock(io_mutex); return status;