I use PostgreSQL 7.4 database with DRUPAL 5. In this database there is no function greatest() which is used in node.module for search queries. For compatibility we need some solution for this.

CREATE OR REPLACE FUNCTION greatest(anyelement,anyelement) RETURNS anyelement AS '
  SELECT CASE WHEN $1 > $2 THEN $1 ELSE $2 END
' LANGUAGE 'sql';

And for three parameters:

CREATE OR REPLACE FUNCTION greatest(anyelement,anyelement,anyelement) RETURNS anyelement AS '
  SELECT CASE WHEN $1 > greatest($2, $3) THEN $1 ELSE greatest($2, $3) END
' LANGUAGE 'sql';

Comments

chx’s picture

Interesting. This function can be found in system_update_125 but nowhere else.

sammys’s picture

Assigned: Unassigned » sammys
Priority: Normal » Critical
Status: Active » Needs review
StatusFileSize
new1.94 KB

Hi @havran,

Thanks for posting this issue! A very important one indeed.

It appears that I left the functions out of system.install when I created the install system code for 5.0. Here is a patch that i've tested on pgsql 7.4 and it'll no doubt work on all the others as well. I simply reused the function defs from 4.7, wrapped them in db_query's and avoided replacing the concat() and rand() functions if they already exist on the system (they do in pgsql 7.4)

Cheers,

--
Sammy Spets
Synerger
http://synerger.com

dries’s picture

Status: Needs review » Fixed

Committed to trunk.

yched’s picture

Status: Fixed » Needs work

Isn't there a mistake in the patch ?

+if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'concat'"))) {
+        db_query('CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS

should probably be

+if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'rand'"))) {
+        db_query('CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS
yched’s picture

Status: Needs work » Needs review
StatusFileSize
new771 bytes

patch attached

dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks.

sammys’s picture

Status: Fixed » Closed (fixed)