diff options
Diffstat (limited to 'contrib/tablefunc')
-rw-r--r-- | contrib/tablefunc/.gitignore | 4 | ||||
-rw-r--r-- | contrib/tablefunc/Makefile | 8 | ||||
-rw-r--r-- | contrib/tablefunc/expected/tablefunc.out | 8 | ||||
-rw-r--r-- | contrib/tablefunc/sql/tablefunc.sql | 11 | ||||
-rw-r--r-- | contrib/tablefunc/tablefunc--1.0.sql (renamed from contrib/tablefunc/tablefunc.sql.in) | 27 | ||||
-rw-r--r-- | contrib/tablefunc/tablefunc--unpackaged--1.0.sql | 16 | ||||
-rw-r--r-- | contrib/tablefunc/tablefunc.c | 24 | ||||
-rw-r--r-- | contrib/tablefunc/tablefunc.control | 5 | ||||
-rw-r--r-- | contrib/tablefunc/tablefunc.h | 4 | ||||
-rw-r--r-- | contrib/tablefunc/uninstall_tablefunc.sql | 32 |
10 files changed, 48 insertions, 91 deletions
diff --git a/contrib/tablefunc/.gitignore b/contrib/tablefunc/.gitignore new file mode 100644 index 0000000000..5dcb3ff972 --- /dev/null +++ b/contrib/tablefunc/.gitignore @@ -0,0 +1,4 @@ +# Generated subdirectories +/log/ +/results/ +/tmp_check/ diff --git a/contrib/tablefunc/Makefile b/contrib/tablefunc/Makefile index 1207c62ef7..eb108931ec 100644 --- a/contrib/tablefunc/Makefile +++ b/contrib/tablefunc/Makefile @@ -1,8 +1,10 @@ -# $PostgreSQL: pgsql/contrib/tablefunc/Makefile,v 1.10 2010/07/05 23:15:56 tgl Exp $ +# contrib/tablefunc/Makefile MODULES = tablefunc -DATA_built = tablefunc.sql -DATA = uninstall_tablefunc.sql + +EXTENSION = tablefunc +DATA = tablefunc--1.0.sql tablefunc--unpackaged--1.0.sql + REGRESS = tablefunc LDFLAGS_SL += $(filter -lm, $(LIBS)) diff --git a/contrib/tablefunc/expected/tablefunc.out b/contrib/tablefunc/expected/tablefunc.out index 15ef758ed7..7ad4336ada 100644 --- a/contrib/tablefunc/expected/tablefunc.out +++ b/contrib/tablefunc/expected/tablefunc.out @@ -1,10 +1,4 @@ --- --- first, define the functions. Turn off echoing so that expected file --- does not depend on contents of tablefunc.sql. --- -SET client_min_messages = warning; -\set ECHO none -RESET client_min_messages; +CREATE EXTENSION tablefunc; -- -- normal_rand() -- no easy way to do this for regression testing diff --git a/contrib/tablefunc/sql/tablefunc.sql b/contrib/tablefunc/sql/tablefunc.sql index 9f559b3977..bf874f26ad 100644 --- a/contrib/tablefunc/sql/tablefunc.sql +++ b/contrib/tablefunc/sql/tablefunc.sql @@ -1,12 +1,4 @@ --- --- first, define the functions. Turn off echoing so that expected file --- does not depend on contents of tablefunc.sql. --- -SET client_min_messages = warning; -\set ECHO none -\i tablefunc.sql -\set ECHO all -RESET client_min_messages; +CREATE EXTENSION tablefunc; -- -- normal_rand() @@ -196,4 +188,3 @@ INSERT INTO connectby_int VALUES(111,11); INSERT INTO connectby_int VALUES(1,111); -- this should not fail due to recursion detection SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '11', 0, '-') AS t(keyid int, parent_keyid int, level int, branch text); - diff --git a/contrib/tablefunc/tablefunc.sql.in b/contrib/tablefunc/tablefunc--1.0.sql index f4864c4558..7bf117cb5c 100644 --- a/contrib/tablefunc/tablefunc.sql.in +++ b/contrib/tablefunc/tablefunc--1.0.sql @@ -1,15 +1,12 @@ -/* $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.sql.in,v 1.12 2007/11/13 04:24:29 momjian Exp $ */ +/* contrib/tablefunc/tablefunc--1.0.sql */ --- Adjust this setting to control where the objects get created. -SET search_path = public; - -CREATE OR REPLACE FUNCTION normal_rand(int4, float8, float8) +CREATE FUNCTION normal_rand(int4, float8, float8) RETURNS setof float8 AS 'MODULE_PATHNAME','normal_rand' LANGUAGE C VOLATILE STRICT; -- the generic crosstab function: -CREATE OR REPLACE FUNCTION crosstab(text) +CREATE FUNCTION crosstab(text) RETURNS setof record AS 'MODULE_PATHNAME','crosstab' LANGUAGE C STABLE STRICT; @@ -39,50 +36,50 @@ CREATE TYPE tablefunc_crosstab_4 AS category_4 TEXT ); -CREATE OR REPLACE FUNCTION crosstab2(text) +CREATE FUNCTION crosstab2(text) RETURNS setof tablefunc_crosstab_2 AS 'MODULE_PATHNAME','crosstab' LANGUAGE C STABLE STRICT; -CREATE OR REPLACE FUNCTION crosstab3(text) +CREATE FUNCTION crosstab3(text) RETURNS setof tablefunc_crosstab_3 AS 'MODULE_PATHNAME','crosstab' LANGUAGE C STABLE STRICT; -CREATE OR REPLACE FUNCTION crosstab4(text) +CREATE FUNCTION crosstab4(text) RETURNS setof tablefunc_crosstab_4 AS 'MODULE_PATHNAME','crosstab' LANGUAGE C STABLE STRICT; -- obsolete: -CREATE OR REPLACE FUNCTION crosstab(text,int) +CREATE FUNCTION crosstab(text,int) RETURNS setof record AS 'MODULE_PATHNAME','crosstab' LANGUAGE C STABLE STRICT; -CREATE OR REPLACE FUNCTION crosstab(text,text) +CREATE FUNCTION crosstab(text,text) RETURNS setof record AS 'MODULE_PATHNAME','crosstab_hash' LANGUAGE C STABLE STRICT; -CREATE OR REPLACE FUNCTION connectby(text,text,text,text,int,text) +CREATE FUNCTION connectby(text,text,text,text,int,text) RETURNS setof record AS 'MODULE_PATHNAME','connectby_text' LANGUAGE C STABLE STRICT; -CREATE OR REPLACE FUNCTION connectby(text,text,text,text,int) +CREATE FUNCTION connectby(text,text,text,text,int) RETURNS setof record AS 'MODULE_PATHNAME','connectby_text' LANGUAGE C STABLE STRICT; -- These 2 take the name of a field to ORDER BY as 4th arg (for sorting siblings) -CREATE OR REPLACE FUNCTION connectby(text,text,text,text,text,int,text) +CREATE FUNCTION connectby(text,text,text,text,text,int,text) RETURNS setof record AS 'MODULE_PATHNAME','connectby_text_serial' LANGUAGE C STABLE STRICT; -CREATE OR REPLACE FUNCTION connectby(text,text,text,text,text,int) +CREATE FUNCTION connectby(text,text,text,text,text,int) RETURNS setof record AS 'MODULE_PATHNAME','connectby_text_serial' LANGUAGE C STABLE STRICT; diff --git a/contrib/tablefunc/tablefunc--unpackaged--1.0.sql b/contrib/tablefunc/tablefunc--unpackaged--1.0.sql new file mode 100644 index 0000000000..20e09816e9 --- /dev/null +++ b/contrib/tablefunc/tablefunc--unpackaged--1.0.sql @@ -0,0 +1,16 @@ +/* contrib/tablefunc/tablefunc--unpackaged--1.0.sql */ + +ALTER EXTENSION tablefunc ADD function normal_rand(integer,double precision,double precision); +ALTER EXTENSION tablefunc ADD function crosstab(text); +ALTER EXTENSION tablefunc ADD type tablefunc_crosstab_2; +ALTER EXTENSION tablefunc ADD type tablefunc_crosstab_3; +ALTER EXTENSION tablefunc ADD type tablefunc_crosstab_4; +ALTER EXTENSION tablefunc ADD function crosstab2(text); +ALTER EXTENSION tablefunc ADD function crosstab3(text); +ALTER EXTENSION tablefunc ADD function crosstab4(text); +ALTER EXTENSION tablefunc ADD function crosstab(text,integer); +ALTER EXTENSION tablefunc ADD function crosstab(text,text); +ALTER EXTENSION tablefunc ADD function connectby(text,text,text,text,integer,text); +ALTER EXTENSION tablefunc ADD function connectby(text,text,text,text,integer); +ALTER EXTENSION tablefunc ADD function connectby(text,text,text,text,text,integer,text); +ALTER EXTENSION tablefunc ADD function connectby(text,text,text,text,text,integer); diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index 609ab48c7c..4ef9b00a6d 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.c,v 1.62 2010/01/02 16:57:32 momjian Exp $ + * contrib/tablefunc/tablefunc.c * * * tablefunc @@ -10,7 +10,7 @@ * And contributors: * Nabil Sayegh <postgresql@e-trolley.de> * - * Copyright (c) 2002-2010, PostgreSQL Global Development Group + * Copyright (c) 2002-2011, PostgreSQL Global Development Group * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without a written agreement @@ -85,7 +85,6 @@ static Tuplestorestate *build_tuplestore_recursively(char *key_fld, MemoryContext per_query_ctx, AttInMetadata *attinmeta, Tuplestorestate *tupstore); -static char *quote_literal_cstr(char *rawstr); typedef struct { @@ -1564,22 +1563,3 @@ compatCrosstabTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc) /* OK, the two tupdescs are compatible for our purposes */ return true; } - -/* - * Return a properly quoted literal value. - * Uses quote_literal in quote.c - */ -static char * -quote_literal_cstr(char *rawstr) -{ - text *rawstr_text; - text *result_text; - char *result; - - rawstr_text = cstring_to_text(rawstr); - result_text = DatumGetTextP(DirectFunctionCall1(quote_literal, - PointerGetDatum(rawstr_text))); - result = text_to_cstring(result_text); - - return result; -} diff --git a/contrib/tablefunc/tablefunc.control b/contrib/tablefunc/tablefunc.control new file mode 100644 index 0000000000..248b0a77a2 --- /dev/null +++ b/contrib/tablefunc/tablefunc.control @@ -0,0 +1,5 @@ +# tablefunc extension +comment = 'functions that manipulate whole tables, including crosstab' +default_version = '1.0' +module_pathname = '$libdir/tablefunc' +relocatable = true diff --git a/contrib/tablefunc/tablefunc.h b/contrib/tablefunc/tablefunc.h index 2870299bd4..a0e03e285d 100644 --- a/contrib/tablefunc/tablefunc.h +++ b/contrib/tablefunc/tablefunc.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.h,v 1.17 2010/01/02 16:57:32 momjian Exp $ + * contrib/tablefunc/tablefunc.h * * * tablefunc @@ -10,7 +10,7 @@ * And contributors: * Nabil Sayegh <postgresql@e-trolley.de> * - * Copyright (c) 2002-2010, PostgreSQL Global Development Group + * Copyright (c) 2002-2011, PostgreSQL Global Development Group * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without a written agreement diff --git a/contrib/tablefunc/uninstall_tablefunc.sql b/contrib/tablefunc/uninstall_tablefunc.sql deleted file mode 100644 index cb58df89bb..0000000000 --- a/contrib/tablefunc/uninstall_tablefunc.sql +++ /dev/null @@ -1,32 +0,0 @@ -/* $PostgreSQL: pgsql/contrib/tablefunc/uninstall_tablefunc.sql,v 1.3 2007/11/13 04:24:29 momjian Exp $ */ - --- Adjust this setting to control where the objects get dropped. -SET search_path = public; - -DROP FUNCTION connectby(text,text,text,text,text,int); - -DROP FUNCTION connectby(text,text,text,text,text,int,text); - -DROP FUNCTION connectby(text,text,text,text,int); - -DROP FUNCTION connectby(text,text,text,text,int,text); - -DROP FUNCTION crosstab(text,text); - -DROP FUNCTION crosstab(text,int); - -DROP FUNCTION crosstab4(text); - -DROP FUNCTION crosstab3(text); - -DROP FUNCTION crosstab2(text); - -DROP TYPE tablefunc_crosstab_4; - -DROP TYPE tablefunc_crosstab_3; - -DROP TYPE tablefunc_crosstab_2; - -DROP FUNCTION crosstab(text); - -DROP FUNCTION normal_rand(int4, float8, float8); |