Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 219309FB393; Fri, 29 Sep 2006 13:36:33 -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 22088-04; Fri, 29 Sep 2006 16:35:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp.savagebeast.com (unknown [63.81.120.10]) by postgresql.org (Postfix) with ESMTP id 9295B9FB2CE; Fri, 29 Sep 2006 13:35:29 -0300 (ADT) Received: from [172.16.100.6] (tailfly.SavageBeast.com [172.16.100.6]) by smtp.savagebeast.com (Postfix) with ESMTP id 1D213808C; Fri, 29 Sep 2006 09:35:28 -0700 (PDT) In-Reply-To: <16926.1159546451@sss.pgh.pa.us> 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> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <595CA7DC-7EC2-47B6-A894-DCD0ED3825F3@pandora.com> Cc: "Paul B. Anderson" , pgsql-admin@postgresql.org, pgsql-general@postgresql.org, pgsql-hackers@postgresql.org Content-Transfer-Encoding: 7bit From: Casey Duncan Subject: Re: [GENERAL] Array assignment behavior (was Re: Stored procedure array limits) Date: Fri, 29 Sep 2006 09:35:25 -0700 To: Tom Lane X-Mailer: Apple Mail (2.752.2) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200609/369 X-Sequence-Number: 23283 On Sep 29, 2006, at 9:14 AM, 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? At first blush, this strikes me as a bit too magical/implicit. Are there other languages where sequences behave similarly? The best analogy that comes to mind is sparse files, but in that case there is an implicit contract that the intervening empty regions do not actually occupy physical space, doesn't sound like that's true here. I think the result of this change would be more difficult debugging of off-by-one errors and their ilk, rather than actually being a real benefit. OTOH, perhaps there is a real use-case I am missing here. I don't see the rest of this thread on GENERAL and I couldn't find it searching the archives, where did it come from? -Casey