Modified:
branches/branch_3_1/connector-j/src/com/mysql/jdbc/ServerPreparedStatement.java
Log:
Fixed truncation on write exception when
sending big decimal incorrectly to server with
server-side prepared statement.
Modified: branches/branch_3_1/connector-j/src/com/mysql/jdbc/ServerPreparedStatement.java
===================================================================
---
branches/branch_3_1/connector-j/src/com/mysql/jdbc/ServerPreparedStatement.java 2006-10-10
14:59:46 UTC (rev 5852)
+++
branches/branch_3_1/connector-j/src/com/mysql/jdbc/ServerPreparedStatement.java 2006-10-10
15:04:27 UTC (rev 5853)
@@ -1477,8 +1477,18 @@
if (x == null) {
setNull(parameterIndex, java.sql.Types.DECIMAL);
} else {
- setString(parameterIndex, StringUtils.fixDecimalExponent(x
- .toString()));
+
+ BindValue binding = getBinding(parameterIndex, false);
+
+ if (this.connection.versionMeetsMinimum(5, 0, 3)) {
+ setType(binding, MysqlDefs.FIELD_TYPE_NEW_DECIMAL);
+ } else {
+ setType(binding, this.stringTypeCode);
+ }
+
+ binding.value = StringUtils.fixDecimalExponent(x.toString());
+ binding.isNull = false;
+ binding.isLongData = false;
}
}
@@ -2035,6 +2045,8 @@
case MysqlDefs.FIELD_TYPE_VAR_STRING:
case MysqlDefs.FIELD_TYPE_STRING:
case MysqlDefs.FIELD_TYPE_VARCHAR:
+ case MysqlDefs.FIELD_TYPE_DECIMAL:
+ case MysqlDefs.FIELD_TYPE_NEW_DECIMAL:
if (value instanceof byte[]) {
packet.writeLenBytes((byte[]) value);
} else if (!this.isLoadDataQuery) {
| Thread |
|---|
| • Connector/J commit: r5853 - branches/branch_3_1/connector-j/src/com/mysql/jdbc | mmatthews | 10 Oct |