X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 86CD49FA437 for ; Tue, 27 Jun 2006 13:57:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 65330-09 for ; Tue, 27 Jun 2006 13:57:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tada.se (1-1-2-48a.rny.sth.bostream.se [82.182.133.12]) by postgresql.org (Postfix) with ESMTP id 128479FA10A for ; Tue, 27 Jun 2006 13:57:46 -0300 (ADT) Received: from [127.0.0.1] (unverified [127.0.0.1]) by tada.se (SurgeMail 3.7b3) with ESMTP id 482 for ; Tue, 27 Jun 2006 18:57:44 +0200 Message-ID: <44A16388.3060108@tada.se> Date: Tue, 27 Jun 2006 18:57:44 +0200 From: Thomas Hallgren User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: "Pgsql-Jdbc@Postgresql.Org" Subject: [Fwd: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject & SetString] Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Server: High Performance Mail Server - http://surgemail.com r=849097733 X-Authenticated-User: thomas@tada.se X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/115 X-Sequence-Number: 15395 There's an inconsistency between the handling of trailing whitespace in query parameters in the client jdbc driver compared to the PL/Java SPI based driver. According to Jean-Pierre, the former apparently trims the trailing spaces before passing the query (see below). What is the correct behavior? Regards, Thomas Hallgren -------- Original Message -------- Subject: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject & SetString Date: Tue, 27 Jun 2006 12:07:19 -0400 From: JEAN-PIERRE PELLETIER To: thomas@tada.se CC: pljava-dev@gborg.postgresql.org Hi Thomas, There are very few char columns on my system, I can easily live with explicit trim in my application code, I only wanted to let you guys know. I am not sure which of the two JDBC implementations is right. psql and pgadmin would both handle char as expected. As for JDBC, you might want to know how other dbms are handling this. Thanks for your reply. Jean-Pierre Pelletier >From: Thomas Hallgren >To: JEAN-PIERRE PELLETIER >CC: pljava-dev@gborg.postgresql.org >Subject: Re: [Pljava-dev] char with trailing >space, PreparedStatement.setObject & SetString >Date: Tue, 27 Jun 2006 17:47:24 +0200 > >Hi Jean-Pierre, >I'm not sure this is incorrect behavior. There's nothing in the spec that >indicates that String values should be trimmed by setString and setObject. >On the contrary. Some datatypes (the CHAR in particular) are sensitive to >whitespace according to the SQL standard. Perhaps the client jdbc driver is >doing something wrong here? > >Regards, >Thomas Hallgren > > >JEAN-PIERRE PELLETIER wrote: >>Hi, >> >>Trailing space are not handled properly by setObject & setString. >> >>PreparedStatement pstmt = connection.prepareStatement( >> "select * from mytable where mycharcolumn = ?"); >> >>String myString = "abc "; >>pstmt.setObject(1, myString); // or setObject(1, myString, Types.CHAR) or >>setString(1, myString) >> >>No rows are returned, but using trim works fine as in: >>pstmt.setObject(1, myString.trim()); >> >>My environment is Pl/Java 1.3, Sun JDK 1.5.07, PostgreSQL 8.1.4, Windows >>XP SP2 >> >>With PostgreSQL own (non pl/java) jdbc driver, setObject on char works >>fine without the trim. >> >>Thanks, >>Jean-Pierre Pelletier >> >> >>_______________________________________________ >>Pljava-dev mailing list >>Pljava-dev@gborg.postgresql.org >>http://gborg.postgresql.org/mailman/listinfo/pljava-dev >>