Revision
15507
Author
ledr
Date
2009-11-17 17:50:03 -0600 (Tue, 17 Nov 2009)

Log Message

Try printing out SQL error - queries don't work anymore - what happened ?

Modified Paths

Diff

Modified: freeswitch/trunk/contrib/ledr/c/mod_odbc_query/mod_odbc_query.c (15506 => 15507)


--- freeswitch/trunk/contrib/ledr/c/mod_odbc_query/mod_odbc_query.c	2009-11-17 22:55:14 UTC (rev 15506)
+++ freeswitch/trunk/contrib/ledr/c/mod_odbc_query/mod_odbc_query.c	2009-11-17 23:50:03 UTC (rev 15507)
@@ -167,6 +167,7 @@
 	char *expanded_query = NULL;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_memory_pool_t *pool = switch_core_session_get_pool(session);
+	char *errmsg;
 
 	if (!channel) {
 		return;
@@ -190,8 +191,10 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Performing query: [%s]\n", expanded_query);
 
-	if (switch_odbc_handle_callback_exec(globals.odbc_handle, expanded_query, odbc_query_callback, channel, NULL) != SWITCH_ODBC_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error running this query: [%s]\n", expanded_query);
+	if (switch_odbc_handle_callback_exec(globals.odbc_handle, expanded_query, odbc_query_callback, channel, &errmsg) != SWITCH_ODBC_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL error [%s] while doing query: [%s]\n", switch_str_nil(errmsg), expanded_query);
+		switch_core_db_free(errmsg);
+		errmsg = NULL;
 	}
 }
 

Modified: freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/mod_xml_odbc.c (15506 => 15507)


--- freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/mod_xml_odbc.c	2009-11-17 22:55:14 UTC (rev 15506)
+++ freeswitch/trunk/contrib/mod/xml_int/mod_xml_odbc/mod_xml_odbc.c	2009-11-17 23:50:03 UTC (rev 15507)
@@ -232,6 +232,7 @@
 	char *value = (char *) switch_xml_attr_soft(helper->xml_in_cur, "value");
 	char *empty_result_break_to = (char *) switch_xml_attr_soft(helper->xml_in_cur, "on-empty-result-break-to");
 	char *new_value = switch_event_expand_headers_by_pool(helper->pool, helper->event, value);
+	char *errmsg;
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	if (globals.debug == SWITCH_TRUE) {
@@ -240,8 +241,10 @@
 
 	helper->rowcount = 0;
 
-	if (switch_odbc_handle_callback_exec(globals.master_odbc, new_value, xml_odbc_query_callback, helper, NULL) != SWITCH_ODBC_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error running this query: [%s]\n", new_value);
+	if (switch_odbc_handle_callback_exec(globals.master_odbc, new_value, xml_odbc_query_callback, helper, &errmsg) != SWITCH_ODBC_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL error [%s] while doing query [%s]\n", switch_str_nil(errmsg), new_value);
+		switch_core_db_free(errmsg);
+		errmsg = NULL;
 		goto done;
 	}