summaryrefslogtreecommitdiff
path: root/contrib/tablefunc/tablefunc.sql.in
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-07-30 16:31:11 +0000
committerBruce Momjian <bruce@momjian.us>2002-07-30 16:31:11 +0000
commit41f862ba8766fd2cee7c3f939c4adf84e2b7b218 (patch)
treeace39087c92cfa216933cc306d388f4235b6c9d2 /contrib/tablefunc/tablefunc.sql.in
parent23a8b77d42463437f1dd52c601bcfeb858aef7b3 (diff)
downloadpostgresql-41f862ba8766fd2cee7c3f939c4adf84e2b7b218.tar.gz
As mentioned above, here is my contrib/tablefunc patch. It includes
three functions which exercise the tablefunc API. show_all_settings() - returns the same information as SHOW ALL, but as a query result normal_rand(int numvals, float8 mean, float8 stddev, int seed) - returns a set of normally distributed float8 values - This routine implements Algorithm P (Polar method for normal deviates) from Knuth's _The_Art_of_Computer_Programming_, Volume 2, 3rd ed., pages 122-126. Knuth cites his source as "The polar method", G. E. P. Box, M. E. Muller, and G. Marsaglia, _Annals_Math,_Stat._ 29 (1958), 610-611. crosstabN(text sql) - returns a set of row_name plus N category value columns - crosstab2(), crosstab3(), and crosstab4() are defined for you, but you can create additional crosstab functions per directions in the README. Joe Conway
Diffstat (limited to 'contrib/tablefunc/tablefunc.sql.in')
-rw-r--r--contrib/tablefunc/tablefunc.sql.in46
1 files changed, 46 insertions, 0 deletions
diff --git a/contrib/tablefunc/tablefunc.sql.in b/contrib/tablefunc/tablefunc.sql.in
new file mode 100644
index 0000000000..746e8f9cff
--- /dev/null
+++ b/contrib/tablefunc/tablefunc.sql.in
@@ -0,0 +1,46 @@
+CREATE VIEW tablefunc_config_settings AS
+ SELECT
+ ''::TEXT AS name,
+ ''::TEXT AS setting;
+
+CREATE OR REPLACE FUNCTION show_all_settings()
+ RETURNS setof tablefunc_config_settings
+ AS 'MODULE_PATHNAME','show_all_settings' LANGUAGE 'c' STABLE STRICT;
+
+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 OR REPLACE FUNCTION crosstab2(text)
+ RETURNS setof tablefunc_crosstab_2
+ AS 'MODULE_PATHNAME','crosstab' LANGUAGE 'c' STABLE STRICT;
+
+CREATE OR REPLACE FUNCTION crosstab3(text)
+ RETURNS setof tablefunc_crosstab_3
+ AS 'MODULE_PATHNAME','crosstab' LANGUAGE 'c' STABLE STRICT;
+
+CREATE OR REPLACE FUNCTION crosstab4(text)
+ RETURNS setof tablefunc_crosstab_4
+ AS 'MODULE_PATHNAME','crosstab' LANGUAGE 'c' STABLE STRICT;
+