From: | "Senden Kris" <Kris(dot)Senden(at)realsoftwaregroup(dot)com> |
---|---|
To: | <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Prepared Statement is not parsed correctly |
Date: | 2006-02-01 15:45:14 |
Message-ID: | 295D4D9E63960946B5A8BB383C51E06E9C3AC6@rls03exc01.rls03.realsoftwaregroup.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi,
Recently we discovered a defect in the jdbc driver of PostgreSQL. It is
detected in version 8.1dev-401 and also found in all later versions. The
problem is that we had a faulty SQL statement in our code that was
partly executed by the jdbc-driver without any warning or error log.
The statement is
SELECT * FROM POSTransaction WHERE DatTransEnd = (SELECT
MAX(DatTransEnd) FROM POSTransaction WHERE IdtCheckout = 9 AND
FlgTraining = ?) AND IdtCheckout = 9 AND FlgTraining = ?) ORDER BY
HouTransEnd DESC
As you can see this statement contains 1 closing bracket ('(') too much.
However while debugging the driver I saw that the problem is caused in
method AbstractJdbc2Statement.parseSql(String, int, StringBuffer,
boolean) throws SQLException. In that method a counter is activated
which holds the number of open brackets. Each time it encounters a ( it
adds one and each time it encounters a ) it substracts one. When the
counter's value is less than zero, the parsings stops. In our case, this
resulted that our sql statement was shortened to
SELECT * FROM POSTransaction WHERE DatTransEnd = (SELECT
MAX(DatTransEnd) FROM POSTransaction WHERE IdtCheckout = 9 AND
FlgTraining = ?) AND IdtCheckout = 9 AND FlgTraining = ?
When executing the same query in pgAdmin III Query, I got a syntax
error : ERROR: syntax error at or near ")" at character 136.
I would expected to have the same syntax error using the prepared
statement.
Can anyone confirm this problem and point me to a possible fix?
All the best,
Kris Senden
From | Date | Subject | |
---|---|---|---|
Next Message | Papp Márton | 2006-02-01 16:20:49 | timestamp parameter is null |
Previous Message | Tom Lane | 2006-02-01 14:32:15 | Re: Postgres-JDBC question |