add indexes to mod_voicemail

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12341 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-02-28 03:56:38 +00:00
parent d5411fe95b
commit 847205b4b0
1 changed files with 26 additions and 0 deletions

View File

@ -234,6 +234,18 @@ static char vm_pref_sql[] =
" password VARCHAR(255)\n"
");\n";
static char *vm_index_list[] = {
"create index voicemail_msgs_idx1 on voicemail_msgs(created_epoch)",
"create index voicemail_msgs_idx2 on voicemail_msgs(username)",
"create index voicemail_msgs_idx3 on voicemail_msgs(domain)",
"create index voicemail_msgs_idx4 on voicemail_msgs(uuid)",
"create index voicemail_msgs_idx5 on voicemail_msgs(in_folder)",
"create index voicemail_msgs_idx6 on voicemail_msgs(read_flags)",
"create index voicemail_prefs_idx1 on voicemail_prefs(username)",
"create index voicemail_prefs_idx2 on voicemail_prefs(domain)",
NULL
};
static switch_status_t load_config(void)
{
char *cf = "voicemail.conf";
@ -323,6 +335,7 @@ static switch_status_t load_config(void)
switch_core_db_t *db;
uint32_t timeout = 10000, max_login_attempts = 3, max_record_len = 300, min_record_len = 3, max_retries = 3;
int x;
db = NULL;
@ -671,6 +684,11 @@ static switch_status_t load_config(void)
}
switch_odbc_handle_exec(profile->master_odbc, "drop table voicemail_data", NULL);
}
for (x = 0; vm_index_list[x]; x++) {
switch_odbc_handle_exec(profile->master_odbc, vm_index_list[x], NULL);
}
#endif
} else {
if ((db = switch_core_db_open_file(profile->dbname))) {
@ -705,6 +723,14 @@ static switch_status_t load_config(void)
switch_core_db_test_reactive(db, "select count(username) from voicemail_prefs", "drop table voicemail_prefs", vm_pref_sql);
switch_core_db_test_reactive(db, "select count(password) from voicemail_prefs", NULL,
"alter table voicemail_prefs add password varchar(255)");
for (x = 0; vm_index_list[x]; x++) {
errmsg = NULL;
switch_core_db_exec(db, vm_index_list[x], NULL, NULL, &errmsg);
switch_safe_free(errmsg);
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database!\n");
continue;