B. Johannessen wrote:
> Huh! This wasn't as simple as I'd hoped...
This Easter-break thing is no good. I haven't had a real cup of coffee
since yesterday and it shows. Attached it what is hopefully tonights
last attempt.
Bob
diff -ruN exim-4.69-orig/src/lookups/mysql.c exim-4.69/src/lookups/mysql.c
--- exim-4.69-orig/src/lookups/mysql.c 2007-08-23 12:16:51.000000000 +0200
+++ exim-4.69/src/lookups/mysql.c 2008-03-20 22:51:46.000000000 +0100
@@ -202,7 +202,7 @@
if (mysql_real_connect(mysql_handle,
/* host user passwd database */
CS sdata[0], CS sdata[2], CS sdata[3], CS sdata[1],
- port, CS socket, 0) == NULL)
+ port, CS socket, CLIENT_MULTI_RESULTS) == NULL)
{
*errmsg = string_sprintf("MYSQL connection failed: %s",
mysql_error(mysql_handle));
@@ -316,6 +316,20 @@
if (mysql_result != NULL) mysql_free_result(mysql_result);
+/* To allow stored procedures to return results, the connection has to be
+set up with the CLIENT_MULTI_RESULTS flag. When we do this, and execute a
+CALL query, there may be more then one result set returned. We are only
+interested in the first one, but we have to retreve and discard the rest
+to avoid complaints of "Commands out of sync; you can't run this command
+now" */
+
+while (0 == mysql_next_result(mysql_handle))
+ {
+ if (NULL != (mysql_result = mysql_use_result(mysql_handle)))
+ mysql_free_result(mysql_result);
+ }
+
+
/* Non-NULL result indicates a sucessful result */
if (result != NULL)