in database/database.pgsql there are two functions.
first of all plpgsql is not neccessary (and in some databases is not available), secondly i think the greatest() function has error but maybe it's supposed to emulate mysql error?
here goes the code:
---
--- Functions
---
--CREATE FUNCTION "greatest"(integer, integer) RETURNS integer AS '
--BEGIN
-- IF $1 > $2 THEN
-- RETURN $1;
-- END IF;
-- RETURN $2;
--END;
--' LANGUAGE 'plpgsql';
-- this is the above function without the need of plpgsql
-- but what if $1 = $2 ?!
CREATE FUNCTION "greatest"(integer, integer) RETURNS integer AS '
SELECT CASE WHEN $1 > $2 THEN $1 ELSE $2 END;
' LANGUAGE 'sql';
--CREATE FUNCTION "rand"() RETURNS float AS '
--BEGIN
-- RETURN random();
--END;
--' LANGUAGE 'plpgsql';
CREATE FUNCTION "rand"() RETURNS float AS '
SELECT random();
' LANGUAGE 'sql';
Comments
Comment #1
adrian commentedThank you for your input. I will apply these changes to the schema files / update script.
Comment #2
adrian commentedi originally had a patch which turned greatest into a case when statement.
it turns out it didn't return the right data.
I will have to test this more completely before i can patch this.. but i am paying attention to it.
Comment #3
killes@www.drop.org commentedIs this still open?
Comment #4
jonbob commentedComment #5
adrian commentedi just neglected to get rid of the last of the plpgsql functions.
drupal 4.6 will be the last version to depend on plpgsql (i promise)
Comment #6
Cvbge commentedSetting to duplicate of http://drupal.org/node/37383 (although this issue was first)
Comment #7
MVRider commentedI just installed the latest version of 5.2 and this function we still in the schema or introduced by another module.
Is this going to be removed? It goes against SQL standards:
Using: PostgreSQL
http://www.postgresql.org/docs/8.2/interactive/sql-keywords-appendix.html
Any thoughts?
CREATE FUNCTION greatest(numeric, numeric) RETURNS numeric
AS $_$SELECT CASE WHEN (($1 > $2) OR ($2 IS NULL)) THEN $1 ELSE $2 END;$_$
LANGUAGE sql;
ALTER FUNCTION public.greatest(numeric, numeric) OWNER TO myowner;
--
-- Name: greatest(numeric, numeric, numeric); Type: FUNCTION; Schema: public; Owner: myowner
--
CREATE FUNCTION greatest(numeric, numeric, numeric) RETURNS numeric
AS $_$SELECT greatest($1, greatest($2, $3));$_$
LANGUAGE sql;
ALTER FUNCTION public.greatest(numeric, numeric, numeric) OWNER TO myowner;
Comment #8
chx commentedthere is no bug report to be fixed. the function you mention is an SQL language function and might be against standards but is only used by pgsql.