*/
function views_install() {
+ if ($GLOBALS['db_type'] == 'pgsql') {
+ db_query('CREATE OR REPLACE FUNCTION first(anyelement, anyelement) RETURNS anyelement AS \'SELECT COALESCE($1, $2);\' LANGUAGE \'sql\';');
+ db_query("DROP AGGREGATE IF EXISTS first(anyelement)");
+ db_query("CREATE AGGREGATE first(sfunc = first, basetype = anyelement, stype = anyelement);");
+ }
drupal_install_schema('views');
db_query("UPDATE {system} SET weight = 10 WHERE name = 'views'");
}
return $ret;
}
+
+/**
+ * Add aggregate function to PostgreSQL so GROUP BY can be used to force only
+ * one result to be returned for each item.
+ */
+function views_update_6007() {
+ $ret = array();
+ if ($GLOBALS['db_type'] == 'pgsql') {
+ $ret[] = update_sql('CREATE OR REPLACE FUNCTION first(anyelement, anyelement) RETURNS anyelement AS \'SELECT COALESCE($1, $2);\' LANGUAGE \'sql\';');
+ $ret[] = update_sql("DROP AGGREGATE IF EXISTS first(anyelement)");
+ $ret[] = update_sql("CREATE AGGREGATE first(sfunc = first, basetype = anyelement, stype = anyelement);");
+ }
+ return $ret;
+}