Skip site navigation (1) Skip section navigation (2)

Re: Binary Cursors, and the COPY command

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Thomas Hallgren <thhal(at)mailblocks(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Binary Cursors, and the COPY command
Date: 2004-07-27 07:07:47
Message-ID: 4105FF43.40508@opencloud.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-jdbc
Thomas Hallgren wrote:
> Oliver Jowett wrote:
>  > This is not true if you happen to be using Java on the client side,
>  > which has no idea (unless you grot around in the guts of the JVM) what
>  > the native byte order is.
>  >
> The method java.nio.ByteOrder.nativeOrder() will tell you what the 
> native byte order is.

NIO is not present before JDK 1.4. The JDBC driver, at least, needs to 
support earlier JVMs.

>  > This actually means that Java clients have the
>  > opposite problem -- it's a lot of work to try to use the 7.3-style
>  > binary formats.
>  >
> The commonly used java.io.DataInput will always use network order but 
> it's easy enough to read/write little endian using the java.nio and 
> java.nio.channel packages.

That's no use if you don't know the endianness of the data you're 
receiving (which is what happens under <= 7.3 -- the data followed the 
server's byte ordering)

The problem with using native byte orderings is not the byte ordering 
itself, but that the order is unpredictable -- at best, you have to 
implement code to handle both orders, and at worst you have to just take 
a guess and hope you were right..

-O

In response to

Responses

pgsql-hackers by date

Next:From: Domas MituzasDate: 2004-07-27 08:15:00
Subject: FW: 'vacuum full' memory leak?
Previous:From: Thomas HallgrenDate: 2004-07-27 06:39:49
Subject: Re: Binary Cursors, and the COPY command

pgsql-jdbc by date

Next:From: j.random.programmerDate: 2004-07-27 08:45:18
Subject: Bug in 7.4_213 driver: returns VARCHAR instead of LONGVARCHAR for text types
Previous:From: Thomas HallgrenDate: 2004-07-27 06:39:49
Subject: Re: Binary Cursors, and the COPY command

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group