aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/python/pgmodule.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-08-15 03:31:45 +0000
committerBruce Momjian <bruce@momjian.us>2002-08-15 03:31:45 +0000
commit147aa84c1a0c4ed6444696e04881e938f38c3c20 (patch)
tree58d9827e6324f7d85e686fc15c6d9c8cb268a8fa /src/interfaces/python/pgmodule.c
parentdb147006c103b67a23fb63a2d5ed08c92a6c2a80 (diff)
downloadpostgresql-147aa84c1a0c4ed6444696e04881e938f38c3c20.tar.gz
postgresql-147aa84c1a0c4ed6444696e04881e938f38c3c20.zip
http://archives.postgresql.org/pgsql-bugs/2002-06/msg00086.php and never
saw a fix offered up. Since I'm gearing up to use Postgres and Python soon, I figured I'd have a hand at trying to get this sucker addressed. Apologies if this has already been plugged. I looked in the archives and never saw a response. At any rate, I must admit I don't think I fully understand the implications of some of the changes I made even though they appear to be straight forward. We all know the devil is in the details. Anyone more knowledgeable is requested to review my changes. :( I also updated the advanced.py script in a somewhat nonsensical fashion to make use of an int8 field in an effort to test this change. It seems to run okay, however, this is by no means an all exhaustive test. So, it's possible that a bumpy road may lay ahead for some. On the other hand...overflows (hopefully) previously lurked (long -> int conversion). Greg Copeland
Diffstat (limited to 'src/interfaces/python/pgmodule.c')
-rw-r--r--src/interfaces/python/pgmodule.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/interfaces/python/pgmodule.c b/src/interfaces/python/pgmodule.c
index df685902531..355c3e4725d 100644
--- a/src/interfaces/python/pgmodule.c
+++ b/src/interfaces/python/pgmodule.c
@@ -289,23 +289,26 @@ get_type_array(PGresult *result, int nfields)
{
case INT2OID:
case INT4OID:
- case INT8OID:
case OIDOID:
typ[j] = 1;
break;
+ case INT8OID:
+ typ[j] = 2;
+ break;
+
case FLOAT4OID:
case FLOAT8OID:
case NUMERICOID:
- typ[j] = 2;
+ typ[j] = 3;
break;
case CASHOID:
- typ[j] = 3;
+ typ[j] = 4;
break;
default:
- typ[j] = 4;
+ typ[j] = 5;
break;
}
}
@@ -1797,23 +1800,26 @@ pgquery_getresult(pgqueryobject * self, PyObject * args)
{
case INT2OID:
case INT4OID:
- case INT8OID:
case OIDOID:
typ[j] = 1;
break;
+ case INT8OID:
+ typ[j] = 2;
+ break;
+
case FLOAT4OID:
case FLOAT8OID:
case NUMERICOID:
- typ[j] = 2;
+ typ[j] = 3;
break;
case CASHOID:
- typ[j] = 3;
+ typ[j] = 4;
break;
default:
- typ[j] = 4;
+ typ[j] = 5;
break;
}
}
@@ -1846,10 +1852,14 @@ pgquery_getresult(pgqueryobject * self, PyObject * args)
break;
case 2:
- val = PyFloat_FromDouble(strtod(s, NULL));
+ val = PyLong_FromLong(strtol(s, NULL, 10));
break;
case 3:
+ val = PyFloat_FromDouble(strtod(s, NULL));
+ break;
+
+ case 4:
{
int mult = 1;
@@ -1946,11 +1956,14 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args)
{
case INT2OID:
case INT4OID:
- case INT8OID:
case OIDOID:
typ[j] = 1;
break;
+ case INT8OID:
+ typ[j] = 2;
+ break;
+
case FLOAT4OID:
case FLOAT8OID:
case NUMERICOID:
@@ -1995,10 +2008,14 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args)
break;
case 2:
- val = PyFloat_FromDouble(strtod(s, NULL));
+ val = PyLong_FromLong(strtol(s, NULL, 10));
break;
case 3:
+ val = PyFloat_FromDouble(strtod(s, NULL));
+ break;
+
+ case 4:
{
int mult = 1;