diff --git a/database/database.pgsql b/database/database.pgsql index 1ce84a83a772b4eee4cae300ceab6d5a1092dc70..8fbf9ad24a9d3f450b79645ab832e4fd497966fa 100644 --- a/database/database.pgsql +++ b/database/database.pgsql @@ -681,8 +681,11 @@ INSERT INTO blocks(module,delta,status) VALUES('user', '1', '1'); --- Functions --- -CREATE FUNCTION "greatest"(integer, integer) RETURNS integer AS ' +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; diff --git a/database/updates.inc b/database/updates.inc index f631e121f030a4caed232383324ed15caafc2252..ef1d869681f1fea931c0974c14382171107ee799 100644 --- a/database/updates.inc +++ b/database/updates.inc @@ -65,6 +65,7 @@ "2004-06-30" => "update_91", "2004-07-07" => "update_92", "2004-07-11" => "update_93", + "2004-07-22" => "update_94" ); function update_32() { @@ -1162,6 +1163,30 @@ function update_93() { return $ret; } +function update_94() { + /** + * Postgres only update + */ + $ret = array(); + if ($GLOBALS['db_type'] == 'pgsql') { + $ret[] = update_sql('DROP FUNCTION "greatest"(integer, integer)'); + $ret[] = update_sql(" + 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'; + "); + } + return $ret; +} + function update_sql($sql) { $edit = $_POST["edit"]; $result = db_query($sql);