diff --git a/contrib/tablefunc/expected/tablefunc.out b/contrib/tablefunc/expected/tablefunc.out
index 95e1b06f89bd8c39c485d40d35b803d24896a02f..06d8b41e603ea3621c5d2552a4104da8615b67ef 100644
--- a/contrib/tablefunc/expected/tablefunc.out
+++ b/contrib/tablefunc/expected/tablefunc.out
@@ -1,6 +1,6 @@
 --
 -- first, define the functions.  Turn off echoing so that expected file
--- does not depend on contents of seg.sql.
+-- does not depend on contents of tablefunc.sql.
 --
 \set ECHO none
 --
diff --git a/contrib/tablefunc/sql/tablefunc.sql b/contrib/tablefunc/sql/tablefunc.sql
index 3d58d814079328840aa76a11bce9e10d60a3f968..25b430e4a03cd7e49d26e168f7daf5dd4759bae7 100644
--- a/contrib/tablefunc/sql/tablefunc.sql
+++ b/contrib/tablefunc/sql/tablefunc.sql
@@ -1,6 +1,6 @@
 --
 -- first, define the functions.  Turn off echoing so that expected file
--- does not depend on contents of seg.sql.
+-- does not depend on contents of tablefunc.sql.
 --
 \set ECHO none
 \i tablefunc.sql
diff --git a/contrib/tablefunc/tablefunc.sql.in b/contrib/tablefunc/tablefunc.sql.in
index 92bb5927d18657ae563d65516203f7f8120fc32a..504d8ee014b0308006508504c14a863e6f732f75 100644
--- a/contrib/tablefunc/tablefunc.sql.in
+++ b/contrib/tablefunc/tablefunc.sql.in
@@ -2,26 +2,29 @@ CREATE OR REPLACE FUNCTION normal_rand(int4, float8, float8, int4)
   RETURNS setof float8
   AS 'MODULE_PATHNAME','normal_rand' LANGUAGE 'c' VOLATILE STRICT;
 
-CREATE VIEW tablefunc_crosstab_2 AS
-  SELECT
-    ''::TEXT AS row_name,
-    ''::TEXT AS category_1,
-    ''::TEXT AS category_2;
-
-CREATE VIEW tablefunc_crosstab_3 AS
-  SELECT
-    ''::TEXT AS row_name,
-    ''::TEXT AS category_1,
-    ''::TEXT AS category_2,
-    ''::TEXT AS category_3;
-
-CREATE VIEW tablefunc_crosstab_4 AS
-  SELECT
-    ''::TEXT AS row_name,
-    ''::TEXT AS category_1,
-    ''::TEXT AS category_2,
-    ''::TEXT AS category_3,
-    ''::TEXT AS category_4;
+CREATE TYPE tablefunc_crosstab_2 AS
+(
+  row_name TEXT,
+  category_1 TEXT,
+  category_2 TEXT
+);
+
+CREATE TYPE tablefunc_crosstab_3 AS
+(
+  row_name TEXT,
+  category_1 TEXT,
+  category_2 TEXT,
+  category_3 TEXT
+);
+
+CREATE TYPE tablefunc_crosstab_4 AS
+(
+  row_name TEXT,
+  category_1 TEXT,
+  category_2 TEXT,
+  category_3 TEXT,
+  category_4 TEXT
+);
 
 CREATE OR REPLACE FUNCTION crosstab2(text)
   RETURNS setof tablefunc_crosstab_2
@@ -46,3 +49,11 @@ CREATE OR REPLACE FUNCTION connectby(text,text,text,text,int,text)
 CREATE OR REPLACE FUNCTION connectby(text,text,text,text,int)
   RETURNS setof record
   AS 'MODULE_PATHNAME','connectby_text' LANGUAGE 'c' STABLE STRICT;
+
+GRANT EXECUTE ON FUNCTION normal_rand(int4, float8, float8, int4) TO PUBLIC;
+GRANT EXECUTE ON FUNCTION crosstab2(text) TO PUBLIC;
+GRANT EXECUTE ON FUNCTION crosstab3(text) TO PUBLIC;
+GRANT EXECUTE ON FUNCTION crosstab4(text) TO PUBLIC;
+GRANT EXECUTE ON FUNCTION crosstab(text,int) TO PUBLIC;
+GRANT EXECUTE ON FUNCTION connectby(text,text,text,text,int,text) TO PUBLIC;
+GRANT EXECUTE ON FUNCTION connectby(text,text,text,text,int) TO PUBLIC;