Re: array_lower /array_prepend doubt - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: array_lower /array_prepend doubt
Date
Msg-id 20040121074533.J95018@megazone.bigpanda.com
Whole thread Raw
In response to array_lower /array_prepend doubt  (Rajesh Kumar Mallah <mallah@trade-india.com>)
List pgsql-sql
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})



pgsql-sql by date:

Previous
From: Rajesh Kumar Mallah
Date:
Subject: array_lower /array_prepend doubt
Next
From: Tom Lane
Date:
Subject: Re: array_lower /array_prepend doubt