[drupal-devel] [feature] pgsql function w/o need for plpgsql

adrian drupal-devel at drupal.org
Sun Mar 27 00:35:27 UTC 2005


Issue status update for http://drupal.org/node/4124

 Project:      Drupal
 Version:      cvs
 Component:    database system
 Category:     feature requests
 Priority:     normal
 Assigned to:  adrian
 Reported by:  Anonymous
 Updated by:   adrian
 Status:       active

i 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)


adrian



Previous comments:
------------------------------------------------------------------------

November 13, 2003 - 20:12 : Anonymous

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';


------------------------------------------------------------------------

November 14, 2003 - 11:10 : adrian

Thank you for your input. I will apply these changes to the schema files
/ update script.


------------------------------------------------------------------------

November 18, 2003 - 19:29 : adrian

i 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.


------------------------------------------------------------------------

July 23, 2004 - 19:03 : killes at www.drop.org

Is this still open?





More information about the drupal-devel mailing list