Skip site navigation (1) Skip section navigation (2)

Re: array_lower /array_prepend doubt

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Rajesh Kumar Mallah <mallah(at)trade-india(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: array_lower /array_prepend doubt
Date: 2004-01-21 15:53:11
Message-ID: (view raw, whole thread or download thread mbox)
Lists: 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})

In response to

pgsql-sql by date

Next:From: Tom LaneDate: 2004-01-21 17:14:30
Subject: Re: array_lower /array_prepend doubt
Previous:From: Rajesh Kumar MallahDate: 2004-01-21 14:00:12
Subject: array_lower /array_prepend doubt

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group