Re: [Fwd: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject

From: Thomas Hallgren <thomas(at)tada(dot)se>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: "Pgsql-Jdbc(at)Postgresql(dot)Org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: [Fwd: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject
Date: 2006-06-27 18:06:18
Message-ID: 44A1739A.2080102@tada.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Kris Jurka wrote:
>
> The JDBC driver does not trim spaces. What it does is pass
> setString() values with a type of varchar, perhaps pljava is using
> text and exposing this subtle difference:
>
> # select 'a '::char(2) = 'a '::text;
> ?column?
> ----------
> f
> (1 row)
> # select 'a '::char(2) = 'a '::varchar;
> ?column?
> ----------
> t
> (1 row)
>
I'm missing something. Both text and varchar consider the space significant:

thhal=# select length(' '::char);
length
--------
0
(1 row)

thhal=# select length(' '::varchar);
length
--------
1
(1 row)

thhal=# select length(' '::text);
length
--------
1
(1 row)

so why does it make a difference to use varchar instead of text? I.e.
why are your comparison results different? Why is the space
insignificant when using char?

Regards,
Thomas Hallgren

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Lane 2006-06-27 19:17:31 Re: [Fwd: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject
Previous Message Kris Jurka 2006-06-27 17:17:12 Re: [Fwd: Re: [Pljava-dev] char with trailing space,