This patch fixes the well-known but unfixed bug that fetchone() always
authorBruce Momjian <bruce@momjian.us>
Thu, 16 Aug 2001 15:21:53 +0000 (15:21 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 16 Aug 2001 15:21:53 +0000 (15:21 +0000)
returns the first result in the DB-API compliant wrapper. It turned out
that the bug was way down in the C code.

Gerhard Häring

src/interfaces/python/pgmodule.c

index a1ce3cd33fe666c9f7a38646cd5e65b56bb5927f..d1a4907189fe5213c9cab94665856d69f7f6e12e 100644 (file)
@@ -554,13 +554,13 @@ pgsource_fetch(pgsourceobject * self, PyObject * args)
 
        for (j = 0; j < self->num_fields; j++)
        {
-           if (PQgetisnull(self->last_result, i, j))
+           if (PQgetisnull(self->last_result, self->current_row, j))
            {
                Py_INCREF(Py_None);
                str = Py_None;
            }
            else
-               str = PyString_FromString(PQgetvalue(self->last_result, i, j));
+               str = PyString_FromString(PQgetvalue(self->last_result, self->current_row, j));
 
            PyTuple_SET_ITEM(rowtuple, j, str);
        }