summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--psycopg/cursor_type.c11
-rw-r--r--psycopg/pqpath.c7
2 files changed, 12 insertions, 6 deletions
diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c
index 1d055f6..bcbae3f 100644
--- a/psycopg/cursor_type.c
+++ b/psycopg/cursor_type.c
@@ -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);
diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c
index f5c3868..8c2c8a1 100644
--- a/psycopg/pqpath.c
+++ b/psycopg/pqpath.c
@@ -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;