From: Oliver Jowett <oliver@opencloud.com>
To: Thomas Hallgren <thomas@tada.se>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: 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: Wed, 28 Jun 2006 09:20:53 +0900
Message-ID: <44A1CB65.6020304@opencloud.com> (raw)
In-Reply-To: <44A1A285.6000900@tada.se>
References: <44A16388.3060108@tada.se>
<Pine.BSO.4.63.0606271211590.8616@leary2.csoft.net>
<44A1739A.2080102@tada.se>
<26695.1151435851@sss.pgh.pa.us>
<44A18A53.5000107@tada.se>
<7957.1151442476@sss.pgh.pa.us>
<44A1A285.6000900@tada.se>
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!
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
Actually, one feature that might be nice in future protocol versions is
some ability to say "I think this parameter is one of these types --
please infer a type and fail to prepare if it doesn't match with the
expected types" which would also help with the timestamp-vs-timestamptz
case. Currently, we don't notice a mismatch between the value we passed
and the type that was inferred until well after the query is executed..
We could wait for a Describe before proceeding, but it seems a bit silly
if you can't do a decent implementation without sending Flush messages
everywhere, given the work the protocol does to let you stream messages
at it without waiting for results.
-O
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: oliver@opencloud.com, thomas@tada.se, tgl@sss.pgh.pa.us, books@ejurka.com
Subject: Re: [Fwd: Re: [Pljava-dev] char with trailing space, PreparedStatement.setObject
In-Reply-To: <44A1CB65.6020304@opencloud.com>
References: <44A16388.3060108@tada.se> <Pine.BSO.4.63.0606271211590.8616@leary2.csoft.net> <44A1739A.2080102@tada.se> <26695.1151435851@sss.pgh.pa.us> <44A18A53.5000107@tada.se> <7957.1151442476@sss.pgh.pa.us> <44A1A285.6000900@tada.se> <44A1CB65.6020304@opencloud.com>
* 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