X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id F2F369FA68D for ; Fri, 23 Jun 2006 05:22:45 -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 66230-10 for ; Fri, 23 Jun 2006 05:22:35 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.200]) by postgresql.org (Postfix) with ESMTP id C3B989FA395 for ; Fri, 23 Jun 2006 05:22:35 -0300 (ADT) Received: by wx-out-0102.google.com with SMTP id i31so403493wxd for ; Fri, 23 Jun 2006 01:22:34 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=googlemail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Mve2qo1JStpTVRh/e4/Pj1eJOGk7sNWTooJ/7DnFDYjlT/hvffXfu9BtdD3vyqEqYTLxTvqdBh3641SHXGBZTGbNdKJEtMQXqWkjLL9qiLK14NeI2KG7Ou5R3PpD7rsjHzjLX1/yYW9z4hOufdVujcKVoTd2+Q80xcuuPKcoQqA= Received: by 10.70.48.17 with SMTP id v17mr4267263wxv; Fri, 23 Jun 2006 01:22:34 -0700 (PDT) Received: by 10.70.78.16 with HTTP; Fri, 23 Jun 2006 01:22:34 -0700 (PDT) Message-ID: <30b57570606230122s4827d2ectd470e3c4ff6ad228@mail.gmail.com> Date: Fri, 23 Jun 2006 09:22:34 +0100 From: "Michael Guyver" To: pgsql-jdbc@postgresql.org Subject: Re: Binary tx format for an array? In-Reply-To: <1151003773.21238.13.camel@archimedes> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <30b57570606211026o66e337c9s658387db0b32aeed@mail.gmail.com> <17160.1150929667@sss.pgh.pa.us> <30b57570606220116h2f216c1eue74e5cfbb41bd5bc@mail.gmail.com> <1048.1150995309@sss.pgh.pa.us> <1151003773.21238.13.camel@archimedes> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/99 X-Sequence-Number: 15379 On 22/06/06, Tom Lane wrote: > No, in the buffer they'll be in network (big-endian) byte order, > > [0x00][0x00][0x00][0x17] On 22/06/06, Mark Lewis wrote: > Java tried so hard to hide endianness from you that it didn't provide > any real support for those times when you DO need to be aware of it. So > the "convention" looks kind of like this (snipped from the PG JDBC > driver): > > public void SendInteger4(int val) throws IOException { > SendChar((val >> 24)&255); > SendChar((val >> 16)&255); > SendChar((val >> 8)&255); > SendChar(val&255); > } Of course that's right: I got myself confused. Thanks very much for your help, no doubt I'll be back for some more (please sir) in the future. I'm optimistic I'm on the right track but wanted to conceive a way of unit testing the different Java classes that represent PG types, and their binary Tx and Rx methods. One way I thought of doing this is simply to send the values over JDBC (specifying binary parameters) and check the contents of a test table once all the inserts are done, but such unit tests get very messy very quickly, and you wind up storing your expected results in a different file, which is firstly something you have to keep in sync with the source code and secondly tends to grow and become unmanageable very quickly. Another way would be to use the JNI mechanism to talk directly to the PG code, calling the xxxrecv() functions for the type you're testing, reading back the type's value using the xxxsend() method. Not being a C man, I'm not sure how easy this would be and would appreciate any suggestions. Regards, Michael