RTS API Documentation
1.10.11
|
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 | database_interface_handle_callback_exec(database_interface, dih, sql, callback, pdata, err) database_interface->callback_exec_detailed(__FILE__, (char *)__SWITCH_FUNC__, __LINE__, dih, sql, callback, pdata, err) |
#define | database_interface_handle_exec(database_interface, dih, sql, err) database_interface->exec_detailed(__FILE__, (char *)__SWITCH_FUNC__, __LINE__, dih, sql, err) |
#define | SQL_CACHE_TIMEOUT 30 |
#define | SQL_REG_TIMEOUT 15 |
#define | MIN(a, b) (((a) < (b)) ? (a) : (b)) |
#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 * 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_row_size_limited_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 database_interface_handle_callback_exec | ( | database_interface, | |
dih, | |||
sql, | |||
callback, | |||
pdata, | |||
err | |||
) | database_interface->callback_exec_detailed(__FILE__, (char *)__SWITCH_FUNC__, __LINE__, dih, sql, callback, pdata, err) |
Definition at line 79 of file switch_core_sqldb.c.
Referenced by switch_cache_db_execute_sql_callback(), switch_cache_db_execute_sql_callback_err(), switch_cache_db_execute_sql_event_callback(), and switch_cache_db_execute_sql_event_callback_err().
#define database_interface_handle_exec | ( | database_interface, | |
dih, | |||
sql, | |||
err | |||
) | database_interface->exec_detailed(__FILE__, (char *)__SWITCH_FUNC__, __LINE__, dih, sql, err) |
Definition at line 80 of file switch_core_sqldb.c.
Referenced by switch_cache_db_execute_sql_real(), and switch_cache_db_test_reactive_ex().
#define EXEC_NOW |
#define MAX_SQL 5 |
Definition at line 2369 of file switch_core_sqldb.c.
Referenced by core_event_handler().
Definition at line 385 of file switch_core_sqldb.c.
Referenced by _switch_cache_db_get_db_handle_dsn_ex(), and switch_database_available().
#define new_sql | ( | ) | switch_assert(sql_idx+1 < MAX_SQL); if (exists) sql[sql_idx++] |
Definition at line 2370 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 2371 of file switch_core_sqldb.c.
Referenced by core_event_handler().
#define SQL_CACHE_TIMEOUT 30 |
Definition at line 259 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 260 of file switch_core_sqldb.c.
Referenced by switch_core_sql_db_thread().
#define SWITCH_SQL_QUEUE_LEN 100000 |
Definition at line 40 of file switch_core_sqldb.c.
Referenced by switch_sql_queue_manager_init_name().
#define SWITCH_SQL_QUEUE_PAUSE_LEN 90000 |
Definition at line 41 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 507 of file switch_core_sqldb.c.
References add_handle(), CACHE_DB_LEN, switch_database_interface_handle::connection_options, switch_cache_db_database_interface_options_t::connection_string, switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_connection_options_t::core_db_options, create_handle(), switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, switch_cache_db_connection_options_t::database_interface_options, switch_runtime::db_handle_timeout, switch_cache_db_core_db_options_t::db_path, destroy_handle(), switch_cache_db_odbc_options_t::dsn, get_handle(), switch_coredb_handle::handle, switch_database_interface::handle_new, switch_coredb_handle::in_memory, switch_cache_db_core_db_options_t::in_memory, switch_cache_db_handle::last_used, switch_cache_db_database_interface_options_t::make_module_no_unloadable, switch_runtime::max_db_handles, switch_loadable_module_interface::module_name, switch_cache_db_handle::name, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, switch_cache_db_connection_options_t::odbc_options, switch_cache_db_database_interface_options_t::original_dsn, switch_database_interface::parent, switch_cache_db_odbc_options_t::pass, switch_cache_db_handle::pool, switch_cache_db_database_interface_options_t::prefix, PROTECT_INTERFACE, runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, sql_manager, switch_cache_db_type_name(), SWITCH_CHANNEL_ID_LOG, SWITCH_CHANNEL_LOG, switch_core_alloc, switch_core_db_close(), switch_core_db_open_file(), switch_core_db_open_in_memory(), switch_epoch_time_now(), switch_loadable_module_protect(), 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_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_self(), SWITCH_TRUE, switch_yield, switch_cache_db_handle::type, UNPROTECT_INTERFACE, and switch_cache_db_odbc_options_t::user.
Referenced by _switch_cache_db_get_db_handle_dsn_ex(), and switch_cache_db_type_name().
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 427 of file switch_core_sqldb.c.
References _switch_cache_db_get_db_handle_dsn_ex(), and SWITCH_FALSE.
switch_status_t _switch_cache_db_get_db_handle_dsn_ex | ( | switch_cache_db_handle_t ** | dbh, |
const char * | dsn, | ||
switch_bool_t | make_module_no_unloadable, | ||
const char * | file, | ||
const char * | func, | ||
int | line | ||
) |
Definition at line 433 of file switch_core_sqldb.c.
References _switch_cache_db_get_db_handle(), switch_cache_db_database_interface_options_t::connection_string, switch_cache_db_connection_options_t::core_db_options, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_connection_options_t::database_interface_options, switch_cache_db_core_db_options_t::db_path, switch_cache_db_odbc_options_t::dsn, switch_cache_db_core_db_options_t::in_memory, switch_cache_db_database_interface_options_t::make_module_no_unloadable, MIN, switch_cache_db_connection_options_t::odbc_options, switch_cache_db_database_interface_options_t::original_dsn, switch_cache_db_odbc_options_t::pass, switch_cache_db_database_interface_options_t::prefix, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, switch_loadable_module_get_database_interface(), switch_set_string, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, SWITCH_TRUE, switch_cache_db_handle::type, UNPROTECT_INTERFACE, and switch_cache_db_odbc_options_t::user.
Referenced by _switch_cache_db_get_db_handle_dsn(), and _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 235 of file switch_core_sqldb.c.
References _switch_cache_db_get_db_handle_dsn_ex(), switch_runtime::dbname, switch_runtime::odbc_dsn, runtime, sql_manager, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, SWITCH_TRUE, and zstr.
|
static |
Definition at line 104 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 2373 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, key, MAX_SQL, switch_cache_db_handle::name, 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(), switch_cache_db_handle::type, and zstr.
Referenced by switch_core_sqldb_start(), and switch_core_sqldb_stop().
|
static |
Definition at line 82 of file switch_core_sqldb.c.
References switch_cache_db_handle::mutex, switch_cache_db_handle::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 127 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(), and switch_cache_db_database_interface_flush_handles().
|
static |
Definition at line 96 of file switch_core_sqldb.c.
References switch_cache_db_handle::pool, and switch_core_destroy_memory_pool.
Referenced by _switch_cache_db_get_db_handle(), sql_close(), and switch_cache_db_database_interface_flush_handles().
|
static |
Definition at line 1744 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 2061 of file switch_core_sqldb.c.
References switch_database_interface::commit, switch_database_interface_handle::connection_options, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, switch_sql_queue_manager::event_db, switch_sql_queue_manager::inner_post_trans_execute, switch_sql_queue_manager::inner_pre_trans_execute, switch_sql_queue_manager::max_trans, switch_sql_queue_manager::mutex, switch_cache_db_handle::name, switch_cache_db_handle::native_handle, switch_sql_queue_manager::numq, switch_cache_db_native_handle_t::odbc_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_DATABASE_INTERFACE, SCDB_TYPE_ODBC, switch_sql_queue_manager::sql_queue, switch_database_interface::sql_set_auto_commit_attr, 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_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 182 of file switch_core_sqldb.c.
References CDF_PRUNE, switch_cache_db_handle::hash, switch_cache_db_handle::last_user, switch_cache_db_handle::mutex, switch_cache_db_handle::next, 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, and switch_cache_db_handle::use_count.
Referenced by _switch_cache_db_get_db_handle().
|
static |
Definition at line 1150 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 1664 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, switch_cache_db_handle::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 2323 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 1603 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 1575 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_sql_queue_manager::skip_wait, 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 3168 of file switch_core_sqldb.c.
References CF_RECOVERING, CF_RECOVERING_BRIDGE, switch_core_session::channel, CS_INIT, 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_channel_var_true(), 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 263 of file switch_core_sqldb.c.
References CDF_NONEXPIRING, CDF_PRUNE, switch_database_interface_handle::connection_options, switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_handle::creator, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, dbh, del_handle(), destroy_handle(), switch_coredb_handle::handle, switch_database_interface::handle_destroy, 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, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, SQL_CACHE_TIMEOUT, sql_manager, SWITCH_CHANNEL_LOG, switch_cond_next(), switch_core_db_close(), SWITCH_LOG_CRIT, SWITCH_LOG_DEBUG10, switch_log_printf(), switch_mutex_lock(), switch_mutex_trylock(), switch_mutex_unlock(), switch_odbc_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 1627 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, switch_cache_db_handle::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 815 of file switch_core_sqldb.c.
References switch_database_interface::affected_rows, switch_database_interface_handle::connection_options, switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, switch_coredb_handle::handle, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, switch_core_db_changes(), switch_odbc_handle_affected_rows(), and switch_cache_db_handle::type.
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 1394 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_database_interface_flush_handles | ( | switch_database_interface_t * | database_interface | ) |
Definition at line 148 of file switch_core_sqldb.c.
References switch_database_interface_handle::connection_options, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, del_handle(), destroy_handle(), switch_database_interface::handle_destroy, switch_cache_db_handle::mutex, switch_cache_db_handle::name, switch_cache_db_handle::native_handle, switch_cache_db_handle::next, SCDB_TYPE_DATABASE_INTERFACE, sql_manager, SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, switch_log_printf(), switch_mutex_lock(), switch_mutex_trylock(), switch_mutex_unlock(), SWITCH_STATUS_SUCCESS, and switch_cache_db_handle::type.
Referenced by switch_loadable_module_unprocess().
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 379 of file switch_core_sqldb.c.
References switch_cache_db_release_db_handle().
Referenced by switch_cache_db_type_name().
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 799 of file switch_core_sqldb.c.
References switch_cache_db_execute_sql_chunked(), SWITCH_STATUS_FALSE, and switch_cache_db_handle::type.
Referenced by do_flush(), do_trans(), switch_cache_db_create_schema(), switch_cache_db_persistant_execute_trans_full(), switch_cache_db_test_reactive_ex(), 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 864 of file switch_core_sqldb.c.
References switch_database_interface_handle::connection_options, switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, switch_database_interface::exec_string, switch_coredb_handle::handle, memset(), switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, running, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, 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_odbc_handle_exec_string(), SWITCH_ODBC_SUCCESS, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_cache_db_handle::type.
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 1285 of file switch_core_sqldb.c.
References switch_database_interface_handle::connection_options, switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, database_interface_handle_callback_exec, switch_coredb_handle::handle, switch_cache_db_handle::last_used, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, 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_odbc_handle_callback_exec, SWITCH_ODBC_SUCCESS, switch_snprintfv(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_cache_db_handle::type.
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 1333 of file switch_core_sqldb.c.
References switch_database_interface_handle::connection_options, switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, database_interface_handle_callback_exec, switch_coredb_handle::handle, switch_cache_db_handle::last_used, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, helper::pdata, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, 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_odbc_handle_callback_exec, SWITCH_ODBC_SUCCESS, switch_snprintfv(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_cache_db_handle::type.
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 743 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 1165 of file switch_core_sqldb.c.
References helper::callback, switch_database_interface_handle::connection_options, switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, database_interface_handle_callback_exec, switch_coredb_handle::handle, helper_callback(), switch_cache_db_handle::last_used, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, helper::pdata, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, 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_odbc_handle_callback_exec, SWITCH_ODBC_SUCCESS, switch_snprintfv(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_cache_db_handle::type.
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 1217 of file switch_core_sqldb.c.
References helper::callback, switch_database_interface_handle::connection_options, switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, database_interface_handle_callback_exec, switch_coredb_handle::handle, helper_callback(), switch_cache_db_handle::last_used, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, helper::pdata, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, 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_odbc_handle_callback_exec, SWITCH_ODBC_SUCCESS, switch_snprintfv(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_cache_db_handle::type.
Referenced by sql_in_thread().
|
static |
Definition at line 683 of file switch_core_sqldb.c.
References switch_database_interface_handle::connection_options, switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, database_interface_handle_exec, switch_coredb_handle::handle, switch_cache_db_handle::name, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, switch_cache_db_database_interface_options_t::prefix, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, SWITCH_CHANNEL_LOG, switch_core_db_exec(), switch_core_db_free(), SWITCH_CORE_DB_OK, SWITCH_LOG_ERROR, switch_log_printf(), switch_odbc_handle_exec(), SWITCH_ODBC_SUCCESS, 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 343 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 338 of file switch_core_sqldb.c.
References switch_cache_db_handle::type.
Referenced by switch_cache_db_type_name(), 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 840 of file switch_core_sqldb.c.
References switch_cache_db_native_handle_t::core_db_dbh, switch_coredb_handle::handle, switch_cache_db_handle::native_handle, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, SWITCH_CHANNEL_LOG, switch_core_db_load_extension(), SWITCH_LOG_DEBUG, SWITCH_LOG_ERROR, switch_log_printf(), and switch_cache_db_handle::type.
switch_status_t switch_cache_db_persistant_execute | ( | switch_cache_db_handle_t * | dbh, |
const char * | sql, | ||
uint32_t | retries | ||
) |
Definition at line 924 of file switch_core_sqldb.c.
References switch_cache_db_execute_sql_real(), SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, switch_log_printf(), 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 958 of file switch_core_sqldb.c.
References switch_database_interface::commit, switch_database_interface_handle::connection_options, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, switch_database_interface::sql_set_auto_commit_attr, 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_odbc_SQLEndTran(), switch_odbc_SQLSetAutoCommitAttr(), SWITCH_ODBC_SUCCESS, switch_safe_free, switch_snprintfv(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_yield, switch_cache_db_handle::type, 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 349 of file switch_core_sqldb.c.
References switch_database_interface::flush, SCDB_TYPE_DATABASE_INTERFACE, sql_manager, switch_epoch_time_now(), switch_mutex_lock(), and switch_mutex_unlock().
Referenced by sql_in_thread(), switch_cache_db_dismiss_db_handle(), switch_cache_db_type_name(), 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 3935 of file switch_core_sqldb.c.
References CACHE_DB_LEN, CDF_NONEXPIRING, count, 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_test_flag, SWITCH_TRUE, switch_cache_db_handle::total_used_count, switch_cache_db_handle::type, switch_cache_db_handle::use_count, and switch_stream_handle::write_function.
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 1422 of file switch_core_sqldb.c.
References switch_cache_db_test_reactive_ex().
Referenced by switch_core_sqldb_start().
switch_bool_t switch_cache_db_test_reactive_ex | ( | switch_cache_db_handle_t * | dbh, |
const char * | test_sql, | ||
const char * | drop_sql, | ||
const char * | reactive_sql, | ||
const char * | row_size_limited_reactive_sql | ||
) |
Definition at line 1428 of file switch_core_sqldb.c.
References switch_database_interface_handle::connection_options, switch_cache_db_native_handle_t::core_db_dbh, switch_cache_db_database_interface_options_t::database_interface, switch_cache_db_native_handle_t::database_interface_dbh, database_interface_handle_exec, switch_coredb_handle::handle, switch_cache_db_handle::native_handle, switch_cache_db_native_handle_t::odbc_dbh, runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, 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_DATABASE_FLAG_ROW_SIZE_LIMIT, SWITCH_FALSE, SWITCH_LOG_DEBUG, switch_log_printf(), switch_odbc_handle_exec(), SWITCH_ODBC_SUCCESS, switch_snprintfv(), SWITCH_STATUS_SUCCESS, switch_test_flag, SWITCH_TRUE, and switch_cache_db_handle::type.
Referenced by switch_cache_db_test_reactive(), and 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 3465 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_status_t switch_core_check_core_db_dsn | ( | void | ) |
Returns error if no suitable database interface found to serve core db dsn.
Definition at line 422 of file switch_core_sqldb.c.
References switch_runtime::odbc_dsn, runtime, and switch_database_available().
Referenced by switch_core_sqldb_init().
switch_cache_db_handle_type_t switch_core_dbtype | ( | void | ) |
Definition at line 3350 of file switch_core_sqldb.c.
References SCDB_TYPE_CORE_DB, sql_manager, switch_mutex_lock(), switch_mutex_unlock(), and switch_cache_db_handle::type.
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 3520 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 3541 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 3133 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 3270 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 3415 of file switch_core_sqldb.c.
References CF_ANSWERED, CF_RECOVERING, CF_TRACKABLE, CF_TRACKED, CS_SOFT_EXECUTE, switch_core_session::endpoint_interface, switch_endpoint_interface::interface_name, 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().
void switch_core_recovery_untrack | ( | switch_core_session_t * | session, |
switch_bool_t | force | ||
) |
Definition at line 3377 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_clear_flag(), switch_channel_get_state(), switch_channel_test_flag(), switch_core_get_uuid(), switch_core_session_get_channel(), switch_core_session_get_uuid(), SWITCH_FALSE, switch_mprintf(), and switch_sql_queue_manager_push().
Referenced by switch_core_standard_on_hangup().
|
static |
Definition at line 1523 of file switch_core_sqldb.c.
References runtime, SCF_USE_SQL, SQL_CACHE_TIMEOUT, sql_close(), sql_manager, SQL_REG_TIMEOUT, switch_core_expire_registration(), switch_epoch_time_now(), switch_test_flag, SWITCH_THREAD_FUNC, switch_user_sql_thread(), switch_yield, and thread.
Referenced by switch_core_sqldb_start().
void switch_core_sql_exec | ( | const char * | sql | ) |
Definition at line 3363 of file switch_core_sqldb.c.
References runtime, SCF_USE_SQL, sql_manager, switch_sql_queue_manager_push(), switch_test_flag, and SWITCH_TRUE.
Referenced by switch_console_set_complete().
switch_status_t switch_core_sqldb_start | ( | switch_memory_pool_t * | pool, |
switch_bool_t | manage | ||
) |
Definition at line 3565 of file switch_core_sqldb.c.
References basic_calls_sql, CDF_NONEXPIRING, switch_database_interface::commit, core_event_handler(), create_alias_sql, create_calls_sql, create_channels_sql, create_complete_sql, create_interfaces_sql, create_nat_sql, create_registrations_sql, create_row_size_limited_channels_sql, create_tasks_sql, DBTYPE_DEFAULT, detailed_calls_sql, manage, switch_runtime::odbc_dbtype, switch_cache_db_handle::pool, recovery_sql, runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, SCF_CLEAR_SQL, SCF_CORE_NON_SQLITE_DB_REQ, SCF_USE_SQL, db_job::sql, sql_manager, switch_database_interface::sql_set_auto_commit_attr, switch_cache_db_create_schema(), switch_cache_db_execute_sql(), switch_cache_db_execute_sql_real(), switch_cache_db_release_db_handle(), switch_cache_db_test_reactive(), switch_cache_db_test_reactive_ex(), SWITCH_CHANNEL_LOG, switch_clear_flag, switch_core_db_handle, switch_core_get_hostname(), switch_core_get_switchname(), switch_core_sql_db_thread(), switch_core_sqldb_start_thread(), SWITCH_EVENT_ADD_SCHEDULE, SWITCH_EVENT_ALL, switch_event_bind(), 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_LOG, SWITCH_EVENT_MODULE_LOAD, SWITCH_EVENT_MODULE_UNLOAD, SWITCH_EVENT_NAT, SWITCH_EVENT_RE_SCHEDULE, SWITCH_EVENT_SHUTDOWN, SWITCH_EVENT_SUBCLASS_ANY, SWITCH_LOG_CRIT, SWITCH_LOG_ERROR, SWITCH_LOG_INFO, switch_log_printf(), switch_mutex_init(), SWITCH_MUTEX_NESTED, switch_odbc_SQLEndTran(), switch_odbc_SQLSetAutoCommitAttr(), SWITCH_ODBC_SUCCESS, SWITCH_PRI_REALTIME, switch_safe_free, switch_set_flag, switch_snprintfv(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_string_replace(), switch_stristr(), switch_test_flag, switch_thread_create(), SWITCH_THREAD_STACKSIZE, switch_threadattr_create(), switch_threadattr_priority_set(), switch_threadattr_stacksize_set(), and SWITCH_TRUE.
Referenced by switch_core_sqldb_init().
|
static |
Definition at line 3885 of file switch_core_sqldb.c.
References switch_runtime::core_db_inner_post_trans_execute, switch_runtime::core_db_inner_pre_trans_execute, switch_runtime::core_db_post_trans_execute, switch_runtime::core_db_pre_trans_execute, switch_runtime::dbname, switch_runtime::odbc_dsn, runtime, sql_manager, SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_MAX_TRANS, switch_mutex_lock(), switch_mutex_unlock(), switch_sql_queue_manager_init_name(), switch_sql_queue_manager_start(), and zstr.
Referenced by switch_core_sqldb_start().
void switch_core_sqldb_stop | ( | void | ) |
Definition at line 3918 of file switch_core_sqldb.c.
References core_event_handler(), sql_close(), sql_manager, switch_cache_db_flush_handles(), switch_core_sqldb_stop_thread(), switch_event_unbind_callback(), and switch_thread_join().
Referenced by switch_core_sqldb_destroy().
|
static |
Definition at line 3871 of file switch_core_sqldb.c.
References sql_manager, SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), and switch_sql_queue_manager_destroy().
Referenced by switch_core_sqldb_stop().
switch_status_t switch_database_available | ( | char * | dsn | ) |
Returns error if no suitable database interface found for a dsn.
Definition at line 388 of file switch_core_sqldb.c.
References MIN, switch_loadable_module_get_database_interface(), switch_odbc_available(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and UNPROTECT_INTERFACE.
Referenced by switch_core_check_core_db_dsn().
char* switch_sql_concat | ( | void | ) |
This routine is a variant of the "sprintf()" from the standard C library. The resulting string is written into memory obtained from malloc() so that there is never a possiblity of buffer overflow. This routine also implement some additional formatting options that are useful for constructing SQL statements.
The strings returned by this routine should be freed by calling switch_core_db_free().
All of the usual printf formatting options apply. In addition, there is a "%q" option. q works like s in that it substitutes a null-terminated string from the argument list. But q also doubles every '\'' character. q is designed for use inside a string literal. By doubling each '\'' character it escapes that character and allows it to be inserted into the string.
For example, so some string variable contains text as follows:
char *zText = "It's a happy day!";
We can use this text in an SQL statement as follows:
char *z = switch_core_db_mprintf("INSERT INTO TABLES('%q')", zText); switch_core_db_exec(db, z, callback1, 0, 0); switch_core_db_free(z);
Because the q format string is used, the '\'' character in zText is escaped and the SQL generated is as follows:
INSERT INTO table1 VALUES('It''s a happy day!')
This is correct. Had we used s instead of q, the generated SQL would have looked like this:
INSERT INTO table1 VALUES('It's a happy day!');
This second example is an SQL syntax error. As a general rule you should always use q instead of s when inserting text into a string literal.
Definition at line 4009 of file switch_core_sqldb.c.
References DBTYPE_MSSQL, switch_runtime::odbc_dbtype, and runtime.
switch_status_t switch_sql_queue_manager_destroy | ( | switch_sql_queue_manager_t ** | qmp | ) |
Definition at line 1858 of file switch_core_sqldb.c.
References do_flush(), switch_sql_queue_manager::name, switch_sql_queue_manager::numq, switch_cache_db_handle::pool, switch_sql_queue_manager::pool, qm, switch_assert, SWITCH_CHANNEL_LOG, switch_core_destroy_memory_pool, SWITCH_LOG_DEBUG, SWITCH_LOG_INFO, switch_log_printf(), switch_sql_queue_manager_stop(), SWITCH_STATUS_NOOP, and SWITCH_STATUS_SUCCESS.
Referenced by switch_core_sqldb_stop_thread().
void switch_sql_queue_manager_execute_sql_callback | ( | switch_sql_queue_manager_t * | qm, |
const char * | sql, | ||
switch_core_db_callback_func_t | callback, | ||
void * | pdata | ||
) |
Definition at line 1700 of file switch_core_sqldb.c.
References new_job(), and switch_thread_pool_launch_thread().
void switch_sql_queue_manager_execute_sql_callback_err | ( | switch_sql_queue_manager_t * | qm, |
const char * | sql, | ||
switch_core_db_callback_func_t | callback, | ||
switch_core_db_err_callback_func_t | err_callback, | ||
void * | pdata | ||
) |
Definition at line 1710 of file switch_core_sqldb.c.
References new_job(), and switch_thread_pool_launch_thread().
void switch_sql_queue_manager_execute_sql_event_callback | ( | switch_sql_queue_manager_t * | qm, |
const char * | sql, | ||
switch_core_db_event_callback_func_t | callback, | ||
void * | pdata | ||
) |
Definition at line 1721 of file switch_core_sqldb.c.
References new_job(), and switch_thread_pool_launch_thread().
void switch_sql_queue_manager_execute_sql_event_callback_err | ( | switch_sql_queue_manager_t * | qm, |
const char * | sql, | ||
switch_core_db_event_callback_func_t | callback, | ||
switch_core_db_err_callback_func_t | err_callback, | ||
void * | pdata | ||
) |
Definition at line 1731 of file switch_core_sqldb.c.
References new_job(), and switch_thread_pool_launch_thread().
switch_status_t switch_sql_queue_manager_init_name | ( | const char * | name, |
switch_sql_queue_manager_t ** | qmp, | ||
uint32_t | numq, | ||
const char * | dsn, | ||
uint32_t | max_trans, | ||
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 2006 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_sql_queue_manager::dsn, switch_sql_queue_manager::inner_post_trans_execute, switch_sql_queue_manager::inner_pre_trans_execute, switch_sql_queue_manager::max_trans, switch_sql_queue_manager::mutex, switch_sql_queue_manager::name, switch_sql_queue_manager::numq, switch_cache_db_handle::pool, switch_sql_queue_manager::pool, switch_sql_queue_manager::post_trans_execute, switch_sql_queue_manager::pre_trans_execute, switch_sql_queue_manager::pre_written, qm, switch_sql_queue_manager::sql_queue, switch_core_alloc, switch_core_new_memory_pool, switch_core_strdup, switch_mutex_init(), SWITCH_MUTEX_NESTED, switch_queue_create(), SWITCH_SQL_QUEUE_LEN, SWITCH_STATUS_SUCCESS, switch_thread_cond_create(), and switch_sql_queue_manager::written.
Referenced by switch_core_sqldb_start_thread().
void switch_sql_queue_manager_pause | ( | switch_sql_queue_manager_t * | qm, |
switch_bool_t | flush | ||
) |
Definition at line 1773 of file switch_core_sqldb.c.
References do_flush(), switch_sql_queue_manager::mutex, switch_sql_queue_manager::numq, switch_sql_queue_manager::paused, switch_mutex_lock(), and switch_mutex_unlock().
switch_status_t switch_sql_queue_manager_push | ( | switch_sql_queue_manager_t * | qm, |
const char * | sql, | ||
uint32_t | pos, | ||
switch_bool_t | dup | ||
) |
Definition at line 1890 of file switch_core_sqldb.c.
References switch_sql_queue_manager::mutex, switch_sql_queue_manager::numq, qm_wake(), sql_manager, switch_sql_queue_manager::sql_queue, SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_queue_trypush(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_yield, and switch_sql_queue_manager::thread_running.
Referenced by core_event_handler(), switch_core_add_registration(), switch_core_del_registration(), switch_core_expire_registration(), switch_core_recovery_track(), switch_core_recovery_untrack(), and switch_core_sql_exec().
switch_status_t switch_sql_queue_manager_push_confirm | ( | switch_sql_queue_manager_t * | qm, |
const char * | sql, | ||
uint32_t | pos, | ||
switch_bool_t | dup | ||
) |
Definition at line 1932 of file switch_core_sqldb.c.
References switch_sql_queue_manager::confirm, dbh, switch_sql_queue_manager::dsn, switch_sql_queue_manager::mutex, switch_sql_queue_manager::numq, switch_sql_queue_manager::pre_written, qm_wake(), sql_manager, switch_sql_queue_manager::sql_queue, switch_cache_db_execute_sql(), switch_cache_db_get_db_handle_dsn, switch_cache_db_release_db_handle(), SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_queue_push(), switch_sql_queue_manager_size(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_yield, switch_sql_queue_manager::thread_running, and switch_sql_queue_manager::written.
void switch_sql_queue_manager_resume | ( | switch_sql_queue_manager_t * | qm | ) |
Definition at line 1763 of file switch_core_sqldb.c.
References switch_sql_queue_manager::mutex, switch_sql_queue_manager::paused, qm_wake(), switch_mutex_lock(), and switch_mutex_unlock().
int switch_sql_queue_manager_size | ( | switch_sql_queue_manager_t * | qm, |
uint32_t | index | ||
) |
Definition at line 1789 of file switch_core_sqldb.c.
References switch_sql_queue_manager::mutex, switch_sql_queue_manager::sql_queue, switch_mutex_lock(), switch_mutex_unlock(), and switch_queue_size().
Referenced by switch_sql_queue_manager_push_confirm().
switch_status_t switch_sql_queue_manager_start | ( | switch_sql_queue_manager_t * | qm | ) |
Definition at line 1835 of file switch_core_sqldb.c.
References switch_sql_queue_manager::event_db, switch_sql_queue_manager::name, switch_sql_queue_manager::pool, SWITCH_CHANNEL_LOG, switch_cond_next(), SWITCH_LOG_INFO, switch_log_printf(), SWITCH_PRI_NORMAL, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_create(), SWITCH_THREAD_STACKSIZE, switch_threadattr_create(), switch_threadattr_priority_set(), switch_threadattr_stacksize_set(), switch_user_sql_thread(), switch_sql_queue_manager::thread, switch_sql_queue_manager::thread_initiated, and switch_sql_queue_manager::thread_running.
Referenced by switch_core_sqldb_start_thread().
switch_status_t switch_sql_queue_manager_stop | ( | switch_sql_queue_manager_t * | qm | ) |
Definition at line 1802 of file switch_core_sqldb.c.
References switch_sql_queue_manager::name, switch_sql_queue_manager::numq, qm_wake(), switch_sql_queue_manager::sql_queue, SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, switch_log_printf(), switch_queue_interrupt_all(), switch_queue_push(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_join(), switch_yield, switch_sql_queue_manager::thread, and switch_sql_queue_manager::thread_running.
Referenced by switch_sql_queue_manager_destroy().
|
static |
Definition at line 2205 of file switch_core_sqldb.c.
References switch_sql_queue_manager::cond, switch_sql_queue_manager::cond2_mutex, switch_sql_queue_manager::cond_mutex, do_flush(), do_trans(), switch_sql_queue_manager::dsn, switch_sql_queue_manager::event_db, switch_sql_queue_manager::max_trans, switch_sql_queue_manager::name, switch_sql_queue_manager::numq, switch_sql_queue_manager::paused, qm, qm_ttl(), runtime, SCDB_TYPE_CORE_DB, SCDB_TYPE_DATABASE_INTERFACE, SCDB_TYPE_ODBC, SCF_DEBUG_SQL, switch_sql_queue_manager::skip_wait, sql_manager, switch_sql_queue_manager::sql_queue, switch_cache_db_execute_sql(), switch_cache_db_get_db_handle_dsn, switch_cache_db_release_db_handle(), SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, switch_log_printf(), SWITCH_LOG_WARNING, switch_mutex_lock(), switch_mutex_unlock(), switch_queue_size(), switch_snprintf(), SWITCH_STATUS_SUCCESS, switch_test_flag, switch_thread_cond_wait(), switch_yield, switch_sql_queue_manager::thread_initiated, switch_sql_queue_manager::thread_running, and switch_cache_db_handle::type.
Referenced by switch_core_sql_db_thread(), and switch_sql_queue_manager_start().
|
static |
Definition at line 3078 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2845 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2937 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2853 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2829 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2947 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2968 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2977 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2895 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
|
static |
Definition at line 2958 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
switch_mutex_t* ctl_mutex |
Definition at line 66 of file switch_core_sqldb.c.
switch_thread_t* db_thread |
Definition at line 62 of file switch_core_sqldb.c.
int db_thread_running |
Definition at line 63 of file switch_core_sqldb.c.
Definition at line 70 of file switch_core_sqldb.c.
Referenced by add_handle(), sql_close(), sql_in_thread(), switch_cache_db_status(), switch_cache_db_type_name(), switch_core_recovery_flush(), switch_core_recovery_recover(), and switch_sql_queue_manager_push_confirm().
switch_mutex_t* dbh_mutex |
Definition at line 65 of file switch_core_sqldb.c.
|
static |
Definition at line 2995 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
switch_cache_db_handle_t* handle_pool |
Definition at line 67 of file switch_core_sqldb.c.
switch_bool_t manage |
Definition at line 64 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
switch_memory_pool_t* memory_pool |
Definition at line 61 of file switch_core_sqldb.c.
int paused |
Definition at line 72 of file switch_core_sqldb.c.
Definition at line 71 of file switch_core_sqldb.c.
Referenced by new_job(), switch_sql_queue_manager_destroy(), switch_sql_queue_manager_init_name(), and switch_user_sql_thread().
|
static |
Definition at line 3068 of file switch_core_sqldb.c.
Referenced by switch_core_sqldb_start().
struct { ... } sql_manager |
Referenced by _switch_cache_db_get_db_handle(), _switch_core_db_handle(), add_handle(), core_event_handler(), del_handle(), get_handle(), sql_close(), switch_cache_db_database_interface_flush_handles(), switch_cache_db_release_db_handle(), switch_cache_db_status(), switch_core_add_registration(), switch_core_dbtype(), switch_core_del_registration(), switch_core_expire_registration(), switch_core_recovery_recover(), switch_core_recovery_track(), switch_core_recovery_untrack(), switch_core_sql_db_thread(), switch_core_sql_exec(), switch_core_sqldb_pause(), switch_core_sqldb_resume(), switch_core_sqldb_start(), switch_core_sqldb_start_thread(), switch_core_sqldb_stop(), switch_core_sqldb_stop_thread(), switch_sql_queue_manager_push(), switch_sql_queue_manager_push_confirm(), and switch_user_sql_thread().
uint32_t total_handles |
Definition at line 68 of file switch_core_sqldb.c.
uint32_t total_used_handles |
Definition at line 69 of file switch_core_sqldb.c.