Commit f8c8386a authored by Peter Eisentraut's avatar Peter Eisentraut

Cleanup pass over PL/Python NLS. Add translation support to PLy_elog and

PLy_exception_set, and clarify some error messages.
parent d0fe3df7
# $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.31 2008/10/02 08:11:11 petere Exp $ # $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.32 2009/01/15 13:49:56 petere Exp $
subdir = src/pl/plpython subdir = src/pl/plpython
top_builddir = ../../.. top_builddir = ../../..
...@@ -54,7 +54,7 @@ python${pytverstr}.def: $(WD)/system32/python${pytverstr}.dll ...@@ -54,7 +54,7 @@ python${pytverstr}.def: $(WD)/system32/python${pytverstr}.dll
endif endif
SHLIB_LINK = $(python_libspec) $(python_additional_libs) SHLIB_LINK = $(python_libspec) $(python_additional_libs) $(filter -lintl,$(LIBS))
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plpythonu REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plpythonu
REGRESS = plpython_schema plpython_populate plpython_function plpython_test plpython_error plpython_drop REGRESS = plpython_schema plpython_populate plpython_function plpython_test plpython_error plpython_drop
......
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
-- the trigger handler once. the errors and subsequent core dump were -- the trigger handler once. the errors and subsequent core dump were
-- interesting. -- interesting.
SELECT invalid_type_uncaught('rick'); SELECT invalid_type_uncaught('rick');
WARNING: plpython: in function invalid_type_uncaught: WARNING: PL/Python: in PL/Python function "invalid_type_uncaught"
DETAIL: plpy.SPIError: Unknown error in PLy_spi_prepare DETAIL: <class 'plpy.SPIError'>: unrecognized error in PLy_spi_prepare
ERROR: type "test" does not exist ERROR: type "test" does not exist
SELECT invalid_type_caught('rick'); SELECT invalid_type_caught('rick');
WARNING: plpython: in function invalid_type_caught: WARNING: PL/Python: in PL/Python function "invalid_type_caught"
DETAIL: plpy.SPIError: Unknown error in PLy_spi_prepare DETAIL: <class 'plpy.SPIError'>: unrecognized error in PLy_spi_prepare
ERROR: type "test" does not exist ERROR: type "test" does not exist
SELECT invalid_type_reraised('rick'); SELECT invalid_type_reraised('rick');
WARNING: plpython: in function invalid_type_reraised: WARNING: PL/Python: in PL/Python function "invalid_type_reraised"
DETAIL: plpy.SPIError: Unknown error in PLy_spi_prepare DETAIL: <class 'plpy.SPIError'>: unrecognized error in PLy_spi_prepare
ERROR: type "test" does not exist ERROR: type "test" does not exist
SELECT valid_type('rick'); SELECT valid_type('rick');
valid_type valid_type
...@@ -23,16 +23,16 @@ SELECT valid_type('rick'); ...@@ -23,16 +23,16 @@ SELECT valid_type('rick');
-- Test Unicode error handling. -- Test Unicode error handling.
-- --
SELECT unicode_return_error(); SELECT unicode_return_error();
ERROR: plpython: function "unicode_return_error" could not create return value ERROR: PL/Python: could not create string representation of Python object in PL/Python function "unicode_return_error" while creating return value
DETAIL: exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128) DETAIL: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
INSERT INTO unicode_test (testvalue) VALUES ('test'); INSERT INTO unicode_test (testvalue) VALUES ('test');
ERROR: plpython: function "unicode_trigger_error" could not modify tuple ERROR: PL/Python: could not compute string representation of Python object in PL/Python function "unicode_trigger_error" while modifying trigger row
DETAIL: exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128) DETAIL: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
SELECT unicode_plan_error1(); SELECT unicode_plan_error1();
WARNING: plpython: in function unicode_plan_error1: WARNING: PL/Python: in PL/Python function "unicode_plan_error1"
DETAIL: plpy.Error: Unknown error in PLy_spi_execute_plan DETAIL: <class 'plpy.Error'>: unrecognized error in PLy_spi_execute_plan
ERROR: plpython: function "unicode_plan_error1" could not execute plan ERROR: PL/Python: PL/Python function "unicode_plan_error1" could not execute plan
DETAIL: exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128) DETAIL: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
SELECT unicode_plan_error2(); SELECT unicode_plan_error2();
ERROR: plpython: function "unicode_plan_error2" could not execute plan ERROR: PL/Python: PL/Python function "unicode_plan_error2" could not execute plan
DETAIL: exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128) DETAIL: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\x80' in position 0: ordinal not in range(128)
...@@ -190,8 +190,7 @@ SELECT test_void_func1(), test_void_func1() IS NULL AS "is null"; ...@@ -190,8 +190,7 @@ SELECT test_void_func1(), test_void_func1() IS NULL AS "is null";
(1 row) (1 row)
SELECT test_void_func2(); -- should fail SELECT test_void_func2(); -- should fail
ERROR: invalid return value from plpython function ERROR: PL/Python function with return type "void" did not return None
DETAIL: Functions returning type "void" must return None.
SELECT test_return_none(), test_return_none() IS NULL AS "is null"; SELECT test_return_none(), test_return_none() IS NULL AS "is null";
test_return_none | is null test_return_none | is null
------------------+--------- ------------------+---------
...@@ -547,7 +546,7 @@ SELECT * FROM test_in_out_params('test_in'); ...@@ -547,7 +546,7 @@ SELECT * FROM test_in_out_params('test_in');
-- this doesn't work yet :-( -- this doesn't work yet :-(
SELECT * FROM test_in_out_params_multi('test_in'); SELECT * FROM test_in_out_params_multi('test_in');
ERROR: plpython functions cannot return type record ERROR: PL/Python functions cannot return type record
SELECT * FROM test_inout_params('test_in'); SELECT * FROM test_inout_params('test_in');
first first
--------------- ---------------
......
# $PostgreSQL: pgsql/src/pl/plpython/nls.mk,v 1.1 2008/10/09 17:24:05 alvherre Exp $ # $PostgreSQL: pgsql/src/pl/plpython/nls.mk,v 1.2 2009/01/15 13:49:56 petere Exp $
CATALOG_NAME := plpython CATALOG_NAME := plpython
AVAIL_LANGUAGES := AVAIL_LANGUAGES :=
GETTEXT_FILES := plpython.c GETTEXT_FILES := plpython.c
GETTEXT_TRIGGERS:= _ errmsg errdetail errdetail_log errhint errcontext write_stderr yyerror GETTEXT_TRIGGERS:= errmsg errdetail errdetail_log errhint errcontext PLy_elog:2 PLy_exception_set:2
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment