diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pl/plpython/expected/plpython_ereport.out | 24 | ||||
-rw-r--r-- | src/pl/plpython/plpy_typeio.c | 10 | ||||
-rw-r--r-- | src/pl/plpython/sql/plpython_ereport.sql | 8 |
3 files changed, 14 insertions, 28 deletions
diff --git a/src/pl/plpython/expected/plpython_ereport.out b/src/pl/plpython/expected/plpython_ereport.out index 13bd0ab3352..1dafd94c721 100644 --- a/src/pl/plpython/expected/plpython_ereport.out +++ b/src/pl/plpython/expected/plpython_ereport.out @@ -94,26 +94,22 @@ kwargs = { "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', @@ -128,8 +124,8 @@ ERROR: plpy.Error: message 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', @@ -139,8 +135,8 @@ SELECT raise_exception(_message => 'message 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 diff --git a/src/pl/plpython/plpy_typeio.c b/src/pl/plpython/plpy_typeio.c index b9c6d64baaf..06743e46ed5 100644 --- a/src/pl/plpython/plpy_typeio.c +++ b/src/pl/plpython/plpy_typeio.c @@ -521,15 +521,9 @@ PLy_input_datum_func2(PLyDatumToOb *arg, MemoryContext arg_mcxt, Oid typeOid, He 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 * diff --git a/src/pl/plpython/sql/plpython_ereport.sql b/src/pl/plpython/sql/plpython_ereport.sql index 2612e933876..889293d33c9 100644 --- a/src/pl/plpython/sql/plpython_ereport.sql +++ b/src/pl/plpython/sql/plpython_ereport.sql @@ -55,12 +55,8 @@ kwargs = { "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'); |