dbTalk Databases Forums  

[BUGS] BUG #2189: Prepared Statement is not parsed correctly

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2189: Prepared Statement is not parsed correctly in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kris Senden
 
Posts: n/a

Default [BUGS] BUG #2189: Prepared Statement is not parsed correctly - 01-21-2006 , 07:57 PM







The following bug has been logged online:

Bug reference: 2189
Logged by: Kris Senden
Email address: kris.senden (AT) realsoftware (DOT) be
PostgreSQL version: 8.0.2
Operating system: Windows XP/2K/2003
Description: Prepared Statement is not parsed correctly
Details:

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.

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly

Reply With Quote
  #2  
Old   
Bruce Momjian
 
Posts: n/a

Default Re: [BUGS] BUG #2189: Prepared Statement is not parsed correctly - 01-21-2006 , 08:44 PM







This is not the place to report jdbc problems. The jdbc project has its
own mailing lists.

---------------------------------------------------------------------------

Kris Senden wrote:
Quote:
The following bug has been logged online:

Bug reference: 2189
Logged by: Kris Senden
Email address: kris.senden (AT) realsoftware (DOT) be
PostgreSQL version: 8.0.2
Operating system: Windows XP/2K/2003
Description: Prepared Statement is not parsed correctly
Details:

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.

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly

--
Bruce Momjian | http://candle.pha.pa.us
pgman (AT) candle (DOT) pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.