Skip to content

Commit 2508516

Browse files
committed
fix: use newer/renumbered MYSQL_* constants with libmysql v8+
Refs #2587
1 parent ca238aa commit 2508516

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

source/dbstructures.mysql.pas

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3153,6 +3153,8 @@ implementation
31533153

31543154

31553155
constructor TMySQLLib.Create(DllFile, DefaultDll: String);
3156+
var
3157+
LibMajorVer: String;
31563158
begin
31573159
inherited;
31583160
// MYSQL_OPT_* constants
@@ -3180,17 +3182,22 @@ constructor TMySQLLib.Create(DllFile, DefaultDll: String);
31803182
MYSQL_OPT_SSL_VERIFY_SERVER_CERT := 21;
31813183
MARIADB_OPT_TLS_VERSION := 7005;
31823184
end
3183-
else if String(mysql_get_client_info).StartsWith('8.') then begin
3184-
// Some constants were removed in MySQL 8.0, so the offsets differ
3185-
MYSQL_PLUGIN_DIR := 16;
3186-
MYSQL_OPT_SSL_KEY := 19;
3187-
MYSQL_OPT_SSL_CERT := 20;
3188-
MYSQL_OPT_SSL_CA := 21;
3189-
MYSQL_OPT_SSL_CIPHER := 23;
3190-
MYSQL_OPT_CONNECT_ATTR_ADD := 27;
3191-
MYSQL_ENABLE_CLEARTEXT_PLUGIN := 30;
3192-
MYSQL_OPT_TLS_VERSION := 34;
3193-
MYSQL_OPT_SSL_MODE := 35;
3185+
else begin
3186+
LibMajorVer := String(mysql_get_client_info);
3187+
LibMajorVer := Copy(LibMajorVer, 1, Pos('.', LibMajorVer)-1);
3188+
if StrToIntDef(LibMajorVer, 0) >= 8 then begin
3189+
// Some constants were removed in MySQL 8.0, so the offsets differ
3190+
// This also covers MySQL 9.x "Innovation" releases, which kept the same offsets as 8.x.
3191+
MYSQL_PLUGIN_DIR := 16;
3192+
MYSQL_OPT_SSL_KEY := 19;
3193+
MYSQL_OPT_SSL_CERT := 20;
3194+
MYSQL_OPT_SSL_CA := 21;
3195+
MYSQL_OPT_SSL_CIPHER := 23;
3196+
MYSQL_OPT_CONNECT_ATTR_ADD := 27;
3197+
MYSQL_ENABLE_CLEARTEXT_PLUGIN := 30;
3198+
MYSQL_OPT_TLS_VERSION := 34;
3199+
MYSQL_OPT_SSL_MODE := 35;
3200+
end;
31943201
end;
31953202
end;
31963203

0 commit comments

Comments
 (0)