When performing an upgrade you have incorrect syntax for PostgreSQL Database.

During an upgrade you get pink text displaying:

Drupal database update

* warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "EXISTS" at character 19 in /var/www/www.cerwinvega.com/live/includes/database.pgsql.inc on line 139.
* user warning: query: DROP AGGREGATE IF EXISTS first(anyelement) in /var/www/www.cerwinvega.com/live/sites/all/modules/views/views.install on line 294.

The following queries were executed
views module
Update #6007

* CREATE OR REPLACE FUNCTION first(anyelement, anyelement) RETURNS anyelement AS 'SELECT COALESCE($1, $2);' LANGUAGE 'sql';
* Failed: DROP AGGREGATE IF EXISTS first(anyelement)
* CREATE AGGREGATE first(sfunc = first, basetype = anyelement, stype = anyelement);

Comments

alek123’s picture

Idem...

mauritsl’s picture

Also happens on a new installation (Drupal 6.16 on Postgres 8.1):

* warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "EXISTS" at character 19 in /var/www/vhosts/maudev/includes/database.pgsql.inc on line 139.
* user warning: query: DROP AGGREGATE IF EXISTS first(anyelement) in /var/www/vhosts/maudev/sites/all/modules/contrib/views/views.install on line 14.

merlinofchaos’s picture

Priority: Critical » Normal

This isn't really critical. I don't think it impacts functionality at all.

mauritsl’s picture

I indeed didn't notice any impact. Views is just working fine as far as I see, it was just the error showing.

iamjon’s picture

Assigned: Unassigned » dawehner

mbukaty,
does the error occur in the latest version of views?

Assigning this to dereine

dawehner’s picture

Assigned: dawehner » Unassigned

Can someone here provide a proper syntax for pgsql?

real_ate’s picture

I can confirm that this error is still shown with: Drupal core 6.19, Views 6.x-2.11 and postgresql-server 8.1.22

To recreate:
1) Install a clean drupal with postgresql.
2) Go to Administer > Site Building > Modules > List and enable Views.
3) After clicking "save configuration" you get the following message:

* warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "EXISTS" at character 19 in /path/to/site/includes/database.pgsql.inc on line 139.
* user warning: query: DROP AGGREGATE IF EXISTS first(anyelement) in /path/to/site/sites/all/modules/views/views.install on line 14.

I have done some investigation into this issue and it seems like there will be no way to conditionally delete the aggregate without installing the plpgsql into the drupal database for versions < 8.2.

The only thing that I would suggest (if you want to support version 8.1) would be to remove the "IF EXISTS" part and suppress any errors from the following command:

@db_query("DROP AGGREGATE first(anyelement)");

This will actually drop the AGGREGATE if it exists and will not warn the user if it does not.

iamjon’s picture

Adding tag

liam morland’s picture

Issue tags: +PostgreSQL

Tagging

mustanggb’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)
liam morland’s picture

Should this instead be "Closed (outdated)"?

mustanggb’s picture

Possibly, I only went with won't fix because D6 isn't really getting commits.

liam morland’s picture

Closed (outdated) is designed for that:

https://www.drupal.org/node/156119#outdated