From: Date: April 26 2006 3:00am Subject: Connector/J commit: r5207 - in branches: branch_3_1/connector-j branch_3_1/connector-j/src/com/mysql/jdbc branch_3_1/connector-j/src/testsuite/regression branch_5_0/connector-j branch_5_0/connector-j/src/com/mysql/jdbc branch_5_0/connector-j/src/testsuite/regression branch_5_1/connector-j branch_5_1/connector-j/src/com/mysql/jdbc branch_5_1/connector-j/src/testsuite/regression List-Archive: http://lists.mysql.com/commits/5535 X-Bug: 19282 Message-Id: <200604260100.k3Q10lpi009554@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/branch_3_1/connector-j/CHANGES branches/branch_3_1/connector-j/src/com/mysql/jdbc/ResultSet.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/ResultSet.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/ResultSet.java branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java Log: Fixed BUG#19282 - ResultSet.wasNull() returns incorrect value when extracting native string from server-side prepared statement generated result set. Modified: branches/branch_3_1/connector-j/CHANGES =================================================================== --- branches/branch_3_1/connector-j/CHANGES 2006-04-26 00:02:01 UTC (rev 5206) +++ branches/branch_3_1/connector-j/CHANGES 2006-04-26 01:00:40 UTC (rev 5207) @@ -105,7 +105,11 @@ - Driver now aware of fix for BIT type metadata that went into MySQL-5.0.21 for server not reporting length consistently (bug number 13601). - + + - Fixed BUG#19282 - ResultSet.wasNull() returns incorrect value + when extracting native string from server-side prepared statement + generated result set. + 11-30-05 - Version 3.1.12 - Fixed client-side prepared statement bug with embedded ? inside Modified: branches/branch_3_1/connector-j/src/com/mysql/jdbc/ResultSet.java =================================================================== --- branches/branch_3_1/connector-j/src/com/mysql/jdbc/ResultSet.java 2006-04-26 00:02:01 UTC (rev 5206) +++ branches/branch_3_1/connector-j/src/com/mysql/jdbc/ResultSet.java 2006-04-26 01:00:40 UTC (rev 5207) @@ -794,7 +794,7 @@ throws SQLException { int columnIndexMinusOne = columnIndex - 1; - this.wasNullFlag = true; + this.wasNullFlag = false; if (this.thisRow[columnIndexMinusOne] instanceof String) { return (String) this.thisRow[columnIndexMinusOne]; @@ -802,6 +802,7 @@ if (this.thisRow[columnIndexMinusOne] == null) { this.wasNullFlag = true; + return null; } Modified: branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java =================================================================== --- branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-04-26 00:02:01 UTC (rev 5206) +++ branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-04-26 01:00:40 UTC (rev 5207) @@ -2308,6 +2308,39 @@ this.rs = this.stmt.executeQuery("select * from testBug17450 where foo is null"); testResult17450(); } + + /** + * Tests fix for BUG#19282 - ResultSet.wasNull() returns + * incorrect value when extracting native string from + * server-side prepared statement generated result set. + * + * @throws Exception if the test fails. + */ + public void testBug19282() throws Exception { + createTable("testBug19282", "(field1 VARCHAR(32))"); + try { + this.pstmt = this.conn.prepareStatement("SELECT field1 FROM testBug19282"); + this.stmt.executeUpdate("INSERT INTO testBug19282 VALUES ('abcdefg')"); + + this.rs = this.pstmt.executeQuery(); + this.rs.next(); + assertEquals(false, this.rs.wasNull()); + this.rs.getString(1); + assertEquals(false, this.rs.wasNull()); + } finally { + if (this.rs != null) { + ResultSet toClose = this.rs; + this.rs = null; + toClose.close(); + } + + if (this.pstmt != null) { + PreparedStatement toClose = this.pstmt; + this.pstmt = null; + toClose.close(); + } + } + } private void testResult17450() throws Exception { this.rs.next(); Modified: branches/branch_5_0/connector-j/CHANGES =================================================================== --- branches/branch_5_0/connector-j/CHANGES 2006-04-26 00:02:01 UTC (rev 5206) +++ branches/branch_5_0/connector-j/CHANGES 2006-04-26 01:00:40 UTC (rev 5207) @@ -237,6 +237,10 @@ MySQL-5.0.21 for server not reporting length consistently (bug number 13601). + - Fixed BUG#19282 - ResultSet.wasNull() returns incorrect value + when extracting native string from server-side prepared statement + generated result set. + 11-30-05 - Version 3.1.12 - Fixed client-side prepared statement bug with embedded ? inside Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java =================================================================== --- branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java 2006-04-26 00:02:01 UTC (rev 5206) +++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java 2006-04-26 01:00:40 UTC (rev 5207) @@ -794,6 +794,8 @@ throws SQLException { int columnIndexMinusOne = columnIndex - 1; + this.wasNullFlag = false; + if (this.thisRow[columnIndexMinusOne] instanceof String) { return (String) this.thisRow[columnIndexMinusOne]; } Modified: branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java =================================================================== --- branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-04-26 00:02:01 UTC (rev 5206) +++ branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-04-26 01:00:40 UTC (rev 5207) @@ -2968,4 +2968,37 @@ assertFalse("wasNull should return false", this.rs.wasNull()); } + /** + * Tests fix for BUG#19282 - ResultSet.wasNull() returns + * incorrect value when extracting native string from + * server-side prepared statement generated result set. + * + * @throws Exception if the test fails. + */ + public void testBug19282() throws Exception { + createTable("testBug19282", "(field1 VARCHAR(32))"); + try { + this.pstmt = this.conn.prepareStatement("SELECT field1 FROM testBug19282"); + this.stmt.executeUpdate("INSERT INTO testBug19282 VALUES ('abcdefg')"); + + this.rs = this.pstmt.executeQuery(); + this.rs.next(); + assertEquals(false, this.rs.wasNull()); + this.rs.getString(1); + assertEquals(false, this.rs.wasNull()); + } finally { + if (this.rs != null) { + ResultSet toClose = this.rs; + this.rs = null; + toClose.close(); + } + + if (this.pstmt != null) { + PreparedStatement toClose = this.pstmt; + this.pstmt = null; + toClose.close(); + } + } + } + } Modified: branches/branch_5_1/connector-j/CHANGES =================================================================== --- branches/branch_5_1/connector-j/CHANGES 2006-04-26 00:02:01 UTC (rev 5206) +++ branches/branch_5_1/connector-j/CHANGES 2006-04-26 01:00:40 UTC (rev 5207) @@ -210,6 +210,10 @@ - Driver now aware of fix for BIT type metadata that went into MySQL-5.0.21 for server not reporting length consistently (bug number 13601). + + - Fixed BUG#19282 - ResultSet.wasNull() returns incorrect value + when extracting native string from server-side prepared statement + generated result set. 11-30-05 - Version 3.1.12 Modified: branches/branch_5_1/connector-j/src/com/mysql/jdbc/ResultSet.java =================================================================== --- branches/branch_5_1/connector-j/src/com/mysql/jdbc/ResultSet.java 2006-04-26 00:02:01 UTC (rev 5206) +++ branches/branch_5_1/connector-j/src/com/mysql/jdbc/ResultSet.java 2006-04-26 01:00:40 UTC (rev 5207) @@ -813,11 +813,15 @@ throws SQLException { int columnIndexMinusOne = columnIndex - 1; + this.wasNullFlag = false; + if (this.thisRow[columnIndexMinusOne] instanceof String) { return (String) this.thisRow[columnIndexMinusOne]; } if (this.thisRow[columnIndexMinusOne] == null) { + this.wasNullFlag = true; + return null; } Modified: branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java =================================================================== --- branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-04-26 00:02:01 UTC (rev 5206) +++ branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-04-26 01:00:40 UTC (rev 5207) @@ -2968,4 +2968,37 @@ assertFalse("wasNull should return false", this.rs.wasNull()); } + /** + * Tests fix for BUG#19282 - ResultSet.wasNull() returns + * incorrect value when extracting native string from + * server-side prepared statement generated result set. + * + * @throws Exception if the test fails. + */ + public void testBug19282() throws Exception { + createTable("testBug19282", "(field1 VARCHAR(32))"); + try { + this.pstmt = this.conn.prepareStatement("SELECT field1 FROM testBug19282"); + this.stmt.executeUpdate("INSERT INTO testBug19282 VALUES ('abcdefg')"); + + this.rs = this.pstmt.executeQuery(); + this.rs.next(); + assertEquals(false, this.rs.wasNull()); + this.rs.getString(1); + assertEquals(false, this.rs.wasNull()); + } finally { + if (this.rs != null) { + ResultSet toClose = this.rs; + this.rs = null; + toClose.close(); + } + + if (this.pstmt != null) { + PreparedStatement toClose = this.pstmt; + this.pstmt = null; + toClose.close(); + } + } + } + }