From: Date: August 30 2007 5:21pm Subject: Connector/J commit: r6531 - in branches/branch_5_0/connector-j: . src/com/mysql/jdbc src/testsuite/regression List-Archive: http://lists.mysql.com/commits/33446 X-Bug: 30664 Message-Id: <200708301521.l7UFL78i007338@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 Log: Fixed BUG#30664. Note that this fix only works for MySQL server versions 5.0.25 and newer, since earlier versions didn't consistently return correct metadata for functions, and thus results from subqueries and functions were indistinguishable from each other, leading to type-related bugs. Modified: branches/branch_5_0/connector-j/CHANGES =================================================================== --- branches/branch_5_0/connector-j/CHANGES 2007-08-29 19:42:13 UTC (rev 6530) +++ branches/branch_5_0/connector-j/CHANGES 2007-08-30 15:21:06 UTC (rev 6531) @@ -21,6 +21,12 @@ - Fixed BUG#29106 - Connection checker for JBoss didn't use same method parameters via reflection, causing connections to always seem "bad". + - Fixed BUG#30664. Note that this fix only works for MySQL server + versions 5.0.25 and newer, since earlier versions didn't consistently + return correct metadata for functions, and thus results from + subqueries and functions were indistinguishable from each other, + leading to type-related bugs. + 07-19-07 - Version 5.0.7 - Setting the configuration parameter "useCursorFetch" to "true" for 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-08-29 19:42:13 UTC (rev 6530) +++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/Field.java 2007-08-30 15:21:06 UTC (rev 6531) @@ -733,7 +733,8 @@ && (this.getMysqlType() == MysqlDefs.FIELD_TYPE_STRING || this.getMysqlType() == MysqlDefs.FIELD_TYPE_VAR_STRING)) { - if (this.originalTableNameLength == 0) { + if (this.originalTableNameLength == 0 && ( + this.connection != null && !this.connection.versionMeetsMinimum(5, 0, 25))) { return false; // Probably from function } Modified: branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java =================================================================== --- branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2007-08-29 19:42:13 UTC (rev 6530) +++ branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2007-08-30 15:21:06 UTC (rev 6531) @@ -4393,4 +4393,47 @@ this.rs.next(); assertEquals("java.lang.String", this.rs.getObject(1).getClass().getName()); } + + /** + * Tests fix for BUG#30664. Note that this fix only works + * for MySQL server 5.0.25 and newer, since earlier versions + * didn't consistently return correct metadata for functions, + * and thus results from subqueries and functions were indistinguishable + * from each other, leading to type-related bugs. + * + * @throws Exception + */ + public void testBug30664() throws Exception { + if (!versionMeetsMinimum(5, 0, 25)) { + return; + } + + createTable("testBug30664_1", "(id int)"); + createTable("testBug30664_2", "(id int, binaryvalue varbinary(10))"); + + try { + this.stmt + .executeUpdate("insert into testBug30664_1 values (1),(2),(3)"); + this.stmt + .executeUpdate("insert into testBug30664_2 values (1,'¢‚¤'),(2,'‚¢‚¤'),(3,' ‚¢¤')"); + this.rs = this.stmt + .executeQuery("select testBug30664_1.id, (select testBug30664_2.binaryvalue from testBug30664_2 where testBug30664_2.id=testBug30664_1.id) as value from testBug30664_1"); + ResultSetMetaData tblMD = this.rs.getMetaData(); + + for (int i = 1; i < tblMD.getColumnCount() + 1; i++) { + switch (i) { + case 1: + assertEquals("INTEGER", tblMD.getColumnTypeName(i) + .toUpperCase()); + break; + case 2: + assertEquals("VARBINARY", tblMD.getColumnTypeName(i) + .toUpperCase()); + break; + } + } + } finally { + closeMemberJDBCResources(); + } + } } \ No newline at end of file