Re: PreparedStatement setObject

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Kobus Walters <kobus(at)iveri(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: PreparedStatement setObject
Date: 2005-02-14 06:36:10
Message-ID: 421046DA.4040706@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Kobus Walters wrote:

> Create a prepared statement with sql "select localtimestamp - time ?". Call setObject(1, java.lang.String) with the String value "00:00:00" for instance. In version 7 this gets executed as "select localtimestamp - time '00:00:00'", while version 8 try to execute it as "select localtimestamp - time 00:00:00", which of cause fails since the quotes are missing.

I can't reproduce this. With the 8.0-310 driver against an 8.0.0 server,
I get a syntax error with that query:

ERROR: syntax error at or near "$1"

The query sent by the driver is:

SELECT LOCALTIMESTAMP - TIME $1

which the backend does not like. The change in behaviour from 7.4-era
drivers is because the 8.0 driver pushes handling of parameters to the
server, so you have to follow the server's rules for where you may place
parameters. Apparently, after TIME isn't one of those places.

To use a string as a time parameter, see the examples in my test code
(attached).

-O

Attachment Content-Type Size
TestTime.java text/plain 836 bytes

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2005-02-14 06:52:22 Re: Bug in ALTER LANGUAGE ... RENAME TO ...;
Previous Message Tom Lane 2005-02-14 06:19:06 Re: Bug in ALTER LANGUAGE ... RENAME TO ...;