Bug #29902 After Upgrade to 5.1.20, executeUpdate() on PreparedStatement Gives Bad Result
Submitted: 19 Jul 2007 15:01 Modified: 19 Jul 2007 15:41
Reporter: Richard Harms Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version:5.1.20-beta OS:MacOS (10.4.10)
Assigned to: CPU Architecture:Any

[19 Jul 2007 15:01] Richard Harms
Description:
After the upgrade to 5.1.20, executeUpdate() on a PreparedStatement has started returning bogus values.

Server was built from source, configure command line was:

./configure --with-plugins=max

How to repeat:
Here's an example:

/* conn id 0 */ SHOW VARIABLES;
/* conn id 0 */ SHOW COLLATION;
/* conn id 0 */ SET NAMES utf8;
/* conn id 0 */ SET character_set_results = NULL;
/* conn id 0 */ SET autocommit=1;
/* conn id 0 */ SET sql_mode='STRICT_TRANS_TABLES';
/* conn id 77 */ INSERT INTO entityids (eid_entityname, eid_lasteid) VALUES ('TestEntityName', 50);
624791

"624791" should have been "1."

The code that executed the insert was:

            int count = ps.executeUpdate();
            System.out.println(count);

Table is:

CREATE TABLE `entityids` (
  `eid_entityname` varchar(60) NOT NULL,
  `eid_lasteid` bigint(20) NOT NULL,
  `eid_dbtimestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`eid_entityname`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

This was tested with MySQL Connector/J 5.0.6.

Suggested fix:
Going back to server version 5.1.19 restored the proper behavior, "1" was displayed when the test was run.

/* conn id 0 */ SHOW VARIABLES;
/* conn id 0 */ SHOW COLLATION;
/* conn id 0 */ SET NAMES utf8;
/* conn id 0 */ SET character_set_results = NULL;
/* conn id 0 */ SET autocommit=1;
/* conn id 0 */ SET sql_mode='STRICT_TRANS_TABLES';
/* conn id 3 */ INSERT INTO entityids (eid_entityname, eid_lasteid) VALUES ('TestEntityName', 50);
1
[19 Jul 2007 15:03] Richard Harms
Code Used in Test

Attachment: PreparedStatementTest.java (, text), 1.69 KiB.

[19 Jul 2007 15:41] Sveta Smirnova
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments to the original bug instead.

Thank you for your interest in MySQL.

Duplicate of Bug #29692