BINARY_FLAG seems broken for fields of a utf8_bin table. Instead use the charset nr returned by a PMYSQL_FIELD. Fixes issue #1479

This commit is contained in:
Ansgar Becker
2009-11-20 17:38:34 +00:00
parent f192953c6b
commit f9c1913d07
2 changed files with 10 additions and 1 deletions

View File

@ -141,6 +141,10 @@ const
FIELD_TYPE_CHAR = FIELD_TYPE_TINY;
FIELD_TYPE_INTERVAL = FIELD_TYPE_ENUM;
COLLATION_BINARY = 63;
// Equivalent to COLLATION_BINARY, this is what a new driver returns when connected to a pre-4.1 server.
COLLATION_NONE = 0;
MAX_MYSQL_MANAGER_ERR = 256;
MAX_MYSQL_MANAGER_MSG = 256;

View File

@ -650,6 +650,7 @@ procedure TMySQLQuery.Execute;
var
i, j, NumFields: Integer;
Field: PMYSQL_FIELD;
IsBinary: Boolean;
begin
FLastResult := Connection.Query(FSQL, True);
FRecordCount := Connection.RowsFound;
@ -664,7 +665,11 @@ begin
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)
if ((Field.flags and BINARY_FLAG) = BINARY_FLAG) and (Datatypes[j].Category <> dtcBinary) then
if Connection.IsUnicode then
IsBinary := Field.charsetnr = COLLATION_BINARY
else
IsBinary := (Field.flags and BINARY_FLAG) = BINARY_FLAG;
if IsBinary and (Datatypes[j].Category = dtcText) then
continue;
FDatatypes[i] := Datatypes[j];
break;