diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-06-24 14:53:33 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-06-24 14:53:33 +0300 |
commit | 9f46ca3e0f3062dd6e9848f6bfd97926144ccbd7 (patch) | |
tree | cadc6ef1ab1c68b22cd85b3c6d03e095a45a37c8 | |
parent | c2fef3f238087c8be9d8ac25fbd4b7fe19370f0b (diff) | |
download | gamma-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.c | 15 |
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) | |||
131 | return smob; | 131 | return smob; |
132 | } | 132 | } |
133 | 133 | ||
134 | static void | ||
135 | flush_result(MYSQL *mysql) | ||
136 | { | ||
137 | while (mysql_next_result(mysql) == 0) { | ||
138 | MYSQL_RES *result = mysql_store_result(mysql); | ||
139 | if (!result) | ||
140 | break; | ||
141 | if (mysql_field_count(mysql)) | ||
142 | while (mysql_fetch_row(result)) | ||
143 | ; | ||
144 | mysql_free_result(result); | ||
145 | } | ||
146 | } | ||
147 | |||
134 | static SCM | 148 | static SCM |
135 | s_mysql_query(struct sql_connect *conn, const char *query) | 149 | s_mysql_query(struct sql_connect *conn, const char *query) |
136 | { | 150 | { |
@@ -186,6 +200,7 @@ s_mysql_query(struct sql_connect *conn, const char *query) | |||
186 | } | 200 | } |
187 | cell = row_head; | 201 | cell = row_head; |
188 | mysql_free_result(result); | 202 | mysql_free_result(result); |
203 | flush_result(mysql); | ||
189 | } else { /* should it have returned something? */ | 204 | } else { /* should it have returned something? */ |
190 | if (mysql_field_count(mysql) == 0) { | 205 | if (mysql_field_count(mysql) == 0) { |
191 | cell = scm_from_ulong(mysql_affected_rows(mysql)); | 206 | cell = scm_from_ulong(mysql_affected_rows(mysql)); |