From: Bruce Momjian Date: Thu, 4 Oct 2001 15:45:49 +0000 (+0000) Subject: Using strtol() on int8 values (input parameters or result sets) in X-Git-Tag: REL7_2_BETA1~188 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=96471bf1068ae757b988aa7678a70b1bb953ea66;p=postgresql Using strtol() on int8 values (input parameters or result sets) in plpython would result in numeric overflows causing the backend to terminate abruptly. This patch fixes it. Bradley McLean --- diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index 2cfdeade62..cd3486fa6d 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -29,7 +29,7 @@ * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.6 2001/10/01 17:53:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.7 2001/10/04 15:45:49 momjian Exp $ * ********************************************************************* */ @@ -229,6 +229,7 @@ static PyObject *PLyDict_FromTuple(PLyTypeInfo *, HeapTuple, TupleDesc); static PyObject *PLyBool_FromString(const char *); static PyObject *PLyFloat_FromString(const char *); static PyObject *PLyInt_FromString(const char *); +static PyObject *PLyLong_FromString(const char *); static PyObject *PLyString_FromString(const char *); @@ -1378,12 +1379,16 @@ PLy_input_datum_func2(PLyDatumToOb *arg, Form_pg_type typeStruct) case 'i': { if ((strncasecmp("int", type, 3) == 0) && - ((type[3] == '4') || (type[3] == '2') || (type[3] == '8')) && + ((type[3] == '4') || (type[3] == '2')) && (type[4] == '\0')) { arg->func = PLyInt_FromString; return; } + else if ( strcasecmp("int8", type) == 0 ) + { + arg->func = PLyLong_FromString; + } break; } case 'n': @@ -1464,6 +1469,12 @@ PLyInt_FromString(const char *src) return PyInt_FromLong(v); } +PyObject * +PLyLong_FromString(const char *src) +{ + return PyLong_FromString((char *)src,NULL,0); +} + PyObject * PLyString_FromString(const char *src) {