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 71DFE9FA437 for ; Tue, 27 Jun 2006 18:26:38 -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 00669-06 for ; Tue, 27 Jun 2006 18:26:32 -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 315869FA10A for ; Tue, 27 Jun 2006 18:26:31 -0300 (ADT) Received: from [127.0.0.1] (unverified [127.0.0.1]) by tada.se (SurgeMail 3.7b3) with ESMTP id 500 for multiple; Tue, 27 Jun 2006 23:26:29 +0200 Message-ID: <44A1A285.6000900@tada.se> Date: Tue, 27 Jun 2006 23:26:29 +0200 From: Thomas Hallgren User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: Tom Lane CC: Kris Jurka , "Pgsql-Jdbc@Postgresql.Org" Subject: Re: [Fwd: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject References: <44A16388.3060108@tada.se> <44A1739A.2080102@tada.se> <26695.1151435851@sss.pgh.pa.us> <44A18A53.5000107@tada.se> <7957.1151442476@sss.pgh.pa.us> In-Reply-To: <7957.1151442476@sss.pgh.pa.us> 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/121 X-Sequence-Number: 15401 Tom Lane wrote: > Thomas Hallgren writes: > >> Hmm, OK. I checked my code and I don't use any specific type. Instead, I >> use SPI_getargtypeid(ePlan, idx) on the prepared query and the >> pgType->typinput function of the type that corresponds to the returned >> oid. Perhaps the SPI_getargtypeid should return varchar for all text types? >> > > Certainly not. That would break most normal uses of SPI_getargtypeid, > and I don't even see how it fixes your problem; once the query is > prepared these decisions are already made. > > regards, tom lane > My problem is simple. When I pass a parameter with a trailing space, that space is considered significant. When the same thing is done using the client jdbc driver, the trailing space is insignificant. The client driver, since it knows nothing about the actual plan, elects to use the varchar type always. PL/Java uses the actual type that it gets from the plan when it performs the parameter coercion. I don't think my solution is wrong but it yields different results and that's undesirable. My questions stem from an uncertainty on how to go about fixing this so that the two drivers behave the same way (and for the same reason). Should this be considered a conscious flaw in the client driver motivated by the desire to limit the number of round trips? If it is, what would the best course of action be for me? Implement the same flaw although I don't have that problem? Regards, Thomas Hallgren