You are here

function views_update_6007 in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 6.3 views.install \views_update_6007()
  2. 6.2 views.install \views_update_6007()

Add aggregate function to PostgreSQL so GROUP BY can be used to force only one result to be returned for each item.

File

./views.install, line 383
Contains install and update functions for Views.

Code

function views_update_6007() {
  if (Database::getConnection()
    ->databaseType() == '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);");
  }
}