From ac15f27a96f5668b0977652abec9c58dc04441ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Fri, 25 Aug 2023 04:24:35 +0200 Subject: [PATCH] Correctly check if the RETURNING keyword is available. [GB.DB.MYSQL] * BUG: Correctly check if the RETURNING keyword is available, by searching for "MariaDB" in the full version string, and checking the version number. --- gb.db.mysql/src/main.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/gb.db.mysql/src/main.c b/gb.db.mysql/src/main.c index 7cbb63a74..452f5aa0f 100644 --- a/gb.db.mysql/src/main.c +++ b/gb.db.mysql/src/main.c @@ -918,6 +918,24 @@ static void set_character_set(DB_DATABASE *db) mysql_free_result(res); } + +static bool is_mariadb(DB_DATABASE *db) +{ + int len = GB.StringLength(db->full_version); + int i; + const char *search = "mariadb"; + const int len_search = strlen(search); + + for (i = 0; i <= len - len_search; i++) + { + if (GB.StrNCaseCmp(&db->full_version[i], search, len_search) == 0) + return TRUE; + } + + return FALSE; +} + + static int open_database(DB_DESC *desc, DB_DATABASE *db) { MYSQL *conn; @@ -982,10 +1000,15 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db) db->handle = conn; init_version(db); + if (is_mariadb(db)) + db->flags.no_returning = db->version >= 100500; + else + db->flags.no_returning = TRUE; + set_character_set(db); - + GB.HashTable.New(POINTER(&db->data), GB_COMP_BINARY); - /* flags: none at the moment */ + return FALSE; }