@ -94,26 +94,22 @@ kwargs = {
"column_name": _column_name, "datatype_name": _datatype_name,
"column_name": _column_name, "datatype_name": _datatype_name,
"constraint_name": _constraint_name
"constraint_name": _constraint_name
}
}
# ignore None values - should work on Python2.3
# ignore None values
dict = {}
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
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 13 , in <module>
PL/Python function "raise_exception", line 9 , in <module>
plpy.error(**dict)
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v) )
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 13 , in <module>
PL/Python function "raise_exception", line 9 , in <module>
plpy.error(**dict)
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v) )
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',
@ -128,8 +124,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 13 , in <module>
PL/Python function "raise_exception", line 9 , in <module>
plpy.error(**dict)
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v) )
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',
@ -139,8 +135,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 13 , in <module>
PL/Python function "raise_exception", line 9 , in <module>
plpy.error(**dict)
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v) )
PL/Python function "raise_exception"
PL/Python function "raise_exception"
DO $$
DO $$
DECLARE
DECLARE