From: Markus Schaber <schabi@logix-tt.com>
To: pgsql-jdbc@postgresql.org
Cc: Matthew Bellew <matthew@bellew.net>
Subject: Re: Inconsistent casting with literal vs parameter
Date: Wed, 08 Feb 2006 10:34:19 +0100
Message-ID: <43E9BB1B.2070207@logix-tt.com> (raw)
In-Reply-To: <43E93867.2050805@bellew.net>
References: <43E91EFA.4080106@bellew.net>
<Pine.BSO.4.61.0602071733300.5391@leary.csoft.net>
<43E9265E.3070209@bellew.net>
<43E9344C.2060805@bellew.net>
<Pine.BSO.4.61.0602071901450.4552@leary.csoft.net>
<43E93867.2050805@bellew.net>
Hi, Matthew,
Matthew Bellew wrote:
> My last 2 cents on the whole topic. There is a fundamental design issue
> here with deciding to handle the expression /column <
> (value/literal/parameter typed or not)/ by converting the column to a
> string. Obviously, with INSERT INTO the data values must be coerced to
> the destination column type. In this case, while there is a
> parsing/optimizing decision to be made, it should be made with a strong
> bias to convert to the column type (and then handling any tricky
> coercion failures or optimization issues).
The problem is that you explicitly send the parameter as a String to the
server, so it gets the bias to coerce the column to the string.
However, you can always make shure the parameters are compared set
correctly by explicityl casting them:
SELECT * FROM floats WHERE x<(?::double precision);
or
SELECT * FROM floats WHERE x<CAST(? as double precision);
AFAIR, the latter one is standards conforming, and such more likely to
work on other databases.
HTH,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS
Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org
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: schabi@logix-tt.com, matthew@bellew.net
Subject: Re: Inconsistent casting with literal vs parameter
In-Reply-To: <43E9BB1B.2070207@logix-tt.com>
References: <43E91EFA.4080106@bellew.net> <Pine.BSO.4.61.0602071733300.5391@leary.csoft.net> <43E9265E.3070209@bellew.net> <43E9344C.2060805@bellew.net> <Pine.BSO.4.61.0602071901450.4552@leary.csoft.net> <43E93867.2050805@bellew.net> <43E9BB1B.2070207@logix-tt.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