Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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.


In response to

pgsql-jdbc by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group