summaryrefslogtreecommitdiff
path: root/test/expected/plproxy_split.out
blob: 7794fd4f3bda2a255f4ea0ec3555ba1f0e8e5318 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
-- partition functions
\c test_part0
create or replace function test_array(a text[], b text[], c text) returns text as
$$
select current_database() || ' $1:' || array_to_string($1, ',')
                          || ' $2:' || array_to_string($2, ',')
                          || ' $3:' || $3;
$$ language sql;
\c test_part1
create or replace function test_array(a text[], b text[], c text) returns text as
$$
select current_database() || ' $1:' || array_to_string($1, ',')
                          || ' $2:' || array_to_string($2, ',')
                          || ' $3:' || $3;
$$ language sql;
\c test_part2
create or replace function test_array(a text[], b text[], c text) returns text as
$$
select current_database() || ' $1:' || array_to_string($1, ',')
                          || ' $2:' || array_to_string($2, ',')
                          || ' $3:' || $3;
$$ language sql;
\c test_part3
create or replace function test_array(a text[], b text[], c text) returns text as
$$
select current_database() || ' $1:' || array_to_string($1, ',')
                          || ' $2:' || array_to_string($2, ',')
                          || ' $3:' || $3;
$$ language sql;
\c regression
-- invalid arg reference
create or replace function test_array(a text[], b text[], c text) returns setof text as
$$ split $4; cluster 'testcluster'; run on 0;$$ language plproxy;
ERROR:  PL/Proxy function public.test_array(3): Compile error at line 1: invalid argument reference: $4
select * from test_array(array['a'], array['g'], 'foo');
ERROR:  function test_array(text[], text[], unknown) does not exist
LINE 1: select * from test_array(array['a'], array['g'], 'foo');
                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
-- invalid arg name
create or replace function test_array(a text[], b text[], c text) returns setof text as
$$ split x; cluster 'testcluster'; run on 0; $$ language plproxy;
ERROR:  PL/Proxy function public.test_array(3): Compile error at line 1: invalid argument reference: x
select * from test_array(array['a'], array['b', 'c'], 'foo');
ERROR:  function test_array(text[], text[], unknown) does not exist
LINE 1: select * from test_array(array['a'], array['b', 'c'], 'foo')...
                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
-- cannot split more than once
create or replace function test_array(a text[], b text[], c text) returns setof text as
$$ split a, b, b; cluster 'testcluster'; run on 0; $$ language plproxy;
ERROR:  PL/Proxy function public.test_array(3): SPLIT parameter specified more than once: b
select * from test_array(array['a'], array['b', 'c'], 'foo');
ERROR:  function test_array(text[], text[], unknown) does not exist
LINE 1: select * from test_array(array['a'], array['b', 'c'], 'foo')...
                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
-- attempt to split non-array
create or replace function test_array(a text[], b text[], c text) returns setof text as
$$ split $3; cluster 'testcluster'; run on 0;$$ language plproxy;
ERROR:  PL/Proxy function public.test_array(3): SPLIT parameter is not an array: $3
select * from test_array(array['a'], array['g'], 'foo');
ERROR:  function test_array(text[], text[], unknown) does not exist
LINE 1: select * from test_array(array['a'], array['g'], 'foo');
                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
-- array size/dimensions mismatch
create or replace function test_array(a text[], b text[], c text) returns setof text as
$$ split a, b; cluster 'testcluster'; run on 0; $$ language plproxy;
select * from test_array(array['a'], array['b', 'c'], 'foo');
ERROR:  PL/Proxy function public.test_array(3): split arrays must be of identical lengths
select * from test_array(array['a','b','c','d'], null, 'foo');
ERROR:  PL/Proxy function public.test_array(3): split arrays must be of identical lengths
select * from test_array(null, array['e','f','g','h'], 'foo');
ERROR:  PL/Proxy function public.test_array(3): split arrays must be of identical lengths
select * from test_array(array[array['a1'],array['a2']], array[array['b1'],array['b2']], 'foo');
ERROR:  PL/Proxy function public.test_array(3): split multi-dimensional arrays are not supported
-- run on array hash, split one array
create or replace function test_array(a text[], b text[], c text) returns setof text as
$$ split a; cluster 'testcluster'; run on ascii(a);$$ language plproxy;
select * from test_array(array['a','b','c','d'], array['e','f','g','h'], 'foo');
            test_array             
