summaryrefslogtreecommitdiff
path: root/database/database.pgsql
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-11-24 20:00:39 +0000
committerDries Buytaert <dries@buytaert.net>2005-11-24 20:00:39 +0000
commit350f2e5affe8d327d5c5d162345da578ff45150a (patch)
tree06da36278c00a0e91b7bc8997c69fbfea10066c1 /database/database.pgsql
parent70eb349d88a73263b9bc49f1f9a2ea394dff35d2 (diff)
downloadbrdo-350f2e5affe8d327d5c5d162345da578ff45150a.tar.gz
brdo-350f2e5affe8d327d5c5d162345da578ff45150a.tar.bz2
- Patch #37383 by Cvbge: fixed clash between greatest() functions from Drupal and postgresql 8.1. Removed dependency on plpgsql.
Diffstat (limited to 'database/database.pgsql')
-rw-r--r--database/database.pgsql39
1 files changed, 15 insertions, 24 deletions
diff --git a/database/database.pgsql b/database/database.pgsql
index 0b4139a73..1499e0bd6 100644
--- a/database/database.pgsql
+++ b/database/database.pgsql
@@ -1,3 +1,6 @@
+-- Do not show NOTICE: messages, it's hard to spot errors.
+set client_min_messages = 'warning';
+
--
-- Table structure for access
--
@@ -869,35 +872,23 @@ ALTER SEQUENCE menu_mid_seq RESTART 3;
--- Functions
---
-CREATE FUNCTION greatest(integer, integer) RETURNS integer AS '
-BEGIN
- IF $2 IS NULL THEN
- RETURN $1;
- END IF;
- IF $1 > $2 THEN
- RETURN $1;
- END IF;
- RETURN $2;
-END;
-' LANGUAGE 'plpgsql';
-
-CREATE FUNCTION greatest(integer, integer, integer) RETURNS integer AS '
+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';
+
+CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric, numeric) RETURNS numeric AS '
SELECT greatest($1, greatest($2, $3));
' LANGUAGE 'sql';
-CREATE FUNCTION "rand"() RETURNS float AS '
-BEGIN
- RETURN random();
-END;
-' LANGUAGE 'plpgsql';
+CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS '
+ SELECT random();
+' LANGUAGE 'sql';
-CREATE FUNCTION "concat"(text, text) RETURNS text AS '
-BEGIN
- RETURN $1 || $2;
-END;
-' LANGUAGE 'plpgsql';
+CREATE OR REPLACE FUNCTION "concat"(text, text) RETURNS text AS '
+ SELECT $1 || $2;
+' LANGUAGE 'sql';
-CREATE FUNCTION "if"(boolean, anyelement, anyelement) RETURNS anyelement AS '
+CREATE OR REPLACE FUNCTION "if"(boolean, anyelement, anyelement) RETURNS anyelement AS '
SELECT CASE WHEN $1 THEN $2 ELSE $3 END;
' LANGUAGE 'sql';