mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Fix PL/Python ereport() test to work on Python 2.3.
Per buildfarm. Pavel Stehule
This commit is contained in:
@ -150,22 +150,26 @@ RETURNS void AS $$
|
|||||||
kwargs = { "message":_message, "detail":_detail, "hint":_hint,
|
kwargs = { "message":_message, "detail":_detail, "hint":_hint,
|
||||||
"sqlstate":_sqlstate, "schema":_schema, "table":_table,
|
"sqlstate":_sqlstate, "schema":_schema, "table":_table,
|
||||||
"column":_column, "datatype":_datatype, "constraint":_constraint }
|
"column":_column, "datatype":_datatype, "constraint":_constraint }
|
||||||
# ignore None values
|
# ignore None values - should work on Python2.3
|
||||||
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
|
dict = {}
|
||||||
|
for k in kwargs:
|
||||||
|
if kwargs[k] is not None:
|
||||||
|
dict[k] = kwargs[k]
|
||||||
|
plpy.error(**dict)
|
||||||
$$ LANGUAGE plpythonu;
|
$$ LANGUAGE plpythonu;
|
||||||
SELECT raise_exception('hello', 'world');
|
SELECT raise_exception('hello', 'world');
|
||||||
ERROR: plpy.Error: hello
|
ERROR: plpy.Error: hello
|
||||||
DETAIL: world
|
DETAIL: world
|
||||||
CONTEXT: Traceback (most recent call last):
|
CONTEXT: Traceback (most recent call last):
|
||||||
PL/Python function "raise_exception", line 6, in <module>
|
PL/Python function "raise_exception", line 10, in <module>
|
||||||
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
|
plpy.error(**dict)
|
||||||
PL/Python function "raise_exception"
|
PL/Python function "raise_exception"
|
||||||
SELECT raise_exception('message text', 'detail text', _sqlstate => 'YY333');
|
SELECT raise_exception('message text', 'detail text', _sqlstate => 'YY333');
|
||||||
ERROR: plpy.Error: message text
|
ERROR: plpy.Error: message text
|
||||||
DETAIL: detail text
|
DETAIL: detail text
|
||||||
CONTEXT: Traceback (most recent call last):
|
CONTEXT: Traceback (most recent call last):
|
||||||
PL/Python function "raise_exception", line 6, in <module>
|
PL/Python function "raise_exception", line 10, in <module>
|
||||||
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
|
plpy.error(**dict)
|
||||||
PL/Python function "raise_exception"
|
PL/Python function "raise_exception"
|
||||||
SELECT raise_exception(_message => 'message text',
|
SELECT raise_exception(_message => 'message text',
|
||||||
_detail => 'detail text',
|
_detail => 'detail text',
|
||||||
@ -180,8 +184,8 @@ ERROR: plpy.Error: message text
|
|||||||
DETAIL: detail text
|
DETAIL: detail text
|
||||||
HINT: hint text
|
HINT: hint text
|
||||||
CONTEXT: Traceback (most recent call last):
|
CONTEXT: Traceback (most recent call last):
|
||||||
PL/Python function "raise_exception", line 6, in <module>
|
PL/Python function "raise_exception", line 10, in <module>
|
||||||
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
|
plpy.error(**dict)
|
||||||
PL/Python function "raise_exception"
|
PL/Python function "raise_exception"
|
||||||
SELECT raise_exception(_message => 'message text',
|
SELECT raise_exception(_message => 'message text',
|
||||||
_hint => 'hint text',
|
_hint => 'hint text',
|
||||||
@ -191,8 +195,8 @@ SELECT raise_exception(_message => 'message text',
|
|||||||
ERROR: plpy.Error: message text
|
ERROR: plpy.Error: message text
|
||||||
HINT: hint text
|
HINT: hint text
|
||||||
CONTEXT: Traceback (most recent call last):
|
CONTEXT: Traceback (most recent call last):
|
||||||
PL/Python function "raise_exception", line 6, in <module>
|
PL/Python function "raise_exception", line 10, in <module>
|
||||||
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
|
plpy.error(**dict)
|
||||||
PL/Python function "raise_exception"
|
PL/Python function "raise_exception"
|
||||||
DO $$
|
DO $$
|
||||||
DECLARE
|
DECLARE
|
||||||
|
@ -102,8 +102,12 @@ RETURNS void AS $$
|
|||||||
kwargs = { "message":_message, "detail":_detail, "hint":_hint,
|
kwargs = { "message":_message, "detail":_detail, "hint":_hint,
|
||||||
"sqlstate":_sqlstate, "schema":_schema, "table":_table,
|
"sqlstate":_sqlstate, "schema":_schema, "table":_table,
|
||||||
"column":_column, "datatype":_datatype, "constraint":_constraint }
|
"column":_column, "datatype":_datatype, "constraint":_constraint }
|
||||||
# ignore None values
|
# ignore None values - should work on Python2.3
|
||||||
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
|
dict = {}
|
||||||
|
for k in kwargs:
|
||||||
|
if kwargs[k] is not None:
|
||||||
|
dict[k] = kwargs[k]
|
||||||
|
plpy.error(**dict)
|
||||||
$$ LANGUAGE plpythonu;
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
SELECT raise_exception('hello', 'world');
|
SELECT raise_exception('hello', 'world');
|
||||||
|
Reference in New Issue
Block a user