From df6397abc73ed9b73515e4aba2ec049c514af1cc Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 11 Jan 2010 22:24:25 +0000 Subject: [PATCH] Fix detection of VARCHAR columns as BLOBs on 4.0 servers. Workaround for shared type FIELD_TYPE_* constants should only apply to (TINY|MEDIUM|LONG)TEXT columns. Fixes issue #1588. --- source/mysql_connection.pas | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/source/mysql_connection.pas b/source/mysql_connection.pas index 6af1083b..3dd7f127 100644 --- a/source/mysql_connection.pas +++ b/source/mysql_connection.pas @@ -1178,16 +1178,18 @@ begin FDatatypes[i] := Datatypes[Integer(dtSet)] else for j:=Low(Datatypes) to High(Datatypes) do begin if Field._type = Datatypes[j].NativeType then begin - // Text and Blob types share the same constants (see FIELD_TYPEs in mysql_api) - // Some function results return binary collation up to the latest versions. Work around - // that by checking if this field is a real table field - // See http://bugs.mysql.com/bug.php?id=10201 - if Connection.IsUnicode then - IsBinary := (Field.charsetnr = COLLATION_BINARY) and (Field.org_table <> '') - else - IsBinary := (Field.flags and BINARY_FLAG) = BINARY_FLAG; - if IsBinary and (Datatypes[j].Category = dtcText) then - continue; + if Datatypes[j].Index in [dtTinytext, dtText, dtMediumtext, dtLongtext] then begin + // Text and Blob types share the same constants (see FIELD_TYPEs in mysql_api) + // Some function results return binary collation up to the latest versions. Work around + // that by checking if this field is a real table field + // See http://bugs.mysql.com/bug.php?id=10201 + if Connection.IsUnicode then + IsBinary := (Field.charsetnr = COLLATION_BINARY) and (Field.org_table <> '') + else + IsBinary := (Field.flags and BINARY_FLAG) = BINARY_FLAG; + if IsBinary then + continue; + end; FDatatypes[i] := Datatypes[j]; break; end;