From: Date: August 30 2007 5:32pm Subject: Connector/J commit: r6532 - in trunk: . connector-j connector-j/src/com/mysql/jdbc connector-j/src/testsuite/regression List-Archive: http://lists.mysql.com/commits/33447 X-Bug: 30664 Message-Id: <200708301532.l7UFWBpI009973@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: trunk/ trunk/connector-j/CHANGES trunk/connector-j/src/com/mysql/jdbc/Field.java trunk/connector-j/src/testsuite/regression/ResultSetRegressionTest.java Log: Merged revisions 6531 via svnmerge from svn+ssh://mmatthews@stripped/connectors-svnroot/connector-j/branches/branch_5_0 ....... r6531 | mmatthews | 2007-08-30 10:21:06 -0500 (Thu, 30 Aug 2007) | 5 lines 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. ....... Property changes on: trunk ___________________________________________________________________ Name: svnmerge-integrated - /branches/branch_5_0:1-6528 /branches/branch_5_1:1-6517 + /branches/branch_5_0:1-6528,6531 /branches/branch_5_1:1-6517 Modified: trunk/connector-j/CHANGES =================================================================== --- trunk/connector-j/CHANGES 2007-08-30 15:21:06 UTC (rev 6531) +++ trunk/connector-j/CHANGES 2007-08-30 15:32:10 UTC (rev 6532) @@ -199,6 +199,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: trunk/connector-j/src/com/mysql/jdbc/Field.java =================================================================== --- trunk/connector-j/src/com/mysql/jdbc/Field.java 2007-08-30 15:21:06 UTC (rev 6531) +++ trunk/connector-j/src/com/mysql/jdbc/Field.java 2007-08-30 15:32:10 UTC (rev 6532) @@ -827,7 +827,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: trunk/connector-j/src/testsuite/regression/ResultSetRegressionTest.java =================================================================== --- trunk/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2007-08-30 15:21:06 UTC (rev 6531) +++ trunk/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2007-08-30 15:32:10 UTC (rev 6532) @@ -4397,4 +4397,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(); + } + } }