Follow up to Conditional SELECT returns incorrect results.

From: "Gary Gesmundo" <ggesmundo(at)tds(dot)net>
To: <pgsql-bugs(at)postgresql(dot)org>
Subject: Follow up to Conditional SELECT returns incorrect results.
Date: 2007-12-08 03:23:59
Message-ID: 000b01c83949$c6ee4900$0364a8c0@recon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

This is a follow up to the bug report filed earlier today.

As reported earlier:

I am receiving incorrect result from a query that is issued via the JDBC
driver. I am running Windows XP, Java version 1.6.0_02, PostgresSQL version
8.2 and using the postgresql-8.2-507-jdbc4.jar. I have also used the
postgresql-8.2-506-jdbc4.jar with the same results.

Java code with try/catch./finally and resource cleanup all left out for
brevity,

String sel = "SELECT testing_table.rec_no, testing_table.test_number FROM
testing_table WHERE test_number >= ? AND test_number <= ? ORDER BY rec_no";

Connection conn = xxx.getConnection();

PreparedStatement ps1 = conn.prepareStatement(sel);

ps1,setString(1, "10.0");

ps1,setString(2, "50.0");

ResultSet rs = ps1.executeQuery();

while (rs.hasNext())

{

// process a row.

}

After further testing I have determined that if the ps1.setString(1, "10.0")
and ps1.setString(2, "50.0") are replaced by ps1.setDouble(1, 10.0) and
ps1.setDouble(2, 50.0) the query executes correctly. I still believe this is
a bug as the database column definition should determine the comparison type
NOT the PreparedStatement parameter type. It would appear that the parameter
type of String is causing a String comparison to be used. Also, using the
same SELECT statement, with or without quotes around the parameters, in the
PostgresSQL query tool returns the correct results.

Regards,

Gary Gesmundo

ggesmundo(at)tds(dot)net

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Dunstan 2007-12-08 09:19:59 Re: [HACKERS] BUG #3799: csvlog skips some logs
Previous Message Reece Hart 2007-12-07 18:57:11 Re: BUG #3801: max_fsm_pages postgresql.conf default != guc.c default