Skip to content

Commit ac1fb2d

Browse files
committed
mysql_affected_rows may return -1
1 parent 42c2b22 commit ac1fb2d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

_mysql.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,9 +827,13 @@ _mysql_ConnectionObject_affected_rows(
827827
_mysql_ConnectionObject *self,
828828
PyObject *args)
829829
{
830+
my_ulonglong ret;
830831
if (!PyArg_ParseTuple(args, "")) return NULL;
831832
check_connection(self);
832-
return PyLong_FromUnsignedLongLong(mysql_affected_rows(&(self->connection)));
833+
ret = mysql_affected_rows(&(self->connection));
834+
if (ret == (my_ulonglong)-1)
835+
return PyInt_FromLong(-1);
836+
return PyLong_FromUnsignedLongLong(ret);
833837
}
834838

835839
static char _mysql_debug__doc__[] =

0 commit comments

Comments
 (0)