Modified:
branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
Log:
Added test for BUG 16458.
Modified: branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
===================================================================
--- branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-01-17 01:03:19 UTC (rev 4814)
+++ branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-01-17 18:38:27 UTC (rev 4815)
@@ -2261,6 +2261,90 @@
assertEquals("java.lang.Integer", this.rs.getObject(1).getClass().getName());
assertEquals("java.lang.Integer", this.rs.getObject(2).getClass().getName());
}
+
+ public void testBug16458() throws Exception {
+ createTable("a", "(id INTEGER NOT NULL, primary key (id)) Type=InnoDB");
+ createTable("b", "(id INTEGER NOT NULL, primary key (id)) Type=InnoDB");
+ createTable("c", "(id INTEGER NOT NULL, primary key (id)) Type=InnoDB");
+
+ createTable(
+ "problem_table",
+ "(id int(11) NOT NULL auto_increment,"
+ + "a_id int(11) NOT NULL default '0',"
+ + "b_id int(11) NOT NULL default '0',"
+ + "c_id int(11) default NULL,"
+
+ + "order_num int(2) NOT NULL default '0',"
+ + "PRIMARY KEY (id),"
+ + "KEY idx_problem_table__b_id (b_id),"
+ + "KEY idx_problem_table__a_id (a_id),"
+ + "KEY idx_problem_table__c_id (c_id),"
+ + "CONSTRAINT fk_problem_table__c FOREIGN KEY (c_id) REFERENCES c (id),"
+ + "CONSTRAINT fk_problem_table__a FOREIGN KEY (a_id) REFERENCES a (id),"
+ + "CONSTRAINT fk_problem_table__b FOREIGN KEY (b_id) REFERENCES b (id)"
+ + ")" + "Type=InnoDB");
+
+ this.stmt
+ .executeUpdate("INSERT INTO `a` VALUES "
+ + "(1),(4),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20),(21),(22),(23"
+ + "),(24),(25),(26),(27),(28),(29),(30),(31),(32),(33),(34),(35),(36),(37),(38),(39"
+ + "),(40),(41),(42),(43),(45),(46),(47),(48),(49),(50)");
+
+ this.stmt
+ .executeUpdate("INSERT INTO `b` VALUES "
+ + "(1),(2),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19"
+ + "),(20)");
+
+ this.stmt
+ .executeUpdate("INSERT INTO `c` VALUES "
+ + "(1),(2),(3),(13),(15),(16),(22),(30),(31),(32),(33),(34),(35),(36),(37),(148),(1"
+ + "59),(167),(174),(176),(177),(178),(179),(180),(187),(188),(189),(190),(191),(192"
+ + "),(193),(194),(195),(196),(197),(198),(199),(200),(201),(202),(203),(204),(205),"
+ + "(206),(207),(208)");
+
+ this.stmt
+ .executeUpdate("INSERT INTO `problem_table` VALUES "
+ + "(1,1,1,NULL,1),(2,1,4,NULL,1),(3,1,5,NULL,1),(4,1,8,NULL,1),(5,23,1,NULL,1),(6,2"
+ + "3,4,NULL,1),(7,24,1,NULL,1),(8,24,2,NULL,1),(9,24,4,NULL,1),(10,25,1,NULL,1),(11"
+ + ",25,2,NULL,1),(12,25,4,NULL,1),(13,27,1,NULL,1),(14,28,1,NULL,1),(15,29,1,NULL,1"
+ + "),(16,15,2,NULL,1),(17,15,5,NULL,1),(18,15,8,NULL,1),(19,30,1,NULL,1),(20,31,1,N"
+ + "ULL,1),(21,31,4,NULL,1),(22,32,2,NULL,1),(23,32,4,NULL,1),(24,32,6,NULL,1),(25,3"
+ + "2,8,NULL,1),(26,32,10,NULL,1),(27,32,11,NULL,1),(28,32,13,NULL,1),(29,32,16,NULL"
+ + ",1),(30,32,17,NULL,1),(31,32,18,NULL,1),(32,32,19,NULL,1),(33,32,20,NULL,1),(34,"
+ + "33,15,NULL,1),(35,33,15,NULL,1),(36,32,20,206,1),(96,32,9,NULL,1),(100,47,6,NULL"
+ + ",1),(101,47,10,NULL,1),(102,47,5,NULL,1),(105,47,19,NULL,1)");
+ PreparedStatement ps = null;
+
+ try {
+ ps = conn.prepareStatement("SELECT DISTINCT id,order_num FROM problem_table WHERE a_id=? FOR UPDATE",
+ ResultSet.TYPE_FORWARD_ONLY,
+ ResultSet.CONCUR_UPDATABLE);
+
+ ps.setInt(1, 32);
+
+ this.rs = ps.executeQuery();
+
+ while(this.rs.next())
+ {
+ this.rs.updateInt(3, 51);
+
+ this.rs.updateRow();
+ }
+ } finally {
+ if (this.rs != null) {
+ ResultSet toCloseRs = this.rs;
+ this.rs = null;
+ toCloseRs.close();
+ }
+
+ if (ps != null) {
+ PreparedStatement toClosePs = ps;
+ ps = null;
+ toClosePs.close();
+ }
+ }
+ }
+
public void testNPEWithUsageAdvisor() throws Exception {
Connection advisorConn = null;
| Thread |
|---|
| • Connector/J commit: r4815 - branches/branch_3_1/connector-j/src/testsuite/regression | mmatthews | 17 Jan |