diff options
author | Bruce Momjian <bruce@momjian.us> | 2007-04-03 15:50:58 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2007-04-03 15:50:58 +0000 |
commit | bfe8b89e41850b67e2dedf117594daa8c9fbafbc (patch) | |
tree | d0abcd6f3e510f2ad7dc366fb4d16e4acc2d9f93 /src | |
parent | 749167cf2ac9b929b04784b597bf41dd9e04d552 (diff) | |
download | postgresql-bfe8b89e41850b67e2dedf117594daa8c9fbafbc.tar.gz postgresql-bfe8b89e41850b67e2dedf117594daa8c9fbafbc.zip |
Allow pl/pythonu >= version 2.3 to return boolean, rather than 1/0.
Marko Kreen
Diffstat (limited to 'src')
-rw-r--r-- | src/pl/plpython/plpython.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index ba7cc4cdda2..8771f60d57b 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -1,7 +1,7 @@ /********************************************************************** * plpython.c - python as a procedural language for PostgreSQL * - * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.98 2007/04/03 13:37:22 momjian Exp $ + * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.99 2007/04/03 15:50:58 momjian Exp $ * ********************************************************************* */ @@ -32,6 +32,14 @@ typedef int Py_ssize_t; #define PY_SSIZE_T_MIN INT_MIN #endif +/* + * PyBool_FromLong is supported from 2.3. + */ +#if PY_VERSION_HEX < 0x02030000 +#define PyBool_FromLong(x) PyInt_FromLong(x) +#endif + + #include "postgres.h" /* system stuff */ @@ -1600,8 +1608,8 @@ PLyBool_FromString(const char *src) * versions. http://docs.python.org/api/boolObjects.html */ if (src[0] == 't') - return PyInt_FromLong(1); - return PyInt_FromLong(0); + return PyBool_FromLong(1); + return PyBool_FromLong(0); } static PyObject * |