Skip to content

Commit bfe8b89

Browse files
committed
Allow pl/pythonu >= version 2.3 to return boolean, rather than 1/0.
Marko Kreen
1 parent 749167c commit bfe8b89

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/pl/plpython/plpython.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**********************************************************************
22
* plpython.c - python as a procedural language for PostgreSQL
33
*
4-
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.98 2007/04/03 13:37:22 momjian Exp $
4+
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.99 2007/04/03 15:50:58 momjian Exp $
55
*
66
*********************************************************************
77
*/
@@ -32,6 +32,14 @@ typedef int Py_ssize_t;
3232
#define PY_SSIZE_T_MIN INT_MIN
3333
#endif
3434

35+
/*
36+
* PyBool_FromLong is supported from 2.3.
37+
*/
38+
#if PY_VERSION_HEX < 0x02030000
39+
#define PyBool_FromLong(x) PyInt_FromLong(x)
40+
#endif
41+
42+
3543
#include "postgres.h"
3644

3745
/* system stuff */
@@ -1600,8 +1608,8 @@ PLyBool_FromString(const char *src)
16001608
* versions. http://docs.python.org/api/boolObjects.html
16011609
*/
16021610
if (src[0] == 't')
1603-
return PyInt_FromLong(1);
1604-
return PyInt_FromLong(0);
1611+
return PyBool_FromLong(1);
1612+
return PyBool_FromLong(0);
16051613
}
16061614

16071615
static PyObject *

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy