Debian Codegraph @

contrib/hstore_plperl/expected/hstore_plperl.out

raw
1 CREATE EXTENSION hstore_plperl CASCADE;
2 NOTICE: installing required extension "hstore"
3 NOTICE: installing required extension "plperl"
4 SELECT transforms.udt_schema, transforms.udt_name,
5 routine_schema, routine_name,
6 group_name, transform_type
7 FROM information_schema.transforms JOIN information_schema.routines
8 USING (specific_catalog, specific_schema, specific_name)
9 ORDER BY 1, 2, 5, 6;
10 udt_schema | udt_name | routine_schema | routine_name | group_name | transform_type
11 ------------+----------+----------------+------------------+------------+----------------
12 public | hstore | public | hstore_to_plperl | plperl | FROM SQL
13 public | hstore | public | plperl_to_hstore | plperl | TO SQL
14 (2 rows)
15
16 -- test perl -> hstore
17 CREATE FUNCTION test2() RETURNS hstore
18 LANGUAGE plperl
19 TRANSFORM FOR TYPE hstore
20 AS $$
21 $val = {a => 1, b => 'boo', c => undef};
22 return $val;
23 $$;
24 SELECT test2();
25 test2
26 ---------------------------------
27 "a"=>"1", "b"=>"boo", "c"=>NULL
28 (1 row)
29
30 -- test perl -> hstore[]
31 CREATE FUNCTION test2arr() RETURNS hstore[]
32 LANGUAGE plperl
33 TRANSFORM FOR TYPE hstore
34 AS $$
35 $val = [{a => 1, b => 'boo', c => undef}, {d => 2}];
36 return $val;
37 $$;
38 SELECT test2arr();
39 test2arr
40 --------------------------------------------------------------
41 {"\"a\"=>\"1\", \"b\"=>\"boo\", \"c\"=>NULL","\"d\"=>\"2\""}
42 (1 row)
43
44 -- check error cases
45 CREATE OR REPLACE FUNCTION test2() RETURNS hstore
46 LANGUAGE plperl
47 TRANSFORM FOR TYPE hstore
48 AS $$
49 return 42;
50 $$;
51 SELECT test2();
52 ERROR: cannot transform non-hash Perl value to hstore
53 CONTEXT: PL/Perl function "test2"
54 CREATE OR REPLACE FUNCTION test2() RETURNS hstore
55 LANGUAGE plperl
56 TRANSFORM FOR TYPE hstore
57 AS $$
58 return [1, 2];
59 $$;
60 SELECT test2();
61 ERROR: cannot transform non-hash Perl value to hstore
62 CONTEXT: PL/Perl function "test2"
63 DROP FUNCTION test2();
64 DROP FUNCTION test2arr();
65 DROP EXTENSION hstore_plperl;
66 DROP EXTENSION hstore;
67 DROP EXTENSION plperl;