summaryrefslogtreecommitdiff
path: root/modules/system/system.install
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system/system.install')
-rw-r--r--modules/system/system.install32
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/system/system.install b/modules/system/system.install
index 758b4a17d..c48c96017 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -550,6 +550,38 @@ function system_install() {
db_query("CREATE DOMAIN smallint_unsigned smallint CHECK (VALUE >= 0)");
db_query("CREATE DOMAIN bigint_unsigned bigint CHECK (VALUE >= 0)");
+ /* create functions */
+ db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric) RETURNS numeric AS
+ \'SELECT CASE WHEN (($1 > $2) OR ($2 IS NULL)) THEN $1 ELSE $2 END;\'
+ LANGUAGE \'sql\''
+ );
+ db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric, numeric) RETURNS numeric AS
+ \'SELECT greatest($1, greatest($2, $3));\'
+ LANGUAGE \'sql\''
+ );
+ if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'concat'"))) {
+ db_query('CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS
+ \'SELECT random();\'
+ LANGUAGE \'sql\''
+ );
+ }
+
+ if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'concat'"))) {
+ db_query('CREATE OR REPLACE FUNCTION "concat"(text, text) RETURNS text AS
+ \'SELECT $1 || $2;\'
+ LANGUAGE \'sql\''
+ );
+ }
+ db_query('CREATE OR REPLACE FUNCTION "if"(boolean, text, text) RETURNS text AS
+ \'SELECT CASE WHEN $1 THEN $2 ELSE $3 END;\'
+ LANGUAGE \'sql\''
+ );
+ db_query('CREATE OR REPLACE FUNCTION "if"(boolean, integer, integer) RETURNS integer AS
+ \'SELECT CASE WHEN $1 THEN $2 ELSE $3 END;\'
+ LANGUAGE \'sql\''
+ );
+
+ /* create tables */
db_query("CREATE TABLE {access} (
aid serial,
mask varchar(255) NOT NULL default '',