X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4CA8BD1D2E5 for ; Wed, 21 Jan 2004 15:56:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 66314-01 for ; Wed, 21 Jan 2004 11:55:52 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 9F07CD1E8A8 for ; Wed, 21 Jan 2004 11:55:48 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 2E9DF3570D; Wed, 21 Jan 2004 07:53:11 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 2D30A3570B; Wed, 21 Jan 2004 07:53:11 -0800 (PST) Date: Wed, 21 Jan 2004 07:53:11 -0800 (PST) From: Stephan Szabo To: Rajesh Kumar Mallah Cc: pgsql-sql@postgresql.org Subject: Re: array_lower /array_prepend doubt In-Reply-To: <400E85EC.4000106@trade-india.com> Message-ID: <20040121074533.J95018@megazone.bigpanda.com> References: <400E85EC.4000106@trade-india.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/195 X-Sequence-Number: 16588 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})