pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: dmp <danap@ttc-cmc.net>
To: David Wall <d.wall@computer.org>
To: pgsql-jdbc@postgresql.org
Subject: Re: JDBC with PG 8.4 bytea character escaping wire protocol
Date: Thu, 22 Oct 2009 10:56:34 -0600
Message-ID: <4AE08EC2.107@ttc-cmc.net> (raw)
In-Reply-To: <4AE0817A.5010502@computer.org>
References: <4ADDDFC7.3010900@computer.org>
	<4AE0817A.5010502@computer.org>

I guess I can not really answer your question, since I have not dug 
around in the code, but I can not understand
why the JDBC would escape a byte[] sent or received using the setBytes() 
or getBytes() API or the stream
methods. These are binary protocols, which can house any integer value 
within the limitations. The bytea
type is is defined as binary which means it does not necessarily 
represent a character. Now the answer I guess
could be answered in two ways.

1. Someone here or yourself would have to know or dig through the code 
to see if some conversion takes place.
2. Make a test case that sends or receives the data using 
setBytes()/getBytes() and one of the APIs that
    does escape characters or you manually escape the characters. Use a 
packet sniffer to check the package size
    in both cases. If they are the same then a conversion is taking 
place. I would suspect the Bytes() method would
    result in less bandwidth, not more, no data size expansion.

danap

>> Does the JDBC 4 driver for PG 8.4 escape each character of the bytea 
>> type, or does it use a binary protocol?
>>
>> From another post, Merlin Moncure wrote, "libpq supports a binary 
>> protocol mode which allows you to execute queries sending bytea 
>> without escaping."  Is that true of the JDBC driver?  I'm concerned 
>> about the data size expansion that would result for the wire protocol 
>> when I use setBytes().
>
>
> I tried downloading the JDBC source and must say it was complex enough 
> to a newbie that I couldn't really determine the answer myself.    
> Does anybody know if the JDBC driver with PG 8.4 communicates using a 
> binary protocol for BYTEA transfers to/from or whether it sends 
> escaped chars only?  Or perhaps which classes handle the transfer of 
> BYTEA to PG and receives BYTEA responses from PG?
>
> Thanks,
> David 




view thread (8+ messages)  latest in thread

Message-ID: <4AE08EC2.107@ttc-cmc.net>
Permalink:  ../4AE08EC2.107@ttc-cmc.net/
Also on:    postgresql.org/message-id/4AE08EC2.107@ttc-cmc.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: danap@ttc-cmc.net, d.wall@computer.org
  Subject: Re: JDBC with PG 8.4 bytea character escaping wire protocol
  In-Reply-To: <4AE08EC2.107@ttc-cmc.net>
  References: <4ADDDFC7.3010900@computer.org> <4AE0817A.5010502@computer.org> <4AE08EC2.107@ttc-cmc.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox