-- test regular sql create function test_select(xuser text, tmp boolean) returns integer as $x$ cluster 'testcluster'; run on hashtext(xuser); select /********* junk ; ********** ****/ id from sel_test where username = xuser and ';' <> 'as;d''a ; sd' and $tmp$ ; 'a' $tmp$ <> 'as;d''a ; sd' and $tmp$ $ $$ $foo$tmp$ <> 'x'; $x$ language plproxy; \c test_part create table sel_test ( id integer, username text ); insert into sel_test values ( 1, 'user'); \c regression select * from test_select('user', true); test_select ------------- 1 (1 row) select * from test_select('xuser', false); ERROR: PL/Proxy function public.test_select(2): Non-SETOF function requires 1 row from remote query, got 0 -- test errors create function test_select_err(xuser text, tmp boolean) returns integer as $$ cluster 'testcluster'; run on hashtext(xuser); select id from sel_test where username = xuser; select id from sel_test where username = xuser; $$ language plproxy; ERROR: PL/Proxy function public.test_select_err(2): Compile error at line 5: Only one SELECT statement allowed select * from test_select_err('user', true); ERROR: function test_select_err(unknown, boolean) does not exist LINE 1: select * from test_select_err('user', true); ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. create function get_zero() returns setof integer as $x$ cluster 'testcluster'; run on all; select (0*0); $x$ language plproxy; select * from get_zero(); get_zero ---------- 0 (1 row) \c test_part create table numbers ( num int, name text ); insert into numbers values (1, 'one'); insert into numbers values (2, 'two'); create function ret_numtuple(int) returns numbers as $x$ select num, name from numbers where num = $1; $x$ language sql; \c regression create type numbers_type as (num int, name text); create function get_one() returns setof numbers_type as $x$ cluster 'testcluster'; run on all; select (ret_numtuple(1)).num, (ret_numtuple(1)).name; $x$ language plproxy; select * from get_one(); num | name -----+------ 1 | one (1 row) \c test_part create function remote_func(a varchar, b varchar, c varchar) returns void as $$ begin return; end; $$ language plpgsql; \c regression CREATE OR REPLACE FUNCTION test1(x integer, a varchar, b varchar, c varchar) RETURNS void AS $$ CLUSTER 'testcluster'; RUN ON 0; SELECT * FROM remote_func(a, b, c); $$ LANGUAGE plproxy; select * from test1(1, 'a', NULL,NULL); test1 ------- (1 row) select * from test1(1, NULL, NULL,NULL); test1 ------- (1 row) CREATE OR REPLACE FUNCTION test2(a varchar, b varchar, c varchar) RETURNS void AS $$ CLUSTER 'testcluster'; RUN ON 0; SELECT * FROM remote_func(a, b, c); $$ LANGUAGE plproxy; select * from test2(NULL, NULL, NULL); test2 ------- (1 row) select * from test2('a', NULL, NULL); test2 ------- (1 row) CREATE OR REPLACE FUNCTION test3(a varchar, b varchar, c varchar) RETURNS void AS $$ CLUSTER 'testcluster'; RUN ON 0; SELECT * FROM remote_func(a, c, b); $$ LANGUAGE plproxy; select * from test3(NULL,NULL, 'a'); test3 ------- (1 row) select * from test3('a', NULL,NULL); test3 ------- (1 row)