Revision
15981
Author
anthm
Date
2009-12-16 16:20:22 -0600 (Wed, 16 Dec 2009)

Log Message

return true/false from sql tester incase you want to do more stuff when the table had to be created

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_core.h (15980 => 15981)


--- freeswitch/trunk/src/include/switch_core.h	2009-12-16 17:05:34 UTC (rev 15980)
+++ freeswitch/trunk/src/include/switch_core.h	2009-12-16 22:20:22 UTC (rev 15981)
@@ -2038,7 +2038,8 @@
 SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t **dbh, const char *file, const char *func, int line);
 #define switch_core_db_handle(_a) _switch_core_db_handle(_a, __FILE__, __SWITCH_FUNC__, __LINE__)
 
-SWITCH_DECLARE(void) switch_cache_db_test_reactive(switch_cache_db_handle_t *db, const char *test_sql, const char *drop_sql, const char *reactive_sql);
+SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_handle_t *db, 
+															const char *test_sql, const char *drop_sql, const char *reactive_sql);
 SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries);
 SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_cache_db_handle_t *dbh, char *sql, uint32_t retries);
 SWITCH_DECLARE(void) switch_cache_db_detach(void);

Modified: freeswitch/trunk/src/switch_core_sqldb.c (15980 => 15981)


--- freeswitch/trunk/src/switch_core_sqldb.c	2009-12-16 17:05:34 UTC (rev 15980)
+++ freeswitch/trunk/src/switch_core_sqldb.c	2009-12-16 22:20:22 UTC (rev 15981)
@@ -719,11 +719,12 @@
 	return status;
 }
 
-SWITCH_DECLARE(void) switch_cache_db_test_reactive(switch_cache_db_handle_t *dbh, const char *test_sql, const char *drop_sql, const char *reactive_sql)
+SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_handle_t *dbh, 
+															const char *test_sql, const char *drop_sql, const char *reactive_sql)
 {
 	char *errmsg;
+	switch_bool_t r = SWITCH_TRUE;
 
-
 	if (dbh->io_mutex) {
 		switch_mutex_lock(dbh->io_mutex);
 	}
@@ -732,6 +733,7 @@
 	case SCDB_TYPE_ODBC:
 		{
 			if (switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
+				r = SWITCH_FALSE;
 				if (drop_sql) {
 					switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, drop_sql, NULL);
 				}
@@ -745,6 +747,7 @@
 				switch_core_db_exec(dbh->native_handle.core_db_dbh, test_sql, NULL, NULL, &errmsg);
 
 				if (errmsg) {
+					r = SWITCH_FALSE;
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n[%s]\nAuto Generating Table!\n", errmsg, test_sql);
 					switch_core_db_free(errmsg);
 					errmsg = NULL;
@@ -772,6 +775,8 @@
 	if (dbh->io_mutex) {
 		switch_mutex_unlock(dbh->io_mutex);
 	}
+
+	return r;
 }