From: Date: March 26 2007 5:06pm Subject: Connector/J commit: r6369 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/com/mysql/jdbc branches/branch_5_0/connector-j/src/testsuite/regression trunk/connector-j trunk/connector-j/src/com/mysql/jdbc trunk/connector-j/src/testsuite/regression List-Archive: http://lists.mysql.com/commits/22942 X-Bug: 25328 Message-Id: <200703261506.l2QF6NYv026101@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/branch_5_0/connector-j/CHANGES branches/branch_5_0/connector-j/src/com/mysql/jdbc/Field.java branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java trunk/connector-j/CHANGES trunk/connector-j/src/com/mysql/jdbc/Field.java trunk/connector-j/src/testsuite/regression/ResultSetRegressionTest.java Log: Fixed BUG#25328 - BIT(> 1) is returned as java.lang.String from ResultSet.getObject() rather than byte[]. Modified: branches/branch_5_0/connector-j/CHANGES =================================================================== --- branches/branch_5_0/connector-j/CHANGES 2007-03-23 19:50:49 UTC (rev 6368) +++ branches/branch_5_0/connector-j/CHANGES 2007-03-26 15:06:20 UTC (rev 6369) @@ -60,7 +60,10 @@ Note that the statement when sent to the server will contain the comments as-is, they're not stripped during the process of preparing the PreparedStatement or CallableStatement. - + + - Fixed BUG#25328 - BIT(> 1) is returned as java.lang.String from ResultSet.getObject() + rather than byte[]. + 03-01-07 - Version 5.0.5 - Fixed BUG#23645 - Some collations/character sets reported as "unknown" Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/Field.java =================================================================== --- branches/branch_5_0/connector-j/src/com/mysql/jdbc/Field.java 2007-03-23 19:50:49 UTC (rev 6368) +++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/Field.java 2007-03-26 15:06:20 UTC (rev 6369) @@ -237,6 +237,7 @@ this.sqlType = Types.VARBINARY; this.colFlag |= 128; // we need to pretend this is a full this.colFlag |= 16; // binary blob + isBinary = true; } } Modified: branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java =================================================================== --- branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2007-03-23 19:50:49 UTC (rev 6368) +++ branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2007-03-26 15:06:20 UTC (rev 6369) @@ -25,6 +25,7 @@ package testsuite.regression; import java.io.Reader; +import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigDecimal; @@ -3804,11 +3805,39 @@ } /** - * Tests fix for BUG#25517 - Statement.setMaxRows() is not effective - * on result sets materialized from cursors. + * Tests fix for BUG#25328 - BIT(> 1) is returned as java.lang.String + * from ResultSet.getObject() rather than byte[]. * - * @throws Exception if the test fails + * @throws Exception if the test fails. */ + public void testbug25328() throws Exception { + createTable("testBug25382", "(BINARY_VAL BIT(64) NULL)"); + + byte[] bytearr = new byte[8]; + + this.pstmt = this.conn + .prepareStatement("INSERT INTO testBug25382 VALUES(?)"); + try { + + this.pstmt.setObject(1, bytearr, java.sql.Types.BINARY); + assertEquals(1, this.pstmt.executeUpdate()); + this.pstmt.clearParameters(); + + this.rs = this.stmt.executeQuery("Select BINARY_VAL from testBug25382"); + this.rs.next(); + assertEquals(this.rs.getObject(1).getClass(), bytearr.getClass()); + } finally { + closeMemberJDBCResources(); + } + } + + /** + * Tests fix for BUG#25517 - Statement.setMaxRows() is not effective on + * result sets materialized from cursors. + * + * @throws Exception + * if the test fails + */ public void testBug25517() throws Exception { Connection fetchConn = null; Statement fetchStmt = null; Modified: trunk/connector-j/CHANGES =================================================================== --- trunk/connector-j/CHANGES 2007-03-23 19:50:49 UTC (rev 6368) +++ trunk/connector-j/CHANGES 2007-03-26 15:06:20 UTC (rev 6369) @@ -85,7 +85,10 @@ Note that the statement when sent to the server will contain the comments as-is, they're not stripped during the process of preparing the PreparedStatement or CallableStatement. - + + - Fixed BUG#25328 - BIT(> 1) is returned as java.lang.String from ResultSet.getObject() + rather than byte[]. + 03-01-07 - Version 5.0.5 - Fixed BUG#23645 - Some collations/character sets reported as "unknown" Modified: trunk/connector-j/src/com/mysql/jdbc/Field.java =================================================================== --- trunk/connector-j/src/com/mysql/jdbc/Field.java 2007-03-23 19:50:49 UTC (rev 6368) +++ trunk/connector-j/src/com/mysql/jdbc/Field.java 2007-03-26 15:06:20 UTC (rev 6369) @@ -237,6 +237,7 @@ this.sqlType = Types.VARBINARY; this.colFlag |= 128; // we need to pretend this is a full this.colFlag |= 16; // binary blob + isBinary = true; } } Modified: trunk/connector-j/src/testsuite/regression/ResultSetRegressionTest.java =================================================================== --- trunk/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2007-03-23 19:50:49 UTC (rev 6368) +++ trunk/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2007-03-26 15:06:20 UTC (rev 6369) @@ -3804,6 +3804,33 @@ } /** + * Tests fix for BUG#25328 - BIT(> 1) is returned as java.lang.String + * from ResultSet.getObject() rather than byte[]. + * + * @throws Exception if the test fails. + */ + public void testbug25328() throws Exception { + createTable("testBug25382", "(BINARY_VAL BIT(64) NULL)"); + + byte[] bytearr = new byte[8]; + + this.pstmt = this.conn + .prepareStatement("INSERT INTO testBug25382 VALUES(?)"); + try { + + this.pstmt.setObject(1, bytearr, java.sql.Types.BINARY); + assertEquals(1, this.pstmt.executeUpdate()); + this.pstmt.clearParameters(); + + this.rs = this.stmt.executeQuery("Select BINARY_VAL from testBug25382"); + this.rs.next(); + assertEquals(this.rs.getObject(1).getClass(), bytearr.getClass()); + } finally { + closeMemberJDBCResources(); + } + } + + /** * Tests fix for BUG#25517 - Statement.setMaxRows() is not effective * on result sets materialized from cursors. *