Re: [GENERAL] Running CREATE only on certain Postgres versions

2012-09-29 Thread Jasen Betts
On 2012-09-24, Robert James wrote: > 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='{}

Re: [GENERAL] Running CREATE only on certain Postgres versions

2012-09-26 Thread Adrian Klaver
On 09/25/2012 08:25 AM, Daniele Varrazzo wrote: On Tue, Sep 25, 2012 at 3:47 PM, Adrian Klaver wrote: To elaborate: test=> SELECT current_setting('server_version_num'); current_setting - 90009 Yes, but knowing that, how does he run a statement only if version e.g. >= 8040

Re: [GENERAL] Running CREATE only on certain Postgres versions

2012-09-25 Thread Igor Neyman
> -Original Message- > From: Daniele Varrazzo [mailto:daniele.varra...@gmail.com] > Sent: Tuesday, September 25, 2012 11:26 AM > To: Adrian Klaver > Cc: David Johnston; Robert James; Igor Neyman; Postgres General > Subject: Re: [GENERAL] Running CREATE only on certain

Re: [GENERAL] Running CREATE only on certain Postgres versions

2012-09-25 Thread Adrian Klaver
On 09/24/2012 06:40 PM, David Johnston wrote: Server parameter: server_version_num http://www.postgresql.org/docs/9.2/interactive/runtime-config-preset.html To elaborate: test=> SELECT current_setting('server_version_num'); current_setting - 90009 And yes, I know it needs t

Re: [GENERAL] Running CREATE only on certain Postgres versions

2012-09-24 Thread David Johnston
Server parameter: server_version_num http://www.postgresql.org/docs/9.2/interactive/runtime-config-preset.html David J. On Sep 24, 2012, at 21:23, Robert James wrote: > Unfortunately, SELECT VERSION() gives a long text string - parsing out > the version isn't reliable. > > So, we can reduce

Re: [GENERAL] Running CREATE only on certain Postgres versions

2012-09-24 Thread Robert James
Unfortunately, SELECT VERSION() gives a long text string - parsing out the version isn't reliable. So, we can reduce my question to a simpler question: What's the best way to determine if postgres is running > version x? Or, what's the best way to determine the exact version number programaticall

Re: [GENERAL] Running CREATE only on certain Postgres versions

2012-09-24 Thread Igor Neyman
> -Original Message- > From: Robert James [mailto:srobertja...@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.postgr

Re: [GENERAL] Running CREATE only on certain Postgres versions

2012-09-24 Thread Daniele Varrazzo
On Mon, Sep 24, 2012 at 2:32 PM, Robert James wrote: > 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=anyarr

[GENERAL] Running CREATE only on certain Postgres versions

2012-09-24 Thread Robert James
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 cod