Re: \0 and IllegalArgumentException

From: Vadim Nasardinov <vadimn(at)redhat(dot)com>
To: Sebastiaan van Erk <sebster(at)sebster(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: \0 and IllegalArgumentException
Date: 2004-10-29 14:24:03
Message-ID: 200410291024.03718@vadim.nasardinov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jon Orris 2004-10-29 14:36:57 Re: \0 and IllegalArgumentException
Previous Message Sebastiaan van Erk 2004-10-29 11:56:52 ps.setCharacterStream() and memory usage