Bug #10479 Invalid result in case of prepared statement with setLong
Submitted: 9 May 2005 14:58 Modified: 9 May 2005 16:40
Reporter: Vitaly Harisov Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.1.8 OS:Microsoft Windows (Windows XP)
Assigned to: CPU Architecture:Any

[9 May 2005 14:58] Vitaly Harisov
Description:
Then I use mysql-connector-java-3.1.8-bin.jar I'm getting invalid query result in case of using prepared statement and statement.setLong.

With mysql-connector-java-3.0.16-ga-bin.jar all works fine.

I have prepared the test-case, its all-sufficient. See attached files.

D:\programs\work\mysql\bin\mysql.exe  Ver 14.7 Distrib 4.1.11, for Win32 (ia32)

java version "1.4.2_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_07-b05)
Java HotSpot(TM) Client VM (build 1.4.2_07-b05, mixed mode)

java -cp mysql-connector-java-3.0.16-ga-bin.jar;. MySQLBug com.mysql.jdbc.Driver "jdbc:mysql://localhost:3306/test?user=root&password=root"
3
3
1
1

java -cp mysql-connector-java-3.1.8-bin.jar;. MySQLBug com.mysql.jdbc.Driver "jdbc:mysql://localhost:3306/test?user=root&password=root"
3
0
1
0

How to repeat:
1. Compile MySQLBug.java

2. Create test database and fill it with MySQLBug.sql

3. Run
java -cp mysql-connector-java-3.1.8-bin.jar;. MySQLBug com.mysql.jdbc.Driver "jdbc:mysql://localhost:3306/test?user=root&password=root"
[9 May 2005 15:00] Vitaly Harisov
Test-case data

Attachment: MySQLBug.sql (application/octet-stream, text), 256 bytes.

[9 May 2005 15:01] Vitaly Harisov
Test-case: Java class

Attachment: MySQLBug.java (application/octet-stream, text), 1.39 KiB.

[9 May 2005 16:40] Mark Matthews
This is a server bug that's fixed in the most recent build from sources (and is probably a dupe of BUG#9777).

The following demonstrates that is is fixed in what will be 4.1.12 (built from a pull from BitKeeper this morning), and that it is broken in 4.1.11:

[mmatthew@localhost mysql-4.1]$ /usr/local/mysql/mysql-4.1/bin/mysql test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.1.12-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> prepare foo1 FROM "SELECT COUNT(a.f_a) FROM t_a a WHERE a.f_a>=1050003600000 AND a.f_a=1050003600000";
Query OK, 0 rows affected (0.00 sec)
Statement prepared

mysql> execute foo1;
+--------------+
| COUNT(a.f_a) |
+--------------+
|            1 |
+--------------+
1 row in set (0.01 sec)

mysql> prepare foo2 FROM "SELECT COUNT(a.f_a) FROM t_a a WHERE a.f_a>=1050003600000 AND a.f_a=?";
Query OK, 0 rows affected (0.00 sec)
Statement prepared

mysql> set @foo_param_2=1050003600000; Query OK, 0 rows affected (0.00 sec)

mysql> execute foo2 using @foo_param_2; +--------------+
| COUNT(a.f_a) |
+--------------+
|            1 |
+--------------+
1 row in set (0.00 sec)

mysql>

(here's a session from MySQL-4.1.11)

[mmatthew@localhost tmp]$ /usr/local/mysql/mysql-4.1/bin/mysql test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1150 to server version: 4.1.11-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> prepare foo1 FROM "SELECT COUNT(a.f_a) FROM t_a a WHERE a.f_a>=1050003600000 AND a.f_a=1050003600000";
Query OK, 0 rows affected (0.05 sec)
Statement prepared

mysql> execute foo1;
+--------------+
| COUNT(a.f_a) |
+--------------+
|            1 |
+--------------+
1 row in set (0.00 sec)