Skip to content

Commit c909773

Browse files
committed
Fix for CONPY-178:
When a cursor was not properly cleared (all results weren't fetched) the clear_result routine has to free result sets only if field_count > 0.
1 parent 5ed872f commit c909773

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

mariadb/mariadb_cursor.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,14 @@ static void MrdbCursor_clear_result(MrdbCursor *self)
386386
self->stmt)
387387
{
388388
/* free current result */
389-
mysql_stmt_free_result(self->stmt);
389+
if (mysql_stmt_field_count(self->stmt))
390+
mysql_stmt_free_result(self->stmt);
390391

391392
/* check if there are more pending result sets */
392393
while (mysql_stmt_next_result(self->stmt) == 0)
393394
{
394-
mysql_stmt_free_result(self->stmt);
395+
if (mysql_stmt_field_count(self->stmt))
396+
mysql_stmt_free_result(self->stmt);
395397
}
396398
} else if (self->is_text)
397399
{
@@ -1631,6 +1633,8 @@ MrdbCursor_callproc(MrdbCursor *self, PyObject *args)
16311633
PyTuple_SetItem(new_args, 0, PyUnicode_FromString(stmt));
16321634
PyTuple_SetItem(new_args, 1, data);
16331635

1636+
MrdbCursor_clear_result(self);
1637+
16341638
rc= MrdbCursor_execute(self, new_args, NULL);
16351639
end:
16361640
if (stmt)

testing/test/conf_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def conf():
1313
d = {
1414
"user": os.environ.get('TEST_USER', 'root'),
1515
"host": os.environ.get('TEST_HOST', 'localhost'),
16+
"unix_socket" : "/tmp/mysql.sock",
1617
"database": os.environ.get('TEST_DATABASE', 'testp'),
1718
"port": int(os.environ.get('TEST_PORT', '3306')),
1819
}

0 commit comments

Comments
 (0)