pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Wall <d.wall@computer.org>
To: pgsql-jdbc <pgsql-jdbc@postgresql.org>
Subject: Re: JDBC with PG 8.4 bytea character escaping wire protocol
Date: Thu, 22 Oct 2009 14:13:02 -0700
Message-ID: <4AE0CADE.1000107@computer.org> (raw)
In-Reply-To: <4AE0C63D.3040303@opencloud.com>
References: <4ADDDFC7.3010900@computer.org>
	<4AE0C63D.3040303@opencloud.com>


> Does the JDBC 4 driver for PG 8.4 escape each character of the bytea 
> type, or does it use a binary protocol?
>
> When sending parameter data to the server, it uses the binary format.
>
> When receiving results from the server, it uses the text format.

Thanks, Oliver.  Well, I hadn't even thought it could be both. <smile> 

There was confusion in the other replies because they were looking at 
how the data moves from my code into the driver, but not how the driver 
communicates with the backend.  It was clear I could store binary data 
as I was doing that just fine, but the PG docs made it sound like much 
of my binary data would end up expanding because more than half of the 
range an octet may have requires escaping per 
http://www.postgresql.org/docs/8.4/static/datatype-binary.html:

*Table 8-7. bytea Literal Escaped Octets*

Decimal Octet Value 	Description 	Escaped Input Representation 
Example 	Output Representation
0 	zero octet 	E'\\000' 	SELECT E'\\000'::bytea; 	\000
39 	single quote 	'''' or E'\\047' 	SELECT E'\''::bytea; 	'
92 	backslash 	E'\\\\' or E'\\134' 	SELECT E'\\\\'::bytea; 	\\
0 to 31 and 127 to 255 	"non-printable" octets 	E'\\/xxx'/ (octal 
value) 	SELECT E'\\001'::bytea; 	\001


I am thinking this should not be a real issue for me since I will be 
using LOs for by big objects and BYTEAs for the smaller objects.

Thanks again,
David

view thread (8+ messages)

Message-ID: <4AE0CADE.1000107@computer.org>
Permalink:  ../4AE0CADE.1000107@computer.org/
Also on:    postgresql.org/message-id/4AE0CADE.1000107@computer.org

 · 

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: d.wall@computer.org
  Subject: Re: JDBC with PG 8.4 bytea character escaping wire protocol
  In-Reply-To: <4AE0CADE.1000107@computer.org>
  References: <4ADDDFC7.3010900@computer.org> <4AE0C63D.3040303@opencloud.com> <4AE0CADE.1000107@computer.org>

* 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