--- /dev/null
+++ b/test/expected/plproxy_errors_2.out
@@ -0,0 +1,178 @@
+-- test bad arg
+create function test_err1(dat text)
+returns text as $$
+    cluster 'testcluster';
+    run on hashtext(username);
+$$ language plproxy;
+select * from test_err1('dat');
+ERROR:  column "username" does not exist
+LINE 1: select * from hashtext(username)
+                               ^
+QUERY:  select * from hashtext(username)
+create function test_err2(dat text)
+returns text as $$
+    cluster 'testcluster';
+    run on hashtext($2);
+$$ language plproxy;
+ERROR:  PL/Proxy function public.test_err2(1): Compile error at line 3: invalid argument reference: $2
+select * from test_err2('dat');
+ERROR:  function test_err2(unknown) does not exist
+LINE 1: select * from test_err2('dat');
+                      ^
+HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
+create function test_err3(dat text)
+returns text as $$
+    cluster 'nonexists';
+    run on hashtext($1);
+$$ language plproxy;
+select * from test_err3('dat');
+ERROR:  no such cluster: nonexists
+CONTEXT:  PL/pgSQL function plproxy.get_cluster_version(text) line 6 at RAISE
+SQL statement "select * from plproxy.get_cluster_version($1)"
+-- should work
+create function test_err_none(dat text)
+returns text as $$
+    cluster 'testcluster';
+    run on hashtext($1);
+    select 'ok';
+$$ language plproxy;
+select * from test_err_none('dat');
+ test_err_none 
+---------------
+ ok
+(1 row)
+
+--- result map errors
+create function test_map_err1(dat text)
+returns text as $$ cluster 'testcluster'; run on 0;
+    select dat as "foo", 'asd' as "bar";
+$$ language plproxy;
+select * from test_map_err1('dat');
+ERROR:  PL/Proxy function public.test_map_err1(1): single field function but got record
+create function test_map_err2(dat text, out res1 text, out res2 text)
+returns record as $$ cluster 'testcluster'; run on 0;
+    select dat as res1;
+$$ language plproxy;
+select * from test_map_err2('dat');
+ERROR:  PL/Proxy function public.test_map_err2(1): Got too few fields from remote end
+create function test_map_err3(dat text, out res1 text, out res2 text)
+returns record as $$ cluster 'testcluster'; run on 0;
+    select dat as res1, 'foo' as res_none;
+$$ language plproxy;
+select * from test_map_err3('dat');
+ERROR:  PL/Proxy function public.test_map_err3(1): Field res2 does not exists in result
+create function test_map_err4(dat text, out res1 text, out res2 text)
+returns record as $$
+    --cluster 'testcluster';
+    run on hashtext(dat);
+    select dat as res2, 'foo' as res1;
+$$ language plproxy;
+ERROR:  PL/Proxy function public.test_map_err4(1): Compile error at line 5: CLUSTER statement missing
+select * from test_map_err4('dat');
+ERROR:  function test_map_err4(unknown) does not exist
+LINE 1: select * from test_map_err4('dat');
+                      ^
+HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
+create function test_variadic_err(first text, rest variadic text[])
+returns text as $$
+    cluster 'testcluster';
+$$ language plproxy;
+ERROR:  PL/Proxy does not support variadic args
+select * from test_variadic_err('dat', 'dat', 'dat');
+ERROR:  function test_variadic_err(unknown, unknown, unknown) does not exist
+LINE 1: select * from test_variadic_err('dat', 'dat', 'dat');
+                      ^
+HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
+create function test_volatile_err(dat text)
+returns text
+stable
+as $$
+    cluster 'testcluster';
+$$ language plproxy;
+ERROR:  PL/Proxy functions must be volatile
+select * from test_volatile_err('dat');
+ERROR:  function test_volatile_err(unknown) does not exist
+LINE 1: select * from test_volatile_err('dat');
+                      ^
+HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
+create function test_pseudo_arg_err(dat cstring)
+returns text
+as $$
+    cluster 'testcluster';
+$$ language plproxy;
+ERROR:  PL/Proxy function public.test_pseudo_arg_err(0): unsupported pseudo type: cstring (2275)
+select * from test_pseudo_arg_err(textout('dat'));
+ERROR:  function test_pseudo_arg_err(cstring) does not exist
+LINE 1: select * from test_pseudo_arg_err(textout('dat'));
+                      ^
+HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
+create function test_pseudo_ret_err(dat text)
+returns cstring
+as $$
+    cluster 'testcluster';
+$$ language plproxy;
+-- not detected in validator
+select * from test_pseudo_ret_err('dat');
+ERROR:  PL/Proxy function public.test_pseudo_ret_err(0): unsupported pseudo type: cstring (2275)
+create function test_runonall_err(dat text)
+returns text
+as $$
+    cluster 'testcluster';
+    run on all;
+$$ language plproxy;
+ERROR:  PL/Proxy function public.test_runonall_err(1): RUN ON ALL requires set-returning function
+select * from test_runonall_err('dat');
+ERROR:  function test_runonall_err(unknown) does not exist
+LINE 1: select * from test_runonall_err('dat');
+                      ^
+HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
+-- make sure that errors from non-setof functions returning <> 1 row have
+-- a proper sqlstate
+create function test_no_results_plproxy()
+returns int
+as $$
+    cluster 'testcluster';
+    run on any;
+    select 1 from pg_database where datname = '';
+$$ language plproxy;
+create function test_no_results()
+returns void
+as $$
+begin
+    begin
+        perform test_no_results_plproxy();
+    exception when no_data_found then
+        null;
+    end;
+end;
+$$ language plpgsql;
+select * from test_no_results();
+ test_no_results 
+-----------------
+ 
+(1 row)
+
+create function test_multi_results_plproxy()
+returns int
+as $$
+    cluster 'testcluster';
+    run on any;
+    select 1 from pg_database;
+$$ language plproxy;
+create function test_multi_results()
+returns void
+as $$
+begin
+    begin
+        perform test_multi_results_plproxy();
+    exception when too_many_rows then
+        null;
+    end;
+end;
+$$ language plpgsql;
+select * from test_multi_results();
+ test_multi_results 
+--------------------
+ 
+(1 row)
+
