From: mmatthews Date: December 20 2005 7:52pm Subject: Connector/J commit: r4719 - in branches/branch_5_0/connector-j: . src/com/mysql/jdbc List-Archive: http://lists.mysql.com/commits/299 X-Bug: 11874 Message-Id: <200512201952.jBKJqYiX009609@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/ConnectionProperties.java branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java Log: Fixed BUG#11874 - ResultSet.getShort() for UNSIGNED TINYINT returned wrong values. Added diagnostics for column not found when calling ResultSet.findColumn(). (merged from 3.1 branch) Modified: branches/branch_5_0/connector-j/CHANGES =================================================================== --- branches/branch_5_0/connector-j/CHANGES 2005-12-20 19:46:18 UTC (rev 4718) +++ branches/branch_5_0/connector-j/CHANGES 2005-12-20 19:52:31 UTC (rev 4719) @@ -101,6 +101,9 @@ (and is thus not complementary to .getObject() on an UNSIGNED LONG type). + - Fixed BUG#11874 - ResultSet.getShort() for UNSIGNED TINYINT + returned wrong values. + 11-30-05 - Version 3.1.12 Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java =================================================================== --- branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java 2005-12-20 19:46:18 UTC (rev 4718) +++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java 2005-12-20 19:52:31 UTC (rev 4719) @@ -1352,6 +1352,8 @@ private BooleanConnectionProperty useGmtMillisForDatetimes = new BooleanConnectionProperty("useGmtMillisForDatetimes", false, "Convert between session timezone and GMT before creating Date and Timestamp instances (value of \"false\" is legacy behavior, \"true\" leads to more JDBC-compliant behavior.", "3.1.12", MISC_CATEGORY, Integer.MIN_VALUE); + private BooleanConnectionProperty dumpMetadataOnColumnNotFound = new BooleanConnectionProperty("dumpMetadataOnColumnNotFound", false, "Should the driver dump the field-level metadata of a result set into " + "the exception message when ResultSet.findColumn() fails?", "3.1.13", DEBUGING_PROFILING_CATEGORY, Integer.MIN_VALUE); + protected DriverPropertyInfo[] exposeAsDriverPropertyInfoInternal( Properties info, int slotsToReserve) throws SQLException { initializeProperties(info); @@ -3563,4 +3565,12 @@ public void setUseGmtMillisForDatetimes(boolean flag) { this.useGmtMillisForDatetimes.setValue(flag); } + + protected boolean getDumpMetadataOnColumnNotFound() { + return this.dumpMetadataOnColumnNotFound.getValueAsBoolean(); + } + + protected void setDumpMetadataOnColumnNotFound(boolean flag) { + this.dumpMetadataOnColumnNotFound.setValue(flag); + } } 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 2005-12-20 19:46:18 UTC (rev 4718) +++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java 2005-12-20 19:52:31 UTC (rev 4719) @@ -3994,7 +3994,7 @@ case MysqlDefs.FIELD_TYPE_TINY: byte tinyintVal = getNativeByte(columnIndex + 1); - if (!f.isUnsigned() || tinyintVal >= 0) { + if (!f.isUnsigned()) { return tinyintVal; } @@ -4003,23 +4003,24 @@ case MysqlDefs.FIELD_TYPE_YEAR: short asShort = getNativeShort(columnIndex + 1); - if (!f.isUnsigned() || asShort >= 0) { + if (!f.isUnsigned()) { return asShort; } - if (this.connection.getJdbcCompliantTruncation()) { - int valueAsInt = asShort + 65536; - + int valueAsInt = asShort + 65536; + + if (this.connection.getJdbcCompliantTruncation() && + valueAsInt > Short.MAX_VALUE) { throwRangeException(String.valueOf(valueAsInt), columnIndex + 1, Types.SMALLINT); } - return asShort; + return (short)valueAsInt; case MysqlDefs.FIELD_TYPE_INT24: case MysqlDefs.FIELD_TYPE_LONG: byte[] bits = (byte[]) this.thisRow[columnIndex]; - int valueAsInt = (bits[0] & 0xff) | ((bits[1] & 0xff) << 8) + valueAsInt = (bits[0] & 0xff) | ((bits[1] & 0xff) << 8) | ((bits[2] & 0xff) << 16) | ((bits[3] & 0xff) << 24); return (short)valueAsInt;