]> granicus.if.org Git - postgresql/blob - contrib/ltree_plpython/sql/ltree_plpython.sql
Add CASCADE support for CREATE EXTENSION.
[postgresql] / contrib / ltree_plpython / sql / ltree_plpython.sql
1 CREATE EXTENSION ltree_plpython2u CASCADE;
2
3
4 CREATE FUNCTION test1(val ltree) RETURNS int
5 LANGUAGE plpythonu
6 TRANSFORM FOR TYPE ltree
7 AS $$
8 plpy.info(repr(val))
9 return len(val)
10 $$;
11
12 SELECT test1('aa.bb.cc'::ltree);
13
14
15 CREATE FUNCTION test1n(val ltree) RETURNS int
16 LANGUAGE plpython2u
17 TRANSFORM FOR TYPE ltree
18 AS $$
19 plpy.info(repr(val))
20 return len(val)
21 $$;
22
23 SELECT test1n('aa.bb.cc'::ltree);
24
25
26 CREATE FUNCTION test2() RETURNS ltree
27 LANGUAGE plpythonu
28 TRANSFORM FOR TYPE ltree
29 AS $$
30 return ['foo', 'bar', 'baz']
31 $$;
32
33 -- plpython to ltree is not yet implemented, so this will fail,
34 -- because it will try to parse the Python list as an ltree input
35 -- string.
36 SELECT test2();