Fixed problem with unitialized value in dsize.

This commit is contained in:
Federico Di Gregorio 2005-11-07 14:26:41 +00:00
parent e727c49134
commit 770e7c34d3
3 changed files with 19 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2005-11-07 Federico Di Gregorio <fog@initd.org>
* psycopg/pqpath.c: fixed problem with uninitialized value (all this was
started by replacing calloc() calls with PyMem_Malloc().)
2005-11-04 Federico Di Gregorio <fog@initd.org>
* psycopg/typecast.c: a lot of changes:

View File

@ -462,17 +462,14 @@ _pq_fetch_tuples(cursorObject *curs)
#ifdef PSYCOPG_DISPLAY_SIZE
dsize = (int *)PyMem_Malloc(pgnfields * sizeof(int));
if (dsize != NULL) {
if (curs->rowcount == 0) {
for (i=0; i < pgnfields; i++)
dsize[i] = -1;
int j, len;
for (i=0; i < pgnfields; i++) {
dsize[i] = -1;
}
else {
int j, len;
for (j = 0; j < curs->rowcount; j++) {
for (i = 0; i < pgnfields; i++) {
len = PQgetlength(curs->pgres, j, i);
if (len > dsize[i]) dsize[i] = len;
}
for (j = 0; j < curs->rowcount; j++) {
for (i = 0; i < pgnfields; i++) {
len = PQgetlength(curs->pgres, j, i);
if (len > dsize[i]) dsize[i] = len;
}
}
}
@ -486,7 +483,7 @@ _pq_fetch_tuples(cursorObject *curs)
PyObject *dtitem = PyTuple_New(7);
PyObject *type = PyInt_FromLong(ftype);
PyObject *cast;
PyObject *cast = NULL;
PyTuple_SET_ITEM(curs->description, i, dtitem);
@ -502,7 +499,8 @@ _pq_fetch_tuples(cursorObject *curs)
}
}
/* else if we got binary tuples and if we got a field that
is binary use the default cast.
is binary use the default cast
FIXME: what the hell am I trying to do here? This just can't work..
*/
else if (pgbintuples && cast == psyco_default_binary_cast) {
Dprintf("_pq_fetch_tuples: Binary cursor and "

View File

@ -1,5 +1,9 @@
[build_ext]
define=PSYCOPG_EXTENSIONS,PSYCOPG_DISPLAY_SIZE,HAVE_PQFREEMEM,HAVE_PQPROTOCOL3
# PSYCOPG_EXTENSIONS enables extensions to PEP-249 (you really want this)
# PSYCOPG_DISPLAY_SIZE enable display size calculation (a little slower)
# HAVE_PQFREEMEM should be defined on PostgreSQL >= 7.4
# HAVE_PQPROTOCOL3 should be defined on PostgreSQL >= 8.0
# PSYCOPG_DEBUG can be added to enable verbose debug information
# PSYCOPG_OWN_QUOTING can be added above but it is deprecated