Re: Invalid message format - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Invalid message format
Date
Msg-id 4064BFE2.2030609@opencloud.com
Whole thread Raw
In response to Invalid message format  (Mikhail Ts <ts_mike@yahoo.ca>)
List pgsql-jdbc
Mikhail Ts wrote:
> Hi,
> I've found what was causing the problem - one of my INSERT statements
> contained 0x00 byte inside a String field. I don't know if it is a bug
> - I've modified my code accordingly and everything went OK.

As I understand it, you can't represent a \0 byte in a text/varchar
constant; this seems to be due to the way the backend internally
represents these types. I always get horribly confused in this area
since these representations are encoding-dependent, though.. You should
be able to represent it ok in a bytea constant (but then of course you
need a bytea field to store it in..)

If you were using PreparedStatement.setString() to set a String
parameter containing an embedded \0, recent drivers should have thrown
an IllegalArgumentException well before the query hit the backend. I'm
interested to know exactly how you managed to get a \0 into the query --
were you constructing the whole INSERT string yourself rather than using
PreparedStatement parameters? I don't think the queries themselves are
checked, from memory.

-O

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: location of jdbc.jar
Next
From: "scott.marlowe"
Date:
Subject: Re: location of jdbc.jar