From 10e5069213c5a5dd30ab5675c31344f10d34f0cd Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 24 May 2026 20:33:30 +0300 Subject: [PATCH] db.mysql: provide MYSQL_OPT_SSL_MODE fallback for old mariadb-connector-c Fix FreeBSD/OpenBSD/Database CI failures introduced in 733b38cd8. The mariadb-connector-c versions shipped by some distributions (Ubuntu 24.04's libmariadb-dev, FreeBSD's mariadb118-client, OpenBSD's mariadb-client) do not declare the MYSQL_OPT_SSL_MODE enum value yet, so the generated C code failed to compile. Add a small compatibility header that gates on MARIADB_PACKAGE_VERSION_ID and supplies a sentinel value mysql_options() will reject at runtime, preserving the existing behavior on libraries that already support the option (MySQL and MariaDB Connector/C 3.4+). --- vlib/db/mysql/_cdefs_nix.c.v | 2 ++ vlib/db/mysql/_cdefs_windows.c.v | 1 + vlib/db/mysql/mysql_compat.h | 11 +++++++++++ 3 files changed, 14 insertions(+) create mode 100644 vlib/db/mysql/mysql_compat.h diff --git a/vlib/db/mysql/_cdefs_nix.c.v b/vlib/db/mysql/_cdefs_nix.c.v index 0f863a757..3bb162e40 100644 --- a/vlib/db/mysql/_cdefs_nix.c.v +++ b/vlib/db/mysql/_cdefs_nix.c.v @@ -30,3 +30,5 @@ $if $pkgconfig('mysqlclient') { #flag openbsd $when_first_existing('/usr/local/lib/libmysqlclient.so','/usr/local/lib/libmariadb.so') #include # Please install the mysql or mariadb development headers } + +#include "@VMODROOT/vlib/db/mysql/mysql_compat.h" diff --git a/vlib/db/mysql/_cdefs_windows.c.v b/vlib/db/mysql/_cdefs_windows.c.v index b8accaac8..b64109dcc 100644 --- a/vlib/db/mysql/_cdefs_windows.c.v +++ b/vlib/db/mysql/_cdefs_windows.c.v @@ -9,3 +9,4 @@ $if tinyc { } #include # Please install https://dev.mysql.com/downloads/installer/ , then copy the include, lib, and bin folders to thirdparty/mysql. Make sure thirdparty/mysql/bin and thirdparty/mysql/lib are on PATH, or copy libmysql.dll next to the produced .exe +#include "@VMODROOT/vlib/db/mysql/mysql_compat.h" diff --git a/vlib/db/mysql/mysql_compat.h b/vlib/db/mysql/mysql_compat.h new file mode 100644 index 000000000..b67b1b235 --- /dev/null +++ b/vlib/db/mysql/mysql_compat.h @@ -0,0 +1,11 @@ +// MYSQL_OPT_SSL_MODE was added in MySQL 5.7 and in MariaDB Connector/C 3.4. +// Older mariadb-connector-c releases (still shipped by some BSDs and Linux +// distributions) declare it as an enum value that is missing entirely, +// which would cause the generated C code to fail to compile. Because the +// symbol is an enum constant rather than a preprocessor macro, a plain +// `#ifndef MYSQL_OPT_SSL_MODE` cannot detect it. Instead, gate on the +// library's published version macros and supply a sentinel that +// mysql_options() will reject at runtime. +#if defined(MARIADB_PACKAGE_VERSION_ID) && MARIADB_PACKAGE_VERSION_ID < 30400 +#define MYSQL_OPT_SSL_MODE 9999 +#endif -- 2.39.5