Fixes to let the dbapi20 test suite pass.

Submitted by James Henstridge in ticket #195.
This commit is contained in:
Daniele Varrazzo 2007-11-11 10:18:43 +00:00
parent 75cb5d75d7
commit fd1ee6fffc
2 changed files with 12 additions and 6 deletions

View File

@ -525,6 +525,7 @@ psyco_curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs)
}
}
Py_XDECREF(iter);
self->rowcount = -1;
Py_INCREF(Py_None);
return Py_None;
@ -931,7 +932,7 @@ psyco_curs_callproc(cursorObject *self, PyObject *args, PyObject *kwargs)
char *procname = NULL, *sql = NULL;
long int async = 0;
Py_ssize_t procname_len, i, nparameters = 0, sl = 0;
PyObject *parameters = NULL;
PyObject *parameters = Py_None;
PyObject *operation = NULL;
PyObject *res = NULL;
@ -948,9 +949,9 @@ psyco_curs_callproc(cursorObject *self, PyObject *args, PyObject *kwargs)
return NULL;
}
if(parameters && parameters != Py_None) {
if(parameters != Py_None) {
nparameters = PyObject_Length(parameters);
if (nparameters < 0) nparameters = 0;
if (nparameters < 0) nparameters = 0;
}
/* allocate some memory, build the SQL and create a PyString from it */
@ -969,8 +970,8 @@ psyco_curs_callproc(cursorObject *self, PyObject *args, PyObject *kwargs)
PyMem_Free((void*)sql);
if (_psyco_curs_execute(self, operation, parameters, async)) {
Py_INCREF(Py_None);
res = Py_None;
Py_INCREF(parameters);
res = parameters;
}
Py_DECREF(operation);

View File

@ -844,6 +844,7 @@ int
pq_fetch(cursorObject *curs)
{
int pgstatus, ex = -1;
const char *rowcount;
/* even if we fail, we remove any information about the previous query */
curs_reset(curs);
@ -920,7 +921,11 @@ pq_fetch(cursorObject *curs)
case PGRES_COMMAND_OK:
Dprintf("pq_fetch: command returned OK (no tuples)");
curs->rowcount = atoi(PQcmdTuples(curs->pgres));
rowcount = PQcmdTuples(curs->pgres);
if (!rowcount || !rowcount[0])
curs->rowcount = -1;
else
curs->rowcount = atoi(rowcount);
curs->lastoid = PQoidValue(curs->pgres);
CLEARPGRES(curs->pgres);
ex = 1;