Bug #5012 Server side prepared statements returning DECIMAL types results in exception.
Submitted: 12 Aug 2004 8:37 Modified: 13 Aug 2004 5:53
Reporter: Chris Wood
Status: Closed
Category:Connector/J Severity:S2 (Serious)
Version:3.1.3-beta OS:
Assigned to: Mark Matthews Target Version:

[12 Aug 2004 8:37] Chris Wood
Description:
Server side prepared statements are broken, the connector cannot handle the binary result
set type for a DECIMAL column.

How to repeat:
Create a server side prepared statement that returns a DECIMAL(6,2) column, an exception
will be thrown when the results are listed.

Suggested fix:
in the method: com.mysql.jdbc.MysqlIO.unpackBinaryResultSetRow

There is no case branch for the MysqlDefs.FIELD_TYPE_DECIMAL type. This results in any
server side prepared statments which return for example DECIMAL(6,2) types to throw an
exception at line 4069 claiming the type is unknown.

The solution is fairly simple, first add a case branch in the last block above the
exception:

                case MysqlDefs.FIELD_TYPE_TINY_BLOB:
                case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:
                case MysqlDefs.FIELD_TYPE_LONG_BLOB:
                case MysqlDefs.FIELD_TYPE_BLOB:
                case MysqlDefs.FIELD_TYPE_VAR_STRING:
                case MysqlDefs.FIELD_TYPE_STRING:
                case MysqlDefs.FIELD_TYPE_DECIMAL:   <--- extra branch, line 4065

Also the com.mysql.jdbc.ResultSet.getNativeString method has to be modified similarly, at
line 4232:

        switch (mysqlType) {
        case MysqlDefs.FIELD_TYPE_TINY_BLOB:
        case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:
        case MysqlDefs.FIELD_TYPE_LONG_BLOB:
        case MysqlDefs.FIELD_TYPE_BLOB:
        case MysqlDefs.FIELD_TYPE_DECIMAL:  <-- extra branch.

then everything works.
[13 Aug 2004 5:53] Mark Matthews
This will be fixed for 3.1.4, and will be available for testing in the next nightly
snapshot build (which will be available after 00:00 GMT on August 14th).

Thanks for your bug report.