Index: driver/utility.c =================================================================== --- driver/utility.c (revision 221) +++ driver/utility.c (working copy) @@ -550,35 +550,40 @@ return SQL_CHAR; case FIELD_TYPE_VAR_STRING: - - if(field->table && field->org_table && field->table[0] && field->org_table[0]) + /* + If we have both the table name and the original table name, we + can trust the length information in the field. Unless there + isn't any, then we assume a length of 255 characters. + */ + if (field->table && field->org_table && + field->table[0] && field->org_table[0]) { - *transfer_length= *precision= *display_size= field->length ? - (stmt->dbc->mysql.charset ? - field->length/stmt->dbc->mysql.charset->mbmaxlen: field->length): 255; - - /* Binary flag is for handling "VARCHAR() BINARY" but is unreliable (see BUG-4578) - PAH */ - if (field_is_binary) - { - if (buff) strmov(buff,"varbinary"); - return SQL_VARBINARY; - } - if ( buff ) strmov(buff,"varchar"); - return SQL_VARCHAR; + *transfer_length= *precision= *display_size= field->length ? + (stmt->dbc->mysql.charset ? + field->length / stmt->dbc->mysql.charset->mbmaxlen : + field->length) : 255; } - else + /* + Otherwise, if it is not already set, we set it to + the size of a MEDIUMTEXT/BLOB. + */ + else if (!(*transfer_length) && !(*precision) && !(*display_size)) { - *transfer_length= *precision= *display_size= 16777216L; - if (field_is_binary) - { - if (buff) strmov(buff,"varbinary"); - return SQL_LONGVARBINARY; - } + *transfer_length= *precision= *display_size= 16777216L; + } - if ( buff ) strmov(buff,"varchar"); - return SQL_LONGVARCHAR; + if (field_is_binary) + { + if (buff) + strmov(buff,"varbinary"); + return SQL_VARBINARY; } + if (buff) + strmov(buff,"varchar"); + + return SQL_VARCHAR; + case FIELD_TYPE_TINY_BLOB: if ( buff ) strmov(buff,(field_is_binary) ? "tinyblob" : "tinytext");