Re: Running CREATE only on certain Postgres versions - Mailing list pgsql-general

From Igor Neyman
Subject Re: Running CREATE only on certain Postgres versions
Date
Msg-id A76B25F2823E954C9E45E32FA49D70EC08EB5495@mail.corp.perceptron.com
Whole thread Raw
In response to Running CREATE only on certain Postgres versions  (Robert James <srobertjames@gmail.com>)
Responses Re: Running CREATE only on certain Postgres versions
List pgsql-general
> -----Original Message-----
> From: Robert James [mailto:srobertjames@gmail.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


pgsql-general by date:

Previous
From: Rachel Owsley
Date:
Subject: Re: N-tile function in postgres
Next
From: craig@gtek.biz
Date:
Subject: Custom prompt