Re: Invalid message format

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Mikhail Ts <ts_mike(at)yahoo(dot)ca>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Invalid message format
Date: 2004-03-26 23:42:26
Message-ID: 4064BFE2.2030609@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2004-03-27 00:46:43 Re: ArrayIndexOutOfBoundsException - bug?
Previous Message scott.marlowe 2004-03-26 22:15:22 Re: location of jdbc.jar