From 0fc0b999505d1a4664ee566cf28696f597a20f79 Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Wed, 26 Sep 2012 08:01:25 -0500
Subject: [PATCH] FS-4654 --resolve

---
 src/switch_console.c    | 4 ++--
 src/switch_core_sqldb.c | 7 ++++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/switch_console.c b/src/switch_console.c
index 3945baec7c..d461333860 100644
--- a/src/switch_console.c
+++ b/src/switch_console.c
@@ -684,7 +684,7 @@ SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const ch
 #endif
 #endif
 
-	if (switch_core_persist_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
+	if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database Error\n");
 		return CC_ERROR;
 	}
@@ -1776,7 +1776,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)
 			SWITCH_STANDARD_STREAM(mystream);
 
 
-			if (switch_core_persist_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
+			if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database Error\n");
 				free(mystream.data);
 				free(mydata);
diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c
index b0f52b6150..5a76d0e1ae 100644
--- a/src/switch_core_sqldb.c
+++ b/src/switch_core_sqldb.c
@@ -2409,9 +2409,14 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
 		break;
 	}
 
+	{
+		switch_cache_db_handle_t *db = NULL;
+		switch_core_persist_db_handle(&db)
+		switch_cache_db_test_reactive(db, "select hostname from aliases", "DROP TABLE aliases", create_alias_sql);
+		switch_cache_db_release_db_handle(&db);
+	}
 
 	switch_cache_db_test_reactive(sql_manager.dbh, "select hostname from complete", "DROP TABLE complete", create_complete_sql);
-	switch_cache_db_test_reactive(sql_manager.dbh, "select hostname from aliases", "DROP TABLE aliases", create_alias_sql);
 	switch_cache_db_test_reactive(sql_manager.dbh, "select hostname from nat", "DROP TABLE nat", create_nat_sql);
 	switch_cache_db_test_reactive(sql_manager.dbh, "delete from registrations where reg_user='' or network_proto='tcp' or network_proto='tls'", 
 								  "DROP TABLE registrations", create_registrations_sql);