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
This commit is contained in:
Bruce Momjian 2001-10-04 15:45:49 +00:00
parent a6020b396b
commit 96471bf106

View file

@ -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)
{