Thread: Invalid message format

Invalid message format

From
Mikhail Ts
Date:
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.

Mikhail

______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca

Re: Invalid message format

From
Oliver Jowett
Date:
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