Modified:
branches/branch_3_1/connector-j/CHANGES
branches/branch_3_1/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java
branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
branches/branch_5_0/connector-j/CHANGES
branches/branch_5_0/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java
branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
branches/branch_5_1/connector-j/CHANGES
branches/branch_5_1/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java
branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
Log:
Fixed BUG#16841 - updatable result set doesn't return AUTO_INCREMENT
values for insertRow() when multiple column primary keys are used. (the
driver was checking for the existence of single-column primary keys and
an autoincrement value > 0 instead of a straightforward isAutoIncrement()
check).
Modified: branches/branch_3_1/connector-j/CHANGES
===================================================================
--- branches/branch_3_1/connector-j/CHANGES 2006-02-02 01:01:29 UTC (rev 4886)
+++ branches/branch_3_1/connector-j/CHANGES 2006-02-02 17:55:24 UTC (rev 4887)
@@ -28,6 +28,12 @@
turns out to be too problematic to code around class loader hierarchies
that change depending on how an application is deployed. Moved information
back into the CharsetMapping class.
+
+ - Fixed BUG#16841 - updatable result set doesn't return AUTO_INCREMENT
+ values for insertRow() when multiple column primary keys are used. (the
+ driver was checking for the existence of single-column primary keys and
+ an autoincrement value > 0 instead of a straightforward isAutoIncrement()
+ check).
11-30-05 - Version 3.1.12
Modified: branches/branch_3_1/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java
===================================================================
--- branches/branch_3_1/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java 2006-02-02
01:01:29 UTC (rev 4886)
+++ branches/branch_3_1/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java 2006-02-02
17:55:24 UTC (rev 4887)
@@ -728,12 +728,6 @@
this.inserter.executeUpdate();
- int numPrimaryKeys = 0;
-
- if (this.primaryKeyIndicies != null) {
- numPrimaryKeys = this.primaryKeyIndicies.size();
- }
-
long autoIncrementId = this.inserter.getLastInsertID();
int numFields = this.fields.length;
byte[][] newRow = new byte[numFields][];
@@ -745,8 +739,11 @@
newRow[i] = this.inserter.getBytesRepresentation(i);
}
- if ((numPrimaryKeys == 1) && this.fields[i].isPrimaryKey()
- && (autoIncrementId > 0)) {
+ //
+ // WARN: This non-variant only holds if MySQL never allows more
+ // than one auto-increment key (which is the way it is _today_)
+ //
+ if (this.fields[i].isAutoIncrement() && autoIncrementId > 0) {
newRow[i] = String.valueOf(autoIncrementId).getBytes();
}
}
Modified:
branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
===================================================================
---
branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-02-02
01:01:29 UTC (rev 4886)
+++
branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-02-02
17:55:24 UTC (rev 4887)
@@ -2234,6 +2234,52 @@
}
}
+ /**
+ * Tests fix for BUG#16841 - updatable result set doesn't
+ * return AUTO_INCREMENT values for insertRow() when multiple
+ * column primary keys are used.
+ *
+ * @throws Exception if the test fails.
+ */
+ public void testBug16841() throws Exception {
+
+ createTable("testBug16841", "(" + "CID int( 20 ) NOT NULL default '0',"
+ + "OID int( 20 ) NOT NULL AUTO_INCREMENT ,"
+ + "PatientID int( 20 ) default NULL ,"
+ + "PRIMARY KEY ( CID , OID ) ," + "KEY OID ( OID ) ,"
+ + "KEY Path ( CID, PatientID)" + ") TYPE = MYISAM");
+
+ String sSQLQuery = "SELECT * FROM testBug16841 WHERE 1 = 0";
+ Statement updStmt = null;
+
+ try {
+ updStmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ ResultSet.CONCUR_UPDATABLE);
+
+ this.rs = updStmt.executeQuery(sSQLQuery);
+
+ this.rs.moveToInsertRow();
+
+ this.rs.updateInt("CID", 1);
+ this.rs.updateInt("PatientID", 1);
+
+ this.rs.insertRow();
+
+ this.rs.last();
+ assertEquals(1, this.rs.getInt("OID"));
+ } finally {
+ if (this.rs != null) {
+ ResultSet toClose = this.rs;
+ this.rs = null;
+ toClose.close();
+ }
+
+ if (updStmt != null) {
+ updStmt.close();
+ }
+ }
+ }
+
private void traverseResultSetBug14562() throws SQLException {
assertTrue(this.rs.next());
Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES 2006-02-02 01:01:29 UTC (rev 4886)
+++ branches/branch_5_0/connector-j/CHANGES 2006-02-02 17:55:24 UTC (rev 4887)
@@ -116,7 +116,13 @@
Removed reliance on .properties files to hold this information, as it
turns out to be too problematic to code around class loader hierarchies
that change depending on how an application is deployed. Moved information
- back into the CharsetMapping class.
+ back into the CharsetMapping class.
+
+ - Fixed BUG#16841 - updatable result set doesn't return AUTO_INCREMENT
+ values for insertRow() when multiple column primary keys are used. (the
+ driver was checking for the existence of single-column primary keys and
+ an autoincrement value > 0 instead of a straightforward isAutoIncrement()
+ check).
11-30-05 - Version 3.1.12
Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java 2006-02-02
01:01:29 UTC (rev 4886)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java 2006-02-02
17:55:24 UTC (rev 4887)
@@ -728,12 +728,6 @@
this.inserter.executeUpdate();
- int numPrimaryKeys = 0;
-
- if (this.primaryKeyIndicies != null) {
- numPrimaryKeys = this.primaryKeyIndicies.size();
- }
-
long autoIncrementId = this.inserter.getLastInsertID();
int numFields = this.fields.length;
byte[][] newRow = new byte[numFields][];
@@ -745,8 +739,11 @@
newRow[i] = this.inserter.getBytesRepresentation(i);
}
- if ((numPrimaryKeys == 1) && this.fields[i].isPrimaryKey()
- && (autoIncrementId > 0)) {
+ //
+ // WARN: This non-variant only holds if MySQL never allows more
+ // than one auto-increment key (which is the way it is _today_)
+ //
+ if (this.fields[i].isAutoIncrement() && autoIncrementId > 0) {
newRow[i] = String.valueOf(autoIncrementId).getBytes();
}
}
@@ -1042,7 +1039,7 @@
ProfilerEvent.TYPE_WARN, "", //$NON-NLS-1$
(this.owningStatement == null) ? "N/A" //$NON-NLS-1$
: this.owningStatement.currentCatalog, //$NON-NLS-1$
- this.connection.getId(),
+ this.connectionId,
(this.owningStatement == null) ? (-1)
: this.owningStatement.getId(), this.resultId,
System.currentTimeMillis(), 0, null,
Modified:
branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
===================================================================
---
branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-02-02
01:01:29 UTC (rev 4886)
+++
branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-02-02
17:55:24 UTC (rev 4887)
@@ -2883,4 +2883,50 @@
}
}
}
+
+ /**
+ * Tests fix for BUG#16841 - updatable result set doesn't
+ * return AUTO_INCREMENT values for insertRow() when multiple
+ * column primary keys are used.
+ *
+ * @throws Exception if the test fails.
+ */
+ public void testBug16841() throws Exception {
+
+ createTable("testBug16841", "(" + "CID int( 20 ) NOT NULL default '0',"
+ + "OID int( 20 ) NOT NULL AUTO_INCREMENT ,"
+ + "PatientID int( 20 ) default NULL ,"
+ + "PRIMARY KEY ( CID , OID ) ," + "KEY OID ( OID ) ,"
+ + "KEY Path ( CID, PatientID)" + ") TYPE = MYISAM");
+
+ String sSQLQuery = "SELECT * FROM testBug16841 WHERE 1 = 0";
+ Statement updStmt = null;
+
+ try {
+ updStmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ ResultSet.CONCUR_UPDATABLE);
+
+ this.rs = updStmt.executeQuery(sSQLQuery);
+
+ this.rs.moveToInsertRow();
+
+ this.rs.updateInt("CID", 1);
+ this.rs.updateInt("PatientID", 1);
+
+ this.rs.insertRow();
+
+ this.rs.last();
+ assertEquals(1, this.rs.getInt("OID"));
+ } finally {
+ if (this.rs != null) {
+ ResultSet toClose = this.rs;
+ this.rs = null;
+ toClose.close();
+ }
+
+ if (updStmt != null) {
+ updStmt.close();
+ }
+ }
+ }
}
Modified: branches/branch_5_1/connector-j/CHANGES
===================================================================
--- branches/branch_5_1/connector-j/CHANGES 2006-02-02 01:01:29 UTC (rev 4886)
+++ branches/branch_5_1/connector-j/CHANGES 2006-02-02 17:55:24 UTC (rev 4887)
@@ -120,6 +120,12 @@
turns out to be too problematic to code around class loader hierarchies
that change depending on how an application is deployed. Moved information
back into the CharsetMapping class.
+
+ - Fixed BUG#16841 - updatable result set doesn't return AUTO_INCREMENT
+ values for insertRow() when multiple column primary keys are used. (the
+ driver was checking for the existence of single-column primary keys and
+ an autoincrement value > 0 instead of a straightforward isAutoIncrement()
+ check).
11-30-05 - Version 3.1.12
Modified: branches/branch_5_1/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java
===================================================================
--- branches/branch_5_1/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java 2006-02-02
01:01:29 UTC (rev 4886)
+++ branches/branch_5_1/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java 2006-02-02
17:55:24 UTC (rev 4887)
@@ -734,12 +734,6 @@
this.inserter.executeUpdate();
- int numPrimaryKeys = 0;
-
- if (this.primaryKeyIndicies != null) {
- numPrimaryKeys = this.primaryKeyIndicies.size();
- }
-
long autoIncrementId = this.inserter.getLastInsertID();
int numFields = this.fields.length;
byte[][] newRow = new byte[numFields][];
@@ -751,8 +745,11 @@
newRow[i] = this.inserter.getBytesRepresentation(i);
}
- if ((numPrimaryKeys == 1) && this.fields[i].isPrimaryKey()
- && (autoIncrementId > 0)) {
+ //
+ // WARN: This non-variant only holds if MySQL never allows more
+ // than one auto-increment key (which is the way it is _today_)
+ //
+ if (this.fields[i].isAutoIncrement() && autoIncrementId > 0) {
newRow[i] = String.valueOf(autoIncrementId).getBytes();
}
}
Modified:
branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
===================================================================
---
branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-02-02
01:01:29 UTC (rev 4886)
+++
branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-02-02
17:55:24 UTC (rev 4887)
@@ -2883,4 +2883,50 @@
}
}
}
+
+ /**
+ * Tests fix for BUG#16841 - updatable result set doesn't
+ * return AUTO_INCREMENT values for insertRow() when multiple
+ * column primary keys are used.
+ *
+ * @throws Exception if the test fails.
+ */
+ public void testBug16841() throws Exception {
+
+ createTable("testBug16841", "(" + "CID int( 20 ) NOT NULL default '0',"
+ + "OID int( 20 ) NOT NULL AUTO_INCREMENT ,"
+ + "PatientID int( 20 ) default NULL ,"
+ + "PRIMARY KEY ( CID , OID ) ," + "KEY OID ( OID ) ,"
+ + "KEY Path ( CID, PatientID)" + ") TYPE = MYISAM");
+
+ String sSQLQuery = "SELECT * FROM testBug16841 WHERE 1 = 0";
+ Statement updStmt = null;
+
+ try {
+ updStmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ ResultSet.CONCUR_UPDATABLE);
+
+ this.rs = updStmt.executeQuery(sSQLQuery);
+
+ this.rs.moveToInsertRow();
+
+ this.rs.updateInt("CID", 1);
+ this.rs.updateInt("PatientID", 1);
+
+ this.rs.insertRow();
+
+ this.rs.last();
+ assertEquals(1, this.rs.getInt("OID"));
+ } finally {
+ if (this.rs != null) {
+ ResultSet toClose = this.rs;
+ this.rs = null;
+ toClose.close();
+ }
+
+ if (updStmt != null) {
+ updStmt.close();
+ }
+ }
+ }
}
| Thread |
|---|
| • Connector/J commit: r4887 - in branches: branch_3_1/connector-j branch_3_1/connector-j/src/com/mysql/jdbc branch_3_1/connector-j/src/testsuite/regress... | mmatthews | 2 Feb |