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

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 (view raw or flat)
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

pgsql-jdbc by date

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

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