[Freeswitch-svn] [commit] r12235 - in freeswitch/trunk/src/mod: applications/mod_limit endpoints/mod_sofia

FreeSWITCH SVN anthm at freeswitch.org
Sun Feb 22 17:49:49 PST 2009


Author: anthm
Date: Sun Feb 22 19:49:49 2009
New Revision: 12235

Log:
create indexes for ODBC as well

Modified:
   freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c

Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c	Sun Feb 22 19:49:49 2009
@@ -211,6 +211,21 @@
 
 #ifdef SWITCH_HAVE_ODBC
 	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))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
 			status = SWITCH_STATUS_FALSE;
@@ -238,6 +253,10 @@
 				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 {
 #endif
 		if ((db = switch_core_db_open_file(globals.dbname))) {

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Sun Feb 22 19:49:49 2009
@@ -3080,6 +3080,38 @@
 
 	if (profile->odbc_dsn) {
 #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))) {
 			return 0;
 		}
@@ -3132,19 +3164,22 @@
 		}
 		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);
-			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, shared_appearance_sql, NULL);
-			}
-			free(test_sql);
+		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) {
+			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);
 		}
+		free(test_sql);
+
+		for (x = 0; indexes[x]; x++) {
+			switch_odbc_handle_exec(profile->master_odbc, indexes[x], NULL);
+		}
+
 
 #else
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
 #endif
-	} else {		
+	} else {
 		if (!(profile->master_db = switch_core_db_open_file(profile->dbname))) {
 			return 0;
 		}
@@ -3172,16 +3207,19 @@
 		switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_authentication", auth_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);
-			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);
-		}
+		
+		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);
+		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);



More information about the Freeswitch-svn mailing list