[asterisk-addons-commits] file: branch 1.2 r316 - /branches/1.2/app_addon_sql_mysql.c

asterisk-addons-commits at lists.digium.com asterisk-addons-commits at lists.digium.com
Tue Nov 28 09:39:25 MST 2006


Author: file
Date: Tue Nov 28 10:39:25 2006
New Revision: 316

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=316
Log:
Print out an error message with the reason if the MySQL query fails. (issue #7837 reported by lupino3)

Modified:
    branches/1.2/app_addon_sql_mysql.c

Modified: branches/1.2/app_addon_sql_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/branches/1.2/app_addon_sql_mysql.c?view=diff&rev=316&r1=315&r2=316
==============================================================================
--- branches/1.2/app_addon_sql_mysql.c (original)
+++ branches/1.2/app_addon_sql_mysql.c Tue Nov 28 10:39:25 2006
@@ -254,6 +254,7 @@
 	char *resultid_var;
 	int connid;
 	char *querystring;
+	int mysql_query_res;
 
 	strsep(&data," "); // eat the first token, we already know it :P 
 
@@ -263,16 +264,21 @@
 
 	if (resultid_var && (connid>=0) && querystring) {
 		if ((mysql=find_identifier(connid,AST_MYSQL_ID_CONNID))!=NULL) {
-			mysql_query(mysql,querystring);
-			if ((mysqlres=mysql_use_result(mysql))!=NULL) {
-				add_identifier_and_set_asterisk_int(chan,resultid_var,AST_MYSQL_ID_RESID,mysqlres);
-				return 0;
-			}
-			else if( mysql_field_count(mysql)==0 ) {
-				return 0;  // See http://dev.mysql.com/doc/mysql/en/mysql_field_count.html
+			mysql_query_res = mysql_query(mysql,querystring);
+			if (mysql_query_res != 0) {
+				ast_log(LOG_WARNING, "aMYSQL_query: mysql_query failed. Error: %s\n", mysql_error(mysql));
 			}
 			else {
-				ast_log(LOG_WARNING,"aMYSQL_query: mysql_store_result() failed on query %s\n",querystring);
+				if ((mysqlres=mysql_use_result(mysql))!=NULL) {
+					add_identifier_and_set_asterisk_int(chan,resultid_var,AST_MYSQL_ID_RESID,mysqlres);
+					return 0;
+				}
+				else if (mysql_field_count(mysql)==0) {
+					return 0;  // See http://dev.mysql.com/doc/mysql/en/mysql_field_count.html
+				}
+				else {
+					ast_log(LOG_WARNING,"aMYSQL_query: mysql_store_result() failed on query %s\n",querystring);
+				}
 			}
 		}
 		else {



More information about the asterisk-addons-commits mailing list