forked from Tencent/TBase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhstore_plperl.out
48 lines (45 loc) · 1.55 KB
/
hstore_plperl.out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
CREATE EXTENSION hstore_plperl CASCADE;
NOTICE: installing required extension "hstore"
NOTICE: installing required extension "plperl"
SELECT transforms.udt_schema, transforms.udt_name,
routine_schema, routine_name,
group_name, transform_type
FROM information_schema.transforms JOIN information_schema.routines
USING (specific_catalog, specific_schema, specific_name)
ORDER BY 1, 2, 5, 6;
udt_schema | udt_name | routine_schema | routine_name | group_name | transform_type
------------+----------+----------------+------------------+------------+----------------
public | hstore | public | hstore_to_plperl | plperl | FROM SQL
public | hstore | public | plperl_to_hstore | plperl | TO SQL
(2 rows)
-- test perl -> hstore
CREATE FUNCTION test2() RETURNS hstore
LANGUAGE plperl
TRANSFORM FOR TYPE hstore
AS $$
$val = {a => 1, b => 'boo', c => undef};
return $val;
$$;
SELECT test2();
test2
---------------------------------
"a"=>"1", "b"=>"boo", "c"=>NULL
(1 row)
-- test perl -> hstore[]
CREATE FUNCTION test2arr() RETURNS hstore[]
LANGUAGE plperl
TRANSFORM FOR TYPE hstore
AS $$
$val = [{a => 1, b => 'boo', c => undef}, {d => 2}];
return $val;
$$;
SELECT test2arr();
test2arr
--------------------------------------------------------------
{"\"a\"=>\"1\", \"b\"=>\"boo\", \"c\"=>NULL","\"d\"=>\"2\""}
(1 row)
DROP FUNCTION test2();
DROP FUNCTION test2arr();
DROP EXTENSION hstore_plperl;
DROP EXTENSION hstore;
DROP EXTENSION plperl;