--- driver-mysql.c 2010-03-05 19:38:10.512212871 +0000 +++ driver-mysql.c 2010-03-05 19:38:17.000000000 +0000 @@ -132,9 +132,10 @@ } alarm(MYSQL_CONNECT_FAILURE_TIMEOUT); + /* CLIENT_MULTI_RESULTS allows the use of stored procedures */ failed = mysql_real_connect(conn->mysql, host, db->user, db->password, db->dbname, db->port, unix_socket, - db->client_flags) == NULL; + db->client_flags | CLIENT_MULTI_RESULTS) == NULL; alarm(0); if (failed) { if (conn->connect_failure_count > 0) { @@ -429,6 +430,7 @@ struct mysql_db *db = (struct mysql_db *)_db; struct mysql_connection *conn; struct mysql_result *result; + int nr; result = i_new(struct mysql_result, 1); result->api = driver_mysql_result; @@ -442,6 +444,17 @@ case 1: /* query ok */ result->result = mysql_store_result(conn->mysql); + while((nr = mysql_next_result(conn->mysql)) >= 0) { + /* more results? -1 = no, >0 = error, 0 = yes + * Because of the CLIENT_MULTI_RESULTS on mysql_real_connect() + * we need to read extra results - there should not be any. + */ + if(nr == 0) /* Just ignore more results */ + continue; + + result->api = driver_mysql_error_result; + goto off; + } if (result->result != NULL || mysql_errno(conn->mysql) == 0) break; /* fallback */ @@ -451,6 +464,7 @@ break; } +off: result->conn = conn; return &result->api; }