FreeSWITCH API Documentation
1.7.0
|
Go to the source code of this file.
Data Structures | |
struct | switch_cache_db_handle |
struct | helper |
struct | switch_sql_queue_manager |
struct | db_job |
Macros | |
#define | SWITCH_SQL_QUEUE_LEN 100000 |
#define | SWITCH_SQL_QUEUE_PAUSE_LEN 90000 |
#define | SQL_CACHE_TIMEOUT 30 |
#define | SQL_REG_TIMEOUT 15 |
#define | EXEC_NOW |
#define | MAX_SQL 5 |
#define | new_sql() switch_assert(sql_idx+1 < MAX_SQL); if (exists) sql[sql_idx++] |
#define | new_sql_a() switch_assert(sql_idx+1 < MAX_SQL); sql[sql_idx++] |
Variables | |
struct { | |
switch_memory_pool_t * memory_pool | |
switch_thread_t * db_thread | |
int db_thread_running | |
switch_bool_t manage | |
switch_mutex_t * io_mutex | |
switch_mutex_t * dbh_mutex | |
switch_mutex_t * ctl_mutex | |
switch_cache_db_handle_t * handle_pool | |
uint32_t total_handles | |
uint32_t total_used_handles | |
switch_cache_db_handle_t * dbh | |
switch_sql_queue_manager_t * qm | |
int paused | |
} | sql_manager |
static char | create_complete_sql [] |
static char | create_alias_sql [] |
static char | create_channels_sql [] |
static char | create_calls_sql [] |
static char | create_interfaces_sql [] |
static char | create_tasks_sql [] |
static char | create_nat_sql [] |
static char | create_registrations_sql [] |
static char | detailed_calls_sql [] |
static char | recovery_sql [] |
static char | basic_calls_sql [] |
#define EXEC_NOW |
#define MAX_SQL 5 |
Definition at line 2203 of file switch_core_sqldb.c.
Referenced by core_event_handler().
#define new_sql | ( | ) | switch_assert(sql_idx+1 < MAX_SQL); if (exists) sql[sql_idx++] |
Definition at line 2204 of file switch_core_sqldb.c.
Referenced by core_event_handler().
#define new_sql_a | ( | ) | switch_assert(sql_idx+1 < MAX_SQL); sql[sql_idx++] |
Definition at line 2205 of file switch_core_sqldb.c.
Referenced by core_event_handler().
#define SQL_CACHE_TIMEOUT 30 |
Definition at line 208 of file switch_core_sqldb.c.
Referenced by sql_close(), switch_cache_db_execute_sql_callback(), switch_cache_db_execute_sql_callback_err(), switch_cache_db_execute_sql_event_callback(), switch_cache_db_execute_sql_event_callback_err(), switch_cache_db_flush_handles(), and switch_core_sql_db_thread().
#define SQL_REG_TIMEOUT 15 |
Definition at line 209 of file switch_core_sqldb.c.
Referenced by switch_core_sql_db_thread().
#define SWITCH_SQL_QUEUE_LEN 100000 |
Definition at line 39 of file switch_core_sqldb.c.
Referenced by switch_sql_queue_manager_init_name().
#define SWITCH_SQL_QUEUE_PAUSE_LEN 90000 |
Definition at line 40 of file switch_core_sqldb.c.
switch_status_t _switch_cache_db_get_db_handle | ( | switch_cache_db_handle_t ** | dbh, |
switch_cache_db_handle_type_t | type, | ||
switch_cache_db_connection_options_t * | connection_options, | ||
const char * | file, | ||
const char * | func, | ||
int | line | ||
) |
Gets a new cached handle from the pool, potentially creating a new connection. The connection is bound to the thread until it (the thread) terminates unless you dismiss rather than release.
[out] | dbh | The handle |
[in] | type | - ODBC or SQLLITE |
[in] | connection_options | (userid, password, etc) |
Definition at line 384 of file switch_core_sqldb.c.
References add_handle(), CACHE_DB_LEN, switch_cache_db_native_handle_t::core_db_dbh, create_handle(), switch_runtime::db_handle_timeout, get_handle(), switch_cache_db_handle::last_used, switch_runtime::max_db_handles, switch_cache_db_handle::name, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, switch_cache_db_native_handle_t::pgsql_dbh, runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, sql_manager, switch_cache_db_type_name(), SWITCH_CHANNEL_ID_LOG, SWITCH_CHANNEL_LOG, switch_core_db_open_file(), switch_epoch_time_now(), SWITCH_LOG_CRIT, SWITCH_LOG_DEBUG10, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_LOG_WARNING, switch_odbc_available(), switch_odbc_handle_connect(), switch_odbc_handle_destroy(), switch_odbc_handle_new(), SWITCH_ODBC_SUCCESS, switch_pgsql_available(), switch_pgsql_handle_connect(), switch_pgsql_handle_destroy(), switch_pgsql_handle_new(), SWITCH_PGSQL_SUCCESS, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_self(), switch_yield, and switch_cache_db_handle::type.
Referenced by _switch_cache_db_get_db_handle_dsn().
switch_status_t _switch_cache_db_get_db_handle_dsn | ( | switch_cache_db_handle_t ** | dbh, |
const char * | dsn, | ||
const char * | file, | ||
const char * | func, | ||
int | line | ||
) |
Definition at line 335 of file switch_core_sqldb.c.
References _switch_cache_db_get_db_handle(), switch_cache_db_connection_options_t::core_db_options, switch_cache_db_core_db_options_t::db_path, switch_cache_db_odbc_options_t::dsn, switch_cache_db_pgsql_options_t::dsn, switch_cache_db_connection_options_t::odbc_options, switch_cache_db_odbc_options_t::pass, switch_cache_db_connection_options_t::pgsql_options, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, switch_set_string, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_cache_db_odbc_options_t::user.
Referenced by _switch_core_db_handle().
switch_status_t _switch_core_db_handle | ( | switch_cache_db_handle_t ** | dbh, |
const char * | file, | ||
const char * | func, | ||
int | line | ||
) |
Open the default system database.
Definition at line 184 of file switch_core_sqldb.c.
References _switch_cache_db_get_db_handle_dsn(), switch_runtime::dbname, switch_runtime::odbc_dsn, runtime, sql_manager, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and zstr.
|
static |
Definition at line 94 of file switch_core_sqldb.c.
References switch_cache_db_handle::creator, dbh, switch_cache_db_handle::hash, switch_cache_db_handle::mutex, switch_cache_db_handle::name, switch_cache_db_handle::next, sql_manager, switch_ci_hashfunc_default(), switch_mutex_lock(), switch_mutex_unlock(), switch_set_string, switch_cache_db_handle::thread_hash, switch_cache_db_handle::total_used_count, and switch_cache_db_handle::use_count.
Referenced by _switch_cache_db_get_db_handle().
|
static |
Definition at line 2207 of file switch_core_sqldb.c.
References CCS_DOWN, CCS_HANGUP, CS_DESTROY, CS_EXECUTE, CS_HANGUP, CS_INIT, CS_NEW, CS_REPORTING, CS_ROUTING, switch_event::event_id, filename, MAX_SQL, new_sql, new_sql_a, parse_presence_data_cols(), db_job::sql, sql_manager, switch_assert, SWITCH_CHANNEL_LOG, switch_core_get_hostname(), switch_core_get_switchname(), switch_epoch_time_now(), SWITCH_EVENT_ADD_SCHEDULE, SWITCH_EVENT_CALL_SECURE, SWITCH_EVENT_CALL_UPDATE, SWITCH_EVENT_CHANNEL_ANSWER, SWITCH_EVENT_CHANNEL_BRIDGE, SWITCH_EVENT_CHANNEL_CALLSTATE, SWITCH_EVENT_CHANNEL_CREATE, SWITCH_EVENT_CHANNEL_DESTROY, SWITCH_EVENT_CHANNEL_EXECUTE, SWITCH_EVENT_CHANNEL_HOLD, SWITCH_EVENT_CHANNEL_ORIGINATE, SWITCH_EVENT_CHANNEL_PROGRESS_MEDIA, SWITCH_EVENT_CHANNEL_STATE, SWITCH_EVENT_CHANNEL_UNBRIDGE, SWITCH_EVENT_CHANNEL_UNHOLD, SWITCH_EVENT_CHANNEL_UUID, SWITCH_EVENT_CODEC, SWITCH_EVENT_DEL_SCHEDULE, SWITCH_EVENT_EXE_SCHEDULE, switch_event_get_header, switch_event_get_header_nil, SWITCH_EVENT_LOG, SWITCH_EVENT_MODULE_LOAD, SWITCH_EVENT_MODULE_UNLOAD, SWITCH_EVENT_NAT, SWITCH_EVENT_RE_SCHEDULE, SWITCH_EVENT_SHUTDOWN, SWITCH_FALSE, switch_ivr_uuid_exists(), SWITCH_LOG_DEBUG, SWITCH_LOG_ERROR, switch_log_printf(), switch_mprintf(), switch_safe_free, switch_sql_queue_manager_push(), switch_str_nil, switch_stristr(), switch_true(), and zstr.
Referenced by switch_core_sqldb_start(), and switch_core_sqldb_stop().
|
static |
Definition at line 80 of file switch_core_sqldb.c.
References switch_cache_db_handle::mutex, switch_cache_db_handle::pool, pool, switch_core_alloc, switch_core_new_memory_pool, switch_mutex_init(), SWITCH_MUTEX_NESTED, and switch_cache_db_handle::type.
Referenced by _switch_cache_db_get_db_handle().
|
static |
Definition at line 117 of file switch_core_sqldb.c.
References switch_cache_db_handle::next, sql_manager, switch_mutex_lock(), and switch_mutex_unlock().
Referenced by sql_close().
|
static |
Definition at line 1597 of file switch_core_sqldb.c.
References switch_sql_queue_manager::mutex, switch_sql_queue_manager::sql_queue, switch_cache_db_execute_sql(), switch_mutex_lock(), switch_mutex_unlock(), switch_queue_trypop(), switch_safe_free, and SWITCH_STATUS_SUCCESS.
Referenced by switch_sql_queue_manager_destroy(), switch_sql_queue_manager_pause(), and switch_user_sql_thread().
|
static |
Definition at line 1902 of file switch_core_sqldb.c.
References switch_sql_queue_manager::event_db, switch_sql_queue_manager::inner_post_trans_execute, switch_sql_queue_manager::inner_pre_trans_execute, switch_cache_db_handle::io_mutex, io_mutex, switch_sql_queue_manager::max_trans, switch_sql_queue_manager::mutex, switch_cache_db_handle::native_handle, switch_sql_queue_manager::numq, switch_cache_db_native_handle_t::odbc_dbh, switch_cache_db_native_handle_t::pgsql_dbh, switch_sql_queue_manager::post_trans_execute, switch_sql_queue_manager::pre_trans_execute, switch_sql_queue_manager::pre_written, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, switch_sql_queue_manager::sql_queue, switch_cache_db_execute_sql(), switch_cache_db_execute_sql_real(), SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_SQLEndTran(), switch_odbc_SQLSetAutoCommitAttr(), SWITCH_ODBC_SUCCESS, switch_pgsql_finish_results, switch_pgsql_SQLEndTran(), switch_pgsql_SQLSetAutoCommitAttr(), SWITCH_PGSQL_SUCCESS, switch_queue_trypop(), switch_safe_free, switch_snprintfv(), SWITCH_STATUS_SUCCESS, switch_cache_db_handle::type, switch_sql_queue_manager::written, and zstr.
Referenced by switch_user_sql_thread().
|
static |
Definition at line 138 of file switch_core_sqldb.c.
References CDF_PRUNE, switch_cache_db_handle::hash, hash, switch_cache_db_handle::last_user, switch_cache_db_handle::mutex, switch_cache_db_handle::next, SCDB_TYPE_PGSQL, sql_manager, switch_ci_hashfunc_default(), switch_mutex_lock(), switch_mutex_trylock(), switch_mutex_unlock(), switch_set_string, SWITCH_STATUS_SUCCESS, switch_test_flag, switch_cache_db_handle::thread_hash, switch_cache_db_handle::total_used_count, switch_cache_db_handle::type, and switch_cache_db_handle::use_count.
Referenced by _switch_cache_db_get_db_handle().
|
static |
Definition at line 1027 of file switch_core_sqldb.c.
References helper::callback, helper::pdata, switch_event_create_array_pair(), and switch_event_destroy().
Referenced by switch_cache_db_execute_sql_event_callback(), and switch_cache_db_execute_sql_event_callback_err().
|
static |
Definition at line 1517 of file switch_core_sqldb.c.
References db_job::callback, db_job::err_callback, db_job::event_callback, db_job::event_err_callback, switch_thread_data_s::func, switch_thread_data_s::obj, db_job::pdata, pool, db_job::pool, qm, db_job::qm, db_job::sql, sql_in_thread(), switch_core_alloc, switch_core_new_memory_pool, and switch_core_strdup.
Referenced by switch_sql_queue_manager_execute_sql_callback(), switch_sql_queue_manager_execute_sql_callback_err(), switch_sql_queue_manager_execute_sql_event_callback(), and switch_sql_queue_manager_execute_sql_event_callback_err().
|
static |
Definition at line 2157 of file switch_core_sqldb.c.
References switch_stream_handle::data, end_of, if(), switch_event_get_header, switch_event_get_header_nil, switch_safe_free, switch_snprintfv(), switch_split, SWITCH_STANDARD_STREAM, switch_stream_handle::write_function, and zstr.
Referenced by core_event_handler().
|
static |
Definition at line 1456 of file switch_core_sqldb.c.
References switch_sql_queue_manager::numq, switch_sql_queue_manager::sql_queue, and switch_queue_size().
Referenced by switch_user_sql_thread().
|
static |
Definition at line 1429 of file switch_core_sqldb.c.
References switch_sql_queue_manager::cond, switch_sql_queue_manager::cond2_mutex, switch_sql_queue_manager::cond_mutex, switch_cond_next(), switch_mutex_trylock(), switch_mutex_unlock(), SWITCH_STATUS_SUCCESS, and switch_thread_cond_signal().
Referenced by switch_sql_queue_manager_push(), switch_sql_queue_manager_push_confirm(), switch_sql_queue_manager_resume(), and switch_sql_queue_manager_stop().
|
static |
Definition at line 2950 of file switch_core_sqldb.c.
References CF_RECOVERING, CF_RECOVERING_BRIDGE, switch_core_session::channel, CS_INIT, ep, switch_xml::next, switch_endpoint_interface::recover_callback, switch_caller_extension_add_application(), switch_caller_extension_new(), switch_channel_get_name(), switch_channel_get_partner_uuid(), switch_channel_get_variable, SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_caller_extension(), switch_channel_set_flag, switch_channel_set_state, switch_channel_test_flag(), switch_core_get_secondary_recover_callback(), switch_core_media_recover_session(), switch_core_session_get_channel(), switch_core_session_request_xml(), switch_core_session_thread_launch(), switch_loadable_module_get_endpoint_interface(), SWITCH_LOG_NOTICE, switch_log_printf(), SWITCH_LOG_WARNING, SWITCH_TRUE, switch_xml_attr_soft(), switch_xml_child(), switch_xml_free(), switch_xml_parse_str_dynamic(), and UNPROTECT_INTERFACE.
Referenced by switch_core_recovery_recover().
|
static |
Definition at line 212 of file switch_core_sqldb.c.
References CDF_PRUNE, switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_handle::creator, dbh, del_handle(), switch_cache_db_handle::last_used, switch_cache_db_handle::last_user, switch_cache_db_handle::mutex, switch_cache_db_handle::name, switch_cache_db_handle::native_handle, switch_cache_db_handle::next, switch_cache_db_native_handle_t::odbc_dbh, switch_cache_db_native_handle_t::pgsql_dbh, switch_cache_db_handle::pool, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SQL_CACHE_TIMEOUT, sql_manager, SWITCH_CHANNEL_LOG, switch_cond_next(), switch_core_db_close(), switch_core_destroy_memory_pool, SWITCH_LOG_CRIT, SWITCH_LOG_DEBUG10, switch_log_printf(), switch_mutex_lock(), switch_mutex_trylock(), switch_mutex_unlock(), switch_odbc_handle_destroy(), switch_pgsql_handle_destroy(), SWITCH_STATUS_SUCCESS, switch_test_flag, switch_cache_db_handle::type, and switch_cache_db_handle::use_count.
Referenced by switch_cache_db_flush_handles(), switch_core_sql_db_thread(), and switch_core_sqldb_stop().
|
static |
Definition at line 1480 of file switch_core_sqldb.c.
References db_job::callback, dbh, switch_sql_queue_manager::dsn, db_job::err_callback, db_job::event_callback, db_job::event_err_callback, db_job::pdata, pool, db_job::pool, db_job::qm, db_job::sql, switch_cache_db_execute_sql_callback(), switch_cache_db_execute_sql_callback_err(), switch_cache_db_execute_sql_event_callback(), switch_cache_db_execute_sql_event_callback_err(), switch_cache_db_get_db_handle_dsn, switch_cache_db_release_db_handle(), SWITCH_CHANNEL_LOG, switch_core_destroy_memory_pool, SWITCH_LOG_ERROR, switch_log_printf(), switch_safe_free, and SWITCH_STATUS_SUCCESS.
Referenced by new_job().
int switch_cache_db_affected_rows | ( | switch_cache_db_handle_t * | dbh | ) |
Get the affected rows of the last performed query.
[in] | dbh | The handle |
[out] | the | number of affected rows |
Definition at line 688 of file switch_core_sqldb.c.
References SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, switch_core_db_changes(), switch_odbc_handle_affected_rows(), and switch_pgsql_handle_affected_rows().
switch_status_t switch_cache_db_create_schema | ( | switch_cache_db_handle_t * | dbh, |
char * | sql, | ||
char ** | err | ||
) |
Executes the create schema sql.
[in] | dbh | The handle |
[in] | sql | - sql to run |
[out] | err | - Error if it exists |
Definition at line 1271 of file switch_core_sqldb.c.
References runtime, SCF_AUTO_SCHEMAS, switch_assert, switch_cache_db_execute_sql(), SWITCH_STATUS_SUCCESS, and switch_test_flag.
Referenced by switch_core_sqldb_start().
void switch_cache_db_dismiss_db_handle | ( | switch_cache_db_handle_t ** | dbh | ) |
Returns the handle to the pool, immediately available for other threads to use.
[in] | The | handle |
Definition at line 329 of file switch_core_sqldb.c.
References switch_cache_db_release_db_handle().
switch_status_t switch_cache_db_execute_sql | ( | switch_cache_db_handle_t * | dbh, |
char * | sql, | ||
char ** | err | ||
) |
Executes the sql.
[in] | dbh | The handle |
[in] | sql | - sql to run |
[out] | err | - Error if it exists |
Definition at line 666 of file switch_core_sqldb.c.
References io_mutex, switch_cache_db_execute_sql_chunked(), switch_mutex_lock(), switch_mutex_unlock(), and SWITCH_STATUS_FALSE.
Referenced by do_flush(), do_trans(), switch_cache_db_create_schema(), switch_cache_db_persistant_execute_trans_full(), switch_cache_db_test_reactive(), switch_core_recovery_flush(), switch_core_recovery_recover(), switch_core_sqldb_start(), switch_sql_queue_manager_push_confirm(), and switch_user_sql_thread().
char* switch_cache_db_execute_sql2str | ( | switch_cache_db_handle_t * | dbh, |
char * | sql, | ||
char * | str, | ||
size_t | len, | ||
char ** | err | ||
) |
Executes the sql and returns the result as a string.
[in] | dbh | The handle |
[in] | sql | - sql to run |
[out] | str | - buffer for result |
[in] | len | - length of str buffer |
[out] | err | - Error if it exists |
Definition at line 734 of file switch_core_sqldb.c.
References io_mutex, memset(), running, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SWITCH_CHANNEL_LOG, switch_cond_next(), switch_copy_string(), SWITCH_CORE_DB_BUSY, switch_core_db_column_count(), switch_core_db_column_text(), switch_core_db_finalize(), switch_core_db_prepare(), SWITCH_CORE_DB_ROW, switch_core_db_step(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_exec_string(), switch_pgsql_handle_exec_string, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
switch_status_t switch_cache_db_execute_sql_callback | ( | switch_cache_db_handle_t * | dbh, |
const char * | sql, | ||
switch_core_db_callback_func_t | callback, | ||
void * | pdata, | ||
char ** | err | ||
) |
Executes the sql and uses callback for row-by-row processing.
[in] | dbh | The handle |
[in] | sql | - sql to run |
[in] | callback | - function pointer to callback |
[in] | pdata | - data to pass to callback |
[out] | err | - Error if it exists |
Definition at line 1161 of file switch_core_sqldb.c.
References io_mutex, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SQL_CACHE_TIMEOUT, SWITCH_CHANNEL_LOG, SWITCH_CORE_DB_ABORT, switch_core_db_exec(), switch_core_db_free(), SWITCH_CORE_DB_OK, switch_epoch_time_now(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_callback_exec, switch_pgsql_handle_callback_exec, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by sql_in_thread(), switch_console_complete(), switch_console_expand_alias(), switch_console_list_uuid(), and switch_core_recovery_recover().
switch_status_t switch_cache_db_execute_sql_callback_err | ( | switch_cache_db_handle_t * | dbh, |
const char * | sql, | ||
switch_core_db_callback_func_t | callback, | ||
switch_core_db_err_callback_func_t | err_callback, | ||
void * | pdata, | ||
char ** | err | ||
) |
Executes the sql and uses callback for row-by-row processing.
[in] | dbh | The handle |
[in] | sql | - sql to run |
[in] | callback | - function pointer to callback |
[in] | err_callback | - function pointer to callback when error occurs |
[in] | pdata | - data to pass to callback |
[out] | err | - Error if it exists |
Definition at line 1210 of file switch_core_sqldb.c.
References io_mutex, helper::pdata, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SQL_CACHE_TIMEOUT, SWITCH_CHANNEL_LOG, SWITCH_CORE_DB_ABORT, switch_core_db_exec(), switch_core_db_free(), SWITCH_CORE_DB_OK, switch_epoch_time_now(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_callback_exec, switch_pgsql_handle_callback_exec, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by sql_in_thread().
|
static |
OMFG you cruel bastards. Who chooses 64k as a max buffer len for a sql statement, have you ever heard of transactions?
Definition at line 605 of file switch_core_sqldb.c.
References end_of_p, switch_assert, switch_cache_db_execute_sql_real(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by switch_cache_db_execute_sql().
switch_status_t switch_cache_db_execute_sql_event_callback | ( | switch_cache_db_handle_t * | dbh, |
const char * | sql, | ||
switch_core_db_event_callback_func_t | callback, | ||
void * | pdata, | ||
char ** | err | ||
) |
Definition at line 1042 of file switch_core_sqldb.c.
References helper::callback, helper_callback(), io_mutex, helper::pdata, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SQL_CACHE_TIMEOUT, SWITCH_CHANNEL_LOG, SWITCH_CORE_DB_ABORT, switch_core_db_exec(), switch_core_db_free(), SWITCH_CORE_DB_OK, switch_epoch_time_now(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_callback_exec, switch_pgsql_handle_callback_exec, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by sql_in_thread().
switch_status_t switch_cache_db_execute_sql_event_callback_err | ( | switch_cache_db_handle_t * | dbh, |
const char * | sql, | ||
switch_core_db_event_callback_func_t | callback, | ||
switch_core_db_err_callback_func_t | err_callback, | ||
void * | pdata, | ||
char ** | err | ||
) |
Definition at line 1095 of file switch_core_sqldb.c.
References helper::callback, helper_callback(), io_mutex, helper::pdata, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SQL_CACHE_TIMEOUT, SWITCH_CHANNEL_LOG, SWITCH_CORE_DB_ABORT, switch_core_db_exec(), switch_core_db_free(), SWITCH_CORE_DB_OK, switch_epoch_time_now(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_callback_exec, switch_pgsql_handle_callback_exec, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.
Referenced by sql_in_thread().
|
static |
Definition at line 540 of file switch_core_sqldb.c.
References switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_handle::io_mutex, io_mutex, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, switch_cache_db_native_handle_t::pgsql_dbh, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SWITCH_CHANNEL_LOG, switch_core_db_exec(), switch_core_db_free(), SWITCH_CORE_DB_OK, SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_exec(), switch_pgsql_handle_exec, switch_safe_free, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_strdup, switch_stristr(), and switch_cache_db_handle::type.
Referenced by do_trans(), switch_cache_db_execute_sql_chunked(), switch_cache_db_persistant_execute(), switch_cache_db_persistant_execute_trans_full(), and switch_core_sqldb_start().
void switch_cache_db_flush_handles | ( | void | ) |
Definition at line 291 of file switch_core_sqldb.c.
References SQL_CACHE_TIMEOUT, sql_close(), and switch_epoch_time_now().
Referenced by switch_core_session_ctl(), and switch_core_sqldb_stop().
switch_cache_db_handle_type_t switch_cache_db_get_type | ( | switch_cache_db_handle_t * | dbh | ) |
Definition at line 286 of file switch_core_sqldb.c.
Referenced by switch_console_complete(), switch_console_expand_alias(), and switch_console_set_alias().
int switch_cache_db_load_extension | ( | switch_cache_db_handle_t * | dbh, |
const char * | extension | ||
) |
load an external extension to db
[in] | dbh | The handle |
[out] | the | path to the extension |
Definition at line 710 of file switch_core_sqldb.c.
References SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SWITCH_CHANNEL_LOG, switch_core_db_load_extension(), SWITCH_LOG_DEBUG, SWITCH_LOG_ERROR, and switch_log_printf().
switch_status_t switch_cache_db_persistant_execute | ( | switch_cache_db_handle_t * | dbh, |
const char * | sql, | ||
uint32_t | retries | ||
) |
Definition at line 801 of file switch_core_sqldb.c.
References io_mutex, switch_cache_db_execute_sql_real(), SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_safe_free, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_yield.
Referenced by switch_console_set_alias().
switch_status_t switch_cache_db_persistant_execute_trans_full | ( | switch_cache_db_handle_t * | dbh, |
char * | sql, | ||
uint32_t | retries, | ||
const char * | pre_trans_execute, | ||
const char * | post_trans_execute, | ||
const char * | inner_pre_trans_execute, | ||
const char * | inner_post_trans_execute | ||
) |
Definition at line 839 of file switch_core_sqldb.c.
References io_mutex, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, switch_cache_db_execute_sql(), switch_cache_db_execute_sql_real(), SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, SWITCH_LOG_DEBUG, SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_SQLEndTran(), switch_odbc_SQLSetAutoCommitAttr(), SWITCH_ODBC_SUCCESS, switch_pgsql_finish_results, switch_pgsql_SQLEndTran(), switch_pgsql_SQLSetAutoCommitAttr(), SWITCH_PGSQL_SUCCESS, switch_safe_free, switch_snprintfv(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_yield, and zstr.
void switch_cache_db_release_db_handle | ( | switch_cache_db_handle_t ** | dbh | ) |
Returns the handle to the pool, handle is NOT available to other threads until the allocating thread actually terminates.
[in] | The | handle |
Definition at line 297 of file switch_core_sqldb.c.
References SCDB_TYPE_PGSQL, sql_manager, switch_epoch_time_now(), switch_mutex_lock(), switch_mutex_unlock(), and switch_pgsql_flush().
Referenced by sql_in_thread(), switch_cache_db_dismiss_db_handle(), switch_console_complete(), switch_console_expand_alias(), switch_console_list_uuid(), switch_console_set_alias(), switch_core_recovery_flush(), switch_core_recovery_recover(), switch_core_sqldb_start(), switch_sql_queue_manager_push_confirm(), and switch_user_sql_thread().
void switch_cache_db_status | ( | switch_stream_handle_t * | stream | ) |
Provides some feedback as to the status of the db connection pool.
[in] | stream | stream for status |
Definition at line 3716 of file switch_core_sqldb.c.
References CACHE_DB_LEN, switch_cache_db_handle::creator, dbh, switch_cache_db_handle::last_used, switch_cache_db_handle::last_user, memset(), switch_cache_db_handle::mutex, switch_cache_db_handle::name, switch_cache_db_handle::next, sql_manager, switch_cache_db_type_name(), switch_epoch_time_now(), SWITCH_FALSE, switch_mutex_lock(), switch_mutex_trylock(), switch_mutex_unlock(), SWITCH_STATUS_SUCCESS, SWITCH_TRUE, switch_cache_db_handle::total_used_count, switch_cache_db_handle::type, and switch_cache_db_handle::use_count.
switch_bool_t switch_cache_db_test_reactive | ( | switch_cache_db_handle_t * | dbh, |
const char * | test_sql, | ||
const char * | drop_sql, | ||
const char * | reactive_sql | ||
) |
Performs test_sql and if it fails performs drop_sql and reactive_sql.
If auto-clear-sql is disabled, then this function will do nothing and it is assumed that the queries are not needed. If auto-create-schemas is disabled, then just test_sql is executed, but drop_sql and reactive_sql are not.
Otherwise, test_sql gets executed. If that succeeds, then there is nothing to do. Otherwise drop_sql is executed (its result is ignored) and then finally reactive_sql is executed.
Definition at line 1299 of file switch_core_sqldb.c.
References io_mutex, runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC, SCDB_TYPE_PGSQL, SCF_AUTO_SCHEMAS, SCF_CLEAR_SQL, switch_assert, switch_cache_db_execute_sql(), SWITCH_CHANNEL_LOG, switch_core_db_exec(), switch_core_db_free(), SWITCH_FALSE, SWITCH_LOG_DEBUG, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_odbc_handle_exec(), SWITCH_ODBC_SUCCESS, switch_pgsql_handle_exec, SWITCH_PGSQL_SUCCESS, SWITCH_STATUS_SUCCESS, switch_test_flag, and SWITCH_TRUE.
Referenced by switch_core_sqldb_start().
switch_status_t switch_core_add_registration | ( | const char * | user, |
const char * | realm, | ||
const char * | token, | ||
const char * | url, | ||
uint32_t | expires, | ||
const char * | network_ip, | ||
const char * | network_port, | ||
const char * | network_proto, | ||
const char * | metadata | ||
) |
Add user registration.
[in] | user | |
[in] | realm | |
[in] | token | |
[in] | url | - a freeswitch dial string |
[in] | expires | |
[in] | network_ip | |
[in] | network_port | |
[in] | network_proto | - one of tls, tcp, udp |
[in] | metadata | - generic metadata supplied by module |
[out] | err | - Error if it exists |
Definition at line 3244 of file switch_core_sqldb.c.
References switch_runtime::multiple_registrations, runtime, SCF_USE_SQL, db_job::sql, sql_manager, switch_core_get_switchname(), SWITCH_FALSE, switch_mprintf(), switch_sql_queue_manager_push(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_str_nil, switch_test_flag, and zstr.
switch_cache_db_handle_type_t switch_core_dbtype | ( | void | ) |
Definition at line 3129 of file switch_core_sqldb.c.
References SCDB_TYPE_CORE_DB, sql_manager, switch_mutex_lock(), and switch_mutex_unlock().
Referenced by switch_console_set_complete().
switch_status_t switch_core_del_registration | ( | const char * | user, |
const char * | realm, | ||
const char * | token | ||
) |
Delete user registration.
[in] | user | |
[in] | realm | |
[in] | token | |
[out] | err | - Error if it exists |
Definition at line 3299 of file switch_core_sqldb.c.
References switch_runtime::multiple_registrations, runtime, SCF_USE_SQL, db_job::sql, sql_manager, switch_core_get_switchname(), SWITCH_FALSE, switch_mprintf(), switch_sql_queue_manager_push(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_test_flag, and zstr.
switch_status_t switch_core_expire_registration | ( | int | force | ) |
Expire user registrations.
[in] | force | delete all registrations |
[out] | err | - Error if it exists |
Definition at line 3320 of file switch_core_sqldb.c.
References runtime, SCF_USE_SQL, db_job::sql, sql_manager, switch_core_get_switchname(), switch_epoch_time_now(), SWITCH_FALSE, switch_mprintf(), switch_sql_queue_manager_push(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_test_flag.
Referenced by switch_core_sql_db_thread().
void switch_core_recovery_flush | ( | const char * | technology, |
const char * | profile_name | ||
) |
Definition at line 2915 of file switch_core_sqldb.c.
References dbh, db_job::sql, switch_cache_db_execute_sql(), switch_cache_db_release_db_handle(), SWITCH_CHANNEL_LOG, switch_core_db_handle, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_LOG_WARNING, switch_mprintf(), switch_safe_free, SWITCH_STATUS_SUCCESS, and zstr.
Referenced by switch_core_session_ctl().
int switch_core_recovery_recover | ( | const char * | technology, |
const char * | profile_name | ||
) |
Definition at line 3049 of file switch_core_sqldb.c.
References dbh, recover_callback(), db_job::sql, sql_manager, switch_cache_db_execute_sql(), switch_cache_db_execute_sql_callback(), switch_cache_db_release_db_handle(), SWITCH_CHANNEL_LOG, switch_core_db_handle, switch_core_get_uuid(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mprintf(), switch_safe_free, SWITCH_STATUS_SUCCESS, and zstr.
Referenced by switch_core_session_ctl().
void switch_core_recovery_track | ( | switch_core_session_t * | session | ) |
Definition at line 3194 of file switch_core_sqldb.c.
References CF_ANSWERED, CF_RECOVERING, CF_TRACKABLE, CF_TRACKED, CS_SOFT_EXECUTE, db_job::sql, sql_manager, switch_channel_get_state(), switch_channel_get_variable_dup(), switch_channel_set_flag, switch_channel_test_flag(), switch_core_get_switchname(), switch_core_get_uuid(), switch_core_session_get_channel(), switch_core_session_get_uuid(), SWITCH_FALSE, switch_ivr_generate_xml_cdr(), switch_mprintf(), switch_safe_free, switch_sql_queue_manager_push(), SWITCH_STATUS_SUCCESS, switch_str_nil, switch_xml_free(), and switch_xml_toxml_nolock().
Referenced by switch_channel_clear_flag(), switch_channel_perform_mark_answered(), switch_core_media_activate_rtp(), and switch_core_session_perform_receive_message().