From a3ab287273ea3e111cabfae21d9dcdcb6dbed4d7 Mon Sep 17 00:00:00 2001 From: "rosenfield.albert" Date: Thu, 7 Aug 2008 21:13:38 +0000 Subject: [PATCH] Bugfix: the BINARY (0x80) flag has been broken in recent libmysql.dll versions, for some reason. Workaround. Sort of fixes issue #660. --- components/zeosdbo/src/dbc/ZDbcMySqlUtils.pas | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/components/zeosdbo/src/dbc/ZDbcMySqlUtils.pas b/components/zeosdbo/src/dbc/ZDbcMySqlUtils.pas index 9685121c..7a435bf6 100644 --- a/components/zeosdbo/src/dbc/ZDbcMySqlUtils.pas +++ b/components/zeosdbo/src/dbc/ZDbcMySqlUtils.pas @@ -171,6 +171,17 @@ begin Result := (UNSIGNED_FLAG and FieldFlags) = 0; end; +// The BINARY (0x80) flag has been broken in recent libmysql.dll versions, for some reason. +function Binary: Boolean; +var + Collation: Cardinal; +begin + Result := False; + Collation := PlainDriver.GetFieldCollationId(FieldHandle); + if Collation = COLLATION_BINARY then Result := True; + if Collation = COLLATION_NONE then Result := True; +end; + begin case PlainDriver.GetFieldType(FieldHandle) of FIELD_TYPE_TINY: @@ -220,17 +231,21 @@ begin Result := stUnicodeString; FIELD_TYPE_TINY_BLOB, FIELD_TYPE_MEDIUM_BLOB, FIELD_TYPE_LONG_BLOB, FIELD_TYPE_BLOB: - if (FieldFlags and BINARY_FLAG) = 0 then - Result := stUnicodeStream - else Result := stBinaryStream; + // TEXT and BLOB columns. + if Binary then Result := stBinaryStream + else Result := stUnicodeStream; FIELD_TYPE_BIT: Result := stBinaryStream; FIELD_TYPE_VARCHAR: Result := stUnicodeString; FIELD_TYPE_VAR_STRING: - Result := stUnicodeString; + // VARCHAR and VARBINARY columns. + if Binary then Result := stBytes + else Result := stUnicodeString; FIELD_TYPE_STRING: - Result := stUnicodeString; + // CHAR and BINARY columns. + if Binary then Result := stBytes + else Result := stUnicodeString; FIELD_TYPE_ENUM: Result := stUnicodeString; FIELD_TYPE_SET: