create indexes for ODBC as well
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12235 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
35fd710488
commit
756575788b
|
@ -211,6 +211,21 @@ static switch_status_t do_config()
|
||||||
|
|
||||||
#ifdef SWITCH_HAVE_ODBC
|
#ifdef SWITCH_HAVE_ODBC
|
||||||
if (globals.odbc_dsn) {
|
if (globals.odbc_dsn) {
|
||||||
|
int x;
|
||||||
|
char *indexes[] = {
|
||||||
|
"create index ld_hostname on limit_data (hostname)",
|
||||||
|
"create index ld_uuid on limit_data (uuid)",
|
||||||
|
"create index ld_realm on limit_data (realm)",
|
||||||
|
"create index ld_id on limit_data (id)",
|
||||||
|
"create index dd_realm on db_data (realm)",
|
||||||
|
"create index dd_data_key on db_data (data_key)",
|
||||||
|
"create index gd_groupname on group_data (groupname)",
|
||||||
|
"create index gd_url on group_data (url)",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!(globals.master_odbc = switch_odbc_handle_new(globals.odbc_dsn, odbc_user, odbc_pass))) {
|
if (!(globals.master_odbc = switch_odbc_handle_new(globals.odbc_dsn, odbc_user, odbc_pass))) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
|
||||||
status = SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
|
@ -238,6 +253,10 @@ static switch_status_t do_config()
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Create SQL Database!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Create SQL Database!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (x = 0; indexes[x]; x++) {
|
||||||
|
switch_odbc_handle_exec(globals.master_odbc, indexes[x], NULL);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
if ((db = switch_core_db_open_file(globals.dbname))) {
|
if ((db = switch_core_db_open_file(globals.dbname))) {
|
||||||
|
|
|
@ -3080,6 +3080,38 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
||||||
|
|
||||||
if (profile->odbc_dsn) {
|
if (profile->odbc_dsn) {
|
||||||
#ifdef SWITCH_HAVE_ODBC
|
#ifdef SWITCH_HAVE_ODBC
|
||||||
|
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 ss_call_id on sip_subscriptions (call_id)",
|
||||||
|
"create index ss_hostname on sip_subscriptions (hostname)",
|
||||||
|
"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 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_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)",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
if (!(profile->master_odbc = switch_odbc_handle_new(profile->odbc_dsn, profile->odbc_user, profile->odbc_pass))) {
|
if (!(profile->master_odbc = switch_odbc_handle_new(profile->odbc_dsn, profile->odbc_user, profile->odbc_pass))) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3132,14 +3164,17 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
||||||
}
|
}
|
||||||
free(test_sql);
|
free(test_sql);
|
||||||
|
|
||||||
if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
|
test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str='' or hostname='%q'", mod_sofia_globals.hostname);
|
||||||
test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str='' or hostname='%q'", mod_sofia_globals.hostname);
|
if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
|
||||||
if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
|
switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_shared_appearance_subscriptions", NULL);
|
||||||
switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_shared_appearance_subscriptions", NULL);
|
switch_odbc_handle_exec(profile->master_odbc, shared_appearance_sql, NULL);
|
||||||
switch_odbc_handle_exec(profile->master_odbc, shared_appearance_sql, NULL);
|
|
||||||
}
|
|
||||||
free(test_sql);
|
|
||||||
}
|
}
|
||||||
|
free(test_sql);
|
||||||
|
|
||||||
|
for (x = 0; indexes[x]; x++) {
|
||||||
|
switch_odbc_handle_exec(profile->master_odbc, indexes[x], NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
||||||
|
@ -3172,16 +3207,19 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
||||||
switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_authentication", auth_sql);
|
switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_authentication", auth_sql);
|
||||||
free(test_sql);
|
free(test_sql);
|
||||||
|
|
||||||
if(sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
|
|
||||||
test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str = '' or hostname='%q'", mod_sofia_globals.hostname);
|
|
||||||
switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql);
|
|
||||||
free(test_sql);
|
|
||||||
|
|
||||||
switch_core_db_exec(profile->master_db, "create index if not exists ssa_hostname on sip_shared_appearance_subscriptions (hostname)", NULL, NULL, NULL);
|
test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str = '' or hostname='%q'", mod_sofia_globals.hostname);
|
||||||
switch_core_db_exec(profile->master_db, "create index if not exists ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)", NULL, NULL, NULL);
|
switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql);
|
||||||
switch_core_db_exec(profile->master_db, "create index if not exists ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)", NULL, NULL, NULL);
|
free(test_sql);
|
||||||
switch_core_db_exec(profile->master_db, "create index if not exists ssa_aor on sip_shared_appearance_subscriptions (aor)", NULL, NULL, NULL);
|
|
||||||
}
|
switch_core_db_exec(profile->master_db, "create index if not exists ssa_hostname on sip_shared_appearance_subscriptions (hostname)",
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
switch_core_db_exec(profile->master_db, "create index if not exists ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)",
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
switch_core_db_exec(profile->master_db, "create index if not exists ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)",
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
switch_core_db_exec(profile->master_db, "create index if not exists ssa_aor on sip_shared_appearance_subscriptions (aor)", NULL, NULL, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch_core_db_exec(profile->master_db, "create index if not exists sr_call_id on sip_registrations (call_id)", NULL, NULL, NULL);
|
switch_core_db_exec(profile->master_db, "create index if not exists sr_call_id on sip_registrations (call_id)", NULL, NULL, NULL);
|
||||||
|
|
Loading…
Reference in New Issue