Nicolas Cannasse a écrit :
hi,
neko cannot handle mysql stored procedures that returns results.
see details here :
http://dev.mysql.com/doc/refman/5.0/en/c-api-multiple-queries.html
here is an ugly hack allowing to handle stored procedures results :
The problem of defining CLIENT_MULTI_STATEMENTS by default is that it
opens a big hole for SQL injection.
Are there no other ways to do that ? Maybe adding a method
enable_stored_procedures(cnx) would be better ?
Nicolas
what about this (better) patch ?
ref : http://bugs.mysql.com/bug.php?id=27544
kaalh
Index: libs/mysql/mysql.c
===================================================================
RCS file: /cvsroot/neko/libs/mysql/mysql.c,v
retrieving revision 1.17
diff -u -r1.17 mysql.c
--- libs/mysql/mysql.c 9 Jun 2006 10:04:47 -0000 1.17
+++ libs/mysql/mysql.c 29 Aug 2007 06:56:31 -0000
@@ -372,6 +372,7 @@
**/
static value request( value o, value r ) {
MYSQL_RES *res;
+ MYSQL_RES *tmp_res;
val_check_kind(o,k_connection);
val_check(r,string);
if( mysql_real_query(MYSQLDATA(o),val_string(r),val_strlen(r)) != 0 )
@@ -383,6 +384,17 @@
else
error(MYSQLDATA(o),val_string(r));
}
+
+ /* check if there are more resultsets */
+ while(mysql_more_results(MYSQLDATA(o)))
+ {
+ if (mysql_next_result(MYSQLDATA(o)) == -1)
+ {
+ tmp_res = mysql_store_result(MYSQLDATA(o));
+ mysql_free_result(tmp_res);
+ }
+ }
+
return alloc_result(res);
}
@@ -431,7 +443,7 @@
{
MYSQL *m = mysql_init(NULL);
value v;
- if( mysql_real_connect(m,val_string(host),val_string(user),val_string(pass),NULL,val_int(port),val_is_null(socket)?NULL:val_string(socket),0) == NULL ) {
+ if( mysql_real_connect(m,val_string(host),val_string(user),val_string(pass),NULL,val_int(port),val_is_null(socket)?NULL:val_string(socket),CLIENT_MULTI_RESULTS) == NULL ) {
buffer b = alloc_buffer("Failed to connect to mysql server : ");
buffer_append(b,mysql_error(m));
mysql_close(m);
--
Neko : One VM to run them all
(http://nekovm.org)