From 79ce5edcf3124202ef6ff882c9fc2e2deab338b9 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Thu, 18 Jan 2024 19:33:15 +0100 Subject: [PATCH] Fix retrieving MySQL events from the current database on older servers which return a lower case schema name, by turning the comparison case insensitive. Further more, don't compare the schema at all on newer servers with a fix for MySQL bug 41907. See https://bugs.mysql.com/bug.php?id=41907#c360194 and https://www.heidisql.com/forum.php?t=41682 --- source/dbconnection.pas | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 49c50a00..4e4a7cea 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -6902,6 +6902,7 @@ var obj: TDBObject; Results: TDBQuery; rx: TRegExpr; + SchemaBug41907Exists, DbNameMatches: Boolean; begin // Return a db's table list try @@ -7066,8 +7067,14 @@ begin end; end; if Assigned(Results) then begin + // Work around old MySQL bug: https://bugs.mysql.com/bug.php?id=41907#c360194 + // "Noted [fixed] in 5.1.57, 5.5.12, 5.6.3 changelogs." + SchemaBug41907Exists := (ServerVersionInt < 50157) or + ((ServerVersionInt >= 50500) and (ServerVersionInt < 50512)) or + ((ServerVersionInt >= 50600) and (ServerVersionInt < 50603)); while not Results.Eof do begin - if Results.Col('Db') = db then begin + DbNameMatches := CompareText(Results.Col('Db'), db) = 0; + if (SchemaBug41907Exists and DbNameMatches) or (not SchemaBug41907Exists) then begin Obj := TDBObject.Create(Self); Cache.Add(obj); Obj.Name := Results.Col('Name');