fi
AC_MSG_CHECKING([Python configuration directory])
python_majorversion=`${PYTHON} -c "import sys; print(sys.version[[0]])"`
+python_minorversion=`${PYTHON} -c "import sys; print(sys.version[[2]])"`
python_version=`${PYTHON} -c "import sys; print(sys.version[[:3]])"`
python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
AC_MSG_RESULT([$python_configdir])
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python configuration directory" >&5
$as_echo_n "checking Python configuration directory... " >&6; }
python_majorversion=`${PYTHON} -c "import sys; print(sys.version[0])"`
+python_minorversion=`${PYTHON} -c "import sys; print(sys.version[2])"`
python_version=`${PYTHON} -c "import sys; print(sys.version[:3])"`
python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $python_configdir" >&5
+ if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
+ as_fn_error $? "Python version $python_version is too old (version 2.4 or later is required)" "$LINENO" 5
+ fi
fi
if test "$cross_compiling" = yes && test -z "$with_system_tzdata"; then
if test "$with_python" = yes; then
PGAC_PATH_PYTHON
PGAC_CHECK_PYTHON_EMBED_SETUP
+ if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
+ AC_MSG_ERROR([Python version $python_version is too old (version 2.4 or later is required)])
+ fi
fi
if test "$cross_compiling" = yes && test -z "$with_system_tzdata"; then
TRANSFORM FOR TYPE hstore
AS $$
assert isinstance(val, dict)
-i = list(val.items())
-i.sort()
-plpy.info(i)
+plpy.info(sorted(val.items()))
return len(val)
$$;
SELECT test1('aa=>bb, cc=>NULL'::hstore);
TRANSFORM FOR TYPE hstore
AS $$
assert isinstance(val, dict)
-i = list(val.items())
-i.sort()
-plpy.info(i)
+plpy.info(sorted(val.items()))
return len(val)
$$;
SELECT test1n('aa=>bb, cc=>NULL'::hstore);
TRANSFORM FOR TYPE hstore
AS $$
assert isinstance(val, dict)
-i = list(val.items())
-i.sort()
-plpy.info(i)
+plpy.info(sorted(val.items()))
return len(val)
$$;
TRANSFORM FOR TYPE hstore
AS $$
assert isinstance(val, dict)
-i = list(val.items())
-i.sort()
-plpy.info(i)
+plpy.info(sorted(val.items()))
return len(val)
$$;
language, you need a <productname>Python</productname>
installation with the header files and
the <application>distutils</application> module. The minimum
- required version is <productname>Python</productname> 2.3.
- (To work with function arguments of type <type>numeric</>, a 2.3.x
- installation must include the separately-available <filename>cdecimal</>
- module; note the <application>PL/Python</> regression tests
- will not pass if that is missing.)
+ required version is <productname>Python</productname> 2.4.
<productname>Python 3</productname> is supported if it's
version 3.1 or later; but see
<![%standalone-include[the <application>PL/Python</> documentation]]>
"column_name": _column_name, "datatype_name": _datatype_name,
"constraint_name": _constraint_name
}
-# ignore None values - should work on Python2.3
-dict = {}
-for k in kwargs:
- if kwargs[k] is not None:
- dict[k] = kwargs[k]
-plpy.error(**dict)
+# ignore None values
+plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
$$ LANGUAGE plpythonu;
SELECT raise_exception('hello', 'world');
ERROR: plpy.Error: hello
DETAIL: world
CONTEXT: Traceback (most recent call last):
- PL/Python function "raise_exception", line 13, in <module>
- plpy.error(**dict)
+ PL/Python function "raise_exception", line 9, in <module>
+ plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
PL/Python function "raise_exception"
SELECT raise_exception('message text', 'detail text', _sqlstate => 'YY333');
ERROR: plpy.Error: message text
DETAIL: detail text
CONTEXT: Traceback (most recent call last):
- PL/Python function "raise_exception", line 13, in <module>
- plpy.error(**dict)
+ PL/Python function "raise_exception", line 9, in <module>
+ plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
PL/Python function "raise_exception"
SELECT raise_exception(_message => 'message text',
_detail => 'detail text',
DETAIL: detail text
HINT: hint text
CONTEXT: Traceback (most recent call last):
- PL/Python function "raise_exception", line 13, in <module>
- plpy.error(**dict)
+ PL/Python function "raise_exception", line 9, in <module>
+ plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
PL/Python function "raise_exception"
SELECT raise_exception(_message => 'message text',
_hint => 'hint text',
ERROR: plpy.Error: message text
HINT: hint text
CONTEXT: Traceback (most recent call last):
- PL/Python function "raise_exception", line 13, in <module>
- plpy.error(**dict)
+ PL/Python function "raise_exception", line 9, in <module>
+ plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
PL/Python function "raise_exception"
DO $$
DECLARE
static PyObject *
PLyBool_FromBool(PLyDatumToOb *arg, Datum d)
{
- /*
- * We would like to use Py_RETURN_TRUE and Py_RETURN_FALSE here for
- * generating SQL from trigger functions, but those are only supported in
- * Python >= 2.4, and we support older versions.
- * http://docs.python.org/api/boolObjects.html
- */
if (DatumGetBool(d))
- return PyBool_FromLong(1);
- return PyBool_FromLong(0);
+ Py_RETURN_TRUE;
+ Py_RETURN_FALSE;
}
static PyObject *
"column_name": _column_name, "datatype_name": _datatype_name,
"constraint_name": _constraint_name
}
-# ignore None values - should work on Python2.3
-dict = {}
-for k in kwargs:
- if kwargs[k] is not None:
- dict[k] = kwargs[k]
-plpy.error(**dict)
+# ignore None values
+plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
$$ LANGUAGE plpythonu;
SELECT raise_exception('hello', 'world');