| 1 |
CREATE EXTENSION ltree_plpython3u CASCADE; |
| 2 |
NOTICE: installing required extension "plpython3u" |
| 3 |
CREATE FUNCTION test1(val ltree) RETURNS int |
| 4 |
LANGUAGE plpython3u |
| 5 |
TRANSFORM FOR TYPE ltree |
| 6 |
AS $$ |
| 7 |
plpy.info(repr(val)) |
| 8 |
return len(val) |
| 9 |
$$; |
| 10 |
SELECT test1('aa.bb.cc'::ltree); |
| 11 |
INFO: ['aa', 'bb', 'cc'] |
| 12 |
test1 |
| 13 |
------- |
| 14 |
3 |
| 15 |
(1 row) |
| 16 |
|
| 17 |
CREATE FUNCTION test1n(val ltree) RETURNS int |
| 18 |
LANGUAGE plpython3u |
| 19 |
TRANSFORM FOR TYPE ltree |
| 20 |
AS $$ |
| 21 |
plpy.info(repr(val)) |
| 22 |
return len(val) |
| 23 |
$$; |
| 24 |
SELECT test1n('aa.bb.cc'::ltree); |
| 25 |
INFO: ['aa', 'bb', 'cc'] |
| 26 |
test1n |
| 27 |
-------- |
| 28 |
3 |
| 29 |
(1 row) |
| 30 |
|
| 31 |
CREATE FUNCTION test2() RETURNS ltree |
| 32 |
LANGUAGE plpython3u |
| 33 |
TRANSFORM FOR TYPE ltree |
| 34 |
AS $$ |
| 35 |
return ['foo', 'bar', 'baz'] |
| 36 |
$$; |
| 37 |
-- plpython to ltree is not yet implemented, so this will fail, |
| 38 |
-- because it will try to parse the Python list as an ltree input |
| 39 |
-- string. |
| 40 |
SELECT test2(); |
| 41 |
ERROR: ltree syntax error at character 1 |
| 42 |
CONTEXT: while creating return value |
| 43 |
PL/Python function "test2" |