Re: [GENERAL] Why is cast array integer[] <--> text[] is not immutable.

2011-12-09 Thread Phil Couling
Thanks I'm having trouble finding any reference to array_out and array_in in the documentation. Is there a way to set a different cast for an array? Regards On 9 December 2011 15:09, Tom Lane wrote: > Phil Couling writes: >> I'm struggling to understand why this cas

[GENERAL] Why is cast array integer[] <--> text[] is not immutable.

2011-12-09 Thread Phil Couling
Hi I'm struggling to understand why this casts is not immutable: integer[]::text[] text[]::integer[] The following are all immutable: integer::text text::integer integer[]::float[] integer::float I hit on this while trying to make a gin index which cast from one to the other. Why does the enc

Re: [GENERAL] Error: timestamp with timezone + interval is not immutable while creating index

2011-10-14 Thread Phil Couling
On 14 October 2011 00:49, Steve Crawford wrote: > On 10/13/2011 04:32 PM, Tom Lane wrote: >> >> Phil Couling  writes: >>> >>> main=>  create index foo_next_update on foo( (last_updated + >>> update_cycle) ) ; >>> ERROR:  functions in index ex

[GENERAL] Error: timestamp with timezone + interval is not immutable while creating index

2011-10-13 Thread Phil Couling
Hi All I've got a table with (amongst others) two fields: last_updated timestamp with time zone; update_cycle interval; I'd like to create an index on these, to index time "next update" time (last_updated + update_cycle). When I try this I get an error though: main=> create index foo_next_updat

[GENERAL] Error: timestamp with timezone + interval is not immutable while creating index

2011-10-13 Thread Phil Couling
Hi All I've got a table with (amongst others) two fields: last_updated timestamp with time zone; update_cycle interval; I'd like to create an index on these, to index time "next update" time (last_updated + update_cycle). When I try this I get an error though: main=> create index foo_next_updat

Re: [GENERAL] gaps/overlaps in a time table : current and previous row question

2011-10-05 Thread Phil Couling
I think you need to get the full list of change dates first. Assuming you're searching over a time period between "period_from" and "period_to": SELECT change_time, sum(diff) as total_diff FROM ( SELECT starttime as change_time, 1 AS diff FROM t WHERE starttime > period_from AND endtime < period_t

Re: [GENERAL] how to select one column into another in same table?

2011-10-05 Thread Phil Couling
I don't this this is possible as postgres. There is something simular with: alter table table_name alter column column_foo using column_bar But I don't think there's any performance advantage over a simple update and the using clause doesn't appear to have an equivalent in an add column statement.

Re: [GENERAL] Add quto increment to existing column

2011-10-04 Thread Phil Couling
Hi Dropping the column is a bit drastic if you already have data in there. You could just set the default on the column: alter table my_table alter hist_id set default nextval('hist_id_seq') Also considder setting the sequence owner: alter sequence hist_id_seq owned by my_table.hist_id; This w

Re: [GENERAL] Convert data into horizontal from vertical form

2011-05-20 Thread Phil Couling
Hi Adarsh You say you need this to be done dynamically. I assume that by this you're looking for a way to have 1 query produce an increasing number of columns as you increase the number of rows in your table. This really isn't possible and doesn't fit with the model SQL was designed for. The conc

Re: [GENERAL] find the greatest, pick it up and group by

2011-05-17 Thread Phil Couling
Hi The method you're using is functionally correct and quite efficient if a little on the verbose side. Other non-postgres variants of SQL have a "DECODE" function which comes in very handy. I dont believe postgres has any equivalent. (Postgres decode() does something entirely differnt). I often

[GENERAL] Extract (Recover) data from a cluster built on a different architecture (ARM).

2011-04-24 Thread Phil Couling
Hi I'm looking for a way to extract the data from a PostgreSQL 8.3.14 database (cluster) that was built using an an ARM/Linux server. The problem is that the hardware itself is a brick and the replacement hardware will be X86/AMD64. Sadly my backups are all copies of the DB files and don't inclu

[GENERAL] Do TEMP Tables have an OID? Can this be a problem if used too frequently?

2009-05-01 Thread Phil Couling
Hi I've just written a search function which creates a temp table, preforms some reasoning on it returning results then drops it again. I'm using temp tables in an attempt to gain efficiency (not repeating work between one section of the function and another). However I'm worried that there ma