Re: \0 and IllegalArgumentException - Mailing list pgsql-jdbc

From Vadim Nasardinov
Subject Re: \0 and IllegalArgumentException
Date
Msg-id 200410291024.03718@vadim.nasardinov
Whole thread Raw
In response to \0 and IllegalArgumentException  (Sebastiaan van Erk <sebster@sebster.com>)
Responses Re: \0 and IllegalArgumentException  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: \0 and IllegalArgumentException  (Jon Orris <jorris@redhat.com>)
List pgsql-jdbc
On Friday 29 October 2004 05:55, Sebastiaan van Erk wrote:
[...]
> however I'm getting:
>
> java.lang.IllegalArgumentException: \0 not allowed
[...]
> 2) I will know where it came from (postgres)...
[...]
> User data CAN in fact contain \0, and the fact that postgres cannot
> handle this is an issue of the backend


Funny you should mention this.  Just yesterday a coworker of mine was
bitching about the PostgreSQL JDBC driver's refusal to allow \0 in
strings.  As he pointed out, it's not totally clear if the blame rests
entirely with the backend.  Consider these examples:

 | test=> create table dropme (str varchar(100));
 | CREATE TABLE
 | test=> insert into dropme values ('Hello' || chr(0) || 'world');
 | INSERT 160829 1
 | test=> select str, length(str) as length from dropme;
 |   str  | length
 | -------+--------
 |  Hello |      5
 | (1 row)
 |
 | test=> select str, length(str) as length from dropme where str like '%world';
 |   str  | length
 | -------+--------
 |  Hello |      5
 | (1 row)
 |
 | test=> select str, length(str) as length from dropme where str like '%Welt';
 |  str | length
 | -----+--------
 | (0 rows)


This is with a fairly old version of PosgreSQL:

 | test=> select substring(version(), 1, 20) as version;
 |        version
 | ----------------------
 |  PostgreSQL 7.3.4-RH
 | (1 row)

Not sure how the latest version behaves.

I think you do have a point though when you say that \0 should be
allowed (and handled properly).



Vadim


pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: \0 and IllegalArgumentException
Next
From: Tom Lane
Date:
Subject: Re: \0 and IllegalArgumentException