Skip to content

Commit 38e4442

Browse files
committed
Fix bugs
1 parent 5533274 commit 38e4442

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/MySQLdb/_mysql.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -2114,18 +2114,25 @@ _mysql_ConnectionObject_discard_result(
21142114
MYSQL *conn = &(self->connection);
21152115

21162116
Py_BEGIN_ALLOW_THREADS;
2117+
21172118
MYSQL_RES *res = mysql_use_result(conn);
21182119
if (res == NULL) {
21192120
Py_BLOCK_THREADS;
2120-
return _mysql_Exception(self);
2121+
if (mysql_errno(conn) != 0) {
2122+
// fprintf(stderr, "mysql_use_result failed: %s\n", mysql_error(conn));
2123+
return _mysql_Exception(self);
2124+
}
2125+
Py_RETURN_NONE;
21212126
}
2127+
21222128
MYSQL_ROW row;
21232129
while (NULL != (row = mysql_fetch_row(res))) {
21242130
// do nothing.
21252131
}
21262132
mysql_free_result(res);
21272133
Py_END_ALLOW_THREADS;
21282134
if (mysql_errno(conn)) {
2135+
// fprintf(stderr, "mysql_free_result failed: %s\n", mysql_error(conn));
21292136
return _mysql_Exception(self);
21302137
}
21312138
Py_RETURN_NONE;

src/MySQLdb/cursors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _discard(self):
9090
con = self.connection
9191
if con is None:
9292
return
93-
while con.next_result():
93+
while con.next_result() == 0: # -1 means no more data.
9494
con.discard_result()
9595

9696
def close(self):

0 commit comments

Comments
 (0)