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: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kris Jurka <books(at)ejurka(dot)com>, "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 21:26:29
Message-ID: 44A1A285.6000900@tada.se (view raw or flat)
Thread:
Lists: pgsql-jdbc
Tom Lane wrote:
> Thomas Hallgren <thomas(at)tada(dot)se> 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


In response to

Responses

pgsql-jdbc by date

Next:From: Tom LaneDate: 2006-06-27 22:31:23
Subject: Re: [Fwd: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject
Previous:From: Tom LaneDate: 2006-06-27 21:07:56
Subject: Re: [Fwd: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject

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