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.
This commit is contained in:
Georg Richter
2021-11-25 06:01:18 +01:00
parent 5ed872fb00
commit c90977316b
2 changed files with 7 additions and 2 deletions

View File

@ -386,12 +386,14 @@ static void MrdbCursor_clear_result(MrdbCursor *self)
self->stmt)
{
/* free current result */
mysql_stmt_free_result(self->stmt);
if (mysql_stmt_field_count(self->stmt))
mysql_stmt_free_result(self->stmt);
/* check if there are more pending result sets */
while (mysql_stmt_next_result(self->stmt) == 0)
{
mysql_stmt_free_result(self->stmt);
if (mysql_stmt_field_count(self->stmt))
mysql_stmt_free_result(self->stmt);
}
} else if (self->is_text)
{
@ -1631,6 +1633,8 @@ MrdbCursor_callproc(MrdbCursor *self, PyObject *args)
PyTuple_SetItem(new_args, 0, PyUnicode_FromString(stmt));
PyTuple_SetItem(new_args, 1, data);
MrdbCursor_clear_result(self);
rc= MrdbCursor_execute(self, new_args, NULL);
end:
if (stmt)

View File

@ -13,6 +13,7 @@ def conf():
d = {
"user": os.environ.get('TEST_USER', 'root'),
"host": os.environ.get('TEST_HOST', 'localhost'),
"unix_socket" : "/tmp/mysql.sock",
"database": os.environ.get('TEST_DATABASE', 'testp'),
"port": int(os.environ.get('TEST_PORT', '3306')),
}