Modified:
branches/branch_5_1/CHANGES
branches/branch_5_1/src/com/mysql/jdbc/ConnectionImpl.java
branches/branch_5_1/src/com/mysql/jdbc/ResultSetRow.java
branches/branch_5_1/src/com/mysql/jdbc/RowDataStatic.java
branches/branch_5_1/src/testsuite/regression/ResultSetRegressionTest.java
Log:
Fixed Bug#34762 - RowDataStatic does't always set the metadata in
ResultSetRow, which can lead to failures when unpacking DATE,
TIME, DATETIME and TIMESTAMP types when using absolute, relative,
and previous result set navigation methods.
Modified: branches/branch_5_1/CHANGES
===================================================================
--- branches/branch_5_1/CHANGES 2008-02-22 20:04:18 UTC (rev 6736)
+++ branches/branch_5_1/CHANGES 2008-02-27 04:30:46 UTC (rev 6737)
@@ -135,6 +135,11 @@
DatabaseMetadata implementations that use "SHOW" commands, and the
INFORMATION_SCHEMA.
+ - Fixed Bug#34762 - RowDataStatic does't always set the metadata in
+ ResultSetRow, which can lead to failures when unpacking DATE,
+ TIME, DATETIME and TIMESTAMP types when using absolute, relative,
+ and previous result set navigation methods.
+
10-09-07 - Version 5.1.5
- Released instead of 5.1.4 to pickup patch for BUG#31053
Modified: branches/branch_5_1/src/com/mysql/jdbc/ConnectionImpl.java
===================================================================
--- branches/branch_5_1/src/com/mysql/jdbc/ConnectionImpl.java 2008-02-22 20:04:18 UTC
(rev 6736)
+++ branches/branch_5_1/src/com/mysql/jdbc/ConnectionImpl.java 2008-02-27 04:30:46 UTC
(rev 6737)
@@ -1234,10 +1234,16 @@
* @throws SQLException
*/
protected void abortInternal() throws SQLException {
- io.forceClose();
- io = null;
- isClosed = true;
- cleanup(null);
+ if (this.io != null) {
+ try {
+ this.io.forceClose();
+ } catch (Throwable t) {
+ // can't do anything about it, and we're forcibly aborting
+ }
+ this.io = null;
+ }
+
+ this.isClosed = true;
}
/**
Modified: branches/branch_5_1/src/com/mysql/jdbc/ResultSetRow.java
===================================================================
--- branches/branch_5_1/src/com/mysql/jdbc/ResultSetRow.java 2008-02-22 20:04:18 UTC (rev
6736)
+++ branches/branch_5_1/src/com/mysql/jdbc/ResultSetRow.java 2008-02-27 04:30:46 UTC (rev
6737)
@@ -1391,7 +1391,9 @@
public abstract void setColumnValue(int index, byte[] value)
throws SQLException;
- public void setMetadata(Field[] f) throws SQLException {
+ public ResultSetRow setMetadata(Field[] f) throws SQLException {
this.metadata = f;
+
+ return this;
}
}
Modified: branches/branch_5_1/src/com/mysql/jdbc/RowDataStatic.java
===================================================================
--- branches/branch_5_1/src/com/mysql/jdbc/RowDataStatic.java 2008-02-22 20:04:18 UTC (rev
6736)
+++ branches/branch_5_1/src/com/mysql/jdbc/RowDataStatic.java 2008-02-27 04:30:46 UTC (rev
6737)
@@ -98,12 +98,12 @@
*
* @return DOCUMENT ME!
*/
- public ResultSetRow getAt(int atIndex) {
+ public ResultSetRow getAt(int atIndex) throws SQLException {
if ((atIndex < 0) || (atIndex >= this.rows.size())) {
return null;
}
- return (ResultSetRow) this.rows.get(atIndex);
+ return ((ResultSetRow) this.rows.get(atIndex)).setMetadata(this.metadata);
}
/**
@@ -215,9 +215,8 @@
if (this.index < this.rows.size()) {
ResultSetRow row = (ResultSetRow) this.rows.get(this.index);
- row.setMetadata(this.metadata);
- return row;
+ return row.setMetadata(this.metadata);
}
return null;
Modified: branches/branch_5_1/src/testsuite/regression/ResultSetRegressionTest.java
===================================================================
--- branches/branch_5_1/src/testsuite/regression/ResultSetRegressionTest.java 2008-02-22
20:04:18 UTC (rev 6736)
+++ branches/branch_5_1/src/testsuite/regression/ResultSetRegressionTest.java 2008-02-27
04:30:46 UTC (rev 6737)
@@ -4601,4 +4601,50 @@
this.rs.getTimestamp(1); // fails
}
+ public void testBug34762() throws Exception {
+ createTable("testBug34762", "(field1 TIMESTAMP)");
+ int numRows = 10;
+
+ for (int i = 0; i < numRows; i++) {
+ this.stmt.executeUpdate("INSERT INTO testBug34762 VALUES (NOW())");
+ }
+
+ this.rs = this.stmt.executeQuery("SELECT field1 FROM testBug34762");
+
+ while (this.rs.next()) {
+ this.rs.getTimestamp(1);
+ }
+
+ this.rs = this.stmt.executeQuery("SELECT field1 FROM testBug34762");
+
+ for (int i = 1; i <= numRows; i++) {
+ this.rs.absolute(i);
+ this.rs.getTimestamp(1);
+ }
+
+ this.rs = this.stmt.executeQuery("SELECT field1 FROM testBug34762");
+
+ this.rs.last();
+ this.rs.getTimestamp(1);
+
+ while (this.rs.previous()) {
+ this.rs.getTimestamp(1);
+ }
+
+ this.rs = this.stmt.executeQuery("SELECT field1 FROM testBug34762");
+
+ this.rs.last();
+
+ while (this.rs.relative(-1)) {
+ this.rs.getTimestamp(1);
+ }
+
+ this.rs = this.stmt.executeQuery("SELECT field1 FROM testBug34762");
+
+ this.rs.beforeFirst();
+
+ while (this.rs.relative(1)) {
+ this.rs.getTimestamp(1);
+ }
+ }
}
| Thread |
|---|
| • Connector/J commit: r6737 - in branches/branch_5_1: . src/com/mysql/jdbc src/testsuite/regression | mmatthews | 27 Feb 2008 |