summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2016-04-09 20:44:54 +0000
committerTom Lane2016-04-09 20:44:54 +0000
commitc7a141a9866b8c15d9e3b6fd5310e54837900394 (patch)
tree4226ea33c4b22451253eafd33fa215f7eaf67396
parent08e785436f84f8824149a2182b0cb9ce2c28e31d (diff)
Fix PL/Python ereport() test to work on Python 2.3.
Per buildfarm. Pavel Stehule
-rw-r--r--src/pl/plpython/expected/plpython_test.out24
-rw-r--r--src/pl/plpython/sql/plpython_test.sql8
2 files changed, 20 insertions, 12 deletions
diff --git a/src/pl/plpython/expected/plpython_test.out b/src/pl/plpython/expected/plpython_test.out
index 05caba1787..bdff07a5fb 100644
--- a/src/pl/plpython/expected/plpython_test.out
+++ b/src/pl/plpython/expected/plpython_test.out
@@ -150,22 +150,26 @@ RETURNS void AS $$
kwargs = { "message":_message, "detail":_detail, "hint":_hint,
"sqlstate":_sqlstate, "schema":_schema, "table":_table,
"column":_column, "datatype":_datatype, "constraint":_constraint }
-# ignore None values
-plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
+# 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)
$$ 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 6, in <module>
- plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
+ PL/Python function "raise_exception", line 10, in <module>
+ plpy.error(**dict)
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 6, in <module>
- plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
+ PL/Python function "raise_exception", line 10, in <module>
+ plpy.error(**dict)
PL/Python function "raise_exception"
SELECT raise_exception(_message => 'message text',
_detail => 'detail text',
@@ -180,8 +184,8 @@ ERROR: plpy.Error: message text
DETAIL: detail text
HINT: hint text
CONTEXT: Traceback (most recent call last):
- PL/Python function "raise_exception", line 6, in <module>
- plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
+ PL/Python function "raise_exception", line 10, in <module>
+ plpy.error(**dict)
PL/Python function "raise_exception"
SELECT raise_exception(_message => 'message text',
_hint => 'hint text',
@@ -191,8 +195,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 6, in <module>
- plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
+ PL/Python function "raise_exception", line 10, in <module>
+ plpy.error(**dict)
PL/Python function "raise_exception"
DO $$
DECLARE
diff --git a/src/pl/plpython/sql/plpython_test.sql b/src/pl/plpython/sql/plpython_test.sql
index 6e5b535ceb..b74c68fe3e 100644
--- a/src/pl/plpython/sql/plpython_test.sql
+++ b/src/pl/plpython/sql/plpython_test.sql
@@ -102,8 +102,12 @@ RETURNS void AS $$
kwargs = { "message":_message, "detail":_detail, "hint":_hint,
"sqlstate":_sqlstate, "schema":_schema, "table":_table,
"column":_column, "datatype":_datatype, "constraint":_constraint }
-# ignore None values
-plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
+# 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)
$$ LANGUAGE plpythonu;
SELECT raise_exception('hello', 'world');