aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-06-24 14:53:33 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-06-24 14:53:33 +0300
commit9f46ca3e0f3062dd6e9848f6bfd97926144ccbd7 (patch)
treecadc6ef1ab1c68b22cd85b3c6d03e095a45a37c8
parentc2fef3f238087c8be9d8ac25fbd4b7fe19370f0b (diff)
downloadgamma-9f46ca3e0f3062dd6e9848f6bfd97926144ccbd7.tar.gz
gamma-9f46ca3e0f3062dd6e9848f6bfd97926144ccbd7.tar.bz2
Improve handling of multi-result sets.
* src/mysql.c (s_mysql_query): Consume any additional results to avoid 'out of sequence' errors.
-rw-r--r--src/mysql.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mysql.c b/src/mysql.c
index 81364b4..1310212 100644
--- a/src/mysql.c
+++ b/src/mysql.c
@@ -131,6 +131,20 @@ s_mysql_connect (SCM parmlist, const char *func_name)
return smob;
}
+static void
+flush_result(MYSQL *mysql)
+{
+ while (mysql_next_result(mysql) == 0) {
+ MYSQL_RES *result = mysql_store_result(mysql);
+ if (!result)
+ break;
+ if (mysql_field_count(mysql))
+ while (mysql_fetch_row(result))
+ ;
+ mysql_free_result(result);
+ }
+}
+
static SCM
s_mysql_query(struct sql_connect *conn, const char *query)
{
@@ -186,6 +200,7 @@ s_mysql_query(struct sql_connect *conn, const char *query)
}
cell = row_head;
mysql_free_result(result);
+ flush_result(mysql);
} else { /* should it have returned something? */
if (mysql_field_count(mysql) == 0) {
cell = scm_from_ulong(mysql_affected_rows(mysql));

Return to:

Send suggestions and report system problems to the System administrator.