Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id C7FE89FA103 for ; Fri, 29 Sep 2006 13:16:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 16478-03-2 for ; Fri, 29 Sep 2006 16:15:23 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 63C939FA1AD for ; Fri, 29 Sep 2006 13:14:12 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k8TGEBGC016927; Fri, 29 Sep 2006 12:14:11 -0400 (EDT) To: "Paul B. Anderson" cc: pgsql-admin@postgresql.org, pgsql-general@postgresql.org, pgsql-hackers@postgresql.org Subject: Array assignment behavior (was Re: Stored procedure array limits) In-reply-to: <451D37C8.8060502@pnlassociates.com> References: <451C48AB.6090508@pnlassociates.com> <9461.1159502232@sss.pgh.pa.us> <451D34FD.3050709@pnlassociates.com> <451D37C8.8060502@pnlassociates.com> Comments: In-reply-to "Paul B. Anderson" message dated "Fri, 29 Sep 2006 11:12:08 -0400" Date: Fri, 29 Sep 2006 12:14:11 -0400 Message-ID: <16926.1159546451@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200609/368 X-Sequence-Number: 23282 [ 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