pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Hallgren <thomas@tada.se>
To: Kris Jurka <books@ejurka.com>
Cc: Pgsql-Jdbc@Postgresql.Org <pgsql-jdbc@postgresql.org>
Subject: Re: [Fwd: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject
Date: Tue, 27 Jun 2006 20:06:18 +0200
Message-ID: <44A1739A.2080102@tada.se> (raw)
In-Reply-To: <Pine.BSO.4.63.0606271211590.8616@leary2.csoft.net>
References: <44A16388.3060108@tada.se>
	<Pine.BSO.4.63.0606271211590.8616@leary2.csoft.net>

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




view thread (10+ messages)  latest in thread

Message-ID: <44A1739A.2080102@tada.se>
Permalink:  ../44A1739A.2080102@tada.se/
Also on:    postgresql.org/message-id/44A1739A.2080102@tada.se

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: thomas@tada.se, books@ejurka.com
  Subject: Re: [Fwd: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject
  In-Reply-To: <44A1739A.2080102@tada.se>
  References: <44A16388.3060108@tada.se> <Pine.BSO.4.63.0606271211590.8616@leary2.csoft.net> <44A1739A.2080102@tada.se>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox