Re: JDBC with PG 8.4 bytea character escaping wire protocol

From: David Wall <d(dot)wall(at)computer(dot)org>
To: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: JDBC with PG 8.4 bytea character escaping wire protocol
Date: 2009-10-22 21:13:02
Message-ID: 4AE0CADE.1000107@computer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


> 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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Eric Jain 2009-10-26 23:18:43 Re: How to ensure that SSL is enabled?
Previous Message Oliver Jowett 2009-10-22 20:53:17 Re: JDBC with PG 8.4 bytea character escaping wire protocol