summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2005-03-31 06:26:19 +0000
committerFederico Di Gregorio <fog@initd.org>2005-03-31 06:26:19 +0000
commit5db776420703e392e839d7fcb833274f65b7893f (patch)
tree3efdfcbae18aa1da11289163dc670023db65b925
parentf4ad71fc1d69544b8c9aa3edb0d30f9c6fd96462 (diff)
downloadpsycopg2-5db776420703e392e839d7fcb833274f65b7893f.tar.gz
Fixed .rowcount (closes: #6).
-rw-r--r--psycopg/adapter_binary.c2
-rw-r--r--psycopg/adapter_qstring.c2
-rw-r--r--psycopg/pqpath.c12
3 files changed, 4 insertions, 12 deletions
diff --git a/psycopg/adapter_binary.c b/psycopg/adapter_binary.c
index a114f3f..7aa775d 100644
--- a/psycopg/adapter_binary.c
+++ b/psycopg/adapter_binary.c
@@ -39,7 +39,7 @@
#define binary_escape PQescapeBytea
#else
static unsigned char *
-binary_escape(char *from, size_t from_length, size_t *to_length)
+binary_escape(char *from, int from_length, int *to_length)
{
unsigneed char *quoted, *chptr, *newptr;
int i, space, new_space;
diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c
index 67d2708..b033517 100644
--- a/psycopg/adapter_qstring.c
+++ b/psycopg/adapter_qstring.c
@@ -80,7 +80,7 @@ qstring_quote(qstringObject *self)
{
PyObject *str;
char *s, *buffer;
- size_t len;
+ int len;
/* if the wrapped object is an unicode object we can encode it to match
self->encoding but if the encoding is not specified we don't know what
diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c
index 034ded7..0292335 100644
--- a/psycopg/pqpath.c
+++ b/psycopg/pqpath.c
@@ -790,18 +790,11 @@ pq_fetch(cursorObject *curs)
Py_XDECREF(curs->pgstatus);
curs->pgstatus = PyString_FromString(PQcmdStatus(curs->pgres));
- /* rowcount has a meaning even for INSERT and UPDATES but to get the right
- number we need to check two times, one with PQntuples for SELECts and
- one with PQcmdTuples for other queries */
- curs->rowcount = PQntuples(curs->pgres);
- if (curs->rowcount == 0)
- curs->rowcount = atoi(PQcmdTuples(curs->pgres));
-
switch(pgstatus) {
case PGRES_COMMAND_OK:
Dprintf("pq_fetch: command returned OK (no tuples)");
- curs->rowcount = 0;
+ curs->rowcount = atoi(PQcmdTuples(curs->pgres));
curs->lastoid = PQoidValue(curs->pgres);
CLEARPGRES(curs->pgres);
ex = 1;
@@ -809,7 +802,6 @@ pq_fetch(cursorObject *curs)
case PGRES_COPY_OUT:
Dprintf("pq_fetch: data from a COPY TO (no tuples)");
- curs->rowcount = 0;
#ifdef HAVE_PQPROTOCOL3
if (curs->conn->protocol == 3)
ex = _pq_copy_out_v3(curs);
@@ -823,7 +815,6 @@ pq_fetch(cursorObject *curs)
case PGRES_COPY_IN:
Dprintf("pq_fetch: data from a COPY FROM (no tuples)");
- curs->rowcount = 0;
#ifdef HAVE_PQPROTOCOL3
if (curs->conn->protocol == 3)
ex = _pq_copy_in_v3(curs);
@@ -837,6 +828,7 @@ pq_fetch(cursorObject *curs)
case PGRES_TUPLES_OK:
Dprintf("pq_fetch: data from a SELECT (got tuples)");
+ curs->rowcount = PQntuples(curs->pgres);
_pq_fetch_tuples(curs); ex = 0;
/* don't clear curs->pgres, because it contains the results! */
break;