-----------------------------------
 test_part1 $1:a $2:e,f,g,h $3:foo
 test_part2 $1:b $2:e,f,g,h $3:foo
 test_part3 $1:c $2:e,f,g,h $3:foo
 test_part0 $1:d $2:e,f,g,h $3:foo
(4 rows)

-- run on text hash, split two arrays (nop split)
create or replace function test_array(a text[], b text[], c text) returns setof text as
$$ split a, b; cluster 'testcluster'; run on ascii(c);$$ language plproxy;
select * from test_array(array['a','b','c','d'], array['e','f','g','h'], 'foo');
               test_array                
-----------------------------------------
 test_part2 $1:a,b,c,d $2:e,f,g,h $3:foo
(1 row)

-- run on array hash, split two arrays
create or replace function test_array(a text[], b text[], c text) returns setof text as
$$ split a, b; cluster 'testcluster'; run on ascii(a);$$ language plproxy;
select * from test_array(array['a','b','c','d'], array['e','f','g','h'], 'foo');
         test_array          
-----------------------------
 test_part1 $1:a $2:e $3:foo
 test_part2 $1:b $2:f $3:foo
 test_part3 $1:c $2:g $3:foo
 test_part0 $1:d $2:h $3:foo
(4 rows)

select * from test_array(null, null, null);
 test_array 
------------
(0 rows)

select * from test_array('{}'::text[], '{}'::text[], 'foo');
 test_array 
------------
(0 rows)

-- run on text hash, split all arrays
create or replace function test_array(a text[], b text[], c text) returns setof text as
$$ split all; cluster 'testcluster'; run on ascii(c);$$ language plproxy;
select * from test_array(array['a','b','c','d'], array['e','f','g','h'], 'foo');
               test_array                
-----------------------------------------
 test_part2 $1:a,b,c,d $2:e,f,g,h $3:foo
(1 row)

-- run on text hash, attempt to split all arrays but none are present
create or replace function test_nonarray_split(a text, b text, c text) returns setof text as
$$ split all; cluster 'testcluster'; run on ascii(a); select * from test_array(array[a], array[b], c);
$$ language plproxy;
select * from test_nonarray_split('a', 'b', 'c');
    test_nonarray_split    
---------------------------
 test_part1 $1:a $2:b $3:c
(1 row)

-- run on array hash, split all arrays
create or replace function test_array(a text[], b text[], c text) returns setof text as
$$ split all; cluster 'testcluster'; run on ascii(a);$$ language plproxy;
select * from test_array(array['a','b','c','d'], array['e','f','g','h'], 'foo');
         test_array          
-----------------------------
 test_part1 $1:a $2:e $3:foo
 test_part2 $1:b $2:f $3:foo
 test_part3 $1:c $2:g $3:foo
 test_part0 $1:d $2:h $3:foo
(4 rows)

-- run on arg
create or replace function test_array_direct(a integer[], b text[], c text) returns setof text as
$$ split a; cluster 'testcluster'; run on a; select test_array('{}'::text[], b, c);$$ language plproxy;
select * from test_array_direct(array[2,3], array['a','b','c','d'], 'foo');
        test_array_direct         
----------------------------------
 test_part2 $1: $2:a,b,c,d $3:foo
 test_part3 $1: $2:a,b,c,d $3:foo
(2 rows)

create or replace function test_array_direct(a integer[], b text[], c text) returns setof text as
$$ split a, b; cluster 'testcluster'; run on a; select test_array('{}'::text[], b, c);$$ language plproxy;
select * from test_array_direct(array[0,1,2,3], array['a','b','c','d'], 'foo');
     test_array_direct      
----------------------------
 test_part0 $1: $2:a $3:foo
 test_part1 $1: $2:b $3:foo
 test_part2 $1: $2:c $3:foo
 test_part3 $1: $2:d $3:foo
(4 rows)