From 309c4c54bdcc260ef4e281955de81b29e5562e8e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 16 Dec 2009 22:20:22 +0000 Subject: [PATCH] return true/false from sql tester incase you want to do more stuff when the table had to be created git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15981 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_core.h | 3 ++- src/switch_core_sqldb.c | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 13e7e7a2f2..dc9985dfe1 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -2038,7 +2038,8 @@ SWITCH_DECLARE(void) switch_cache_db_status(switch_stream_handle_t *stream); 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); diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index caeb1bf468..a16886b3ce 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -719,10 +719,11 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cach 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 @@ SWITCH_DECLARE(void) switch_cache_db_test_reactive(switch_cache_db_handle_t *dbh 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_DECLARE(void) switch_cache_db_test_reactive(switch_cache_db_handle_t *dbh 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 @@ SWITCH_DECLARE(void) switch_cache_db_test_reactive(switch_cache_db_handle_t *dbh if (dbh->io_mutex) { switch_mutex_unlock(dbh->io_mutex); } + + return r; }