Re: Running CREATE only on certain Postgres versions

From: Igor Neyman <ineyman(at)perceptron(dot)com>
To: Robert James <srobertjames(at)gmail(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Running CREATE only on certain Postgres versions
Date: 2012-09-24 18:14:05
Message-ID: A76B25F2823E954C9E45E32FA49D70EC08EB5495@mail.corp.perceptron.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: Robert James [mailto:srobertjames(at)gmail(dot)com]
> Sent: Monday, September 24, 2012 9:33 AM
> To: Postgres General
> Subject: Running CREATE only on certain Postgres versions
>
> I have some code which creates a function in Postgres, taken from
> http://wiki.postgresql.org/wiki/Array_agg .
>
> DROP AGGREGATE IF EXISTS array_agg(anyelement); CREATE AGGREGATE
> array_agg(anyelement) ( SFUNC=array_append, STYPE=anyarray,
> INITCOND='{}'
> );
>
> The function was added in 8.4, and so the code fails when run on 8.4 or
> higher.
>
> How can I make the code cross-version compatible? For instance, how
> can I tell it to check the version, and only run if 8.3 or lower? Or
> another way to make it cross-version?

Find your PG version with:
SELECT version();

and continue accordingly...

Regards,
Igor Neyman

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message craig 2012-09-24 18:20:12 Custom prompt
Previous Message Rachel Owsley 2012-09-24 18:12:04 Re: N-tile function in postgres