Template:Postgres function installation: Difference between revisions
No edit summary |
|||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
CREATE OR REPLACE FUNCTION exodus_call(bytea, bytea, bytea, bytea, bytea, int4, int4) | -- cut and paste the following SQL to register the functions into postgres -- | ||
RETURNS bytea | |||
CREATE OR REPLACE FUNCTION exodus_call(bytea, bytea, bytea, bytea, bytea, int4, int4) RETURNS bytea | |||
AS 'pgexodus', 'exodus_call' LANGUAGE C IMMUTABLE; | AS 'pgexodus', 'exodus_call' LANGUAGE C IMMUTABLE; | ||
Line 8: | Line 8: | ||
RETURNS bytea AS 'pgexodus', 'exodus_extract_bytea' LANGUAGE C IMMUTABLE; | RETURNS bytea AS 'pgexodus', 'exodus_extract_bytea' LANGUAGE C IMMUTABLE; | ||
CREATE OR REPLACE FUNCTION exodus_extract_text(bytea, int4, int4, int4) | CREATE OR REPLACE FUNCTION exodus_extract_text(bytea, int4, int4, int4) RETURNS text | ||
RETURNS text | |||
AS 'pgexodus', 'exodus_extract_text' LANGUAGE C IMMUTABLE; | AS 'pgexodus', 'exodus_extract_text' LANGUAGE C IMMUTABLE; | ||
CREATE OR REPLACE FUNCTION exodus_extract_sort(bytea, int4, int4, int4) | CREATE OR REPLACE FUNCTION exodus_extract_sort(bytea, int4, int4, int4) RETURNS text | ||
RETURNS text | |||
AS 'pgexodus', 'exodus_extract_sort' LANGUAGE C IMMUTABLE; | AS 'pgexodus', 'exodus_extract_sort' LANGUAGE C IMMUTABLE; | ||
Line 19: | Line 17: | ||
-- also return NULL if passed zero length strings | -- also return NULL if passed zero length strings | ||
CREATE OR REPLACE FUNCTION exodus_extract_text2(bytea, int4, int4, int4) | CREATE OR REPLACE FUNCTION exodus_extract_text2(bytea, int4, int4, int4) RETURNS text | ||
RETURNS text | |||
AS 'pgexodus', 'exodus_extract_text2' LANGUAGE C IMMUTABLE STRICT; | AS 'pgexodus', 'exodus_extract_text2' LANGUAGE C IMMUTABLE STRICT; | ||
CREATE OR REPLACE FUNCTION exodus_extract_date(bytea, int4, int4, int4) | CREATE OR REPLACE FUNCTION exodus_extract_date(bytea, int4, int4, int4) RETURNS date | ||
RETURNS date | |||
AS 'pgexodus', 'exodus_extract_date' LANGUAGE C IMMUTABLE STRICT; | AS 'pgexodus', 'exodus_extract_date' LANGUAGE C IMMUTABLE STRICT; | ||
CREATE OR REPLACE FUNCTION exodus_extract_time(bytea, int4, int4, int4) | CREATE OR REPLACE FUNCTION exodus_extract_time(bytea, int4, int4, int4) RETURNS time | ||
RETURNS time | |||
AS 'pgexodus', 'exodus_extract_time' LANGUAGE C IMMUTABLE STRICT; | AS 'pgexodus', 'exodus_extract_time' LANGUAGE C IMMUTABLE STRICT; | ||
CREATE OR REPLACE FUNCTION exodus_extract_datetime(bytea, int4, int4, int4) | CREATE OR REPLACE FUNCTION exodus_extract_datetime(bytea, int4, int4, int4) RETURNS timestamp | ||
RETURNS timestamp | |||
AS 'pgexodus', 'exodus_extract_datetime' LANGUAGE C IMMUTABLE STRICT; | AS 'pgexodus', 'exodus_extract_datetime' LANGUAGE C IMMUTABLE STRICT; |
Latest revision as of 14:00, 24 November 2010
-- cut and paste the following SQL to register the functions into postgres --
CREATE OR REPLACE FUNCTION exodus_call(bytea, bytea, bytea, bytea, bytea, int4, int4) RETURNS bytea AS 'pgexodus', 'exodus_call' LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION exodus_extract_bytea(bytea, int4, int4, int4) RETURNS bytea AS 'pgexodus', 'exodus_extract_bytea' LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION exodus_extract_text(bytea, int4, int4, int4) RETURNS text AS 'pgexodus', 'exodus_extract_text' LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION exodus_extract_sort(bytea, int4, int4, int4) RETURNS text AS 'pgexodus', 'exodus_extract_sort' LANGUAGE C IMMUTABLE;
-- Remaining functions are STRICT therefore never get called with NULLS -- also return NULL if passed zero length strings
CREATE OR REPLACE FUNCTION exodus_extract_text2(bytea, int4, int4, int4) RETURNS text AS 'pgexodus', 'exodus_extract_text2' LANGUAGE C IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION exodus_extract_date(bytea, int4, int4, int4) RETURNS date AS 'pgexodus', 'exodus_extract_date' LANGUAGE C IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION exodus_extract_time(bytea, int4, int4, int4) RETURNS time AS 'pgexodus', 'exodus_extract_time' LANGUAGE C IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION exodus_extract_datetime(bytea, int4, int4, int4) RETURNS timestamp AS 'pgexodus', 'exodus_extract_datetime' LANGUAGE C IMMUTABLE STRICT;