Bug #34196 Bug in MyODBC noticed in 3.51.22 similar to COnnector/NET bug #27221
Submitted: 31 Jan 2008 13:24 Modified: 31 Jan 2008 17:28
Reporter: Mark Rabjohn Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:MyODBC 3.51.22 / MySQL 4.1.20 Community OS:Windows
Assigned to: CPU Architecture:Any
Tags: array of bytes, Describe command, MyODBC

[31 Jan 2008 13:24] Mark Rabjohn
Description:
I have been using various versions of MySQL with MyODBC 3.51.12 reliably (for what we do) for around 18 months. The application is written in ASP.NET, but I use the ODBC connector because the Connector/NET was less reliable at the outset of the project.

Recently a colleague upgraded MyODBC to 3.51.22, and our application failed.

Essentially, the command "DESCRIBE USERS" should return data as a sequence of strings (as it does on MyODBC 3.51.12), but with MyODBC 3.51.22, the result is an array of bytes.

The byte data appears to be an ascii value representation of the string, so I could work around, but clearly this is a fault that has been introduced.

How to repeat:
'NB) derived from code and may need work to compile

dim dbase as new ODBCConnection("Driver={MySQL ODBC 3.51 Driver};Server=xxx.xxx.xxx.xxx;Port=3306;Database=xxxxxx;User=xxxxxxx;Password=xxxxxxx;Option=2050;")
dbase.open()

Dim drc As DataRowCollection
Dim dt As New DataTable
Dim dr As DataRow
Dim typestr As String
Dim types As String()
Dim tc As Collection
Dim i As Int32

Dim cmd As New OdbcCommand
Dim adp As New OdbcDataAdapter(cmd)

cmd.connection=dbase
cmd.CommandText="describe users"
dbase.open()

adp.Fill(dt)
drc=dt.rows

For Each dr In drc
    'CRASH: We expect dr("Field") to be of type String, but we get an Array of Bytes
    If dr("Field") = column Then
        typestr = dr("Type")
        If LCase(Left(typestr, 3)) = "enu" Then
            types = Split(Mid(typestr, 7, Len(typestr) - 8), "','")
        Else
            types = Split(Mid(typestr, 6, Len(typestr) - 7), "','")
        End If
        tc = New Collection
        For i = LBound(types) To UBound(types)
            tc.Add(types(i))
        Next
        setcache.Add(table & "##" & column, tc)
        Return tc
    End If
Next

dbase.close()

Suggested fix:
I believe that one of the threads relating to similar bugs says that the solution is to detect the use of DESCRIBE and variations of the SHOW command and build meta information such that the client processes the data as strings.
[31 Jan 2008 17:28] Jim Winstead
This was Bug #10491 in the server, which has now been fixed in MySQL Server 5.0.48 and 5.1.21.