pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Rajesh Kumar Mallah <mallah@trade-india.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: array_lower /array_prepend doubt
Date: Wed, 21 Jan 2004 07:53:11 -0800 (PST)
Message-ID: <20040121074533.J95018@megazone.bigpanda.com> (raw)
In-Reply-To: <400E85EC.4000106@trade-india.com>
References: <400E85EC.4000106@trade-india.com>


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})




view thread (12+ messages)  latest in thread

Message-ID: <20040121074533.J95018@megazone.bigpanda.com>
Permalink:  ../20040121074533.J95018@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20040121074533.J95018@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, mallah@trade-india.com
  Subject: Re: array_lower /array_prepend doubt
  In-Reply-To: <20040121074533.J95018@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox