diff --git a/src/pl/plpython/expected/plpython_composite.out b/src/pl/plpython/expected/plpython_composite.out index 61b3046..e7a7edb 100644 --- a/src/pl/plpython/expected/plpython_composite.out +++ b/src/pl/plpython/expected/plpython_composite.out @@ -270,9 +270,13 @@ yield {'tab': [['first', 1], ['second', 2]], {'first': 'fourth', 'second': 4}]} $$ LANGUAGE plpythonu; SELECT * FROM composite_types_table(); -ERROR: PL/Python functions cannot return type table_record[] -DETAIL: PL/Python does not support conversion to arrays of row types. -CONTEXT: PL/Python function "composite_types_table" + tab | typ +----------------------------+---------------------------- + {"(first,1)","(second,2)"} | {"(third,3)","(fourth,4)"} + {"(first,1)","(second,2)"} | {"(third,3)","(fourth,4)"} + {"(first,1)","(second,2)"} | {"(third,3)","(fourth,4)"} +(3 rows) + -- check what happens if the output record descriptor changes CREATE FUNCTION return_record(t text) RETURNS record AS $$ return {'t': t, 'val': 10} diff --git a/src/pl/plpython/expected/plpython_types.out b/src/pl/plpython/expected/plpython_types.out index b98318c..9576905 100644 --- a/src/pl/plpython/expected/plpython_types.out +++ b/src/pl/plpython/expected/plpython_types.out @@ -632,13 +632,12 @@ PL/Python function "test_type_conversion_array_mixed2" CREATE FUNCTION test_type_conversion_array_record() RETURNS type_record[] AS $$ return [None] $$ LANGUAGE plpythonu; -ERROR: PL/Python functions cannot return type type_record[] -DETAIL: PL/Python does not support conversion to arrays of row types. SELECT * FROM test_type_conversion_array_record(); -ERROR: function test_type_conversion_array_record() does not exist -LINE 1: SELECT * FROM test_type_conversion_array_record(); - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. + test_type_conversion_array_record +----------------------------------- + {NULL} +(1 row) + CREATE FUNCTION test_type_conversion_array_string() RETURNS text[] AS $$ return 'abc' $$ LANGUAGE plpythonu; diff --git a/src/pl/plpython/expected/plpython_types_3.out b/src/pl/plpython/expected/plpython_types_3.out index e104356..f38e2a7 100644 --- a/src/pl/plpython/expected/plpython_types_3.out +++ b/src/pl/plpython/expected/plpython_types_3.out @@ -632,13 +632,12 @@ PL/Python function "test_type_conversion_array_mixed2" CREATE FUNCTION test_type_conversion_array_record() RETURNS type_record[] AS $$ return [None] $$ LANGUAGE plpython3u; -ERROR: PL/Python functions cannot return type type_record[] -DETAIL: PL/Python does not support conversion to arrays of row types. SELECT * FROM test_type_conversion_array_record(); -ERROR: function test_type_conversion_array_record() does not exist -LINE 1: SELECT * FROM test_type_conversion_array_record(); - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. + test_type_conversion_array_record +----------------------------------- + {NULL} +(1 row) + CREATE FUNCTION test_type_conversion_array_string() RETURNS text[] AS $$ return 'abc' $$ LANGUAGE plpython3u; diff --git a/src/pl/plpython/plpy_typeio.c b/src/pl/plpython/plpy_typeio.c index 7a5e581..2fc9230 100644 --- a/src/pl/plpython/plpy_typeio.c +++ b/src/pl/plpython/plpy_typeio.c @@ -404,11 +404,7 @@ PLy_output_datum_func2(PLyObToDatum *arg, HeapTuple typeTup) Oid funcid; if (type_is_rowtype(element_type)) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("PL/Python functions cannot return type %s", - format_type_be(arg->typoid)), - errdetail("PL/Python does not support conversion to arrays of row types."))); + arg->func = PLyObject_ToComposite; arg->elm = PLy_malloc0(sizeof(*arg->elm)); arg->elm->func = arg->func; @@ -834,11 +830,6 @@ PLySequence_ToArray(PLyObToDatum *arg, int32 typmod, PyObject *plrv) else { nulls[i] = false; - - /* - * We don't support arrays of row types yet, so the first argument - * can be NULL. - */ elems[i] = arg->elm->func(arg->elm, -1, obj); } Py_XDECREF(obj);