On Wed, 21 Jan 2004, Rajesh Kumar Mallah wrote: > can anyone explain why > SELECT array_lower(array_prepend(0, ARRAY[1,2,3]), 1); > returns 0 not 1 > > because > > tradein_clients=# SELECT array_prepend(0, ARRAY[1,2,3]); > +---------------+ > | array_prepend | > +---------------+ > | {0,1,2,3} | > +---------------+ > (1 row)
It looks like array_prepend is basically inserting the new value at the index before the start of the array, so 0 is the lower bound. This means that array_prepend(0,ARRAY[1,2,3]) is not the same array as ARRAY[0,1,2,3]. If you stick both in a table, and select col[1], in one you appear to get back 1, in the other 0. However, I think there is a bug here somewhere, because the former array does not appear to dump/restore as the same value (both seem to dump as (0,1,2,3}) ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster