Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 3A13C9FA2CA; Fri, 29 Sep 2006 14:08:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 80599-10; Fri, 29 Sep 2006 14:08:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail731.megamailservers.com (mail731.megamailservers.com [69.49.98.41]) by postgresql.org (Postfix) with ESMTP id 20DD89FA2A9; Fri, 29 Sep 2006 14:08:20 -0300 (ADT) X-Authenticated-User: paul.a.pnlassociates.com Received: from [69.3.2.106] (h-69-3-2-106.mclnva23.covad.net [69.3.2.106]) (authenticated bits=0) by mail731.megamailservers.com (8.13.6.20060614/8.13.1) with ESMTP id k8TH8FOj028346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 29 Sep 2006 13:08:19 -0400 Message-ID: <451D52FF.5000602@pnlassociates.com> Date: Fri, 29 Sep 2006 13:08:15 -0400 From: "Paul B. Anderson" User-Agent: Thunderbird 1.5.0.7 (Macintosh/20060909) MIME-Version: 1.0 To: pgsql-admin@postgresql.org, pgsql-general@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: Array assignment behavior (was Re: Stored procedure array References: <451C48AB.6090508@pnlassociates.com> <9461.1159502232@sss.pgh.pa.us> <451D34FD.3050709@pnlassociates.com> <451D37C8.8060502@pnlassociates.com> <16926.1159546451@sss.pgh.pa.us> In-Reply-To: <16926.1159546451@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------010201090002020705030004" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.159 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200609/371 X-Sequence-Number: 23285 This is a multi-part message in MIME format. --------------010201090002020705030004 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit It seems that the suggestion to fill intermediate positions with NULLs would be preferable to the current behavior. I know of no requirement to populate arrays in sequence in any other language so I think other programmers would be surprised too by the current behavior. Paul Tom Lane wrote: > [ expanding this thread, as it now needs wider discussion ] > > "Paul B. Anderson" writes: > >> Actually, I was not filling all of the arrays in sequential order. I >> added code to initialize them in order and the function seems to be >> working now. Is that a known problem? >> > > Well, it's a documented behavior: section 8.10.4 saith > > A stored array value can be enlarged by assigning to an element > adjacent to those already present, or by assigning to a slice > that is adjacent to or overlaps the data already present. > > Up to 8.2 we didn't have a lot of choice about this, because without any > ability to have nulls embedded in arrays, there wasn't any sane thing to > do with the intermediate positions if you assigned to an element not > adjacent to the existing range. As of 8.2 we could allow assignment to > arbitrary positions by filling the intermediate positions with nulls. > The code hasn't actually been changed to allow that, but it's something > we could consider doing now. > > Comments? > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match > > . > > --------------010201090002020705030004 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit It seems that the suggestion to fill intermediate positions with NULLs would be preferable to the current behavior. 

I know of no requirement to populate arrays in sequence in any other language so I think other programmers would be surprised too by the current behavior.

Paul


Tom Lane wrote:
[ expanding this thread, as it now needs wider discussion ]

"Paul B. Anderson" <paul.a@pnlassociates.com> writes:
  
Actually, I was not filling all of the arrays in sequential order.  I 
added code to initialize them in order and the function seems to be 
working now.  Is that a known problem? 
    

Well, it's a documented behavior: section 8.10.4 saith

	A stored array value can be enlarged by assigning to an element
	adjacent to those already present, or by assigning to a slice
	that is adjacent to or overlaps the data already present.

Up to 8.2 we didn't have a lot of choice about this, because without any
ability to have nulls embedded in arrays, there wasn't any sane thing to
do with the intermediate positions if you assigned to an element not
adjacent to the existing range.  As of 8.2 we could allow assignment to
arbitrary positions by filling the intermediate positions with nulls.
The code hasn't actually been changed to allow that, but it's something
we could consider doing now.

Comments?

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

.

  
--------------010201090002020705030004--