Calls to _mysql__fetch_row() might move the row tuple, so use a PyObject **.

Thanks to Andy Martin for finding this.
This commit is contained in:
adustman
2001-04-28 00:39:06 +00:00
parent 30fca0e176
commit d72f605a67

View File

@ -745,7 +745,7 @@ typedef PyObject *_PYFUNC(_mysql_ResultObject *, MYSQL_ROW);
int int
_mysql__fetch_row( _mysql__fetch_row(
_mysql_ResultObject *self, _mysql_ResultObject *self,
PyObject *r, PyObject **r,
int skiprows, int skiprows,
int maxrows, int maxrows,
_PYFUNC *convert_row) _PYFUNC *convert_row)
@ -767,12 +767,12 @@ _mysql__fetch_row(
goto error; goto error;
} }
if (!row) { if (!row) {
if (_PyTuple_Resize(&r, i, 0) == -1) goto error; if (_PyTuple_Resize(r, i, 0) == -1) goto error;
break; break;
} }
v = convert_row(self, row); v = convert_row(self, row);
if (!v) goto error; if (!v) goto error;
PyTuple_SET_ITEM(r, i, v); PyTuple_SET_ITEM(*r, i, v);
} }
return i-skiprows; return i-skiprows;
error: error:
@ -808,7 +808,7 @@ _mysql_ResultObject_fetch_row(
convert_row = row_converters[how]; convert_row = row_converters[how];
if (maxrows) { if (maxrows) {
if (!(r = PyTuple_New(maxrows))) goto error; if (!(r = PyTuple_New(maxrows))) goto error;
rowsadded = _mysql__fetch_row(self, r, skiprows, maxrows, rowsadded = _mysql__fetch_row(self, &r, skiprows, maxrows,
convert_row); convert_row);
if (rowsadded == -1) goto error; if (rowsadded == -1) goto error;
} else { } else {
@ -816,7 +816,7 @@ _mysql_ResultObject_fetch_row(
maxrows = 1000; maxrows = 1000;
if (!(r = PyTuple_New(maxrows))) goto error; if (!(r = PyTuple_New(maxrows))) goto error;
while (1) { while (1) {
rowsadded = _mysql__fetch_row(self, r, skiprows, rowsadded = _mysql__fetch_row(self, &r, skiprows,
maxrows, convert_row); maxrows, convert_row);
if (rowsadded == -1) goto error; if (rowsadded == -1) goto error;
skiprows += rowsadded; skiprows += rowsadded;
@ -826,7 +826,7 @@ _mysql_ResultObject_fetch_row(
/* XXX if overflow, maxrows<0? */ /* XXX if overflow, maxrows<0? */
maxrows = (int) mysql_num_rows(self->result); maxrows = (int) mysql_num_rows(self->result);
if (!(r = PyTuple_New(maxrows))) goto error; if (!(r = PyTuple_New(maxrows))) goto error;
rowsadded = _mysql__fetch_row(self, r, 0, rowsadded = _mysql__fetch_row(self, &r, 0,
maxrows, convert_row); maxrows, convert_row);
if (rowsadded == -1) goto error; if (rowsadded == -1) goto error;
} }