add auto-create-schemas param to switch.conf.xml
This commit is contained in:
parent
0ec9ffe649
commit
a11f4e4fb3
|
@ -252,7 +252,8 @@ typedef enum {
|
|||
SCF_USE_HEAVY_TIMING = (1 << 9),
|
||||
SCF_USE_CLOCK_RT = (1 << 10),
|
||||
SCF_VERBOSE_EVENTS = (1 << 11),
|
||||
SCF_USE_WIN32_MONOTONIC = (1 << 12)
|
||||
SCF_USE_WIN32_MONOTONIC = (1 << 12),
|
||||
SCF_AUTO_SCHEMAS = (1 << 13)
|
||||
} switch_core_flag_enum_t;
|
||||
typedef uint32_t switch_core_flag_t;
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include "mod_sofia.h"
|
||||
#include <switch_stun.h>
|
||||
|
||||
switch_cache_db_handle_t *sofia_glue_get_db_handle(sofia_profile_t *profile);
|
||||
|
||||
|
||||
void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *t38_options, int insist)
|
||||
{
|
||||
|
@ -4683,8 +4685,6 @@ void sofia_glue_tech_track(sofia_profile_t *profile, switch_core_session_t *sess
|
|||
int sofia_glue_init_sql(sofia_profile_t *profile)
|
||||
{
|
||||
char *test_sql = NULL;
|
||||
switch_core_db_t *db = NULL;
|
||||
switch_odbc_handle_t *odbc_dbh = NULL;
|
||||
|
||||
char reg_sql[] =
|
||||
"CREATE TABLE sip_registrations (\n"
|
||||
|
@ -4813,295 +4813,138 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
|||
" expires INTEGER\n"
|
||||
");\n";
|
||||
|
||||
if (switch_odbc_available() && profile->odbc_dsn) {
|
||||
int x;
|
||||
char *indexes[] = {
|
||||
"create index sr_call_id on sip_registrations (call_id)",
|
||||
"create index sr_sip_user on sip_registrations (sip_user)",
|
||||
"create index sr_sip_host on sip_registrations (sip_host)",
|
||||
"create index sr_profile_name on sip_registrations (profile_name)",
|
||||
"create index sr_presence_hosts on sip_registrations (presence_hosts)",
|
||||
"create index sr_contact on sip_registrations (contact)",
|
||||
"create index sr_expires on sip_registrations (expires)",
|
||||
"create index sr_hostname on sip_registrations (hostname)",
|
||||
"create index sr_status on sip_registrations (status)",
|
||||
"create index sr_network_ip on sip_registrations (network_ip)",
|
||||
"create index sr_network_port on sip_registrations (network_port)",
|
||||
"create index sr_sip_username on sip_registrations (sip_username)",
|
||||
"create index sr_sip_realm on sip_registrations (sip_realm)",
|
||||
"create index sr_orig_server_host on sip_registrations (orig_server_host)",
|
||||
"create index sr_orig_hostname on sip_registrations (orig_hostname)",
|
||||
"create index ss_call_id on sip_subscriptions (call_id)",
|
||||
"create index ss_hostname on sip_subscriptions (hostname)",
|
||||
"create index ss_network_ip on sip_subscriptions (network_ip)",
|
||||
"create index ss_sip_user on sip_subscriptions (sip_user)",
|
||||
"create index ss_sip_host on sip_subscriptions (sip_host)",
|
||||
"create index ss_presence_hosts on sip_subscriptions (presence_hosts)",
|
||||
"create index ss_event on sip_subscriptions (event)",
|
||||
"create index ss_proto on sip_subscriptions (proto)",
|
||||
"create index ss_sub_to_user on sip_subscriptions (sub_to_user)",
|
||||
"create index ss_sub_to_host on sip_subscriptions (sub_to_host)",
|
||||
"create index sd_uuid on sip_dialogs (uuid)",
|
||||
"create index sd_hostname on sip_dialogs (hostname)",
|
||||
"create index sd_presence_data on sip_dialogs (presence_data)",
|
||||
"create index sd_call_info on sip_dialogs (call_info)",
|
||||
"create index sd_call_info_state on sip_dialogs (call_info_state)",
|
||||
"create index sd_expires on sip_dialogs (expires)",
|
||||
"create index sp_hostname on sip_presence (hostname)",
|
||||
"create index sa_nonce on sip_authentication (nonce)",
|
||||
"create index sa_hostname on sip_authentication (hostname)",
|
||||
"create index ssa_hostname on sip_shared_appearance_subscriptions (hostname)",
|
||||
"create index ssa_network_ip on sip_shared_appearance_subscriptions (network_ip)",
|
||||
"create index ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)",
|
||||
"create index ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)",
|
||||
"create index ssa_aor on sip_shared_appearance_subscriptions (aor)",
|
||||
"create index ssd_profile_name on sip_shared_appearance_dialogs (profile_name)",
|
||||
"create index ssd_hostname on sip_shared_appearance_dialogs (hostname)",
|
||||
"create index ssd_contact_str on sip_shared_appearance_dialogs (contact_str)",
|
||||
"create index ssd_call_id on sip_shared_appearance_dialogs (call_id)",
|
||||
"create index ssd_expires on sip_shared_appearance_dialogs (expires)",
|
||||
"create index sr_1 on sip_recovery (runtime_uuid)",
|
||||
"create index sr_2 on sip_recovery (profile_name)",
|
||||
"create index sr_3 on sip_recovery (hostname)",
|
||||
"create index sr_4 on sip_recovery (uuid)",
|
||||
NULL
|
||||
};
|
||||
|
||||
int x;
|
||||
char *indexes[] = {
|
||||
"create index sr_call_id on sip_registrations (call_id)",
|
||||
"create index sr_sip_user on sip_registrations (sip_user)",
|
||||
"create index sr_sip_host on sip_registrations (sip_host)",
|
||||
"create index sr_profile_name on sip_registrations (profile_name)",
|
||||
"create index sr_presence_hosts on sip_registrations (presence_hosts)",
|
||||
"create index sr_contact on sip_registrations (contact)",
|
||||
"create index sr_expires on sip_registrations (expires)",
|
||||
"create index sr_hostname on sip_registrations (hostname)",
|
||||
"create index sr_status on sip_registrations (status)",
|
||||
"create index sr_network_ip on sip_registrations (network_ip)",
|
||||
"create index sr_network_port on sip_registrations (network_port)",
|
||||
"create index sr_sip_username on sip_registrations (sip_username)",
|
||||
"create index sr_sip_realm on sip_registrations (sip_realm)",
|
||||
"create index sr_orig_server_host on sip_registrations (orig_server_host)",
|
||||
"create index sr_orig_hostname on sip_registrations (orig_hostname)",
|
||||
"create index ss_call_id on sip_subscriptions (call_id)",
|
||||
"create index ss_hostname on sip_subscriptions (hostname)",
|
||||
"create index ss_network_ip on sip_subscriptions (network_ip)",
|
||||
"create index ss_sip_user on sip_subscriptions (sip_user)",
|
||||
"create index ss_sip_host on sip_subscriptions (sip_host)",
|
||||
"create index ss_presence_hosts on sip_subscriptions (presence_hosts)",
|
||||
"create index ss_event on sip_subscriptions (event)",
|
||||
"create index ss_proto on sip_subscriptions (proto)",
|
||||
"create index ss_sub_to_user on sip_subscriptions (sub_to_user)",
|
||||
"create index ss_sub_to_host on sip_subscriptions (sub_to_host)",
|
||||
"create index sd_uuid on sip_dialogs (uuid)",
|
||||
"create index sd_hostname on sip_dialogs (hostname)",
|
||||
"create index sd_presence_data on sip_dialogs (presence_data)",
|
||||
"create index sd_call_info on sip_dialogs (call_info)",
|
||||
"create index sd_call_info_state on sip_dialogs (call_info_state)",
|
||||
"create index sd_expires on sip_dialogs (expires)",
|
||||
"create index sp_hostname on sip_presence (hostname)",
|
||||
"create index sa_nonce on sip_authentication (nonce)",
|
||||
"create index sa_hostname on sip_authentication (hostname)",
|
||||
"create index ssa_hostname on sip_shared_appearance_subscriptions (hostname)",
|
||||
"create index ssa_network_ip on sip_shared_appearance_subscriptions (network_ip)",
|
||||
"create index ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)",
|
||||
"create index ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)",
|
||||
"create index ssa_aor on sip_shared_appearance_subscriptions (aor)",
|
||||
"create index ssd_profile_name on sip_shared_appearance_dialogs (profile_name)",
|
||||
"create index ssd_hostname on sip_shared_appearance_dialogs (hostname)",
|
||||
"create index ssd_contact_str on sip_shared_appearance_dialogs (contact_str)",
|
||||
"create index ssd_call_id on sip_shared_appearance_dialogs (call_id)",
|
||||
"create index ssd_expires on sip_shared_appearance_dialogs (expires)",
|
||||
"create index sr_1 on sip_recovery (runtime_uuid)",
|
||||
"create index sr_2 on sip_recovery (profile_name)",
|
||||
"create index sr_3 on sip_recovery (hostname)",
|
||||
"create index sr_4 on sip_recovery (uuid)",
|
||||
NULL
|
||||
};
|
||||
|
||||
switch_cache_db_handle_t *dbh = sofia_glue_get_db_handle(profile);
|
||||
|
||||
if (!dbh) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_registrations where (contact like '%%TCP%%' "
|
||||
"or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' "
|
||||
"and network_ip like '%%' and network_port like '%%' and sip_username "
|
||||
"like '%%' and mwi_user like '%%' and mwi_host like '%%' "
|
||||
"and orig_server_host like '%%' and orig_hostname like '%%'", mod_sofia_globals.hostname);
|
||||
|
||||
|
||||
if (!(odbc_dbh = switch_odbc_handle_new(profile->odbc_dsn, profile->odbc_user, profile->odbc_pass))) {
|
||||
return 0;
|
||||
switch_cache_db_test_reactive(dbh, test_sql, "drop table sip_registrations", reg_sql);
|
||||
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
|
||||
char *test2 = switch_mprintf("%s;%s", test_sql, test_sql);
|
||||
|
||||
if (switch_cache_db_execute_sql(dbh, test2, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "GREAT SCOTT!!! Cannot execute batched statements!\n"
|
||||
"If you are using mysql, make sure you are using MYODBC 3.51.18 or higher and enable FLAG_MULTI_STATEMENTS\n");
|
||||
sofia_clear_pflag(profile, PFLAG_SQL_IN_TRANS);
|
||||
|
||||
}
|
||||
|
||||
if (switch_odbc_handle_connect(odbc_dbh) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Connecting ODBC DSN: %s\n", profile->odbc_dsn);
|
||||
switch_odbc_handle_destroy(&odbc_dbh);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", profile->odbc_dsn);
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_registrations where (contact like '%%TCP%%' "
|
||||
"or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' "
|
||||
"and network_ip like '%%' and network_port like '%%' and sip_username "
|
||||
"like '%%' and mwi_user like '%%' and mwi_host like '%%' "
|
||||
"and orig_server_host like '%%' and orig_hostname like '%%'", mod_sofia_globals.hostname);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_registrations", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, reg_sql, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
|
||||
char *test2 = switch_mprintf("%s;%s", test_sql, test_sql);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test2, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "GREAT SCOTT!!! Cannot execute batched statements!\n"
|
||||
"If you are using mysql, make sure you are using MYODBC 3.51.18 or higher and enable FLAG_MULTI_STATEMENTS\n");
|
||||
sofia_clear_pflag(profile, PFLAG_SQL_IN_TRANS);
|
||||
|
||||
}
|
||||
free(test2);
|
||||
}
|
||||
|
||||
free(test_sql);
|
||||
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip like '%%' and network_port like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_subscriptions", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, sub_sql, NULL, NULL);
|
||||
}
|
||||
|
||||
free(test_sql);
|
||||
test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and expires <> -9999 or rpid=''", mod_sofia_globals.hostname);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_dialogs", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, dialog_sql, NULL, NULL);
|
||||
}
|
||||
|
||||
free(test_sql);
|
||||
test_sql = switch_mprintf("delete from sip_presence where hostname='%q' or open_closed=''", mod_sofia_globals.hostname);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_presence", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, pres_sql, NULL, NULL);
|
||||
}
|
||||
|
||||
free(test_sql);
|
||||
test_sql = switch_mprintf("delete from sip_authentication where hostname='%q' or last_nc >= 0", mod_sofia_globals.hostname);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_authentication", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, auth_sql, NULL, NULL);
|
||||
}
|
||||
free(test_sql);
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str='' or hostname='%q' and network_ip like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_shared_appearance_subscriptions", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, shared_appearance_sql, NULL, NULL);
|
||||
}
|
||||
free(test_sql);
|
||||
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_shared_appearance_dialogs where contact_str='' or hostname='%q' and network_ip like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_shared_appearance_dialogs", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, shared_appearance_dialogs_sql, NULL, NULL);
|
||||
}
|
||||
free(test_sql);
|
||||
|
||||
|
||||
|
||||
test_sql = switch_mprintf("select count(profile_name) from sip_recovery where hostname='%q'", mod_sofia_globals.hostname);
|
||||
|
||||
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_recovery", NULL, NULL);
|
||||
switch_odbc_handle_exec(odbc_dbh, recovery_sql, NULL, NULL);
|
||||
}
|
||||
|
||||
free(test_sql);
|
||||
|
||||
|
||||
|
||||
for (x = 0; indexes[x]; x++) {
|
||||
switch_odbc_handle_exec(odbc_dbh, indexes[x], NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
} else if (profile->odbc_dsn) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
||||
} else {
|
||||
if (!(db = switch_core_db_open_file(profile->dbname))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_registrations where (contact like '%%TCP%%' "
|
||||
"or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' "
|
||||
"and network_ip like '%%' and network_port like '%%' and sip_username "
|
||||
"like '%%' and mwi_user like '%%' and mwi_host like '%%' "
|
||||
"and orig_server_host like '%%' and orig_hostname like '%%'", mod_sofia_globals.hostname);
|
||||
|
||||
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_registrations", reg_sql);
|
||||
free(test_sql);
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip like '%%' or network_port like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_subscriptions", sub_sql);
|
||||
free(test_sql);
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and expires <> -9999 or rpid=''", mod_sofia_globals.hostname);
|
||||
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_dialogs", dialog_sql);
|
||||
free(test_sql);
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_presence where hostname='%q' or open_closed=''", mod_sofia_globals.hostname);
|
||||
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_presence", pres_sql);
|
||||
free(test_sql);
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_authentication where hostname='%q' or last_nc >= 0", mod_sofia_globals.hostname);
|
||||
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_authentication", auth_sql);
|
||||
free(test_sql);
|
||||
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str = '' or hostname='%q' and network_ip like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql);
|
||||
free(test_sql);
|
||||
|
||||
test_sql =
|
||||
switch_mprintf("delete from sip_shared_appearance_dialogs where contact_str = '' or hostname='%q' and network_ip like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_shared_appearance_dialogs", shared_appearance_dialogs_sql);
|
||||
free(test_sql);
|
||||
|
||||
|
||||
test_sql = switch_mprintf("select count(profile_name) from sip_recovery where hostname='%q'", mod_sofia_globals.hostname);
|
||||
|
||||
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_recovery", recovery_sql);
|
||||
free(test_sql);
|
||||
|
||||
|
||||
switch_core_db_exec(db, "create index if not exists ssa_hostname on sip_shared_appearance_subscriptions (hostname)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ssa_aor on sip_shared_appearance_subscriptions (aor)", NULL, NULL, NULL);
|
||||
|
||||
|
||||
switch_core_db_exec(db, "create index if not exists ssd_profile_name on sip_shared_appearance_dialogs (profile_name)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ssd_hostname on sip_shared_appearance_dialogs (hostname)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ssd_network_ip on sip_shared_appearance_dialogs (network_ip)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ssd_contact_str on sip_shared_appearance_dialogs (contact_str)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ssd_call_id on sip_shared_appearance_dialogs (call_id)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ssd_expires on sip_shared_appearance_dialogs (expires)", NULL, NULL, NULL);
|
||||
|
||||
|
||||
|
||||
switch_core_db_exec(db, "create index if not exists sr_call_id on sip_registrations (call_id)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_sip_user on sip_registrations (sip_user)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_sip_host on sip_registrations (sip_host)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_profile_name on sip_registrations (profile_name)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_presence_hosts on sip_registrations (presence_hosts)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_contact on sip_registrations (contact)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_expires on sip_registrations (expires)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_hostname on sip_registrations (hostname)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_status on sip_registrations (status)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_network_ip on sip_registrations (network_ip)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_network_port on sip_registrations (network_port)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_sip_username on sip_registrations (sip_username)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_sip_realm on sip_registrations (sip_realm)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_orig_server_host on sip_registrations (orig_server_host)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_orig_hostname on sip_registrations (orig_hostname)", NULL, NULL, NULL);
|
||||
|
||||
|
||||
switch_core_db_exec(db, "create index if not exists ss_call_id on sip_subscriptions (call_id)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ss_hostname on sip_subscriptions (hostname)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ss_network_ip on sip_subscriptions (network_ip)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ss_sip_user on sip_subscriptions (sip_user)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ss_sip_host on sip_subscriptions (sip_host)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ss_presence_hosts on sip_subscriptions (presence_hosts)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ss_event on sip_subscriptions (event)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ss_proto on sip_subscriptions (proto)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ss_sub_to_user on sip_subscriptions (sub_to_user)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists ss_sub_to_host on sip_subscriptions (sub_to_host)", NULL, NULL, NULL);
|
||||
|
||||
switch_core_db_exec(db, "create index if not exists sd_uuid on sip_dialogs (uuid)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sd_hostname on sip_dialogs (hostname)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sd_contact on sip_dialogs (contact)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sd_presence_id on sip_dialogs (presence_id)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sd_presence_data on sip_dialogs (presence_data)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sd_call_info on sip_dialogs (call_info)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sd_call_info_state on sip_dialogs (call_info_state)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sd_expires on sip_dialogs (expires)", NULL, NULL, NULL);
|
||||
|
||||
switch_core_db_exec(db, "create index if not exists sp_hostname on sip_presence (hostname)", NULL, NULL, NULL);
|
||||
|
||||
switch_core_db_exec(db, "create index if not exists sa_nonce on sip_authentication (nonce)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sa_hostname on sip_authentication (hostname)", NULL, NULL, NULL);
|
||||
|
||||
switch_core_db_exec(db, "create index if not exists sr_1 on sip_recovery (runtime_uuid)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_2 on sip_recovery (profile_name)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_3 on sip_recovery (hostname)", NULL, NULL, NULL);
|
||||
switch_core_db_exec(db, "create index if not exists sr_4 on sip_recovery (uuid)", NULL, NULL, NULL);
|
||||
|
||||
free(test2);
|
||||
}
|
||||
|
||||
if (odbc_dbh) {
|
||||
switch_odbc_handle_destroy(&odbc_dbh);
|
||||
return 1;
|
||||
free(test_sql);
|
||||
|
||||
|
||||
test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip like '%%' and network_port like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
switch_cache_db_test_reactive(dbh, test_sql, "DROP TABLE sip_subscriptions", sub_sql);
|
||||
|
||||
free(test_sql);
|
||||
test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and expires <> -9999 or rpid=''", mod_sofia_globals.hostname);
|
||||
|
||||
|
||||
switch_cache_db_test_reactive(dbh, test_sql, "DROP TABLE sip_dialogs", dialog_sql);
|
||||
|
||||
free(test_sql);
|
||||
test_sql = switch_mprintf("delete from sip_presence where hostname='%q' or open_closed=''", mod_sofia_globals.hostname);
|
||||
|
||||
switch_cache_db_test_reactive(dbh, test_sql, "DROP TABLE sip_presence", pres_sql);
|
||||
|
||||
free(test_sql);
|
||||
test_sql = switch_mprintf("delete from sip_authentication where hostname='%q' or last_nc >= 0", mod_sofia_globals.hostname);
|
||||
|
||||
switch_cache_db_test_reactive(dbh, test_sql, "DROP TABLE sip_authentication", auth_sql);
|
||||
|
||||
free(test_sql);
|
||||
test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str='' or hostname='%q' and network_ip like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
|
||||
switch_cache_db_test_reactive(dbh, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql);
|
||||
|
||||
free(test_sql);
|
||||
test_sql = switch_mprintf("delete from sip_shared_appearance_dialogs where contact_str='' or hostname='%q' and network_ip like '%%'",
|
||||
mod_sofia_globals.hostname);
|
||||
|
||||
switch_cache_db_test_reactive(dbh, test_sql, "DROP TABLE sip_shared_appearance_dialogs", shared_appearance_dialogs_sql);
|
||||
|
||||
free(test_sql);
|
||||
test_sql = switch_mprintf("select count(profile_name) from sip_recovery where hostname='%q'", mod_sofia_globals.hostname);
|
||||
|
||||
|
||||
switch_cache_db_test_reactive(dbh, test_sql, "DROP TABLE sip_recovery", recovery_sql);
|
||||
free(test_sql);
|
||||
|
||||
for (x = 0; indexes[x]; x++) {
|
||||
switch_cache_db_execute_sql(dbh, indexes[x], NULL);
|
||||
}
|
||||
|
||||
if (db) {
|
||||
switch_core_db_close(db);
|
||||
return 1;
|
||||
}
|
||||
switch_cache_db_release_db_handle(&dbh);
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1227,6 +1227,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
|
|||
runtime.dummy_cng_frame.datalen = sizeof(runtime.dummy_data);
|
||||
runtime.dummy_cng_frame.buflen = sizeof(runtime.dummy_data);
|
||||
switch_set_flag((&runtime.dummy_cng_frame), SFF_CNG);
|
||||
switch_set_flag((&runtime), SCF_AUTO_SCHEMAS);
|
||||
|
||||
switch_set_flag((&runtime), SCF_NO_NEW_SESSIONS);
|
||||
runtime.hard_log_level = SWITCH_LOG_DEBUG;
|
||||
|
@ -1261,9 +1262,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
|
|||
switch_dir_make_recursive(SWITCH_GLOBAL_dirs.sounds_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
|
||||
switch_dir_make_recursive(SWITCH_GLOBAL_dirs.temp_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
|
||||
|
||||
|
||||
switch_mutex_init(&runtime.uuid_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
|
||||
|
||||
switch_mutex_init(&runtime.throttle_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
|
||||
|
||||
switch_mutex_init(&runtime.session_hash_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
|
||||
switch_mutex_init(&runtime.global_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
|
||||
switch_mutex_init(&runtime.global_var_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
|
||||
|
@ -1272,7 +1275,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
|
|||
switch_event_create_plain(&runtime.global_vars, SWITCH_EVENT_CHANNEL_DATA);
|
||||
switch_core_hash_init(&runtime.mime_types, runtime.memory_pool);
|
||||
load_mime_types();
|
||||
runtime.flags = flags;
|
||||
runtime.flags |= flags;
|
||||
runtime.sps_total = 30;
|
||||
|
||||
*err = NULL;
|
||||
|
@ -1314,9 +1317,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
|
|||
|
||||
runtime.tipping_point = 5000;
|
||||
runtime.timer_affinity = -1;
|
||||
|
||||
switch_load_core_config("switch.conf");
|
||||
|
||||
|
||||
switch_core_state_machine_init(runtime.memory_pool);
|
||||
|
||||
if (switch_core_sqldb_start(runtime.memory_pool, switch_test_flag((&runtime), SCF_USE_SQL) ? SWITCH_TRUE : SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -1435,6 +1438,12 @@ static void switch_load_core_config(const char *file)
|
|||
if (tmp > -1 && tmp < 11) {
|
||||
switch_core_session_ctl(SCSC_DEBUG_LEVEL, &tmp);
|
||||
}
|
||||
} else if (!strcasecmp(var, "auto-create-schemas")) {
|
||||
if (switch_true(val)) {
|
||||
switch_set_flag((&runtime), SCF_AUTO_SCHEMAS);
|
||||
} else {
|
||||
switch_clear_flag((&runtime), SCF_AUTO_SCHEMAS);
|
||||
}
|
||||
} else if (!strcasecmp(var, "enable-early-hangup") && switch_true(val)) {
|
||||
switch_set_flag((&runtime), SCF_EARLY_HANGUP);
|
||||
} else if (!strcasecmp(var, "colorize-console") && switch_true(val)) {
|
||||
|
@ -1553,7 +1562,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t
|
|||
if (switch_core_init(flags, console, err) != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
|
||||
if (runtime.runlevel > 1) {
|
||||
/* one per customer */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
@ -1583,7 +1592,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t
|
|||
#endif
|
||||
signal(SIGHUP, handle_SIGHUP);
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bringing up environment.\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading Modules.\n");
|
||||
if (switch_loadable_module_init() != SWITCH_STATUS_SUCCESS) {
|
||||
|
|
|
@ -196,6 +196,11 @@ SWITCH_DECLARE(void) switch_core_db_test_reactive(switch_core_db_t *db, char *te
|
|||
{
|
||||
char *errmsg;
|
||||
|
||||
if (switch_test_flag((&runtime), SCF_AUTO_SCHEMAS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (db) {
|
||||
if (test_sql) {
|
||||
switch_core_db_exec(db, test_sql, NULL, NULL, &errmsg);
|
||||
|
|
|
@ -784,6 +784,10 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand
|
|||
char *errmsg;
|
||||
switch_bool_t r = SWITCH_TRUE;
|
||||
|
||||
if (!switch_test_flag((&runtime), SCF_AUTO_SCHEMAS)) {
|
||||
return SWITCH_TRUE;
|
||||
}
|
||||
|
||||
if (dbh->io_mutex) {
|
||||
switch_mutex_lock(dbh->io_mutex);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue