Обсуждение: [BUGS] BUG #14730: Passing an array of composites to a plpythonu functionresults in a list of strs
[BUGS] BUG #14730: Passing an array of composites to a plpythonu functionresults in a list of strs
От
foxxy@foxdogstudios.com
Дата:
The following bug has been logged on the website: Bug reference: 14730 Logged by: Peter Sutton Email address: foxxy@foxdogstudios.com PostgreSQL version: 9.6.3 Operating system: Linux Description: Passing an array of composites to a plpythonu function results in a list of strs, not a list of dicts or tuples as I expected. Here's an example: BEGIN; CREATE TABLE mytable ( col1 INTEGER , col2 BOOLEAN , col3 TEXT ); INSERT INTO mytable VALUES (1, TRUE , 'Text') , (2, NULL , 'Text') , (3, FALSE, NULL ) ; CREATE FUNCTION myfunc (ts mytable[]) RETURNS VOID LANGUAGE plpythonu AS $plpythonu$ from pprint import pformat plpy.notice(pformat(ts)) if ts: plpy.notice(type(ts[0])) $plpythonu$; SELECT myfunc(array_agg(t)) FROM mytable AS t; -- psql:local/script.pgsql:28: NOTICE: ['(1,t,Text)', '(2,,Text)', '(3,f,)'] -- psql:local/script.pgsql:28: NOTICE: <type 'str'> -- myfunc -- -------- -- -- (1 row) SELECT myfunc(ARRAY[t]) FROM mytable AS t; -- psql:local/script.pgsql:29: NOTICE: ['(1,t,Text)'] -- psql:local/script.pgsql:29: NOTICE: <type 'str'> -- psql:local/script.pgsql:29: NOTICE: ['(2,,Text)'] -- psql:local/script.pgsql:29: NOTICE: <type 'str'> -- psql:local/script.pgsql:29: NOTICE: ['(3,f,)'] -- psql:local/script.pgsql:29: NOTICE: <type 'str'> -- myfunc -- -------- -- -- -- -- (3 rows) ROLLBACK; https://gist.github.com/dj-foxxy/16ba42d0a76da2bf384353cc024682b0 I expected the items of list list to be tuple or dicts, e.g., [(1, True, 'Text'), ...]. Thanks, Peter. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs