--- ../drupal-head-copy/database/database.pgsql 2005-06-26 23:45:36.000000000 -0500 +++ database/database.pgsql 2005-06-29 23:32:40.000000000 -0500 @@ -2,6 +2,13 @@ -- Table structure for access -- +--- uncomment the two lines below to install Drupal into a schema other than public +--- Change 'myDrupalSchema' into whatever the name of the schema you want + +-- CREATE SCHEMA myDrupalSchema; +-- SET search_path TO myDrupalSchema; + + CREATE TABLE access ( aid SERIAL, mask varchar(255) NOT NULL default '', @@ -823,37 +830,36 @@ --- --- Functions ---- +--- always installed in 'public' as prefix isn't appended to function names + +SET search_path TO public; 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'; + SELECT + CASE WHEN (($1 > $2) OR ($2 IS NULL)) THEN $1 + ELSE $2 + END; +' LANGUAGE 'sql'; CREATE FUNCTION greatest(integer, integer, integer) RETURNS integer AS ' SELECT greatest($1, greatest($2, $3)); ' LANGUAGE 'sql'; - + CREATE FUNCTION "rand"() RETURNS float AS ' -BEGIN - RETURN random(); -END; -' LANGUAGE 'plpgsql'; + SELECT random(); +' LANGUAGE 'sql'; CREATE FUNCTION "concat"(text, text) RETURNS text AS ' -BEGIN - RETURN $1 || $2; -END; -' LANGUAGE 'plpgsql'; + SELECT $1 || $2; +' LANGUAGE 'sql'; + +-- usage of function needs to be phased out with CASE WHEN .. THEN .. ELSE .. END construct +-- because "if()" is not ANSI SQL -CREATE FUNCTION "if"(boolean, anyelement, anyelement) RETURNS anyelement AS ' - SELECT CASE WHEN $1 THEN $2 ELSE $3 END; +CREATE FUNCTION "if"(anyelement, anyelement, anyelement) RETURNS anyelement AS ' + SELECT + CASE WHEN (($1 <> 0) AND ($1 IS NOT NULL)) THEN $2 + ELSE $3 + END; ' LANGUAGE 'sql';