From: | foxxy(at)foxdogstudios(dot)com |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #14730: Passing an array of composites to a plpythonu function results in a list of strs |
Date: | 2017-07-03 12:21:50 |
Message-ID: | 20170703122150.1448.39204@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 14730
Logged by: Peter Sutton
Email address: foxxy(at)foxdogstudios(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2017-07-03 14:22:12 | Re: BUG #14729: Between operator is slow when same value used for low and high margin |
Previous Message | pavel.tavoda | 2017-07-03 10:09:23 | BUG #14729: Between operator is slow when same value used for low and high margin |