Re: [Fwd: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject

From: Thomas Hallgren <thomas(at)tada(dot)se>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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-28 06:20:03
Message-ID: 44A21F93.2090007@tada.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Oliver Jowett wrote:
> Thomas Hallgren wrote:
>
>> 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?
>
> There is considerably more to it than trying to avoid an extra
> round-trip (although that is part of it). If we're given a String
> parameter, why should we interpret it as anything other than a String?
> We don't really want to implement an any-type-to-any-other-type
> conversion routine in the driver!
>
No, of course not. I fully appreciate the way you do it today. The whole discussion stems
from a misunderstanding on my part. I thought that that type returned by the SPI_getargtype
was inferred from its context within the query. As it turns out it isn't.

> Nevertheless there is a "fix" here -- pass "stringtype=unspecified" as a
> URL parameter in the JDBC URL and the driver will pass parameters set
> via setString() with unspecified types. This was originally put in to
> handle apps that expected to be able to setString("42") on an int
> column, but it should deal with your particular situation too. Use at
> your own risk. See
> http://jdbc.postgresql.org/documentation/head/connect.html#connection-parameters
>
Right. Apparently, what I do is similar to using "stringtype-unspecified" always (and not
just for string types either). My driver has some room for improvements :-)

Anyway, thanks for helping me clearing this up. Now I know what to do.

Regards,
Thomas Hallgren

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tamás Barta 2006-06-28 10:01:29 JDBC Driver
Previous Message Oliver Jowett 2006-06-28 00:20:53 Re: [Fwd: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject