Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 9C0BC632B76 for ; Wed, 8 Apr 2009 12:11:58 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 56123-06 for ; Wed, 8 Apr 2009 12:11:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kickstone.com (smtp.kickstone.com [87.194.183.70]) by mail.postgresql.org (Postfix) with ESMTP id 9E78F6327AF for ; Wed, 8 Apr 2009 12:11:56 -0300 (ADT) Received: from madras2.square-pi.com ([192.168.2.131]:1435 helo=MADRAS2) by mail.kickstone.com with esmtpa (Exim 4.69) (envelope-from ) id 1LrZRT-0005Gx-3n; Wed, 08 Apr 2009 16:11:55 +0100 Message-ID: <24AD6A221A5B4B03B87163A772D2F8BB@squarepi.com> From: "John Lister" To: "Andrew Chernow" Cc: References: <89DBB5874E89413698A8E275E5E79154@squarepi.com> <4ECCF5BAADF94C5E9FD5CF2FA52CD061@squarepi.com> <49DCBB2F.7040406@esilo.com> <49DCBDBB.9070303@esilo.com> Subject: Re: Array types Date: Wed, 8 Apr 2009 16:11:55 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.322 tagged_above=0 required=5 tests=AWL=0.322 X-Spam-Level: X-Archive-Number: 200904/440 X-Sequence-Number: 136543 Cheers for the pointers. Am i right in thinking that if i get an array of arrays, the nested arrays are sent in wire format as well - it seems to be from the docs. Secondly, comments are a bit scarse in the code, but am i also right in thinking that an array indexing can start at an arbitrary value? This seems to be what the lbound value is for... or is this a addition to deal with nulls eg, {null, null, null, 4} would have a lbound of 3.... (or both) Thanks ----- Original Message ----- From: "Andrew Chernow" To: "John Lister" Cc: Sent: Wednesday, April 08, 2009 4:07 PM Subject: Re: [HACKERS] Array types > Andrew Chernow wrote: >> John Lister wrote: >>> Following this up, is there any docs on the binary wire format for >>> arrays? >>> >> >> None that I know of. >> >> Check out the backend source: (array_recv() and array_send() functions) >> http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/arrayfuncs.c?rev=1.154 >> Or, look at libpqtypes array.c: >> http://libpqtypes.esilo.com/browse_source.html?file=array.c >> > > Forgot to mention, this is not as simple as understanding the array > format. You have to understand the wire format for all types that can be > array elements. The array wire format serializes its array elements as > [elem_len][elem_data]. elem_data is the wire format of the array element > type, like an int, timestamp, polygon, bytea, etc... So once you unravel > the array container format, you still have to demarshal the type data. > > -- > Andrew Chernow > eSilo, LLC > every bit counts > http://www.esilo.com/ >