From dad2e3f8faefe15ed794b024e792f6437510f4f4 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Sat, 17 Nov 2012 18:17:50 +0200 Subject: [PATCH] Test for "RETURNS TABLE (..)" functions --- Makefile | 2 +- test/expected/plproxy_table.out | 38 +++++++++++++++++++++++++++++++++ test/sql/plproxy_table.sql | 30 ++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 test/expected/plproxy_table.out create mode 100644 test/sql/plproxy_table.sql diff --git a/Makefile b/Makefile index 75f2c72..d8aa2e3 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ PG91 = $(shell test "$(PGVER)" "<" "9.1" && echo "false" || echo "true") # SQL/MED available, add foreign data wrapper and regression tests ifeq ($(SQLMED), true) -REGRESS += plproxy_sqlmed +REGRESS += plproxy_sqlmed plproxy_table PLPROXY_SQL += sql/plproxy_fdw.sql endif diff --git a/test/expected/plproxy_table.out b/test/expected/plproxy_table.out new file mode 100644 index 0000000..f34f2e5 --- /dev/null +++ b/test/expected/plproxy_table.out @@ -0,0 +1,38 @@ +\c test_part0 +create or replace function test_ret_table(id int) +returns table(id int, t text) as $$ + select * from (values(1, 'test'),(2, 'toto') ) as toto; +$$ language sql; +select * from test_ret_table(0); + id | t +----+------ + 1 | test + 2 | toto +(2 rows) + +\c regression +create or replace function test_ret_table_normal(in _id integer, out id integer, out t text) +returns setof record as $$ + cluster 'testcluster'; + run on _id; + target test_ret_table; +$$ language plproxy; +select * from test_ret_table_normal(0); + id | t +----+------ + 1 | test + 2 | toto +(2 rows) + +create or replace function test_ret_table(in _id integer) +returns table (id integer, t text) as $$ + cluster 'testcluster'; + run on _id; +$$ language plproxy; +select * from test_ret_table(0); + id | t +----+------ + 1 | test + 2 | toto +(2 rows) + diff --git a/test/sql/plproxy_table.sql b/test/sql/plproxy_table.sql new file mode 100644 index 0000000..2f8acdc --- /dev/null +++ b/test/sql/plproxy_table.sql @@ -0,0 +1,30 @@ + +\c test_part0 + + +create or replace function test_ret_table(id int) +returns table(id int, t text) as $$ + select * from (values(1, 'test'),(2, 'toto') ) as toto; +$$ language sql; + +select * from test_ret_table(0); + +\c regression + +create or replace function test_ret_table_normal(in _id integer, out id integer, out t text) +returns setof record as $$ + cluster 'testcluster'; + run on _id; + target test_ret_table; +$$ language plproxy; + +select * from test_ret_table_normal(0); + +create or replace function test_ret_table(in _id integer) +returns table (id integer, t text) as $$ + cluster 'testcluster'; + run on _id; +$$ language plproxy; + +select * from test_ret_table(0); + -- 2.39.5